Hi ramthen, Try this,
use strict; use File::Basename; my @f_path=qw(Framework/Templates_Doc.Conventions/CSSP_TPL_Excel_Meta- +Template.xlt Engineering/SBI/PD_PRC/Overall_SWReleaseFlow_v0.1.vsd); for (@f_path){ my ($dir) =dirname($_); my ($fname) =basename($_); print "\n\nOriginal : $_"; print "\nDirectory : $dir"; print "\nFielname : $fname\n"; } __END__ Original : Framework/Templates_Doc.Conventions/CSSP_TPL_Excel_Meta-Te +mplate.xlt Directory : Framework/Templates_Doc.Conventions Fielname : CSSP_TPL_Excel_Meta-Template.xlt Original : Engineering/SBI/PD_PRC/Overall_SWReleaseFlow_v0.1.vsd Directory : Engineering/SBI/PD_PRC Fielname : Overall_SWReleaseFlow_v0.1.vsd
Updated : Using Regular Expression, Change the above for loop by the following:
for (@f_path){ my ($dir, $fname)= $_ =~ /^(.*?)[\\\/]([^\\\/]+)$/; print "\n\nOriginal : $_"; print "\nDirectory : $dir"; print "\nFielname : $fname\n"; }
Regards,
Velusamy R.
In reply to Re: regular expression on filenames with absolute path
by Samy_rio
in thread regular expression on filenames with absolute path
by ramthen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |