barewor...ehandles(3)

✨ NAME ✨

bareword::filehandles β€” disables bareword filehandles. That’s the whole assignment, bestie. πŸ’…

πŸŽ€ VERSION πŸŽ€

version 0.007

πŸ¦‹ SYNOPSIS πŸ¦‹

Okay so you drop this into your code and the bareword-filehandle vibe check begins:

no bareword::filehandles;

open FH, $file            # dies
open my $fh, $file;       # doesn't die

print FH $string          # dies
print STDERR $string      # doesn't die

πŸ’– DESCRIPTION πŸ’–

Real talk: this module lexically disables the use of bareword filehandles with builtin functions. The only exceptions β€” the special builtin filehandles that are still invited to the group chat β€” are STDIN, STDOUT, STDERR, ARGV, ARGVOUT and DATA. Iconic behavior, no cap. ✨

🌈 METHODS 🌈

🧚 unimport

unimport disables bareword filehandles for the remainder of the scope being compiled. It’s giving β€œturn the bareword filehandle switch off,” fr fr. 🫢

🧚 import

import enables bareword filehandles for the remainder of the scope being compiled. Yep, it’s the enable side. Slay. πŸ’–

πŸ’€ LIMITATIONS πŸ’€

Okay, tiny caveat, don’t come for me: Filetest operators (-X) can not be checked on Perl versions before 5.32, because hooking the op check function for these breaks stacked tests, e.g. -f -w -x $file. That’s the limitation, periodt. 😭

πŸ”₯ SEE ALSO πŸ”₯

  • perlfunc
  • B::Hooks::OP::Check

πŸ‘‘ AUTHOR πŸ‘‘

Dagfinn Ilmari MannsΓ₯ker <ilmari@ilmari.org> β€” iconic, obviously. πŸ‘‘

This software is copyright (c) 2011 - 2016 by Dagfinn Ilmari MannsΓ₯ker.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


πŸ’… That’s the whole page, bestie. Shoutout to the footer crew: perl v5.32.1 and the date 2022-01-20 β€” manual page delivered, vibe included. Byeee! 🫢🌸

πŸ“¦ where this page comes from