Grokbase
Topics Posts Groups | in
x
[ help ]

Re: lc(undef) is not undef: bug or feature?

View PostFlat  Thread  Threaded | < Prev - Next >
Michael G Schwern Re: lc(undef) is not undef: bug or feature?
| +1 vote
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
Jonathan Rockway wrote:
>     $ "\L$foo"
>
>     $
>     
> Note that the cases above all warn, except the last one. I think it
> should... am I missing something? \U, \u, \l also do the same thing.

I'll betcha $5 that \L is implemented using the same op as lc()...

Yep, toke.c would seem to confirm.

/*
  * Now come three functions related to double-quote context,
  * S_sublex_start, S_sublex_push, and S_sublex_done.  They're used when
  * converting things like "\u\Lgnat" into ucfirst(lc("gnat")).  They
  * interact with PL_lex_state, and create fake ( ... ) argument lists
  * to handle functions and concatenation.
  * They assume that whoever calls them will be setting up a fake
  * join call, because each subthing puts a ',' after it.  This lets
  *   "lower \luPpEr"
  * become
  *  join($, , 'lower ', lcfirst( 'uPpEr', ) ,)
  *
  * (I'm not sure whether the spurious commas at the end of lcfirst's
  * arguments and join's arguments are created or not).
  */



--
...they shared one last kiss that left a bitter yet sweet taste in her
mouth--kind of like throwing up after eating a junior mint.
     -- Dishonorable Mention, 2005 Bulwer-Lytton Fiction Contest
by Tami Farmer

Thread : lc(undef) is not undef: bug or feature?
1)
Alberto Simões Well, the subject says it all :) lc(undef) is the empty string. This might be good, this might be...
2)
Andy Armstrong I think the anomaly is that it doesn't cause a warning even with use warnings. Functions generally...
3)
Alberto Simões Just to explain how I found out: while(defined($line = lc(<>))) { But ok, I can put it on two lines...
4)
Abigail Of course. What would you expect? It's not different from 1 + undef being 1, and not undef. undef...
5)
Alberto Simões OK It's true. Well, good point ;)...
6)
Marvin Humphrey This is precisely the kind of situation where I'd hope that Perl would warn if I had warnings...
7)
Marvin Humphrey Oops. I read that backwards. Sorry for the noise. Marvin Humphrey Rectangular Research...
8)
Alberto Simões Use of uninitialized value on... ? Not sure if this was what you asked for. Cheers ambs
9)
Jonathan Rockway Interestingly, some similar cases also don't warn where they should: $ my $foo $ "$foo" Use of...
10)
Michael G Schwern I'll betcha $5 that \L is implemented using the same op as lc()... Yep, toke.c would seem to...
11)
Andy Armstrong Presumably "\L$smoo" and lc $smoo compile to the same thing.
12)
Rafael Garcia-Suarez I've added regression tests for it. I've applied patch for that. All tests pass. #33088. It's a...
spacer
View PostFlat  Thread  Threaded | < Prev - Next >