Re: Can I tell if *DATA is exhausted? (eof, etc?)



<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.
.



Relevant Pages

  • Declare function und Pfad
    ... Hallo, wie kann ich den Pfad, der auf eine DLL verweist aus einer Variablen ... ByVal c2 As String, n As Long) As Boolean ... Prev by Date: ...
    (microsoft.public.de.word.vba)
  • Re: Is a txt file Read-Only?
    ... Public Function DoesFileExist1997(ByVal FilePath As String) As Boolean ... Const FileNotFoundErrNumber As Long = 53 ... Prev by Date: ...
    (comp.databases.ms-access)
  • Re: from false to true in an ArrayList
    ... > how can i change the value of a boolean in an ArrayList from false to ... > public void crbCheck (String name) ... Prev by Date: ...
    (comp.lang.java.help)
  • Method Returns String of Boolean - Why Dont You Need to Include "= True" or "= False" ?
    ... >From a article at Realbasic Univeristy: Column 35 the following method was ... Function bStr(b as boolean) As string ... Prev by Date: ...
    (comp.lang.basic.realbasic)
  • Re: 7 String?
    ... > I'd probably be ok with one tuned like a guitar on the bottom with an ... > additional string on top and then tuned down, ... Prev by Date: ...
    (rec.music.makers.guitar.jazz)