Solved

perl condition to check for filename that starts and end with

Posted on 2014-10-07
1
203 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
Comment Utility
next unless ($file =~ /^sample.*\.txt$/i);

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now