regex to change second variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • incognito

    regex to change second variable

    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!
  • Gunnar Hjalmarsson

    #2
    Re: regex to change second variable

    incognito wrote:[color=blue]
    >
    > my $image="/u/bk/edieusqa01.tgz" ;
    >
    > I want to create a new variable, based on $image:
    >
    > my $md=($image =~ s/edie/md5.edie/);[/color]

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

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl

    Comment

    Working...