reading output file data as input data

Discussion in 'Perl Misc' started by Stephen Moon, Feb 28, 2004.

  1. Stephen Moon

    Stephen Moon Guest

    At the command prompt,

    I type "perl test.pl <file1> <file2> <file3>" to run the program.

    Initially, I open <file1> as an input file and output the information
    to <file2>. Later on in the same program, I use <file2> as an input
    and write the output to <file3>.

    I get an error saying that "filehandler FH opened for output only"
    although I close the <file2> and reopen it with a new filehandle.

    -Steve
     
    Stephen Moon, Feb 28, 2004
    #1
    1. Advertising

  2. Stephen Moon <> wrote:
    > At the command prompt,
    >
    > I type "perl test.pl <file1> <file2> <file3>" to run the program.
    >
    > Initially, I open <file1> as an input file and output the information
    > to <file2>. Later on in the same program, I use <file2> as an input
    > and write the output to <file3>.
    >
    > I get an error saying that "filehandler FH opened for output only"
    > although I close the <file2> and reopen it with a new filehandle.



    There is an error on line 42.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Feb 28, 2004
    #2
    1. Advertising

  3. (Stephen Moon) writes:

    > At the command prompt,
    >
    > I type "perl test.pl <file1> <file2> <file3>" to run the program.
    >
    > Initially, I open <file1> as an input file and output the information
    > to <file2>. Later on in the same program, I use <file2> as an input
    > and write the output to <file3>.
    >
    > I get an error saying that "filehandler FH opened for output only"
    > although I close the <file2> and reopen it with a new filehandle.


    There's probably something wrong with your program "test.pl".


    --
     
    Beable van Polasm, Feb 29, 2004
    #3
  4. Stephen Moon

    Stephen Moon Guest

    Tad McClellan <> wrote in message news:<>...
    > Stephen Moon <> wrote:
    > > At the command prompt,
    > >
    > > I type "perl test.pl <file1> <file2> <file3>" to run the program.
    > >
    > > Initially, I open <file1> as an input file and output the information
    > > to <file2>. Later on in the same program, I use <file2> as an input
    > > and write the output to <file3>.
    > >
    > > I get an error saying that "filehandler FH opened for output only"
    > > although I close the <file2> and reopen it with a new filehandle.

    >
    >
    > There is an error on line 42.


    well, actually there is an error on line 45:)
    I will look into more and try to figure out.

    In C, there is a way to make a file readable, writable, appendable, etc.
    Is there a way to do the same in perl in the Windows environment?

    -Steve
     
    Stephen Moon, Feb 29, 2004
    #4
  5. Stephen Moon

    ko Guest

    Stephen Moon wrote:
    > Tad McClellan <> wrote in message news:<>...
    >
    >>Stephen Moon <> wrote:
    >>
    >>>At the command prompt,
    >>>
    >>>I type "perl test.pl <file1> <file2> <file3>" to run the program.
    >>>
    >>>Initially, I open <file1> as an input file and output the information
    >>>to <file2>. Later on in the same program, I use <file2> as an input
    >>>and write the output to <file3>.
    >>>
    >>>I get an error saying that "filehandler FH opened for output only"
    >>>although I close the <file2> and reopen it with a new filehandle.

    >>
    >>
    >>There is an error on line 42.

    >
    > well, actually there is an error on line 45:)
    > I will look into more and try to figure out.


    You're missing the point. There are lots of people willing to help, but
    with the limited description given and lack of any code whatsoever its
    difficult to see what's going on - except for those who have figured out
    how to use the PSI::ESP module :)

    > In C, there is a way to make a file readable, writable, appendable, etc.
    > Is there a way to do the same in perl in the Windows environment?


    'perldoc perlopentut' from your shell. The documentation covers the many
    ways to open files in Perl.

    HTH - keith
     
    ko, Feb 29, 2004
    #5
  6. Stephen Moon <> wrote:

    > In C, there is a way to make a file readable, writable, appendable, etc.
    > Is there a way to do the same in perl in the Windows environment?



    Yes.

    You open files in Perl using the appropriately named open() function.

    Perhaps the documentation for that function might help...


    perldoc -f open



    Your articles may become invisible if you don't stop asking us
    to read the documentation for you...


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Feb 29, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dietrich
    Replies:
    1
    Views:
    647
    Joe Smith
    Jul 22, 2004
  2. Emel
    Replies:
    2
    Views:
    5,875
    nish a
    Jan 29, 2010
  3. igoR Buttler
    Replies:
    2
    Views:
    10,513
    Chris
    Jan 6, 2004
  4. Replies:
    3
    Views:
    393
  5. Replies:
    5
    Views:
    86
    Chris Angelico
    May 14, 2014
Loading...

Share This Page