Xiong has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; use Perl6::Say; # print with trailing newline my $lunch ; my @lunch ; my %lunch ; sub lunch { return ( 'Beans', 'Burger' ); }; say '1: ', lunch(); $lunch = lunch(); say '2: ', $lunch; $lunch = ( 'Pork', 'Salad' ); say '3: ', $lunch; @lunch = ( 'Rice', 'Noodles' ); say '4: ', @lunch; $lunch = @lunch; say '5: ', $lunch; %lunch = ( 'Chicken', 'Steak'); say '6: ', %lunch; $lunch = %lunch; say '7: ', $lunch; @lunch = %lunch; say '8: ', @lunch; $lunch = @lunch; say '9: ', $lunch; __DATA__ Output: Useless use of a constant in void context at ./return-demo.pl line 20. 1: BeansBurger 2: Burger 3: Salad 4: RiceNoodles 5: 2 6: ChickenSteak 7: 1/8 8: ChickenSteak 9: 2 __END__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Typecasting Hashes
by almut (Canon) on Feb 20, 2010 at 11:03 UTC | |
by Xiong (Hermit) on Feb 20, 2010 at 12:54 UTC | |
|
OT: Code tags (re: Typecasting Hashes)
by roboticus (Chancellor) on Feb 20, 2010 at 14:04 UTC | |
by CountZero (Bishop) on Feb 20, 2010 at 16:05 UTC | |
by roboticus (Chancellor) on Feb 21, 2010 at 16:41 UTC |