Keep It Simple, Stupid PerlMonks

### Legacy Code

by GotToBTru (Prior)
 on Apr 01, 2011 at 15:26 UTC Need Help??

With apologies to Charles Schulz.
```\$nmbrvalues = 11;
\$position1 = 0;
\$position2 = 0;
\$linelength = length(\$linein);
for (\$cntr = 1; \$cntr <= \$nmbrvalues; \$cntr++) {
\$position1 = \$position2;
\$position1 = index(\$linein,'|',\$position1);
\$position2 = index(\$linein,'|',\$position1 + 1);
\$fldlength = \$position2 - (\$position1+1);
if (\$cntr == 1) {\$hold1 = substr(\$linein,\$position1+1,\$fldlength);}
if (\$cntr == 7) {\$hold2 = substr(\$linein,\$position1+1,\$fldlength);}
if (\$cntr == 8) {\$hold3 = substr(\$linein,\$position1+1,\$fldlength);}
if (\$cntr == 9) {
\$position3 = \$position1+1;
\$position3 = index(\$linein,'@',\$position3);
If (\$position3 > 0) {
if (\$position2 < 0) {\$position2 = length(\$linein);}
\$fldlength = \$position2 - (\$position1+1);
} #end of IF
if (\$position3 <= 0) {\$emailaddress = "mgrs\@server.com";}
} #end of if
} #end of FOR
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
GGGGGGGGGGGGGGGGGGGGGGGHHHHHHHHHHHHHHHHHHHHHHH!

You may now resume your regularly scheduled Perlmonks browsing.

Update: corrected the misspelled name.

Replies are listed 'Best First'.
Re: Legacy Code
by repellent (Priest) on Apr 03, 2011 at 06:16 UTC
Here, I've written the first test.

Once you're done adding tests, you can modify foo() to your heart's content. The tests must still pass.
Re: Legacy Code
by holli (Monsignor) on Apr 03, 2011 at 13:02 UTC
You gotta love the end block comments!

holli

You can lead your users to water, but alas, you cannot drown them.
Re: Legacy Code
by sundialsvc4 (Abbot) on Apr 04, 2011 at 17:44 UTC

s/Schultz/Schulz/g

Create A New User
Node Status?
node history
Node Type: perlmeditation [id://896944]
Approved by wazoox
help
Chatterbox?
 [Discipulus]: to specify use 5.0.x to be sure to have pairmap from the module.. [Corion]: Discipulus: I think Module::Corelist ( or corelist ) can tell you that [Corion]: Meh - Module::CoreList [choroba]: Just use List::Util 1.29 [choroba]: Be kind to people using old Perl with newer version of the module [Corion]: But why not simply specify 'List::Util' => 1.29 in your prerequisites? People might install a more recent version of the module into their Perl [Corion]: (what choroba said)

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2017-05-25 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My favorite model of computation is ...

Results (187 votes). Check out past polls.