Openning and reading from file in Perl
Results 1 to 3 of 3

Thread: Openning and reading from file in Perl

  1. #1
    Senior Member
    Join Date
    May 2002
    Posts
    344

    Openning and reading from file in Perl

    Howdy guys its been a LONG time since i have been on here! recently i am just getting back into programming and i am creating a program that will open up a log file and read some data from it and store it in hashes. anyways, my question is, how do i open up a file in perl to read from it? I think its a simple question, but unfortunetly i havent found a simple answer. if someone can point me to a tutorial or something of the sort, or better yet, explain it, that would be much appriciated. In the meantime, i will continue searching on google and other places for the answer. I am sure i will have more questions so stay alert! Thanks in advance...
    Support your right to arm bears.


    ^^This was the first video game which i played on an old win3.1 box

  2. #2
    Jaded Network Admin nebulus200's Avatar
    Join Date
    Jun 2002
    Posts
    1,356
    http://search.cpan.org/dist/perl/pod/perl.pod

    open (HANDLE, filename)

    open (IN, "/path/to/foo");

    At this point its just another file handle so you would input like with STDIN <>, so:

    while ( $_ = <IN> )
    {
    blah;
    }

    close(IN);
    There is only one constant, one universal, it is the only real truth: causality. Action. Reaction. Cause and effect...There is no escape from it, we are forever slaves to it. Our only hope, our only peace is to understand it, to understand the 'why'. 'Why' is what separates us from them, you from me. 'Why' is the only real social power, without it you are powerless.

    (Merovingian - Matrix Reloaded)

  3. #3
    Senior Member
    Join Date
    May 2002
    Posts
    344
    perfect thanks i wish they just wrote that in the books...
    Support your right to arm bears.


    ^^This was the first video game which i played on an old win3.1 box

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •