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
perldoc -f my should perhaps mention BEGIN and END #7861
Comments
From @jidanniMaybe "perldoc -f my" should add: |
From perl5-porters@ton.iguana.beIn article <rt-3.0.11-34650-109976.5.58716831800943@perl.org>,
Absolutely not. You shouldn't just randomly add things to shut up |
The RT System itself - Status changed from 'new' to 'open' |
From @schwernOn Sat, Apr 02, 2005 at 10:53:47PM +0000, Ton Hospel wrote:
I agree. I'm also curious as to how BEGIN and END blocks play a role here. Dan, maybe you should post what you're doing with our, BEGIN and END so |
@smpeters - Status changed from 'open' to 'rejected' |
From @jidanniD> Dan, maybe you should post what you're doing with our, BEGIN and END so User is told to use strict. |
From @schwernOn Tue, Apr 05, 2005 at 03:55:26AM +0800, Dan Jacobson wrote:
Whoa... efficiency? How is using the BEGIN block more efficient? Perhaps in this contrived example of using strict in a -n one-liner it But I do see where you're going with this.
Traditionally this sort of stuff is discussed in perlsub but that's probably our doesn't help this situation as even though it declares a global $ perl -Mstrict -wle 'BEGIN { our $k = 3; } print "$k"' You would have to say: perl -Mstrict -wle 'our $k; BEGIN { $k = 3; } print "$k"' And at that point, unless $k really is supposed to be global, you might as perl -Mstrict -wle 'my $k; BEGIN { $k = 3; } print "$k"' And finally because our() and my() both occur at compile time you can perl -Mstrict -wle 'my $k = 3; print "$k"' I agree its probably useful for my() to mention our() as they are related. I also agree that its probably useful to talk about scoping, declaration |
From @AbigailOn Mon, Apr 04, 2005 at 03:06:01PM -0700, Michael G Schwern wrote:
For this particular case, yes. But in general, there is a difference my $var = EXPR; and my $var; BEGIN {$var = EXPR} You are right that the my() is done at compile time. The evaluation Abigail |
From @tamiasOn Tue, Apr 05, 2005 at 03:55:26AM +0800, Dan Jacobson wrote:
seq 3|perl -wne 'use strict;my $k;BEGIN{$k=3}print "$k$_"' There are no "special challenges". You simply need to declare your Using our where you have my doesn't even fix the problem: seq 3|perl -wne 'use strict;BEGIN{our $k=3}print "$k$_"' #bzzt so I'm not sure why you suggested that. Ronald |
From @AbigailOn Mon, Apr 04, 2005 at 05:53:30PM -0400, Ronald J Kimball wrote:
$ seq 3|perl -wne 'use strict;my $k;BEGIN{$k=3}print "$k$_"' Problem is the -n. The entire program is inside a block, which is $ seq 3|perl -wne 'use strict;BEGIN{$::k=3}print "$::k$_"' Abigail |
From @demerphqOn Apr 5, 2005 12:34 AM, Abigail <abigail@abigail.nl> wrote:
its a pity that perl -we "use strict; $k=3;" -ne "print $k$_" doesnt do the right thing. maybe a new switch could be provided that It would make thing like this a lot easier to read, and would Just a thought. Yves -- |
From @AbigailOn Tue, Apr 05, 2005 at 08:01:29AM +0200, demerphq wrote:
The following works up to 5.8.1: $ seq 3|/opt/perl/5.8.1/bin/perl -Mstrict='});my $k;()=({' -wne 'BEGIN{$k=3}print "$k$_"' But in 5.8.2 and beyond: $ seq 3|/opt/perl/5.8.2/bin/perl -Mstrict='});my $k;()=({' -wne 'BEGIN{$k=3}print "$k$_"' I guess noone runs 'make torturetest'. Abigail |
From @pjcjOn Wed, Apr 06, 2005 at 12:16:21AM +0200, Abigail wrote:
I don't, as a rule. I suppose this patch would be in order then? Inline Patch--- japh/abigail.t.org 2005-02-21 14:24:03.000000000 +0100
+++ japh/abigail.t 2005-04-06 01:30:36.000000000 +0200
@@ -68,7 +68,7 @@
my $JaPH_c = "Just another Perl Hacker,";
my $JaPh_c = "Just another Perl hacker,";
-plan tests => 130;
+plan tests => 129;
{
my $out = sprintf "Just another Perl Hacker";
@@ -413,15 +413,6 @@
ARGS: $datafile
EXPECT: 6
-####### Abusing -M
-1
-SWITCHES
--Mstrict='}); print "Just another Perl Hacker"; ({'
--l
-SKIP_OS: VMS
-MSWin32
-NetWare
-
####### rand
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
-- Paul Johnson - paul@pjcj.net |
From @AbigailOn Wed, Apr 06, 2005 at 01:36:12AM +0200, Paul Johnson wrote:
Or rather: Inline Patch--- t/japh/abigail.t.orig Wed Apr 6 01:38:40 2005
+++ t/japh/abigail.t Wed Apr 6 01:39:59 2005
@@ -418,7 +418,7 @@
SWITCHES
-Mstrict='}); print "Just another Perl Hacker"; ({'
-l
-SKIP_OS: VMS
+SKIP: No longer works in 5.8.2 and beyond.
MSWin32
NetWare
Abigail |
From @schwernOn Wed, Apr 06, 2005 at 01:41:55AM +0200, Abigail wrote:
Before we stub it out, anyone know what changed to cause this to break? |
From @ysthOn Tue, Apr 05, 2005 at 07:59:14PM -0700, Michael G Schwern wrote:
There was a change at one point to prevent people doing "dangerous" things |
From @ysthOn Tue, Apr 05, 2005 at 07:59:14PM -0700, Michael G Schwern wrote:
Ah, it's change 21429. Abigail was relying on the split ',', q{ ... } that |
From @rgsAbigail wrote:
Thanks, applied as #24192.
|
Migrated from rt.perl.org#34650 (status was 'rejected')
Searchable as RT34650$
The text was updated successfully, but these errors were encountered: