regex to change second variable

Discussion in 'Perl' started by incognito, Aug 10, 2004.

  1. incognito

    incognito Guest

    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!
     
    incognito, Aug 10, 2004
    #1
    1. Advertising

  2. 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
     
    Gunnar Hjalmarsson, Aug 10, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Ti4gU2hlaHphZA==?=

    change of session does not fire button click event for second time

    =?Utf-8?B?Ti4gU2hlaHphZA==?=, Apr 4, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,055
    Scott Allen
    Apr 5, 2005
  2. misiek
    Replies:
    7
    Views:
    6,862
    misiek
    Feb 28, 2006
  3. Replies:
    3
    Views:
    810
    Reedick, Andrew
    Jul 1, 2008
  4. yelipolok
    Replies:
    4
    Views:
    282
    John W. Krahn
    Jan 27, 2010
  5. xhe
    Replies:
    1
    Views:
    138
    Randy Webb
    Feb 9, 2007
Loading...

Share This Page