Skip to content

Assorted File::stat changes and clean-up #23509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 1, 2025
Merged

Conversation

mauke
Copy link
Contributor

@mauke mauke commented Jul 30, 2025

Building on #23508, here are some bigger changes:

  • Make File::stat::stat and File::stat::lstat always return a scalar, even in list context. In particular, the failure case now always returns undef, not the empty list.
  • Implement the CORE::stat (and CORE::lstat) behavior of checking $_ if no arguments are given.
  • Document stat(\*_) syntax to reuse previous stat results.
  • Add more examples to the documentation.
  • Add more links to the documentation.
  • Clean up whitespace.

  • This set of changes requires a perldelta entry, and it is included.

@mauke mauke force-pushed the file-stat-cleanup branch 2 times, most recently from 8eaf284 to 895a91f Compare July 30, 2025 20:58
@mauke mauke force-pushed the file-stat-cleanup branch from 895a91f to 8762b05 Compare July 30, 2025 22:14
mauke added 9 commits August 1, 2025 08:51
Previously, a failing stat would return an empty list in list context,
not undef. This can cause surprises in code like:

    foo(stat $file);  # would call foo() without arguments if stat fails

    my %hash = (
        stat => stat($file),
        # Odd number of elements in hash assignment if stat fails
    );
That is, show how to access File::stat::stat without overriding anything
and how to access CORE::stat despite overriding stat.
Previously, the POD used a mix of 1-space and 4-space indents.

Also, hyperlink stat(2) and Class::Struct.
Most lines in these files used spaces for indentation, but a few of them
still had tabs. Keep things consistent by using spaces everywhere.
I'm not sure why the "unexported and undocumented populate() function"
had to be mentioned here. The more straightforward `stat(\*_)` syntax
works on all perl versions back to (at least) 5.8.9 and is compatible
with CORE::stat, too.
@mauke mauke force-pushed the file-stat-cleanup branch from 8762b05 to 1335ada Compare August 1, 2025 06:52
@mauke mauke removed the hasConflicts label Aug 1, 2025
@mauke mauke merged commit 4b09079 into Perl:blead Aug 1, 2025
33 checks passed
@mauke mauke deleted the file-stat-cleanup branch August 1, 2025 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants