Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-05-08
2
Medium Priority
?
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 39

Accepted Solution

by:
abel earned 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Six Sigma Control Plans

722 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