perl5 icon indicating copy to clipboard operation
perl5 copied to clipboard

Document a way to perform `use Module VERSION LIST` on the command-line

Open book opened this issue 4 years ago • 13 comments

The split(/,/,q{foo,bar}) seems to still happen.

This is the currently documented case:

$ perl -MO=Deparse '-MList::Util=any,all' -e1
use List::Util (split(/,/, 'any,all', 0));
'???';
-e syntax OK

And these work too (and the split on comma also happens somehow):

$ perl -MO=Deparse '-MList::Util any,all' -e1
use List::Util ('any', 'all');
'???';
-e syntax OK

$ perl -MO=Deparse '-MList::Util 1.5' -e1
use List::Util 1.5;
'???';
-e syntax OK

$ perl -MO=Deparse '-MList::Util 1.5 any,all' -e1
use List::Util 1.5 ('any', 'all');
'???';
-e syntax OK

book avatar Jul 25 '21 17:07 book

The split actually doesn't happen, this only works because strict is not active.

Grinnz avatar Jul 25 '21 17:07 Grinnz

-M is a very naive filter, it literally sticks the argument verbatim into a use statement. Only when the = is provided are the arguments split into a list of strings.

Grinnz avatar Jul 25 '21 17:07 Grinnz

I would not approve of the current wording of this because it is B::Deparse that generates that syntax, not -M.

Grinnz avatar Jul 25 '21 17:07 Grinnz

I would not approve of the current wording of this because it is B::Deparse that generates that syntax, not -M.

Agreed. I was confused by the difference in the B::Deparse output. Thanks for the explanation.

If I understand your comment correctly, it's the log message I should rework, not the actual documentation patch, right?

book avatar Jul 25 '21 17:07 book

I think mentioning that the quoted form without = can be used to insert a version check and quoted argument list would be useful. But it should be quoted in that case because the = argument splitting doesn't occur.

Grinnz avatar Jul 25 '21 17:07 Grinnz

Re-reading your comments after a day, I now fully understand all of your comments:

  • " this only works because strict is not active": no strict 'subs' enables poetry mode, so barewords are treated as strings
  • " it is B::Deparse that generates that syntax, not -M": B::Deparse produces the string syntax from the barewords-interpreted-as-strings above
  • "it should be quoted in that case because the = argument splitting doesn't occur": with strict, the quotes are indeed required; and without =, no splitting is done

I'll rewrite the patch and the message to be more accurate, and force push on my branch again.

book avatar Jul 26 '21 12:07 book

@book pinging you about this

khwilliamson avatar Dec 16 '21 15:12 khwilliamson

@khwilliamson sorry, didn't find time to rewrite this in a satisfactory way yet.

book avatar Jan 13 '22 14:01 book

@khwilliamson sorry, didn't find time to rewrite this in a satisfactory way yet.

@book, can you provide us with an update on the status of this p.r.?

Thank you very much. Jim Keenan

jkeenan avatar Jul 03 '22 18:07 jkeenan

@khwilliamson sorry, didn't find time to rewrite this in a satisfactory way yet.

@book, can you provide us with an update on the status of this p.r.?

Thank you very much. Jim Keenan

@book, any progress on this? Or should we close the ticket?

jkeenan avatar Sep 16 '22 22:09 jkeenan

I'll get back to it, after I'm done with #20337.

book avatar Sep 26 '22 11:09 book

@book maybe do this first? Its just a doc patch, so it should be easy to get it right and merged.

demerphq avatar Feb 08 '23 07:02 demerphq

I'll get back to it, after I'm done with #20337.

@book, should we continue to keep this pull request open?

jkeenan avatar Jul 13 '24 20:07 jkeenan