0

hi , i am pretty new to perl and I have a quick question.
below the code won't work unless fileName is under the same directory. would any one please give a quick reference in how to specify the full address of the file? such as /home/myName/fileName

#!/usr/bin/perl
cat fileName;

thanks

2
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by k2k
0
#!/usr/bin/perl
system("cat '/something/something/something/darkside.txt'");

thanks and may i also ask how to assign the value to a variable?

i tried

$var = system("cat '/root/file' | wc -l"); 
print "$var"

it somehow returns 0 which is not right.
what is the proper way? thanks

0
#!/usr/bin/perl

$filename = "/root/file";
$var = `cat $filename | wc -l`;

print "$var";

EDIT: you shouldn't be stomping around a system as root.

0

thanks it worked. sorry i forgot to mark it solved.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.