Dan Muey wrote:
> > $m = $_[1] ? $_[1] : 'text/plain';
> Excellent!! I also received the suggestion
> my $m = $_[1] || 'text/plain';
>
> Any body have any pros/cons about which would be more
> efficient/better ??
I second Rob H's version - the second one - as being
more Perlish. It also avoids re
t; Sent: Wednesday, March 05, 2003 11:33 AM
> To: [EMAIL PROTECTED]
> Subject: single line condition statement with semicolon
>
>
> Hello
>
>
> What I want to do is assign the value of $_[1] to $m unless
> it's empty then assign it 'text/plain' This
> > $m = 'text/plain';
> > $m = $_[1] unless(!$_[1]);
> >
> > Somehting like
> >
> > $m = $_[1] unless(!$_[1]) :$m = 'text/plain';
> >
> > But I can get it right, any assistance would be much appreciated.
> >
> > Thanks
> >
> > Dan
> >
>
> $m = $_[1] ? $_[1] : 'text/plain';
Excellent!! I a
Hi -
> -Original Message-
> From: Dan Muey [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 05, 2003 6:33 AM
> To: [EMAIL PROTECTED]
> Subject: single line condition statement with semicolon
>
>
> Hello
>
>
> What I want to do is assign the value of
I think something like:
if( $_[1] ) ? $m = $_[1] : $m ='text/plain';
might work. Try looking up the perl 'trinary' operator.
"Dan Muey" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
com...
Hello
What I want to do is assign the value of $_[1] to $m unless it's empty then
assign
uot; (not
blank, zero or undef) will be used.
Rob
-Original Message-
From: Dan Muey [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 05, 2003 11:33 AM
To: [EMAIL PROTECTED]
Subject: single line condition statement with semicolon
Hello
What I want to do is assign the value of $_[1] to
Hello
What I want to do is assign the value of $_[1] to $m unless it's empty then assign it
'text/plain'
This currently works but I want to do a one liner
I think you can do that with a colon but I can't seem to find the syntax
$m = 'text/plain';
$m = $_[1] unless(!$_[1]);
Somehting like
$m