Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Lady_Aleena's scratchpad

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


sub textify { my ($text, $opt) = @_; my $root_link = get_root('link'); $text =~ s/$root_link\///; $text =~ s/<.+?>//g; $text =~ s/_/ /g; $text =~ s/\s\(.*?\)$// if !$opt->{'parens'}; $text =~ s/\s&\s/ &amp; /g; $text =~ s/_(Mr|Mrs|Ms|Dr)_/_$1._/g; $text =~ s/\.\w{2,5}?$// unless $text =~ /\.(?:com|net|org)$/; # $text =~ s/(?<!\A)((?<! )\p{uppercase})/ $1/g; # from Kenosis, kcot +t, and tye on PerlMonks return $text; }


my $noon = '12:00'; my $dawn = ''; my $dusk = ''; 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} );

Reminder code

my @monsters = map{chomp $_; $_} <$word_find_list>; my @items; for my $monster (@monsters) { push @items, [$monster, { class => 'monster_item' }]; }

is now

my @monsters = map { chomp $_; [$_, { class => 'monster_item' }] } < +$word_find_list>;

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)
  • GotToBTru: imho, you have nothing that needs defending. (from the Chatterbox on April 21, 2015)
  • SuicideJunkie: "you have nothing that needs defending" might be better stated as "you have a lot that needs no defending" (from the Chatterbox on April 21, 2015)

Things I should get a grip on

  • objects - After seeing how little objects do, I will keep my procedural code. Objects may be self-aware, but they are dumb as dirt. I write subroutines to work with predefined and preprocessed data. I have seen objects with predefined data, but I don't know how they do it. For example Net::Twitter::Lite knows where the data is and grabs it without me having to lug around the entire Twitter database with me. Why can't my objects have predefined data too?

    I write modules to reduce repetitive code. One repetitive thing is building hashes; so I build them in a module and write subroutines to return the data (possibly more processed than in the hash). From what I've been told in various threads objects don't do that. If that is the case, then objects are not for me.

  • SQL - I'm waiting for SQL to be standardized. I don't want to have to choose a flavor of SQL and then find out it is not compatible with where I am sending the SQL files.
  • 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 taking refuge in the Monastery: (12)
As of 2015-11-25 19:21 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (686 votes), past polls