Hi Lucy,
> I have file name, such as:
> My $file =
"c:\views\12352_Utilities\na_gcs_12352fmcdealer\Ut
ilities\Source\Migration
> Tool\MigrationTool.exe";
you did not try to print that one, true?
If you are using \ (the escape character) within
"" then it will just emphasize
the next char, so your path will be without any \. You have
to write it using ''
as delimiter or use duplicated \ (C:\\views.....) or
just change the path
delimiter to / (UNIX like).
The latter won't matter, PERL will treat the path correctly
on Windows even
if it is a UNIX style path.
> How can I get just file name
"MigrationTool.exe" by using regular expression?
Now to your little problem:
parts = split (/[\\\/]/, $path);
$filename_with_suffix = pop ( parts);
With the first line you tell PERL to generate the list of
the pathparts delimited
by either '/' or '\'.
The second line will retrieve the last element of that list.
And the solution is using a reguar expression (/[\\\/]/)
in which the duplication
of the escape character \ is used.
Have a nice day,
Axel
_______________________________________________
ActivePerl mailing list
ActivePerl listserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs
|