• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 454
  • Last Modified:

What does chop do?

ddump is a utility that dump Debugging Information from elf file to TEMP.    What do the last two lines in below code snippet exactly do?


open TEMP, "$ddump -D $elf|" or die("\nError dumping file!\n");
....
....
$line = <TEMP>;
chop($line);
0
naseeam
Asked:
naseeam
4 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
0
 
ozoCommented:
perldoc -f chop
       chop VARIABLE
       chop( LIST )
       chop    Chops off the last character of a string and returns the char-
               acter chopped.  It is much more efficient than "s/.$//s"
               because it neither scans nor copies the string.  If VARIABLE is
               omitted, chops $_.  If VARIABLE is a hash, it chops the hash's
               values, but not its keys.

               You can actually chop anything that's an lvalue, including an
               assignment.

               If you chop a list, each element is chopped.  Only the value of
               the last "chop" is returned.

               Note that "chop" returns the last character.  To return all but
               the last character, use "substr($string, 0, -1)".

               See also "chomp".
0
 
Adam314Commented:
In the code you have above, it would probably be safer to use chomp
http://perldoc.perl.org/functions/chomp.html
0
 
TintinCommented:
$line = <TEMP>;

Reads one line from the filehandle TEMP, ie: the output of the ddump command

chop($line);

Removes the last character from value of $line.

0
 
naseeamAuthor Commented:
Quick response.  Great Answers!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now