Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

How a script becomes a module

by brian_d_foy (Abbot)
on Oct 05, 2004 at 20:53 UTC ( [id://396759]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl
    
    ...
        }
        
    print "The high score was $high_score\n";
    
  2. or download this
    #!/usr/bin/perl
    
    ...
        }
        
    print "The high score was $high_score\n";
    
  3. or download this
    #!/usr/bin/perl
    
    ...
        }
        
    print "The high score was $high_score\n";
    
  4. or download this
    #!/usr/bin/perl
    
    ...
    sub last_score { $_[0]->{$_[1]}[-1]          }
    sub game_count { scalar @{ $_[0]->{$_[1]} }  }
    sub score_n    { $_[0]->{$_[1]}[ $_[2] - 1 ] }
    
  5. or download this
    #!/usr/bin/perl
    
    ...
        $sum += score_n( @_, $_ ) foreach ( 1 .. game_count( @_ ) );
        $sum;
        }
    
  6. or download this
    sub stats
        {                
        @{ $_[0] }{ qw(name sum average last) } = 
            ( $_[1], &sum, &average, &last_score );
        }
    
  7. or download this
    #!/usr/bin/perl
    
    ...
            
        \%hash;
        }
    
  8. or download this
    #!/usr/bin/perl
    
    ...
        }
    
    sub high_score { ... }
    
  9. or download this
    package Local::Scores;
    use DBM::Deep;
    ...
        }
    
    sub high_score { ... }
    
  10. or download this
    #!/usr/bin/perl
    
    ...
        {
        $modules->{$elem->[0]} = $elem->[1];
        }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://396759]
Approved by kutsu
Front-paged by kutsu
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-03-28 20:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found