Solved

What does chop do?

Posted on 2007-11-20
5
426 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
5 Comments
 
LVL 142

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

776 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