is not defined, as $name is defined within the if block, and no longer in scope (and hence no longer defined)once it leaves that block. try something like this:my $outfile = "outfile[$name].txt";
Note that I have not checked the rest of the code for errors, just what needed to remove the one error.#!/usr/bin/perl -w use strict; my $input = "transfer_to_linux.txt"; open (INPUT, "<$input"); while (my $line = <INPUT>){ print "here\n"; my $name; if ($line =~ /^%(.{1,100})$/){ print "EEEEEEEEEEEEEEEEEEEEEEEEEEEE\n"; $name = $&; } my $outfile = "outfile[$name].txt"; open (OUTFILE, "+>>$outfile"); if ($line =~ /^(\d{1,6})\t(\d{3})$/){ my $count = $1; print "COUNT: $count"; my $SPSS_figures = $2; print "SPSS_figures : $SPSS_figures"; my @split = split (//, $SPSS_figures); for (my $x = 0 ; $x <= $count; $x++){ print OUTFILE "$split[1]\t$split[2]\t$split[3]\n"; } } }
-enlil
In reply to Re: requires explicit package name
by Enlil
in thread requires explicit package name
by matth
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |