Rob Dixon wrote:

Sudarshan Raghavan wrote:


anthony wrote:



Hi,

I have a question, what i do is if i have
$string = "a,b,c,d,e,f,g,"

I just do
chop $string;

there is no while loop with this
Would this be as good??



Careful, chop removes the last character no matter what. It is advisable
to use chomp in this scenario. chomp removes any trailing string that is
the same as $/ (perldoc perlvar). The chomp version for this can be
written as

sub remove_last_comma {
local $/ = ',';
chomp ($_[0]);
}



Much easier to do


$string =~ s/,$//;


Easier, yes. My post was only meant as a warning to avoid chop and use chomp instead. :-)



Rob










-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to