Loading ...
Sorry, an error occurred while loading the content.

[PBML] Re: reading a text file

Expand Messages
  • crengifo@reacciun.ve
    Hello silviaza! ... #!/Perl/bin/perl # filename: archi.pl # open cand.txt file and print it # Perl: 5.005_3 built for MSWin32-x86-object (519) # OS: Windows
    Message 1 of 3 , Nov 13, 1999
    • 0 Attachment
      Hello silviaza!

      Example 1:
      --------------------
      #!/Perl/bin/perl

      # filename: archi.pl
      # open cand.txt file and print it
      # Perl: 5.005_3 built for MSWin32-x86-object (519)
      # OS: Windows 98

      # Tree:
      # Examples (dir)
      # test (subdir)
      # tk (subdir)

      # cand.txt:
      # line 1
      # line 2

      # cand.txt and archi.pl are in test dir


      if (-e "cand.txt") { # if exist
      open (LEITURA, "cand.txt"); # open cand.txt
      while (<LEITURA>) { #
      print $_; # print line into $b file
      }
      close(LEITURA) || die "cannot close $a: $!"; # close the file

      } else {
      print "The file cand.txt doesn't exist!\n";
      exit;
      }
      --------
      Example 2:
      -------
      #!/Perl/bin/perl

      # filename: archi2.pl
      # open cand2.txt file and print it
      # Perl: 5.005_3 built for MSWin32-x86-object (519)
      # OS: Windows 98

      # Tree:
      # Examples (dir)
      # test (subdir)
      # tk (subdir)

      # cand2.txt
      # line 3
      # line 4

      # archi2.pl is in test dir
      # cand2.txt is in tk dir

      if (-e "../tk/cand2.txt") { # if exist
      open (LEITURA, "../tk/cand2.txt"); # open cand2.txt
      while (<LEITURA>) { #
      print $_; # print cand2.txt
      }
      close(LEITURA) || die "cannot close $a: $!"; # close the file

      } else {
      print "The file cand2.txt doesn't exist!\n";
      exit;
      }



      Send reply to: perl-beginner@egroups.com
      Date sent: Fri, 12 Nov 1999 07:27:24 -0800
      From: silviaza@...
      To: perl-beginner@...
      Subject: [PBML] reading a text file

      > I have created a perl script to read and query a text file. It is very
      > simple, but it do not work because it can not find the file!
      >
      > I have already put the file in different directories, with different
      > permissions but when I test for the existence of the file, the script
      > tells me it isn't there.
      >
      > Below it's the part of the script that tests for the existence of the
      > text file.
      >
      > if (-e "/cand2.txt") {
      > open (LEITURA, "/cand2.txt");
      > } else {
      > print "The file /cand2.txt doesn't exist!\n";
      > exit;
      > }
      >
      >
      > ------------------------------------------------------------------------
      > et the most popular downloads on the Web. They¹re new!
      > They¹re hot! They’re FREE! Utilities, drivers, games.
      > It’s all here. http://clickhere.egroups.com/click/1610
      >
      >
      >
      > -- Talk to your group with your own voice!
      > -- http://www.egroups.com/VoiceChatPage?listName=perl-beginner&m=1
      >
      >
      >
      >

      C Rengifo A.
    • crengifo@reacciun.ve
      I´m sorry, but my files archi.pl and archi2.pl have an error. Please, write those lines again: archi.pl and archi2.pl: It says: close(LEITURA) || die cannot
      Message 2 of 3 , Nov 14, 1999
      • 0 Attachment
        I´m sorry, but my files archi.pl and archi2.pl
        have an error. Please, write those lines again:

        archi.pl and archi2.pl:

        It says:
        close(LEITURA) || die "cannot close $a: $!"; # close the file

        Should say:
        close(LEITURA) || die "cannot close $!"; # close the file

        In my test file, I had written:
        $a="cand.txt"; (archi.pl) and
        $a="cand2.txt"; (archi2.pl)

        Excuse me, again.

        Carmelo Rengifo A.



        Send reply to: perl-beginner@egroups.com
        Date sent: Fri, 12 Nov 1999 07:27:24 -0800
        From: silviaza@...
        To: perl-beginner@...
        Subject: [PBML] reading a text file

        > I have created a perl script to read and query a text file. It is very
        > simple, but it do not work because it can not find the file!
        >
        > I have already put the file in different directories, with different
        > permissions but when I test for the existence of the file, the script
        > tells me it isn't there.
        >
        > Below it's the part of the script that tests for the existence of the
        > text file.
        >
        > if (-e "/cand2.txt") {
        > open (LEITURA, "/cand2.txt");
        > } else {
        > print "The file /cand2.txt doesn't exist!\n";
        > exit;
        > }
        >
        >
        > ------------------------------------------------------------------------
        > et the most popular downloads on the Web. They¹re new!
        > They¹re hot! They’re FREE! Utilities, drivers, games.
        > It’s all here. http://clickhere.egroups.com/click/1610
        >
        >
        >
        > -- Talk to your group with your own voice!
        > -- http://www.egroups.com/VoiceChatPage?listName=perl-beginner&m=1
        >
        >
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.