Solved

perl condition to check for filename that starts and end with

Posted on 2014-10-07
1
219 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 26

Accepted Solution

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

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to count occurrences of each item in an array.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

809 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