Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

substitution 1

Status
Not open for further replies.

nychris

MIS
Dec 4, 2004
103
US
This is an easy question, but I just can't seem to find the answer. How can I do this substitution in a single line?
Code:
$str = 'alpha.txt';
$new = $str;
$new =~ s/txt$/pol/;
I tried the following, but all it does is return the number of substitutions that were made...
Code:
$new = ($str =~ s/txt$/pol/;

Thanks
 
Code:
($new = $str = 'alpha.txt') =~ s/txt$/pol/;

- Miller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top