Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Legacy Code

by GotToBTru (Prior)
on Apr 01, 2011 at 15:26 UTC ( #896944=perlmeditation: print w/replies, xml ) 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); $emailaddress = substr($linein,$position1+1,$fldlength); } #end of IF if ($position3 <= 0) {$emailaddress = "mgrs\";} } #end of if } #end of FOR

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!


    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


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://896944]
Approved by wazoox
[choroba]: Discipulus: Yes, all get calls should be wrapped in a Try::Tiny
[choroba]: you can just create a ticket :)
[Discipulus]: Ah! is i'll have some fre4e time i'll try try::tiny

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2017-07-24 09:29 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (349 votes). Check out past polls.