in reply to grep with multiple choice
use warnings; use strict; my @array = qw(Julia_Roberts(1,5) Cintheia Chelsia Rohan); my $pattern = 'Julia_Roberts'; my $change = 'Cintheia'; # Find your pattern my ($found) = grep /$pattern/, @array; # Change your pattern into the new value $found =~ s/$pattern/$change/; # Replace the change item with your new value for (@array) { s/$change/$found/; } print map "$_\n", @array;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: grep with multiple choice
by sroy5 (Initiate) on Jun 12, 2007 at 05:35 UTC | |
by Roy Johnson (Monsignor) on Jun 12, 2007 at 15:56 UTC |