Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > regex to change second variable

Thread Tools

regex to change second variable

Posts: n/a
I've read the camel book. I've searched newsgroups. I can't find the
I seems like this should be simple and common, but I'm stumped.

Here's what I'm trying to do:

my $image="/u/bk/edieusqa01.tgz";

I want to create a new variable, based on $image:

my $md=($image =~ s/edie/md5.edie/);

But, it changes $image instead of creating $md.

What I want at the end is:


I'm having to do it the following way, but it seems like it should be
able to be done on one line:

my $image="/u/bk/edieusqa01.tgz";
my $md=$image;
$md =~ s/edie/md5.edie/;

Reply With Quote
Gunnar Hjalmarsson
Posts: n/a
incognito wrote:
> my $image="/u/bk/edieusqa01.tgz";
> I want to create a new variable, based on $image:
> my $md=($image =~ s/edie/md5.edie/);

( my $md = $image ) =~ s/edie/md5.edie/;

Gunnar Hjalmarsson
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
strip all but second second line from bottom and then strip that!!!! yelipolok Perl Misc 4 01-27-2010 08:14 AM
How make regex that means "contains regex#1 but NOT regex#2" ?? Python 3 07-01-2008 03:06 PM
Observe variable set and variable change Ruby 6 11-19-2007 02:33 PM
How can the change of second window trigger change of first window xhe Javascript 1 02-09-2007 06:16 PM
A Paradise DNS address change? What change? There was no change. Tony Neville NZ Computing 7 09-22-2006 01:02 PM