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
What does init 5 and init 0 do?
Comment on array slicing and range operator
What is the use of 'ne' operator?
How to read multi lines from a file in perl?
How do I print the entire contents of an array with Perl?
How do you turn on the perl warnings?
How will you access an element of a perl array?
Explain join function in perl?
How do I sort a hash by the hash value?
How do you give functions private variables that retain their values between calls?
Define dynamic scoping.
What is perl dbi?
How to create a package?
What are perl strings?
Explain splicing of arrays?