In the future, you may want to post using Plain Text instead of RTF or HTML.  
More people may respond.

Check out the documentation on module File::Basename

    use File::Basename;

    ($name,$path,$suffix) = fileparse($fullname,@suffixlist);
    $name = fileparse($fullname,@suffixlist);
    fileparse_set_fstype($os_string);
    $basename = basename($fullname,@suffixlist);
    $dirname = dirname($fullname);

    ($name,$path,$suffix) = fileparse("lib/File/Basename.pm",qr{\.pm});
    fileparse_set_fstype("VMS");
    $basename = basename("lib/File/Basename.pm",".pm");
    $dirname = dirname("lib/File/Basename.pm");
 


________________________________

        From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fabricio 
Soares Martins - Site CBN - SGR
        Sent: Friday, April 13, 2007 4:26 PM
        To: John Townsend; [EMAIL PROTECTED]
        Subject: RES: Getting file name from a path
        
        
        try this:
         
        #!/perl -w
         
        $current_file = "c:/somedir/test.ps";
        $current_file =~ /.*(\/|\\)(.*)/gi;
         
        print $2;
         
        :)
        fabrício s. martins
         

                -----Mensagem original-----
                De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] nome de John 
Townsend
                Enviada em: sexta-feira, 13 de abril de 2007 17:53
                Para: [EMAIL PROTECTED]
                Assunto: Getting file name from a path
                
                

                Often I need to extract the file name from a path. Typically I 
do something like following. Any better ways I could do this?


                #path test 
                $current_file = "c:/somedir/test.ps"; 
                @split_path = split("/",$current_file); 
                $current_file = @split_path[-1]; 
                print $current_file; 


                However, I'm pretty sure I could extract the file name using a 
regular expression. How might I do this? Any suggestions welcome.

                Thanks 

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to