|
From: ofer on 17 Feb 2006 07:34 Thanks, it is always good to avoid bad programming habits :) I didn't understand what this should do: chomp(@quotes = <DATA>); This does the same as: while ( <DATA> ) chomp; push @quotes, $_; } ? I've fixed everything you said beside of this because I want to understand what have you done here first :) Thanks a lot for your time
From: A. Sinan Unur on 17 Feb 2006 07:41 ofer(a)ilunix.org wrote in news:1140179672.675863.160700 @f14g2000cwb.googlegroups.com: [ Please quote some context when you reply. Intersperse your comments with the bits you are commenting on. ] > Thanks, it is always good to avoid bad programming habits :) > I didn't understand what this should do: > chomp(@quotes = <DATA>); > This does the same as: > > while ( <DATA> ) > chomp; > push @quotes, $_; > } > > ? Well, it first slurps the filehandle into an array. At this point, each element of the array is a line from the cookies.txt file (still containing the record separator which we set to "%\n"). So, we need to get rid of those "%\n" sequences at the end. chomp, applied to list, works element-wise. That is, it chomps every element of the array. See perldoc -f chomp. After chomp(@quotes = <DATA>); we have in @quotes each quote without the "%\n" sequence. Sinan -- A. Sinan Unur <1usa(a)llenroc.ude.invalid> (reverse each component and remove .invalid for email address) comp.lang.perl.misc guidelines on the WWW: http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
From: ofer on 17 Feb 2006 09:32 okay got it! thank you. works like a charm. you can see it working in http://ilunix.org under the "user-agent" line. :)
From: Josef Moellers on 17 Feb 2006 09:36 ofer(a)ilunix.org wrote: > okay got it! thank you. works like a charm. > you can see it working in http://ilunix.org under the "user-agent" > line. :) > No, apparently you haven't "got it": [ Please quote some context when you reply. Intersperse your comments with the bits you are commenting on. ] -- Josef Möllers (Pinguinpfleger bei FSC) If failure had no penalty success would not be a prize -- T. Pratchett
From: ofer on 17 Feb 2006 09:49 what do you mean?
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: Can I Grep multiple lines?? Next: Problem reading & displaying MHTML file type |