On Jan 22, Jerry Preston said:
>I am looking for a better way, a perl way for the following:
>
> foreach ( @data ) ) {
> s/^ //;
> $data_[ $jp++ ] = $_;
> }
You do realize that you're modifying the elements in @data as well, right?
So that, unless $jp starts at some value other than 0, @data_ and @data
are exactly the same.
If you DON'T want that, you'd have to do:
for (@data) {
(my $copy = $_) =~ s/^ //;
push @data_, $copy;
}
Or something to that effect. Here's a one-liner:
@data_ = map { (my $copy = $_) =~ s/^ //; $copy } @data;
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]