Re: Use of uninitialized value in substitution (s///)
- From: anno4000@xxxxxxxxxxxxxxxxxxxxxxx (Anno Siegel)
- Date: 23 Aug 2005 14:17:14 GMT
Hugh Lawson <hlawson@xxxxxxxxxxxx> wrote in comp.lang.perl.misc:
> anno4000@xxxxxxxxxxxxxxxxxxxxxxx (Anno Siegel) writes:
[...]
> > > How can the code work right if $_ is undefined?
> >
> > Perl converts the undefined value to an empty string, if forced. It
> > does that here, finds that the empty string doesn't end with a "0" and
> > returns the empty string unchanged. That works perfectly well, but it
> > may not be what the programmer intended, hence the warning.
>
>
> Hello Anno,
>
> Thank you for the reply. Perhaps we are communicating at cross
> purposes. My point is that warning or not, the substitution seems to
> work as expected.
How is that surprising? The purpose of the substitution is to get rid
of a trailing null byte in C strings. If $_ is undefined, the
substitution returns an empty string. That doesn't have a trailing null
byte, so the purpose of the substitution is attained.
> To see what I'm talking about, search for this line
>
> $db->filter_fetch_value(
> sub { no warnings 'uninitialized' ;s/\0$// } ) ;
>
> in perldoc perldbmfilter.
I don't have perldbmfilter around (is it really spelled that way?).
The code is the same as earlier in the thread. What's to discover?
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
.
- References:
- Use of uninitialized value in substitution (s///)
- From: Hugh Lawson
- Re: Use of uninitialized value in substitution (s///)
- From: Hugh Lawson
- Re: Use of uninitialized value in substitution (s///)
- From: Anno Siegel
- Re: Use of uninitialized value in substitution (s///)
- From: Hugh Lawson
- Use of uninitialized value in substitution (s///)
- Prev by Date: Re: Symbol tables
- Next by Date: Re: Use of uninitialized value in substitution (s///)
- Previous by thread: Re: Use of uninitialized value in substitution (s///)
- Next by thread: Re: Use of uninitialized value in substitution (s///)
- Index(es):
Relevant Pages
|