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

Answer Posted / pallavi

Chop function removes the last character of any specified
string or variable and returns the chopped data.

Ex: $a="abcdefghijkla";
$b= chop($a);
print $a;

Output - abcdefghijkl

Where as chomp removes all the new line at the end of any
specified string or variable and returns nothing.

Is This Answer Correct ?    15 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the various perl data types based on the context?

533


What rules must be followed by modules in perl.

557


How to read multi lines from a file in perl?

497


Explain subroutine in perl?

482


List the files in current directory sorted by size ?

518






What is the use of "stderr()"?

565


What is the syntax used in Perl grep function?

581


What are numeric operators in perl?

536


Explain lists in perl?

551


Comment on the scope of variables in perl.

520


How to connect to SQL server through Perl?

556


Explain the various characteristics of perl.

515


Define perl scripting?

571


What is a chop() function in perl?

564


How to remove a directory in perl?

480