develooper Front page | perl.beginners | Postings from March 2002

why can't I write to a file

Thread Next
From:
richard noel fell
Date:
March 29, 2002 05:51
Subject:
why can't I write to a file
Message ID:
3CA47759.181E7136@rcn.com

Here is an abridged version of what I am trying to do which is:
1) write to a file in one subroutine
2) write the contents of the original file to another file in  a
separate subroutine.

However, I get the error message:

Use of uninitialized value in string at ./scratch2.pl line 24, <In1>
line 1.
Use of uninitialized value in string at ./scratch2.pl line 24, <In1>
line 2.
Use of uninitialized value in string at ./scratch2.pl line 24, <In1>
line 3.
Use of uninitialized value in string at ./scratch2.pl line 24, <In1>
line 4.
Use of uninitialized value in string at ./scratch2.pl line 24, <In1>
line 5.
Use of uninitialized value in string at ./scratch2.pl line 24, <In1>
line 6.
Use of uninitialized value in string at ./scratch2.pl line 24, <In1>
line 7.
Use of uninitialized value in string at ./scratch2.pl line 24, <In1>
line 8.
Use of uninitialized value in string at ./scratch2.pl line 24, <In1>
line 9.



I cannot figure out what is happening. Can anyone explain this behavior
to me?
Thanks,
Dick Fell


#!/usr/local/ActivePerl-5.6/bin/perl5.6.1 -w
use strict;

&print_to_in();
&print_out();




#subroutines
sub print_to_in{
open Out1,">/home/rfell/tutoring/beaven/webproject/tmp/in.tmp" or die
"Cannot open in.tmp:$!";
for (my $i=1;$i<10;$i++){
print Out1 "$i\n";
}
close Out1;
}


sub print_out{
open In1,"/home/rfell/tutoring/beaven/webproject/tmp/in.tmp" or die
"Cannot open in.tmp:$!";
open Out1, ">/home/rfell/tutoring/beaven/webproject/tmp/out.tmp" or die
"Cannot open out.tmp:$!";
while(defined<In1>){
print Out1  "$_";
}
}

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About