Re: Perl file exists check

2016-11-10 Thread Shawn H Corey
On Thu, 10 Nov 2016 12:15:48 +0100 jaceke wrote: > sub escMe($) { Don't use sub prototypes. There are not the same as in C. They do something completely different. They are best not used until you know what they really do. :) -- Don't stop where the ink does. Shawn H

Re: Perl file exists check

2016-11-10 Thread Jim Gibson
> On Nov 10, 2016, at 3:34 AM, jaceke wrote: > > I would like as argument of function use path with special characters then '' > are needed. > That's why function adding apostrophe but after adding apostrofe file cannot > be found. If the string value of the scalar variable

Re: Perl file exists check

2016-11-10 Thread Jim Gibson
See inline comments below. On Nov 10, 2016, at 3:15 AM, jaceke wrote: > > This example will be better : > > #!/usr/bin/perl > use strict; > use File::Basename; > use utf8; > You should indent all blocks (subroutines, if statements, loops, etc.) to make it easier to read and

Re: Re: Perl file exists check

2016-11-10 Thread jaceke
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

Re: Re: Perl file exists check

2016-11-10 Thread jaceke
#!/usr/bin/perl use strict; use File::Basename; use utf8; sub escMe($) { my $f1 = shift; my $f2 = '/etc/passwd'; my $f2 = "'/etc/passwd'"; my $f3 = '/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

Re: Perl file exists check

2016-11-10 Thread Jim Gibson
On Nov 10, 2016, at 2:30 AM, jaceke wrote: > > Hi, > how can I check if file exist or not ? > > Here's a short test/example: > > if (-e '/etc/passwd') > { > printf "File exist !\n"; > } else { > printf "File not exist !\n"; > } > > That works great ! > > but next a short

Perl file exists check

2016-11-10 Thread jaceke
Hi, how can I check if file exist or not ?   Here's a short test/example:   if (-e '/etc/passwd') { printf "File exist !\n"; } else { printf "File not exist !\n"; }   That works great !   but next a short test/example:   my $f1 = '/etc/passwd';   if (-e $f1) { printf "File exist !\n"; } else {