Created
March 28, 2012 06:02
-
-
Save anazawa/2224110 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # while_each_last.pl | |
| use strict; | |
| use warnings; | |
| my %foo = ( foo => 'bar' ); | |
| while ( my ( $k, $v ) = each %foo ) { | |
| print "$k: $v\n"; | |
| last; | |
| } | |
| # last でループを抜けたため、each %foo の iteration がリセットされていない | |
| while ( my ( $k, $v ) = each %foo ) { | |
| print "$k: $v\n"; | |
| last; | |
| } | |
| $ perl -v | |
| This is perl 5, version 12, subversion 3 (v5.12.3) built for darwin-multi-2level | |
| ... | |
| $ perl while_each_last.pl | |
| foo: bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment