in reply to Re: stat function used with linux find gives me no data
in thread stat function used with linux find gives me no data

Thank you. At first I tried:

$output = chomp($_);

That didn't work. So I found, from the online documentation, how to properly use chomp(). I tried:

$output = $_; chomp($output);

... and it worked!

Thank you, also, for those other suggestions. I will also give File::Find, File::Find::Rule and Path::Tiny a try soon.

Replies are listed 'Best First'.
Re^3: stat function used with linux find gives me no data
by hippo (Archbishop) on Oct 13, 2022 at 12:44 UTC

    Well done for consulting the docs - they really are rather good.

    You might also want to know that a simple assignment can be chomped as well so you could write this as chomp ($output = $_); instead. Full demo script:

    #!/usr/bin/env perl use strict; use warnings; $_ = "foo\n"; print "in: '$_'\n"; chomp (my $output = $_); print "out: '$output'\n";

    I concur with others in warning against shelling out to find for your original task, not least because of the vagaries of the arguments and output formats of such a utility across platforms. Stick with the modules which come with Perl or are on CPAN for better portability.


    🦛

Re^3: stat function used with linux find gives me no data
by NERDVANA (Priest) on Oct 13, 2022 at 23:04 UTC
    from the online documentation

    In case you didn't know, you can also find out about any perl function with perldoc -f chomp from the command line, or perldoc MODULENAME for any installed perl module. On Unix, you can often see them as manual pages as well: man MODULENAME, but that depends on your distro.