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

Re^2: Repeating Code - there has GOT to be a better way!

by jedikaiti (Friar)
on Mar 31, 2010 at 17:13 UTC ( #832092=note: print w/replies, xml ) Need Help??


in reply to Re: Repeating Code - there has GOT to be a better way!
in thread Repeating Code - there has GOT to be a better way!

I wish I could. Alas, at this point, I have no say in how the data is pulled from the DB and stored. Although I might get to re-write that code later, in which case I will keep this in mind! But for now, this is what I am stuck with.

Kaiti
Swiss Army Nerd
  • Comment on Re^2: Repeating Code - there has GOT to be a better way!

Replies are listed 'Best First'.
Re^3: Repeating Code - there has GOT to be a better way!
by cleverett (Friar) on Mar 31, 2010 at 17:59 UTC
    You might try something like:
    my %Cmd; { no strict 'vars'; # you have a 'use strict;' line, right? %Cmd = do ("db/$name" . 'Cmd.pm'); }

      Or even

      #!/usr/bin/perl my %cmds = map { (/(.*)Cmd/) => { do $_ } } <*Cmd.pm>; use Data::Dumper; print Dumper \%cmds;
      $ cat *Cmd.pm ; ./832111.pl %barCmd = ( # barCmd.pm BAR => 99, # ... ); %fooCmd = ( # fooCmd.pm FOO => 42, # ... ); $VAR1 = { 'bar' => { 'BAR' => 99 }, 'foo' => { 'FOO' => 42 } };
      %Cmd = do ("db/${name}Cmd.pm");

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2016-10-01 22:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (9 votes). Check out past polls.