slartsa has asked for the wisdom of the Perl Monks concerning the following question:
I have absolutely no idea of coding so please don't insult me if you find any brain misusage from within the code =) I'm getting this report when trying to run it:#!perl use strict; use warnings; my $readfile = 'blah.csv'; my $writefile = 'bleh.csv'; my $row = <$fh>; my $found = 0; my @cols; my (@col1,@col2); my @words = split(//,@col1); open my $fh, "<", $readfile; open my $wfh, "<", $writefile; foreach (<$fh>) { tr /a-z/A-Z/; chomp; my @cols = split /\;/; push @col1, $cols[0]; push @col2, $cols[1]; if ( @col2 =~ m/$words[$_](\d+)/ ) { $found++; @words++; } open($wfh) or die "YARRG: $!"; print $wfh "$row';'@words';'$found"; $found = 0; @words = 0; }
I don't know how I could fix those, help please? As many of you guys might already have noticed it is not even my intention to print the results into the file that is being read from but the whole thing is copied into a new file with the result intact. All help is appreciated! edit: oops, "(a)words" is not supposed to be in here but it doesn't really matter concerning the result.Applying pattern match (m//) to @array will act on scalar(@array) at C +:\blah\vertailu2.pl line 24. Global symbol "$fh" requires explicit package name at C:\blah\vertailu +2.pl line 8. Execution of C:\blah\vertailu2.pl aborted due to compilation errors.
if ( @col2 =~ m/$words[$_](\d+)/ ) { $found++; @words++; }
|
|---|