Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

perl condition to check for filename that starts and end with

Posted on 2014-10-07
1
Medium Priority
?
247 Views
Last Modified: 2014-10-07
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
0
Comment
Question by:shragi
1 Comment
 
LVL 27

Accepted Solution

by:
wilcoxon earned 2000 total points
ID: 40366864
next unless ($file =~ /^sample.*\.txt$/i);

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Screencast - Getting to Know the Pipeline
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question