neversaint has asked for the wisdom of the Perl Monks concerning the following question:
How can I generalize my regex above when the file name comes with one or more path:my $file = "somename.out"; my $name = ( split( /\./, $file ) )[0]; print "$file - $name\n"; # This prints "somename" correctly
Such that it yields the same result: somenamemy $file_with_path = "path/somename.out" # or my $file_with_path2 = "path/path2/somename.out"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Capturing Base Name of a File With or Without Path
by monkfan (Curate) on Jan 26, 2006 at 07:04 UTC | |
by chargrill (Parson) on Jan 26, 2006 at 07:12 UTC | |
|
Re: Capturing Base Name of a File With or Without Path
by chargrill (Parson) on Jan 26, 2006 at 07:10 UTC | |
|
Re: Capturing Base Name of a File With or Without Path
by smokemachine (Hermit) on Jan 26, 2006 at 10:10 UTC |