Link to home
Start Free TrialLog in
Avatar of shragi
shragiFlag for India

asked on

perl condition to check for filename that starts and end with

I had the below code to check whether the filename ends with txt or not...but how can i modify the condition to check whether the filename starts with "sample" and ends with 'txt"

foreach my $file (@files) {
  next if ($file !~ /\.txt$/i);
  system("copy \"$source\\$file\" \"$destination\"");
 }

I tried to modify the line as below but it did not copy anything
  next if ($file !~ /sample*\.txt$/i);

filename will be somthing like sample.test1.devenv.txt
ASKER CERTIFIED SOLUTION
Avatar of wilcoxon
wilcoxon
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial