Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: substr in nested foreach loop

by Jasper (Chaplain)
on May 22, 2006 at 17:09 UTC ( #550982=note: print w/ replies, xml ) Need Help??


in reply to substr in nested foreach loop

The problem is that this line :

HETATM 1562 O HOH 189 48.728 50.544 -16.104

is only 43 characters long, and you're doing $zh= substr $_,48,8; on it. That takes the 48th through to the 55th characters and sticks them in a string. Read the error message with this in mind, and see if you can work it out :)


Comment on Re: substr in nested foreach loop
Download Code
Re^2: substr in nested foreach loop
by sarani (Sexton) on May 23, 2006 at 04:02 UTC
    There are whitespaces on either side, and length gives 57. The file is formatted such that except for the last line, each line has that many chars. :) That's the cause of my confusion.
      Yeah but no but yeah.

      If you stick a warning before each substr operation giving the length of the string and which characters it's trying to find, I bet you'll trace the problem pretty quickly.
        Jasper: Yeah, I got it. *sheepish grin* End of line char at the end of file. Thanks. :)

        Oh, and a couple of places where the file formatting was irregualr because of overwriting. *feels dumb*

        On the positive side, I've learnt more in the time it took me to read this thread and attempt to implement all of the suggestions (I did) than I did while trying to debug all by myself...So I owe all the Monks who were kind enough to reply a huge thanks.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (15)
As of 2014-07-25 15:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (172 votes), past polls