[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



>I'm trying to strip the file name from the following string:
>
>/opt/SAM/SystemConfig/vtun.pl
>
>I'm using the following regext:
>
>m/\/(.+)/;
>
>That seems to only work if there is only one '/' in the name.
>Since the file can be called with any pathname I need to strip
>all the way to the last '/'  Is there a way to do this with
>regex or should I use strip and get the last element of
>the array?
>
>Thanks,
>Chris


Chris,

#!c:\perl\bin\perl.exe -w

use strict;

my $full_path = '/opt/SAM/SystemConfig/vtun.pl';

my ($file_name) = ($full_path =~ /\/([^\/]+)$/);

print ($file_name, "\n");


use File::Basename;

my ($other_way, undef, undef) = fileparse($full_path,);

print ($other_way, "\n");


keith

-------------

Keith R. Watson                        GTRI/ITD
Systems Support Specialist III         Georgia Tech Research Institute
keith.watson at gtri.gatech.edu           Atlanta, GA  30332-0816
404-894-0836


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00331" href="msg00331.html">[ale] Perl Regexe questions</a></strong>
<ul><li><em>From:</em> fletch at phydeaux.org (Fletch)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00324" href="msg00324.html">[ale] Perl Regexe questions</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Christopher Fowler)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00329.html">[ale] ssl tools</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00331.html">[ale] Perl Regexe questions</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00324.html">[ale] Perl Regexe questions</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00331.html">[ale] Perl Regexe questions</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00330"><strong>Date</strong></a></li>
<li><a href="threads.html#00330"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>