Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

stat() returning values in random order for files on s3 bucket? (SOLVED)

by nysus (Parson)
on Jun 15, 2021 at 21:08 UTC ( [id://11133902]=perlquestion: print w/replies, xml ) Need Help??

nysus has asked for the wisdom of the Perl Monks concerning the following question:

I'm seeing some weird behavior. Got this line: my @stats = stat($f);

$f is the path to a file sitting on an amazon s3 bucket. I am using s3fs to mount the bucket on my instance and the path to the file looks like a normal path, something like: /backups/backups_db/some_dir/file. The backups_db is a symlink to /s3bucket/backups_db At any rate, @stats contains values from the stat() function above but in totally random order. Here's a dump of three different files:

[DEBUG] Rex.CLI: 206 $VAR1 = [ 'gid', 1000, 'size', 325342, 'mode', '0644', 'mtime', 1623769844, 'uid', 1000, 'atime', 0 ]; [DEBUG] Rex.CLI: 206 $VAR1 = [ 'uid', 1000, 'size', 325316, 'atime', 0, 'gid', 1000, 'mode', '0644', 'mtime', 1623771735 ]; [DEBUG] Rex.CLI: 206 $VAR1 = [ 'gid', 1000, 'mtime', 1623772143, 'mode', '0644', 'atime', 0, 'uid', 1000, 'size', 325346 ];

I'm not sure if I'm just being an idiot on how to use the stat() function or if the stat() function does not work properly on a file on an s3 bucket using s3fs. If it's the latter, can this be fixed?

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

Replies are listed 'Best First'.
Re: stat() returning values in random order for files on s3 bucket?
by Fletch (Bishop) on Jun 15, 2021 at 21:17 UTC

    Perhaps something has pulled in something similar to File::stat and overridden the builtin stat with something providing a hash (which is getting flattened into a list and you're saving into an arrayref . . . somehow; without more context like the code producing your sample output it's hard to tell so that's just guessing)?

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: stat() returning values in random order for files on s3 bucket?
by nysus (Parson) on Jun 15, 2021 at 21:20 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11133902]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-25 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found