1833021 Members
2286 Online
110049 Solutions
New Discussion

chomp() in perl 4

 
SOLVED
Go to solution
kenny chia
Regular Advisor

chomp() in perl 4

Hi to all perl experts
It seems that the there is no chomp($var) function in my server which has perl 4. Is there a replacement for that?
All Your Bases Are Belong To Us!
3 REPLIES 3
RolandH
Honored Contributor

Re: chomp() in perl 4

Yes there is a replacement for Perl4.

It is called Perl5 and can everything what Perl4 can do and many more.

You can get it from here:

http://big.asknet.de/hppd/hpux/Languages/perl-5.8.0/

HTH

Roland
Sometimes you lose and sometimes the others win
Steven Gillard_2
Honored Contributor
Solution

Re: chomp() in perl 4

Definitely upgrade to perl 5 if you can. Otherwise, if you're just trying to strip newline characters from the end of a string just use a search & replace of white-space at the end of the line:

$var =~ s/\s*$//;

Regards,
Steve
H.Merijn Brand (procura
Honored Contributor

Re: chomp() in perl 4

Rolands answer hits the nail right on the head. If you upgrade skip right to 5.8.0 or higher. Also available on my ITRC site: http://www.cmve.net/~merijn or https://www.beepz.com/personal/merijn

chomp is a `safe' vaersion of chop, which only chop's if the last `character' is the input record separator (\n or newline by default)

perl4's version of chomp

s/($/)?$//

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn