how to include a text pattern in system function in PERL

Pleeeeease help..

I'm working in perl

i have a system function to check whether a file is readable for others or not.

i just want to print a text in that command

my command is :

system ("ls -la $filename | awk '\$1~ /^-......r../ {print \$9}'");

i know for displaying text in awk command one needs to put it in double quotes "" but here how to do that.. when we are executing awk in system command (which already has double quotes in the start and end)

Perl has file tests too, you know. You can do this to check if a file is readable or not!

if ( -r "/path/to/file.txt" ) {
    print "Yes, readable.\n";
}

if (-r ) would display the print output if the file is readable for the user.

i need to check it for others.

E.g.

-rw--rw-r--

it means its :-

readable and writable for user
readable and writable for group
and only readable other

so.. i need it for others

As i said in the another thread, you need to check stat

its not helping

when i write stat file.txt on the command terminal the file statistics appear.

but when i write this in a perl script .. output doesn't appear

i anyway have to use

system (stat file.txt)

then it appear

but again difficulties are there in system command to print a string

Indeed it is helping a lot.

If you would have checked the link itkamaraj posted correctly, you would have seen this example, which has just been changed by the shebang and a variable $filename:

$ cat mach.pl
#!/usr/bin/perl
$filename = "./infile";
$mode = (stat($filename))[2];
printf "Permissions are %04o\n", $mode & 07777;

It produces:

$ ls -la infile
-rw-r--r-- 1 root root 0 23. Aug 11:12 infile
$ ./mach.pl
Permissions are 0644
#!/usr/bin/perl -w
$file="input.txt";
$mode = sprintf '%04o', (stat $file)[2] & 07777;
print "Permissions are $mode\n";