Solved

What does chop do?

Posted on 2007-11-20
5
437 Views
Last Modified: 2012-06-21
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
Comment
Question by:naseeam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 120 total points
ID: 20322468
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 140 total points
ID: 20322476
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
 
LVL 39

Assisted Solution

by:Adam314
Adam314 earned 80 total points
ID: 20322560
In the code you have above, it would probably be safer to use chomp
http://perldoc.perl.org/functions/chomp.html
0
 
LVL 48

Accepted Solution

by:
Tintin earned 160 total points
ID: 20322671
$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
 
LVL 1

Author Closing Comment

by:naseeam
ID: 31410195
Quick response.  Great Answers!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Remove Malware code from PHP file 6 99
read PayflowPro reports using the report metadata using perl 11 44
rename outfile before writing 2 76
perl syntax 3 34
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question