-
chop returns the character choped off, so if you
expect it to print "fred" it won't.
-
chop "$a" isn't the same thing as
chop $a. You have to pass a variable to chop,
so it can modify it -- what you are passing it is a string
constant that you made which contains the variable.
| [reply] [d/l] [select] |
| [reply] |
PS, perldoc is your friend...
laptop:~> perldoc -f chop
chop VARIABLE
chop LIST
chop Chops off the last character of a string and
returns the character 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 "sub-
str($string, 0, -1)".
| [reply] |
chop modifies its argument and returns the chopped character. Does your program print 'd'?
I'm assuming the html line breaks are a posting error and not present in your source.
Don't use $a or $b as a user variable, they are owned by sort.
After Compline, Zaxo
| [reply] |