Solved

Changing the extension of a .txt file to .pl file

Posted on 2009-05-08
2
184 Views
Last Modified: 2012-05-06
I am having a an array like
@array=('a.txt','b.txt',c.txt);
i want to convert the extension of these files to .pl

I did like
foreach  @array
{
tr /.*.tx/.*.p/;
print $_."\n";
}

But it is printing like
a.plp
b.plp
c.plp
How can i print like a.pl,b.pl,c.pl
0
Comment
Question by:ashok1312
2 Comments
 
LVL 39

Accepted Solution

by:
abel earned 250 total points
Comment Utility
the tr command replaces each letter of its first argument with the corresponding letter in the replacement string. It is not a regular expression. I think what you are after was this:

s/\.txt$/.pl/;
instead.
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
foreach(  @array )
{
s/\.txt$/.pl/;
print $_."\n";
}
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I have been reconstructing a PHP-based application that has grown into a full blown interface system over the last ten years by a developer that has now gone into business for himself building websites. I am not incredibly fond of writing PHP code o…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

728 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

11 Experts available now in Live!

Get 1:1 Help Now