Bug 23172

Summary: urpmi_rpm-find-leaves won't run unless "my " is removed in " while (my $_ = shift) {" in /usr/bin/urpmi_rpm-find-leaves, line 26
Product: Mageia Reporter: Marja Van Waes <marja11>
Component: RPM PackagesAssignee: Thierry Vignaud <thierry.vignaud>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Normal CC: liam, thierry.vignaud
Version: Cauldron   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Source RPM: urpmi-8.111-2.mga7 CVE:
Status comment:

Description Marja Van Waes 2018-06-12 16:09:58 CEST
Some time ago, ankh reported on IRC that urpmi_rpm-find-leaves won't run. 

# urpmi_rpm-find-leaves 
Can't use global $_ in "my" at /usr/bin/urpmi_rpm-find-leaves line 26, near "my $_ "
Execution of /usr/bin/urpmi_rpm-find-leaves aborted due to compilation errors


I can confirm that, like he said, removing "my " in " while (my $_ = shift) {"  in /usr/bin/urpmi_rpm-find-leaves solves the issue.

Git blame told me that "my " was added to that line in this commit

http://gitweb.mageia.org/software/rpm/urpmi/commit/?id=6aaf7d1e438b9820164b94d3b548a858bb6abf68

   -while ($_ = shift) {
   +while (my $_ = shift) {

It didn't tell me whether that change should be reverted, or that another solution is better :-p
Comment 1 Marja Van Waes 2018-06-12 16:30:51 CEST
(In reply to Marja Van Waes from comment #0)

> 
> http://gitweb.mageia.org/software/rpm/urpmi/commit/
> ?id=6aaf7d1e438b9820164b94d3b548a858bb6abf68
> 
>    -while ($_ = shift) {
>    +while (my $_ = shift) {
> 
> It didn't tell me whether that change should be reverted, or that another
> solution is better :-p

I now think the above commit was exactly as intended. However, "my $_" is no longer allowed in Perl, even if it was since Perl 5.10:
https://rt.cpan.org/Public/Bug/Display.html?id=108203
Comment 2 Frédéric "LpSolit" Buclin 2018-06-13 12:29:37 CEST
Using $_ as a variable name is completely unhelpful to understand what the variable contains/is.
Thierry Vignaud 2018-06-13 17:56:54 CEST

Assignee: mageiatools => thierry.vignaud
Status: NEW => ASSIGNED

Comment 3 Thierry Vignaud 2018-06-13 17:57:57 CEST
I love perl regressions :-)
Comment 4 Thierry Vignaud 2018-06-13 18:02:36 CEST
Fixed in git

Resolution: (none) => FIXED
Status: ASSIGNED => RESOLVED