Solved

What does chop do?

Posted on 2007-11-20
5
405 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
 

Author Closing Comment

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

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now