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
Solved

What does chop do?

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTTP Error 502.2 - Bad Gateway 3 222
Filtering a file to table 9 101
Rename file based on contents in the file? 3 97
Regex rule to match two different url 5 74
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…

839 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