Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Lady_Aleena's scratchpad

by Lady_Aleena (Deacon)
on Sep 07, 2007 at 20:54 UTC ( #637756=scratchpad: print w/ replies, xml ) Need Help??

#!/usr/bin/perl use strict; use warnings FATAL => qw( all ); local $\ = "\n"; my @laundry_loads = ('cottons', 'cold water items', 'sheets', 'uniform +s', 'clothing of the day'); my @laundry_tasks = ('wash', 'dry', 'fold'); sub dry { my ($load, $loads) = @_; } for my $load (@laundry_loads) { for my $task (@laundry_tasks) { my $load_task = "$task $load"; print "$load_task"; if ($task eq 'fold') { if ($load =~ /sheets|uniforms|clothing of the day/) { my $new_load = $load eq 'sheets' ? 'laundry' : $load ; print "put away $new_load"; } if ($load eq 'sheets') { print 'vacuum the house'; print 'make the bed'; } if ($load eq 'uniforms') { print 'take showers'; } } } print "" if $load ne 'clothing of the day'; }


my $noon = 12:00; my %dayparts = ( 'morning' => { 'begin' => $dawn, 'end' => $noon}, 'afternoon' => { 'begin' => $noon, 'end' => $dusk - 1}, 'evening' => { 'begin' => $dusk - 1, 'end' => $dusk + 1}, 'night' => { 'begin' => $dusk + 1, 'end' => $dawn} );

Notes to self

  • Do not print Dumper when trying to display a script in a browser without using <pre> tags.
  • Do print Dumper when something goes wrong. The data structure is usually the problem.
  • If one changes a variable, check the whole script for that variable to make sure that the results will be as expected.
  • rename will not create directories, be sure to use mkdir in conjunction with rename if the files are also being moved to a new directory.

Notes from others

  • bart: LA it's often considered good practice to increment the variable in a continue block, to prevent running out of sync when using next.
  • Intrepid: btw, i wish i could explain to a lot of people i know, how efficacious Lady_Aleena's explained strategy can be (to use coding and thinking about coding to master a disquieted state of mind)
  • ambrus: In general, use magic only when normal solutions aren't enough.
  • GrandFather: each time through its loop while asks itself "Can I loop this time? Can I? Can I Can I? Please?" and if the answer is no (false statement) while gets grumpy and stops
  • GrandFather: First make it work (using the easiest to maintain code you can) then, only if you need to, make it faster. (from: Re^5: I have a list expanding when I don't want it to)

Things I should get a grip on

  • objects
  • SQL
  • version control
  • testing
Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2015-03-29 07:46 GMT
Find Nodes?
    Voting Booth?

    When putting a smiley right before a closing parenthesis, do you:

    Results (630 votes), past polls