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
package MYCALC; use Exporter; our @EXPORT = (); our @ISA = qw(Exporter); our @EXPORT_OK = qw(addition multi); our %EXPORT_TAGS = (DEFAULT => [qw(&addition)],Both => [qw(&addition & +multi)]); sub addition { return $_[0] + $_[1]; } sub multi { return $_[0] * $_[1]; } 1; Program: use strict; use warnings; my @list = qw (2 2); use Module qw(:DEFAULT); print addition(@list),"\n"; Above coding is my module MYCALC and the program which using this module, I have not exported any function using @EXPORT, but I have used the DEFAULT in %EXPORT_TAGS with the function addition, when I call this function from the main it says the error as,
How do I sort a hash by the hash key?
Explain the internal working of cgi
How to get help for perl?
You want to empty an array. How would you do that?
You want to open and read data files with perl. How would you do that?
How does polymorphism work in perl? Give an example.
How to deleting an existing file in perl programming?
Is there any way to add two arrays together?
What is cpan ? What are the modules coming under this?
How do find the length of an array?
Explain the various characteristics of perl.
What $! In perl?
What are hashes?
Create a function that is only available inside the scope where it is defined ?