Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

regex to change second variable

 
 
incognito
Guest
Posts: n/a
 
      08-10-2004
I've read the camel book. I've searched newsgroups. I can't find the
answer.
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:

$image="/u/bk/edieusqa01.tgz";
$md="/u/bk/md5.edieusqa01.tgz";

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/;

Help!
 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      08-10-2004
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
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
 
 
Reply

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" ?? seberino@spawar.navy.mil Python 3 07-01-2008 03:06 PM
Observe variable set and variable change saladin.mundi@gmx.de 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



Advertisments