in reply to How to remove unwanted text from elements of an array?

How about:

| | hand waving here. | # that didn't work: @array1 = map { s/INVITE:// } @array; @array1 = @array; $_ =~ s/INVITE:// foreach @array1; # that works... | | #


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Replies are listed 'Best First'.
Re^2: How to remove unwanted text from elements of an array?
by Anonymous Monk on Oct 06, 2006 at 13:55 UTC
    That modifies the elements of @array, leaving the results of the substitution (success or not) in @array1.
Re^2: How to remove unwanted text from elements of an array?
by caelifer (Scribe) on Oct 06, 2006 at 19:36 UTC
    # that didn't work: @array1 = map { s/INVITE:// } @array;

    In the code above you collect results of s/// operator, i.e. number of successful substitutions, which is not what you want. You want the content of $_ after substitution. And thus, you have to do this instead:

    @array1 = map { s/INVITE://; $_ } @array;
    ... which indeed does work quiet nicely :)

    BR

    Update: expanded explanation about return value of s/// operator.