Solved

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

Posted on 2009-05-08
2
188 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
ID: 24334462
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
ID: 24334483
foreach(  @array )
{
s/\.txt$/.pl/;
print $_."\n";
}
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
pattern problem 9 84
Greater than or equal to 2005? 3 52
regx  exclude  pattern 6 48
Regular Expression 1-100 with two digits 15 60
Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
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…

821 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