And for those with embedded JavaScript to write, in which you already
have too many quotes: =o)
print<<END;
Here, put "whatever text you 'like'."
The quotes are handled.
By default, $everything is treated as if it had "" around it,
but you can still use "". $vars will be expanded to their $values.
END
To alter the bahavior, you can put certain types of quotes around END.
For example, if you wanted to print $foo without it being evaluated,
you could say
print<<'END';
$foo here will show as $foo, dollar sign and all,
and you can still embed "" and '' without fear.
END
This wasn't very well documented in the Perl docs last time I looked,
but it seems to follow the Posix standard well enough. =o)
--- "King, Jason" <[EMAIL PROTECTED]> wrote:
> David Gilden writes ..
>
> >Original from the class:
> >
> >print "<input type=\"checkbox\" name=\"delete\" value=\"yes\"
> checked>\n";
> >
> >
> >Is this bad style?
>
> yep .. avoid backwhacks at all costs - that's my opinion
>
>
> >print '<input type="checkbox" name="delete" value="yes"
> checked>',"\n";
> >
> >better?
>
> yep .. much better
>
> >print '<input type="checkbox" name="delete" value="yes" checked>'.
> "\n";
>
> also good - but generally accepted as inferior to the second snippet
>
> >I do believe that these 3 statements are all equivalent.
>
> nope .. but the differences are subtle .. the first one is
> essentially
> equivalent to the last one .. but the one with the comma is different
> in
> that it passes two parameters as a list to the print function and can
> be
> affected by the built-in variable $,
>
> to see the difference try this code snippet
>
> $, = '_wow_';
>
> print 'foo', 'bar', "\n";
>
> print 'foo'. 'bar'. "\n";
>
> but - use of $, is pretty rare and usually discouraged and the second
> snippet that you showed is the best of the three
>
> even better is to realise that double-quotes are operators ..
> specifically
> they're shorthand for the qq// operator .. in other words the
> following two
> are EXACTLY equivalent to Perl
>
> print "foobar\n";
> print qq/foobar\n/;
>
> so .. when you want to include double-quotes AND have the string
> interpolated you can do this
>
> print qq/<input type="checkbox" name="delete" value="yes"
> checked>\n/;
>
> also note that the '/' character is not the only delimiter that you
> can use
> .. you can use anything .. so the following are all equivalent to the
> above
>
> print qq#<input type="checkbox" name="delete" value="yes"
> checked>\n#;
> print qq*<input type="checkbox" name="delete" value="yes"
> checked>\n*;
> print qq|<input type="checkbox" name="delete" value="yes"
> checked>\n|;
>
> even the rather obfuscated
>
> print qq q<input type="checkbox" name="delete" value="yes"
> checked>\nq;
>
> you can even use bracketing constructs and Perl will pair them up ..
> so the
> following works a treat
>
> print qq(some more parens () in here - perl isn't fooled\n);
>
>
> Manual Refereces:
>
> "Quote and Quote-like Operators" section of perlop manual
>
> --
> jason king
>
> No children may attend school with their breath smelling of "wild
> onions" in West Virginia. - http://dumblaws.com/
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/