Why use int () in Perl chmod?

Why do you need to use the int () function when setting up perms to a file in Perl?

die "blab, blah" if (! chmod(int(0664), $tmp_file)); 

I can understand the use of oct (), as in the following perldoc example:

 $mode = "0644"; chmod(oct($mode), $tmp_file); 

but int () function?

Edit

Just for completeness, here's a recommendation from perldoc -f chmod ...

 $mode = 0644; chmod $mode, "foo"; # this is best 
+6
source share
1 answer

It makes no sense. 0664 already leads to an integer.

 $ perl -MDevel::Peek -e'Dump(0664)' SV = IV(0x7a6118) at 0x7a6128 REFCNT = 1 FLAGS = (PADTMP,IOK,READONLY,pIOK) IV = 436 

IOK signals that the scalar contains an integer value.

This is the result of someone starting with oct("0644") , but they don’t quite understand what they do when they leave the line.

+10
source

All Articles