[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Tue Jun 15 20:37:57 2004 -->
- <!--x-from-r13: xrvgu.jngfba ng tgev.tngrpu.rqh (Yrvgu D. Ingfba) -->
- <!--x-message-id: [email protected] -->
- <!--x-reference: [email protected] --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] Perl Regexe questions -->
- <li><em>date</em>: Tue Jun 15 20:37:57 2004</li>
- <li><em>from</em>: keith.watson at gtri.gatech.edu (Keith R. Watson)</li>
- <li><em>in-reply-to</em>: <<a href="msg00324.html">[email protected]</a>></li>
- <li><em>subject</em>: [ale] Perl Regexe questions</li>
>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>