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

Re: [Fun With Perl] Does this count as a one-liner?



On Tue, Jun 15, 1999 at 06:22:54PM -0400, mjd-list-fwp@plover.com wrote:
> 
> I agree.  I would suggest:
> 
>      $query = (unindent ($quantity < 1) ? <<""  : <<"");
> 
>          DELETE FROM Contents
>          WHERE cartnum = '$cartnum'
>            AND itemid = '$itemid';
>  
>          UPDATE Contents
>          SET quantity = $quantity
>          WHERE cartnum = '$cartnum'
>            AND itemid = '$itemid';
>  
> 

Except that those lines should actually be blank, rather than having
invisible whitespace (which my editor seems to drop in the quoting), and
there cannot be a blank line after the first line, since that terminates
the first here-doc as an empty string.


> 
> It's funny how people always forget that the <<TAG doesn't have to be
> the last thing on the line.  They always write
> 
> 	print (...., <<EOM
> 	..
> 	..
> 	..
> 	EOM
> 	);
> 
> When they should have written
> 
> 	print (...., <<EOM);
> 	..
> 	..
> 	..
> 	EOM
> 
> 

That's true.  Silly people!


> Try this:
> 
>      $query = (unindent ($quantity < 1) ? <<'' : <<"") . <<"";
> 
>          DELETE FROM Contents
>  
>          UPDATE Contents
>          SET quantity = $quantity
>  
>          WHERE cartnum = '$cartnum'
>            AND itemid = '$itemid';
> 

Same problems as above.

 
> 
> > Also, do I really save any CPU time with the <<'' rather than <<"" in
> > the first part of this last example?
> 
> I humbly suggest that if you're really worried about that, you're
> programming in the wrong language.
> 

Agreed.  That's a good way of putting it.  :)

Ronald

==== Want to unsubscribe from this list? (Don't you love us anymore?)
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org