I've removed [EMAIL PROTECTED] from the Cc: list.  I don't see how any
of this directly relates to CGI.  Please avoid cross-posting unless relevant
and absolutely necessary.


On Sat, Mar 23, 2002 at 05:30:25AM +0800, Connie Chan wrote:
> 1. When I open a text file with *lines, however, I just want to read the
> first line, would this be a good idea ? open (FILE, "textfile.txt");
> $firstline = <FILE>; close (FILE); would this process run till EOF, or
> terminated after read $firstline ?

The short answer is no, $firstline = <FILE> will not read to EOF.

The <FILE> construct, in scalar context (as you have it in the assignment
$firstline = <FILE>) will read a chunk of the file, then return to you the
first "line" of that chunk.  It is possible the read will read until EOF. 
However, the size of the chunk it reads is in the kilobytes, usually one,
two, or four, so if you're concerned about memory usage it shouldn't cause a
problem.


> 2. I am using Win32 system , would you tell when is \n apprear and when is
> \r\n apprear ? What about this when dealing with binary files ?

When dealing with a file in normal (as opposed to binary) mode \r\n should
be translated automatically to \n when you read a line.  When dealing with a
file in binary mode the \r\n will not automatically be translated.

 
> 3. Is this different for this 2 scripts ?
> version 1 :  sub any { for (@data) { my ($a, $b) = split (/=/, $_) } return 1 }
> version 2 :  sub any { my $a, $b ; for (@data) { ($a, $b, $c) = split (/=/, $_) } 
>return 1 } 

There are various differences between the two snippets of code.  What are
you trying to get at?


> 4. Is that reading binary data faster then reading text file ?

It depends on how you're reading the files.  For example, $line = <FILE> on
a binary file will potentially be much slower, depending on where the
newline is located in the file.

 
> 5. How can I write multiple line if remark like /* and  */ pairs, instead
> of using # at every line ?

With POD, see perldoc perlpod


> 6. Is that any syntax for local call about  'use' and 'require', so as
> something like 'not require', 'not use' expressions ?

I don't understand this question.

 
> 7. Would you give me some short examples for //e, and //g ? I am confused
> for their usuage.

Any examples I give you would be rather contrived.  Perhaps someone else has
some relevant and short examples.


> 8. Any modules can help to check connecting threats for a certain page ?

What is a "connecting threat"?


> or if I run $alive = `ping $ip` a good idea ?

I don't know, what does your ping program do?  Where did you get $ip?  Are
you asking if it's a good idea from a security standpoint, or if it'll work?


> 9. Any modules can help to read and write the ID3vX for mp3 files ?

There are several, see search.cpan.org.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to