[Brisbane-pm] To Chomp or not to Chomp

Martin Jacobs martin_jacobs at optusnet.com.au
Mon Feb 26 23:32:33 PST 2007


Hi folks,

Here's another one of those 'it should be easy' scenarios. Again, I  
would appreciate your help.

This time, I've got a borrowed 'chomp' regex (chomp behaves in  
exactly the same way). But, instead of chopping off the last  
character in the string, it returns the value '1'.

I can only guess that this is because Perl is working in 'list mode',  
not in 'paragraph mode' (see here), which makes sense because the  
file it is reading from is a list. And its chopping off 1 character  
(the new line character).

Please tell me how to get Perl doing the right thing here. I am going  
to need to get it right for my 7 million line long arrays in future.  
I could resort to substr, but that's not as efficient (apparently),  
and I've got to get to grips with regexes anyway.

I enclose the relevant code. PERRMOSS_Control_File.txt needs to be in  
the same directory as Input_file_chomp.pl.

Regards,
Martin
Visit my website...
http://web.mac.com/martin_jacobs1


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/brisbane-pm/attachments/20070227/5025092d/attachment-0003.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Input_file_chomp.pl
Type: text/x-perl-script
Size: 265 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/brisbane-pm/attachments/20070227/5025092d/attachment-0001.bin 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/brisbane-pm/attachments/20070227/5025092d/attachment-0004.html 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: PERRMOSS_Control_File.txt
Url: http://mail.pm.org/pipermail/brisbane-pm/attachments/20070227/5025092d/attachment-0001.txt 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/brisbane-pm/attachments/20070227/5025092d/attachment-0005.html 


More information about the Brisbane-pm mailing list