Dear Monks , i am trying to open a txt file( Junk.txt) which contains list of other txt files. My code is not working and it displays error: No such file or directory at R_loop2.pl line 19. i tried many ways but failed. I will be thankful for any help. My file contents and code is below
my text file ( junk.txt ) is here
file0.txt file1.txt file2.txt file3.txt file4.txt file5.txt file6.txt file7.txt file8.txt file9.txt file10.txt
my code is here
use strict; sub R_loop2(){ my $file = "junk.txt"; open (FH, "< $file") or die "Can't open $file for read: $!"; my @lines; while (<FH>) { push (@lines, $_); } close FH or die "Cannot close $file: $!"; #print @lines; my $count= @lines + 1; my @dude; for ( my $k=0; $k<$count; $k++){ open FILE, '<', "@lines[$k]" or die $!; #my @dude; while (my $line = <FILE>) { my ($ip) = $line =~ /(\d+\.\d+\.\d+\.\d+)/; #print $ip; push(@dude,$ip); #print "$hh"; } system("clear"); print "The packet traverse through this path :\n"; my $num = @dude + 1; for(my $o = 0; $o<$num; $o++){ print " @dude[$o]\n"; } } my %seen; foreach my $string(@dude) { next unless $seen{$string}++; print "Routing Loop Detected \n"; return 1; } }1;
In reply to No such file or directory at R_loop2.pl line 19. by zakishah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |