[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] YAGOLF: password generation




"Joey Mitchell Comeau" <aw096@chebucto.ns.ca> wrote:
> >     perl -pe'map$\.=chr 33+rand 93,0..7'
> 
> I'm having trouble with both of these actually. They work fine in a
> script, but from the command line I have to hit enter. I don't think I
> understand exactly what -p does.
> 
>  perl -e'map$\.=chr 33+rand 93,0..7;print'
> 
> works fine. But the above, which I thought was equivalent, does
> not. Can anybody shed any light on what I am doing wrong?

Actually, -p means

    while (<>) {
        # whatever is in -e
        print;
    }

The problem in the scripts above is that no line is provided as
input to the scripts. That's why the original script I posted goes
like

    echo|perl -pe ...

The echo guarantees one (empty) line to the script. And 'echo|'
is 1 shorter than ';print', although it's a little less unportable,
as Ronald Kimball pointed out (it doesn't work in tcsh).

Hope this answered your questions about -p.

- Branden



==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe