in reply to Quick REGEXP question
Some further suggestions.use File::Spec; use warnings; foreach my $systempath ( <DATA> ) { chomp $systempath; print "-"x50, "\nPATH: $systempath\n\n"; my ($volume,$directories,$file) = File::Spec->splitpath( $systempath + ); #-- regex with replacement to get the extension my $extension = ""; if ( $file =~ s/(\.[^\.]*)\s*$// ) { $extension = $1; } print "File::Spec way\n"; print "Vol\t", $volume, "\n"; print "Dir\t",$directories, "\n"; print "File\t", $file, "\n"; print "Ext\t", $extension, "\n"; } __DATA__ C:\program files\temp\abc.exe /usr/local/bin/abc C:/this/is/a path/only/ /is/this/a/path/or/a/file /this/is/a/path/
|
|---|