| Back to Questions Page |
| Question |
What is the difference between chop & chomp functions in perl? |
Rank |
Answer Posted By |
|
Interview Question Submitted By :: Jkonakan |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer |
chop is used remove last character,chomp function removes
only line endings.  |
0 | Thangaraju |
| |
| |
| Answer |
Chop and Chomp are two very similar functions. Both of them
are used to delete symbols from the tail of the given
string. While both work with string and list parameters,
Chop deletes any ending symbol Chomp deletes only specified
substring from the end. If you pass list to any of these
two, all list elements will get processed and the return
value would be the result of last operation.  |
0 | Wicked_sunny [Wipro] |
| |
| |
| Answer |
chop() removes the last character from a scalar value.
chomp() checks whether the last characters of a string or
list of strings match the input line separator defined by
the $/ system variable. If they do, chomp removes them.
 |
0 | Nagaraju Kancherla [Wipro] |
| |
| |
|
|
| |
| Answer |
chop will indiscriminately remove (and return) the last
character passed to it, while chomp will only remove the
end of record marker (generally, "\n"), and return the
number of characters so removed.  |
0 | Devinder Kumar [Wipro] |
| |
| |
|
| |
|
Back to Questions Page |