http://www.perlmonks.org?node_id=857104


in reply to What is this line doing in the perl script?

You haven't told us what part of the line you have problems understanding.

You can learn what the line is doing from perlre about the /g flag, and from perlsyn about what the assignment does.

Maybe it helps you to look at this example:

use strict; use Data::Dumper; my @list = ("abcdef" = /(.)./g); print Dumper \@list; (my ($first)) = @list; print "$first\n"; # in one step (my $first) = ("abcdef" = /(.)./g);

Replies are listed 'Best First'.
Re^2: What is this line doing in the perl script?
by codeacrobat (Chaplain) on Aug 25, 2010 at 18:54 UTC
    You are missing the tilde in the match.
    Should've been:
    use strict; use Data::Dumper; my @list = ("abcdef" =~ /(.)./g); print Dumper \@list; (my ($first)) = @list; print "$first\n"; # in one step (my $first) = ("abcdef" =~ /(.)./g);

    print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});