Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: how do subroutines work

by hipowls (Curate)
on Mar 22, 2008 at 21:24 UTC ( [id://675684]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    eval { print speak('sheep'), "\n"; };
    print $@ if $@;
    ...
    __END__
    Died at Perl-1.pl line 21.
    foo
    
  2. or download this
    use 5.010_000;
    
    ...
    __END__
    baa
    foo
    
  3. or download this
    BEGIN {
        my %says = (
    ...
            return $says{$animal};
        }
    }
    
  4. or download this
    {
        my $says;
    ...
            return $says->{$animal};
        }
    }
    
  5. or download this
    sub speak {
        my $animal = shift;
    ...
        die unless defined $says->{$animal};
        return $says->{$animal};
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://675684]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2024-04-24 08:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found