note
Loops
<p>Hi ArifS,</p>
<p>There are a number of problems with your code that would have been shown to you had you started your program off using strict and warnings. There is a function provided by [mod://File::Spec::Functions] named catfile, which will put the proper separator between your directory and file. I'd also suggest using the 3 argument version of open along with a lexical variable instead of a bareword "INPUT". Example changes shown below along with use of [mod://Win32] GetFolderPath to use the Desktop as the target directory:</p>
<c>
use strict;
use warnings;
use File::Spec::Functions;
use Win32 qw(CSIDL_DESKTOP);
my $directory = Win32::GetFolderPath(CSIDL_DESKTOP);
my $file = "my log file.log";
my $path = catfile($directory,$file);
open my $input, '<', $path or die "Can't open INPUT: $!";
my @lines = <$input>;
print "I have access to the folder\n";
close $input;
</c>
1105900
1105900