Questions tagged [perl5.10]

Perl5.10 refers to a version 10 of Perl 5, released in 2007. It is officially unsupported.

21 questions
19
votes
4 answers

The good, the bad, and the ugly of lexical $_ in Perl 5.10+

Starting in Perl 5.10, it is now possible to lexically scope the context variable $_, either explicitly as my $_; or in a given / when construct. Has anyone found good uses of the lexical $_? Does it make any constructs simpler / safer /…
Eric Strom
  • 39,821
  • 2
  • 80
  • 152
14
votes
6 answers

Where are some good resources for learning the new features of Perl 5.10?

I didn't realize until recently that Perl 5.10 had significant new features and I was wondering if anyone could give me some good resources for learning about those. I searched for them on Google and all I found was some slides and a quick…
Frew Schmidt
  • 9,364
  • 16
  • 64
  • 86
10
votes
4 answers

Why doesn't Perl file glob() work outside of a loop in scalar context?

According to the Perl documentation on file globbing, the <*> operator or glob() function, when used in a scalar context, should iterate through the list of files matching the specified pattern, returning the next file name each time it is called or…
Rob
  • 333
  • 2
  • 9
8
votes
2 answers

How does O=Deparse work, and does Perl have and fold constant arrays?

I'm wondering, does -MO=Deparse show you all of the Perl optimizations, and why doesn't this get folded in Perl 5.10? $ perl -MO=Deparse -e'[qw/foo bar baz/]->[0]' ['foo', 'bar', 'baz']->[0]; -e syntax OK Some on IRC thought that O=Deparse might…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
7
votes
3 answers

Can I make sure Perl code written on 5.10+ will run on 5.8?

Some of the new features of Perl 5.10 and 5.12, such as "say", are defined as features, that you can enable or disallow explicitly using the "feature" pragma. But other additions, like the named capture groups of regexes, are implicit. When I write…
Thomas Kappler
  • 3,795
  • 1
  • 22
  • 21
4
votes
6 answers

Can't use string ("1") as a subroutine ref while "strict refs" in use

In a Perl daemon reacting to various events I'm trying to use a Null object pattern in 2 cases by creating anonymous subroutines, which should just return a value of 1 aka "true" (please scroll to the right to see the check subroutines for LOGIN and…
Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
3
votes
1 answer

Efficient pre-perl-5.10 equivalent of pack("Q>")

Update: Salva correctly points out that I was wrong about the introduction of the "Q" pack template. It's the ">" modifier that doesn't go back to 5.8. Perl 5.10 introduced the pack() modifier ">", which, for my use case with "Q" packs an unsigned…
tsee
  • 5,034
  • 1
  • 19
  • 27
3
votes
2 answers

Perl signal handlers are reset in END blocks

This works as expected since Perl 5.10.1: SIGINTs are trapped. #!/usr/bin/perl use strict; use warnings; $SIG{INT} = sub { die "Caught a sigint $!" }; sleep(20); But here SIGINTs are not trapped. #!/usr/bin/perl use strict; use…
gxtaillon
  • 1,016
  • 1
  • 19
  • 33
3
votes
1 answer

Matching a border of a russian word with \b

Is this a bug or am I doing something wrong (when trying to match Russian swear words in a multiplayer game chat log) on CentOS 6.5 with the stock perl 5.10.1? # echo блядь | perl -ne 'print if /\bбля/' # echo блядь | perl -ne 'print if…
Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
2
votes
3 answers

How flush file in perl under mac?

I have perl, v5.10.0 built for darwin-thread-multi-2level in remote iMac. And I want to run some perl script which prints to file some data and flushes after each line of output. $file_handle->flush(); autoflush $file_handle; I have tried this two…
Mihran Hovsepyan
  • 10,810
  • 14
  • 61
  • 111
2
votes
2 answers

Can a value be uninitialized, but still defined, in Perl?

Running ActiveState Perl 5.10.1 on win32. How is it that this code: die(defined($r->unparsed_uri =~ '/(logout.pl)?$')); ...dies with 1, whereas changing the same line to say this: die($r->unparsed_uri =~ '/(logout.pl)?$'); ...dies with Use of…
Kev
  • 15,899
  • 15
  • 79
  • 112
2
votes
2 answers

Did Perl 5.10 mess something up with prototypes?

I know this type of thing I want to do used to work in 5.8. Am I doing something wrong? Is there a way to get back there in Perl 5.10? Here's the module: package TableMod; use base qw; our @EXPORT_OK = qw; use Data::Dumper; sub…
Axeman
  • 29,660
  • 2
  • 47
  • 102
2
votes
1 answer

Perl: Adding writer in Moose class denies attribute access

I just started learning Moose, and I've created a very basic class. Here is my code: Person.pm package Person; use Moose; has fname => ( is => 'rw', isa => 'Str', reader => 'getFirstName', ); has lname => ( is => 'rw', isa => 'Str', …
incutonez
  • 3,241
  • 9
  • 43
  • 92
2
votes
3 answers

Adding new members while iterating a hash with "each"

In perl 5.10.1 is it ok to add new members to a hash while iterating through it with the each operator? Smth. like in this code (preparing data for Google charts), where I have a hash of hashes of arrays and I am trying to move the last element of…
Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
1
vote
1 answer

Encode - String bytes length

I've file file1.pl: use strict; use warnings; use Encode; my @flist = `svn diff --summarize ...`; foreach my $file (@flist) { my $foo = "$one/$file"; use bytes; print(bytes::length($one)."\n"); print(bytes::length($file)."\n"); …
Toru
  • 905
  • 1
  • 9
  • 28
1
2