Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub PrintAA
- {
- my $test = shift;
- my %aa = shift;
- print $test . "n";
- foreach (keys %aa)
- {
- print $_ . " : " . $aa{$_} . "n";
- $aa{$_} = $aa{$_} . "+";
- }
- }
- PrintAA("abc", %fooHash);
- sub PrintAA
- {
- my $test = shift;
- my $aaRef = shift;
- print $test, "n";
- foreach (keys %{$aaRef})
- {
- print $_, " : ", $aaRef->{$_}, "n";
- }
- }
- #!/bin/perl -w
- use strict;
- sub PrintAA
- {
- my($test, %aa) = @_;
- print $test . "n";
- foreach (keys %aa)
- {
- print $_ . " : " . $aa{$_} . "n";
- }
- }
- my(%hash) = ( 'aaa' => 1, 'bbb' => 'balls', 'ccc' => &PrintAA );
- PrintAA("test", %hash);
- my $test = shift;
- my(%aa) = @_;
- Reference found where even-sized list expected at xx.pl line 18.
- ...
- Use of uninitialized value in concatenation (.) or string at xx.pl line 13.
- sub PrintAA
- {
- my $test = shift;
- my %aa = @_;
- print $test . "n";
- foreach (keys %aa)
- {
- print $_ . " : " . $aa{$_} . "n";
- $aa{$_} = $aa{$_} . "+";
- }
- }
- sub PrintAA
- {
- my $test = shift;
- my $aa = shift;
- if (ref($aa) != "HASH") { die "bad arg!" }
- ....
- }
- PrintAA($foo, %bar);
- my %aa = shift;
- my $scalar = 5;
- my %hash = (a => 1, b => 2, c => 3);
- func($scalar, %hash)
- sub func {
- my $scalar_var = shift;
- my %hash_var = @_;
- ... Do something ...
- }
- sub PrintAA ($%)
- {
- my $test = shift;
- my %aa = ${shift()};
- print "$testn";
- foreach (keys %aa)
- {
- print "$_ : $aa{$_}n";
- $aa{$_} = "$aa{$_}+";
- }
- }
- PrintAA("test", %hash);
- PrintAA("test", %$ref_to_hash);
- my %myhash = ( key1 => "val1", key2 => "val2" );
- my $href = %myhash
- %$href
- my $myhref = shift;
- keys %$myhref;
- sub get_args { ref( $_[0] ) ? shift() : ( @_ % 2 ) ? {} : {@_}; }
- sub PrintAA
- {
- my $test = shift;
- my $aa = get_args(@_);;
- #then
- $aa->{somearg} #do something
- $aa->{anotherearg} #do something
- }
- printAA($firstarg,somearg=>1, anotherarg=>2)
- printAA($firstarg,{somearg=>1, anotherarg=>2})
- my(%hash) = ( 'aaa' => 1, 'bbb' => 'balls', 'ccc' => PrintAA );
- PrintAA("test", %hash);
Add Comment
Please, Sign In to add comment