Skip Menu |

This queue is for tickets about the lib-with-preamble CPAN distribution.

Report information
The Basics
Id: 110487
Status: open
Priority: 0/
Queue: lib-with-preamble

People
Owner: Nobody in particular
Requestors: Mai [...] jochen-schweizer.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: unspecified behavior in require_with_preamble
Date: Mon, 21 Dec 2015 16:40:48 +0000
To: "bug-lib-with-preamble [...] rt.cpan.org" <bug-lib-with-preamble [...] rt.cpan.org>
From: Lukas Mai <Mai [...] jochen-schweizer.de>
Hello, in https://metacpan.org/source/ETHER/lib-with-preamble-0.001003/lib/lib/with/preamble.pm#L10-20 require_with_preamble returns a filehandle if it succeeds (‘-f $cand’). But if it doesn’t, it returns whatever the return value of ‘foreach’ is, which is documented as (perldoc perlsyn): Perceptive Perl hackers may have noticed that a for loop has a return value, and that this value can be captured by wrapping the loop in a do<http://perldoc.perl.org/functions/do.html> block. The reward for this discovery is this cautionary advice: The return value of a for loop is unspecified and may change without notice. Do not rely on it. It might be a good idea to add an explicit ‘return;’ in line 20. Lukas Mai JEP Developer Jochen Schweizer Technology Solutions GmbH Rosenheimer Strasse 145 e-f D- 81671 München Telefon: +49 89 606089-348 Fax: +49 89 606089-949 E-Mail: mai@jochen-schweizer.de<mailto:mai@jochen-schweizer.de> Ein Unternehmen der Jochen Schweizer Unternehmensgruppe www.jochen-schweizer.de/unternehmensgruppe<http://www.jochen-schweizer.de/unternehmensgruppe> HRB München 203111 Geschäftsführer: Florian Herschke Prokurist: Saad Daoud PS: Du bist, was du erlebst. Jetzt die Jochen Schweizer App kostenlos downloaden www.jochen-schweizer.de/app<http://www.jochen-schweizer.de/on/demandware.store/Sites-JSShop-Site/default/Gutschein-Landingpage?cid=erlebnis-app&src=emailfooter&utm_source=email&utm_medium=referral&utm_campaign=app&utm_term=footer> Hinweis: Diese Nachricht und jeder Anhang ist vertraulich und möglicherweise rechtlich geschützt. Sollten Sie diese Nachricht irrtümlich empfangen haben, benachrichtigen Sie bitte den Absender per Rückantwort. Löschen Sie diese Nachricht anschließend sofort von Ihrem System. Bitte kopieren Sie diese Nachricht nicht, nutzen Sie den Inhalt der Nachricht nicht anderweitig und machen Sie die Nachricht und deren Inhalt keinem Dritten zugänglich. Missbrauch kann strafrechtlich und zivilrechtlich verfolgt werden. Notice: The information contained in this e-mail is confidential or may otherwise be legally privileged. It is intended for the named recipient only. If you have received it in error, please notify us immediately by reply and delete this message and all its attachments. Please note that any unauthorised review, copying, disclosing or otherwise making use of the information is strictly prohibited.
On Mon Dec 21 11:41:11 2015, Mai@jochen-schweizer.de wrote: Show quoted text
> It might be a good idea to add an explicit ‘return;’ in line 20.
Here's a patch doing that.
Subject: 0001-don-t-rely-on-foreach-return-value-RT-110487.patch
From 2975aa111ed3e803480d464e30bbf233be9d2ae5 Mon Sep 17 00:00:00 2001 From: Lukas Mai <l.mai@web.de> Date: Fri, 8 Jan 2016 21:43:44 +0100 Subject: [PATCH] don't rely on foreach return value (RT#110487) --- lib/lib/with/preamble.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/lib/with/preamble.pm b/lib/lib/with/preamble.pm index 42b6b3a..81f323d 100644 --- a/lib/lib/with/preamble.pm +++ b/lib/lib/with/preamble.pm @@ -17,6 +17,7 @@ sub require_with_preamble { } } } + return; } sub with_preamble { -- 2.7.0