in reply to Re^3: replace with hash value?!
in thread replace with hash value?!

yes, but can't I save $1 from m// to $PRTABLE and use it in second part of s///? Thanks!!

Replies are listed 'Best First'.
Re^5: replace with hash value?!
by borisz (Canon) on Jan 19, 2005 at 13:54 UTC
    Yes, but the second part of s/// is never reached, since the first part of s/// does not match. It would work, if the first part match!.
    Boris
      Which is ok because I'm saying in the s/// "if you find the time of day replace it with this hash value". If it doesn't find it it won't do anything, right? I guess my question was can't I access a hash from within a reg like this s/whatever/$clocks{$PRTABLE}/; If your answer is yes you can then I'm messing up the logic somewhere, or maybe I can't use that kind of reg and variable combination. I just don't understand why s/// replaces a blank but with print it give me the correct value.

        "replaces a blank" (or, "replaces with a blank", I assume you mean). That's very pertinant information. Something is fishy there:

        $ perl5.8 -e '$x = "a b c d"; $a = "blah"; $b{$a} = "foo"; $x =~ s/a b +/$b{$a}/; print "$x\n"' foo c d
        Works fine here ... so, yes, there's something incomplete here. Perhaps you should post a complete test line that you expect to be modified by all of this so we can take a closer look.