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 is the use of "stderr()"?

812


Write a cgi program to show the header part?

728


What is the difference between perl list and perl array?

668


Why Perl aliases are considered to be faster than references?

759


What are the various file operations in perl. Explain with example.

733


What are stdin, stdout and stderr?

713


Explain lexical variables.

738


How will you declare a variable in perl?

770


Write syntax to use grep function?

762


What is the easiest way to download the contents of a URL with Perl?

752


Explain about the applications of perl?

746


There are two types of eval statements i.e. Eval expr and eval block. Explain them.

747


How to determine strings length in perl?

760


what is the function of Return Value?

790


What are the steps involved in configuring a server using cgi programming?

693