in reply to passing string to sub and string split
#!usr/bin/perl -w use strict; my %hash = ( 'NAME' => 'name222', 'COLOR' => 'yellow', 'SIZE' => 'big', ); Some_subroutine(%hash); sub Some_subroutine { my @list = @_; print "This shows that %hash is just a list of key,value pairs\n"; print " when passed like sub(%hash)\n"; print "list=@list\n\n"; my %hash = @_; print "This shows that assigning default list (@_) \n"; print " to %hash results in hash (key,value) assignments\n\n"; foreach my $key (keys %hash) { print "key $key \tvalue is $hash{$key}\n"; } } __END__ PRINTS: This shows that %hash is just a list of key,value pairs when passed like sub(%hash) list=SIZE big COLOR yellow NAME name222 This shows that assigning default list (SIZE big COLOR yellow NAME nam +e222) to %hash results in hash (key,value) assignments key COLOR value is yellow key SIZE value is big key NAME value is name222
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: passing string to sub and string split
by BioLion (Curate) on Aug 02, 2009 at 10:33 UTC | |
by Marshall (Canon) on Aug 02, 2009 at 14:36 UTC | |
|
Re^2: passing string to sub and string split
by BioLion (Curate) on Aug 02, 2009 at 10:32 UTC |