Why not just use a regex?

($basename)=$file_string=~m!([^/]+)$!;

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 24, 2001 1:44 PM
To: [EMAIL PROTECTED]
Subject: Re: basename ?


Gary,

In article <[EMAIL PROTECTED]>, Gary Stainburn wrote:
>The bit I want to get is:
>
>qi_test.exe
>
>What I'm getting is:
>
>var/spool/exim/qtine/15P4aa-0000U5-00.exp/qi_test.exe

A very simple thing to do here would be to split
'var/spool/exim/qtine/15P4aa-0000U5-00.exp/qi_test.exe' on '/'
chars, and grab the final element of the resulting array:

  #!/usr/bin/perl -w     
  $file_string = 'var/spool/exim/qtine/15P4aa-0000U5-00.exp/qi_test.exe';

  @path_parts = split(/\//, $file_string);     
  $basename = $path_parts[$#path_parts];     
  print "Basename is: $basename\n";     

You could also get this by futzing around with File::Basename, if you were
of a mind to drag a couple hundred extra lines of code. :)

Hope that helps,

John
-- 
               John Fox <[EMAIL PROTECTED]>
    System Administrator, InfoStructure, Ashland OR USA
  ---------------------------------------------------------
"What is loved endures.  And Babylon 5 ... Babylon 5 endures."
              --Delenn, "Rising Stars", Babylon 5

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to