This example will be better :
#!/usr/bin/perl
use strict;
use File::Basename;
use utf8;
sub escMe($) {
my $f1 = shift;
my $f2 = '/etc/passwd';
my $f3 = "'/etc/passwd'";
my $f4 = '/etc/passwd';
$f1 = "'" . $f1 . "'";
if($f1 eq $f2) {
print("Files are same $f1$f2\n");
} else {
print("Files are NOT same $f1$f2\n");
}
if (-e $f1)
{
printf "File exist $f1 !\n";
} else {
printf "File not exist $f1 !\n";
}
if (-e '$f2')
{
printf "File exist $f2 !\n";
} else {
printf "File not exist $f2 !\n";
}
if (-e '$f3')
{
printf "File exist $f3 !\n";
} else {
printf "File not exist $f3 !\n";
}
if (-e '$f4')
{
printf "File exist $f4 !\n";
} else {
printf "File not exist $f4 !\n";
}
if (-e '/etc/passwd')
{
printf "File exist !\n";
} else {
printf "File not exist !\n";
}
return $f1;
}
escMe("/etc/passwd");
Output:
Files are NOT same '/etc/passwd'/etc/passwd
File not exist '/etc/passwd' !
File not exist /etc/passwd !
File not exist '/etc/passwd' !
File not exist /etc/passwd !
File exist !
W dniu 2016-11-10 11:52:46 użytkownik Jim Gibson <
jimsg...@gmail.com> napisał:
> Both of those versions work on my system. There is no reason for the version using a scalar variable holding the file path not to work.
>
> Can you post a complete, short, working program that you think does not work?
>
>
> --
> To unsubscribe, e-mail:
beginners-...@perl.org
> For additional commands, e-mail:
beginne...@perl.org
>
http://learn.perl.org/
>
>
>