Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: help with (what I consider) a strange problem

by danger (Priest)
on Mar 19, 2001 at 07:16 UTC ( #65346=note: print w/replies, xml ) Need Help??

in reply to help with (what I consider) a strange problem

You are assigning the return value of chomp() to $_ ... and chomp() returns whatever it chomped off the end of the string, not the chomped string.

updateMy bad ... chomp() returns the number of characters chomped off --- it seems Text::Bastardize has a problem with digits and hangs, at least that's what I get with this example:

#!/usr/bin/perl -w use strict; use Text::Bastardize; my $latin = Text::Bastardize->new(); $latin->charge('blah 10 '); print $latin->pig(),"\n"

seems like a bug in Bastardize to me.

Replies are listed 'Best First'.
Re: Re: help with (what I consider) a strange problem
by sachmet (Scribe) on Mar 19, 2001 at 07:26 UTC
    Nope... chomp returns number of chars chopped. So:
    $t = "t\n"; $num = chomp($t); print "$num"
    prints "1", whereas:
    $t = "t"; $num = chomp($t); print "$num"
    prints "", whereas:
    @t = ("t\n","u\n","v","w\n"); $num = chomp(@t); print "$num";

    prints "3".

    (edited: error in my code fixed)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://65346]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2021-06-24 05:30 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (123 votes). Check out past polls.