in reply to array manipulation with string

s/^(?=\d+\.\d+\.\d+\.\d+)/IP_/ for values %{ $newHosts->{ server } };

Replies are listed 'Best First'.
Re^2: array manipulation with string
by Bloodnok (Vicar) on Sep 24, 2009 at 08:56 UTC
    Hmmm ,

    The OP would like the existing IP address prefixed with i.e. not replaced by, the string 'IP_', viz:

    s/^/IP_/ for values %{ $newHosts->{ server } };
    or
    $_ = q/IP_/ . $_ for values %{ $newHosts->{ server } };
    A user level that continues to overstate my experience :-))

      jwkrahn's code is not doing a replacement because his pattern is inside a zero-width positive look-ahead assertion, i.e. it is in effect doing an insertion at a point in the string that is followed by the pattern because the item being substituted is zero-width.

      Cheers,

      JohnGG

        ...which just goes to show how apposite my sig is ;-)

        .oO(I should've TIAS !!)

        Many thanx johngg for the enlightenment - self-evidently jwkrahn is a big fan of unnecessary typing :-D

        A user level that continues to overstate my experience :-))