Phoenix.pm: Perl stuuf

Peter J Jones p at dancris.com
Thu Mar 4 00:15:25 CST 1999


Shay Harding wrote:

> On Tue, 02 Mar 1999, you wrote:
> >Hey, look! An actual Perl-related email!
> >
> >So, I have this little update pl fed by an HTML form. One of the things it
> >does is to store a copy of the updated content seperate so that it can be
> >edited later. So, here is where it gets wierd...
> >
> >$text = $FORM{'text'};
> >$action = $FORM{'action'};
> >$action = "nada" unless $action;
>      ### $action = "nada" if !$action; ### :)

or even less typing...
$action |= "nada";

>
> >
> >if ($action =~ "norm") {
> >       unless (open (TEXT, ">$path/idx.txt")) {
> >               $msg = "(1) Could not open $path/idx.txt";
> >               &mailme;
> >               exit;
> >       }
> >       print TEXT "$text";
> >       close <TEXT>;
> >
> >(just a fragment of the code...)
> >
> >So on our machine there is no problem, but on the clients maching, the
> >data file "idx.txt" ends up containing the contents of $text, followed by
> >the words ("nada" unless $action;)
> >
> >Any ideas what the hell is causing this???
>
> Ahhh.. 'unless' must diiiee...:) Phew got that out. Sorry I just hate unless.
> Why not use if !condition? Saves 4 bytes :)
>

'unless' ROCKS! But '|=' is better :-)

>
> --
>
> Shay Harding
> sharding at ccbill.com




More information about the Phoenix-pm mailing list