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

Re: Surviving 'Illegal division by zero'

by zakzebrowski (Curate)
on Jun 23, 2004 at 20:58 UTC ( #369176=note: print w/replies, xml ) Need Help??


in reply to Surviving 'Illegal division by zero'

I ran into a similar situation at work today actually, however, I wasn't trying to do a mathimatical situation. Since I'm bored, I'll share. What I was trying to do is load a file into memory, and then perform a subsistuion, similar to $line =~ s/\n//g; , and then I was going to perform additional string subsitutions on the line. This didn't work and resulted in a "illegal division by zero" error, so I needed a different work around. I thought of subsituting a different character for \n, but that character could exist in the file, so I backed off from that approach. I never really did find out a good way to do it, so instead I made a seperate regular expression which would catch the cases where a \n was embeded in the the other regular expression I wanted to extract from the file. I think this is the more elegent and robust solution, since I later found additional special cases that I wasn't taken into effect...


----
Zak - the office

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://369176]
help
Chatterbox?
[shmem]: result := the discarded result (what's leftmost of the statement)
[shmem]: push returns the number of elements in @foo, the assignment returns all the elements in the (renewed) @foo
[Lady_Aleena]: Sanity check please? push @line, ref($list_addition ) eq 'ARRAY' ? @$list_addition : $list_addiction; # so I don't have the change existing uses of the sub.
[shmem]: $list_addiction should be $list_addition
Discipulus loose the tozzetto party!
[shmem]: .oO( addition of cookies for addiction to cookies )
[Lady_Aleena]: Other than my typos shmem. 8)
[shmem]: otherwise fine
[Discipulus]: tozzetti & vinsanto
[Lady_Aleena]: The whole line is push @line, ref($list_addition ) ? @$list_addition : $list_addition if $list_addition;

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2017-04-27 11:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (503 votes). Check out past polls.