iamcal has asked for the wisdom of the Perl Monks concerning the following question:
(When code is executed, @a and @b are both contain the values of the grep)#!/usr/bin/perl -w use strict; my @a = qw(bob.txt bob jack.bmp dave.txt mark); my @b = grep{$_=(m|^(.*)\.(.*?)$|)?$1:$_}@a; print join(', ',@a)."\n".join(', ',@b);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Grep is changing the original list?
by merlyn (Sage) on Apr 17, 2001 at 20:46 UTC | |
|
Re: Grep is changing the original list?
by arturo (Vicar) on Apr 17, 2001 at 20:50 UTC | |
|
Re: Grep is changing the original list?
by Masem (Monsignor) on Apr 17, 2001 at 20:47 UTC | |
by merlyn (Sage) on Apr 17, 2001 at 20:50 UTC | |
|
Re: Grep is changing the original list?
by kschwab (Vicar) on Apr 17, 2001 at 20:48 UTC | |
|
Re: Grep is changing the original list?
by Malkavian (Friar) on Apr 17, 2001 at 20:49 UTC | |
|
Re: Grep is changing the original list?
by iamcal (Friar) on Apr 17, 2001 at 20:58 UTC | |
by merlyn (Sage) on Apr 17, 2001 at 21:00 UTC |