It was in an item by
Dominus (I think) that I found out that the \u and \L operators are interchangeable. i.e
$x = "string";
$x = "\u\L$x";
print $x,"\n";
$x = "string";
$x = "\L\u$x";
print $x,"\n";
Gives
String
String
The reasoning behind this being that Perl assumes you made a typo and put them in the wrong order.
Do the Monks think that this is a good idea or not? Should Perl make this assumption?
Are there any other ocasions when Perl will do this sort of thing?
Granted it seems a harmless and reasonable thing to do in this case, but I remember having great 'fun' years ago with a 'C' compiler that when it discovered a undeclared variable would try to pattern match an existing one also assuming a typo.
Look, I'm not much good at big speeches, and I know I haven't
always been an easy guy to get on with. And I know that, given the
choice, I probably wouldn't have chosen you as friends. But, I just
want to say ... that over the years, ... I have come to regard you ...
as ... people ... I met. I'd just better go, OK?
Rimmers Farewell speech (one of them) - Red Drawf
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.