RE: Getting file name from a path

2007-04-13 Thread Jerry Kassebaum
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

Re: RES: Getting file name from a path

2007-04-13 Thread Andy_Bach
> Often I need to extract the file name from a path. $current_file = "c:/somedir/test.ps"; @split_path = split("/",$current_file); $current_file = @split_path[-1]; print $current_file; You want to use the '$' sigil here, not '@' (you're refering to just one element, not the whole array): $cur

RE: Getting file name from a path

2007-04-13 Thread Adam R. Frielink
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); fil

RE: Getting file name from a path

2007-04-13 Thread Tobias Hoellrich
Perfectly fine the way you wrote it - why involve a regexp when you got an elegant solution? If you insist on a regexp, try this instead: $current_file = (split(/[/\\]/,$current_file))[-1]; Tobias PS: How's Adobe treating you? ;-) From: [EMAIL PROTECTED]

RES: Getting file name from a path

2007-04-13 Thread Fabricio Soares Martins - Site CBN - SGR
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: [EMAI

Getting file name from a path

2007-04-13 Thread John Townsend
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