Re: Can I tell if *DATA is exhausted? (eof, etc?)
- From: anno4000@xxxxxxxxxxxxxxxxxxxxxxx (Anno Siegel)
- Date: 23 Nov 2005 10:22:03 GMT
<usenet@xxxxxxxxxxxxxxx> wrote in comp.lang.perl.misc:
> A. Sinan Unur wrote:
> > If you use a while loop, read line-by-line, you should observe only one
> > 1 being printed.
>
> True (I see '1" - one 1). But I still don't understand why I don't see
> '001' (as Anno reports with "for"). I don't understand why I see only
> "1", because if I say:
I reported "two false and one true values", not "001".
> #!/usr/bin/perl
> while (<DATA>) {
> print $_;
> }
> __DATA__
> 1
> 2
> 3
>
> I see "123". So if I "print eof" instead of "print $_" then why do I
> only see "1"? I seem to be very confused.
Perl's boolean "false" has a numeric value of 0, but a string value of
"". If you print it, you see the string, i.e. nothing. Print with
line feeds.
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:
- Can I tell if *DATA is exhausted? (eof, etc?)
- From: usenet
- Re: Can I tell if *DATA is exhausted? (eof, etc?)
- From: A. Sinan Unur
- Re: Can I tell if *DATA is exhausted? (eof, etc?)
- From: usenet
- Can I tell if *DATA is exhausted? (eof, etc?)
- Prev by Date: Re: Can I tell if *DATA is exhausted? (eof, etc?)
- Next by Date: FAQ 9.13 How do I edit my .htpasswd and .htgroup files with Perl?
- Previous by thread: Re: Can I tell if *DATA is exhausted? (eof, etc?)
- Next by thread: How to update perl
- Index(es):
Relevant Pages
|