What is the difference between chop & chomp functions in perl?

Answer Posted / shaheed

If there is new line character at the end of string, chop()
and chomp() both will remove that new line character.

Else if there is no new line character at the end of string
then chop() will remove last character from the string
while chomp() keeps the string unchanged.

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to connect to SQL server through Perl?

566


Write a program that shows the distinction between child and parent process?

512


What does Perl do if you try to exploit the execve(2) race involving setuid scripts?

528


How to disable the mod_perl from apache_server as i have used perlfect search on the site and its pagination is not working and the remedy is to disable the mod_perl.

1799


Why is it hard to call this function: sub y { "because" } ?

539






What are perl strings?

516


What are stdin, stdout and stderr?

515


How does polymorphism work in perl? Give an example.

481


I have one question regarding to eval function. I know eval function is use for error checking but I am not able to understand below line. eval \'exec perl -S $0 ${1+\"$@\"}\' if 0; $0 for script name $@ set if error occur

1612


What's the difference between /^Foo/s and /^Foo/?

553


There is no strict data types in perl unlike in other high level languages like Java so wouldn't that be a problem if a code in perl is to be a written by a big team of 20+ members ?"

1997


What is warn function in perl?

533


How many ways can we express string in Perl?

540


Explain goto expr?

495


What syntax is used for grep() function?

571