fasoli has asked for the wisdom of the Perl Monks concerning the following question:
Dear Wise Monks, I'm trying to open a bunch of files in ARGV and read them line by line and then split in the way I'm specifying in the code - and then for testing I am trying to print their contents. However I'm getting a "Can't open GLOB(0x605d48): No such file or directory" error :( Can anyone please give me a hint what's happening? I'd be extremely grateful.
I'm trying to use two different filehandles to open the files and then push those two filehandles into @ARGV. Then I'm trying to use the <> operator. There is something that messes things up though and I'm getting an error. Any hints/feedback would be immensely useful.#!/bin/perl/ use strict; use warnings; my $molec1 = "molec1"; my $molec2 = "molec2"; my $input1; my $input2; @ARGV = (); my $i; my $j; my $path = "/store/group/comparisons"; my $line; my @columns; my $nextUnless = 2; # nr of lines to skip from beginning my $CountLines = 0; # total nr of lines in all files, including commen +ts for ($i=1; $i<=3; $i++) { open $input1, '<', "$path\/File-${molec1}-cluster${i}.out" or die $! +; for ($j=1; $j<=4; $j++) { open $input2, '<', "$path\/File-${molec2}-cluster${j}.out" or die +$!; push @ARGV, $input1; push @ARGV, $input2; my @list; my $list; my $a; my $b; while ($line = <>) { $CountLines += 1; next unless $. > $nextUnless; chomp $line; $line =~ s/^\s+|\s+$//g; push @list, [split/\s+/, $line]; @columns = split /\s+/, $line; } close $input1; close $input2; for ($a=0; $a<=$#columns; $a++) { for ($b=0; $b<=$#columns; $b++) { print "$list[$a][$b] "; # to check matrices } print " \n"; } } # for j } # for i
|
|---|