in reply to Split and print hash based on regex

WRT your first SSCCE:   while does not automatically assign the result of its CONDITION evaluation to  $_ (in contrast to the
    while (<FILEHANDLE>) { do_something_with($_); }
special case):

c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "foreach my $filename (qw(a b c)) { dd 'before while loop, $filename is', $filename; while ($filename) { dd 'in while loop, $_ is', $_; last; } } " ("before while loop, \$filename is", "a") ("in while loop, \$_ is", undef) ("before while loop, \$filename is", "b") ("in while loop, \$_ is", undef) ("before while loop, \$filename is", "c") ("in while loop, \$_ is", undef)


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: Split and print hash based on regex
by Maire (Scribe) on Mar 28, 2018 at 07:22 UTC
    Great, thank you!