Skip to content
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

Specify an empty import as () #2855

Closed
bschmalhofer opened this issue Jan 21, 2024 · 1 comment
Closed

Specify an empty import as () #2855

bschmalhofer opened this issue Jan 21, 2024 · 1 comment
Assignees
Labels
tidying Tidying of the code
Milestone

Comments

@bschmalhofer
Copy link
Contributor

bschmalhofer commented Jan 21, 2024

When an empty list is passed to an use statement then the method import() of the module is not called. The empty list can be specified as () or as qw().

$ cat t.pl 
use List::Util;
use List::Util qw();
use List::Util ();

$ perl -MO=Deparse t.pl
use List::Util;
use List::Util ();
use List::Util ();
t.pl syntax OK

() makes a bit more sense as this is the version presented in the documentation of ùse: https://perldoc.perl.org/functions/use . There are also no words to be quoted. So let's standardize on ()` in order to be a bit more consistent. This will also make future tidyings, using the command perlimports, easier. See also https://perladvent.org/2023/2023-12-23.html .

The relavant cases can be found with:
grep -r 'use' | grep 'qw()' | grep -v cpan-lib | tee ../grep.out

@bschmalhofer bschmalhofer added the tidying Tidying of the code label Jan 21, 2024
@bschmalhofer bschmalhofer added this to the OTOBO 11.0 milestone Jan 21, 2024
@bschmalhofer bschmalhofer self-assigned this Jan 21, 2024
bschmalhofer added a commit that referenced this issue Jan 21, 2024
As opposed to qw() which is also an empty list, but slightly less tidy.
bschmalhofer added a commit that referenced this issue Jan 21, 2024
Issue #2855: specify an empty import list as ().
@bschmalhofer
Copy link
Contributor Author

The test suite still looks fine. PR is merged. Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tidying Tidying of the code
Projects
None yet
Development

No branches or pull requests

1 participant