For Programmers: Free Programming Magazines  


Home > Archive > PERL Programming > June 2004 > Re: chomp pb when using linux









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: chomp pb when using linux
Doug Gale

2004-06-25, 6:40 pm

"Sylvain" <sylvain.boucher@aitb.org> wrote in message
news:cbbid5$dng$1@voyager.news.surf.net...
> Hi All,
>
> I have a problem running a script on Linux system (it used to work on HP
> and Solaris) because a return character in Linux is actually (Ctrl M +
> Ctrl J), chomp get rid only of Ctrl J however.
> My question was the following:
> Is there a way ( such as a 'use something;' or defining a special
> variable) to make chomp work correctly?


The $/ variable determines the behavior of chomp

If I do this:

$/ = 'theend';

and then this:

$var = 'this is theend';

and then do this:

chomp $var;

Then $var becomes 'this is ';

Don't forget that $/ also affects the <FILEHANDLE> operator when reading.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com