At 10:44 AM -0700 12/24/10, Chris Stinemetz wrote:
Okay I appreciate everyones help. I feel like i am getting closer.
Below is my current code and error I get.
Thank you all!
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4
5 # Intialization begins
6
7 my $cell ='';
8 my $filename ='';
9 my $in ='';
Do not declare $in here and give it a value. Using lexical variables
as file handles only works if the are undefined. You are assigning a
value to $in.
10 my $line ='';
11 my $mtype ='';
12 my $out ='';
Same here for $out
13 my $outputfile ="processed.txt";
14 my $rlptxat ='';
15 my $sector ='';
16 my $version ='';
17
18
19 my @data = ();
20 my @fields = (0, 5, 44, 31, 32);
21 my @val = (split /:/, $line);
22
23 # Initialization ends
24
25 #Get data from EVDOPCMD.txt file and output to processed.txt file.
26
27 print "What file do you want to parse?";
28 $filename = <STDIN>;
29
30 open($in, '<', $filename) or die("Can't open $filename for reading: $!");
31 open($out, '>', $outputfile) or die("Can't create file $outputfile: $!");
Replace with
open( my $in,...;
open( my $out, ...;
and do not declare $in and $out above,
--
Jim Gibson
j...@gibson.org
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/