#!/usr/bin/perl #********************************************************* # Example of the my function # # by Al Bento # Assigns values to variables using the my function. # Prints them in the same block, but not outside # of the block. #********************************************************* # assign values to variables @_=("name",10,5); %animals = (dog=>"fido",cat=>"sleepy",bird=>"raven"); $d = 9; # prints inside the block print "\n *** print inside of the block ***\n\n"; {my ($friends,$a,$c) = @_; my $d; print "$friends,$a,$c,$d,$animals{bird}\n"; } # print outside of the block print "\n *** print outside of the block ***\n\n"; {my ($friends,$a,$c) = @_; my $d; } print "$friends,$a,$c,$d,$animals{bird}\n";