Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

What version of Strawberry Perl to use?

by gepebril69 (Scribe)
on Feb 08, 2013 at 16:20 UTC ( #1017850=perlquestion: print w/replies, xml ) Need Help??
gepebril69 has asked for the wisdom of the Perl Monks concerning the following question:


I've been building a project on two machines with the same Straweberry Perl versions: this worked fine and I could all install necessary CPAN modules. Now the hardware of my latest system is failing so I'm preparing a new machien with same Strawberry Perl version, but suddenly on a fresh install of Windows 7 packages like: Win32::DriveInfo and Date::Manip, pp can't be installed and errors arise like:

Can't use string ("Win32::API::Struct") as a HASH ref while "strict re +fs" in use at C:/strawberry/perl/site/lib/ / line 158. dmake.EXE: Error code 255, while making 'test_dynamic' CJOHNSTON/ C:\strawberry\c\bin\dmake.EXE test -- NOT OK

I like to use this new development machine to create similar par packages which can be distributed over server located over several places and are compatible with the par packages created by the current ones

Is this the way to do so, or I always should take the latest Strawberry Perl version to work with? And where do these errors suddenly come from?

Replies are listed 'Best First'.
Re: What version of Strawberry Perl to use?
by tobyink (Abbot) on Feb 08, 2013 at 16:47 UTC

    That particular message usually comes from using a sub designed to be used as an object method as a class method instead.

    Quick demo:

    use v5.10; use strict; use warnings; { package Local::Class; sub new { my $class = shift; my %self = @_; bless \%self => $class; } sub foo { my $self = shift; return $self->{foo}; } } my $object = Local::Class->new(foo => 42); say $object->foo; my $foo = Local::Class->foo;

    So that's what that error message means. It's not especially Perl version dependent though, so I can't imagine upgrading to a newer version of Perl will fix this particular bug.

    Though in general I'd always recommend running the latest stable version of Perl possible; currently 5.16.2.

    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

      Thanks for the answer.

      So it is wise to use the latest version of Perl. Even if you have to be compatible. (I never worry to do so with PHP) But it doesn't explain why it refuses to install now and had no problems in the past. See result with perldoc perllocal

      Tue Apr 3 10:36:14 2012: "Module" Win32::SystemInfo * "installed into: C:\strawberry\perl\site\lib" * "LINKTYPE: dynamic" * "VERSION: 0.11" * "EXE_FILES: "
        If php works for you, by all means :)
Re: What version of Strawberry Perl to use?
by bulk88 (Priest) on Feb 09, 2013 at 02:33 UTC

      ????, I'm using Win32:SystemInfo, what has that to do with Win32::API?

      Anyway I'm using the latest version of Perl now, I still couldn't install Win32::SystemInfo via Cpan as normal user or admin (windows) and than I used:

      force install Win32:SystemInfo

      That worked! I don't know if that was the way to go, or why suddenly this problem with this module is there?

      Any way when I use example code of the cpan page with this module the call failes:

      Can't use string ("Win32::API::Struct") as a HASH ref while "strict re +fs" in use at C:/strawberry/perl/vendor/lib/Win32 PI/ line 158.

      After I run

      my %mHash = (TotalPhys => 0, AvailPhys => 0, MemLoad => 0); if (Win32::SystemInfo::MemoryStatus(%mHash))

      What is a quick way to get around this problem and can use this module again, like it worked before, should I open a new node?

      The Win32::SystemInfo code is misusing Win32::API. See my post below.

Re: What version of Strawberry Perl to use?
by Mr. Muskrat (Canon) on Feb 09, 2013 at 17:33 UTC

    I just installed Win32::SystemInfo on one of my PCs using Strawberry Perl 5.12.3.

    Here's the code that doesn't throw an error (but it certainly does not work):

    use Win32::SystemInfo; my %mHash = (TotalPhys => 0, AvailPhys => 0); if (Win32::SystemInfo::MemoryStatus(%mHash)) { print $mHash{TotalPhys}; }

    Output: 4294967295 (It doesn't work because total physical memory is 16 GB.)

    This code throws a similar but different error to what you described (update: bug 65287):

    require Win32::SystemInfo; my %mHash = (TotalPhys => 0, AvailPhys => 0); if (Win32::SystemInfo::MemoryStatus(%mHash)) { print $mHash{TotalPhys}; }

    Output: Can't use string ("AvailPhys") as a HASH ref while "strict refs" in use at C:/strawberry/perl/site/lib/Win32/ line 231.

    I'll try it under Strawberry Perl 5.16 and update this post afterwards.

    Updates below...

    Build failure under Strawberry Perl reported to the author. Same error you reported above.

    It looked to be related to bug 48008 so I changed the source as described. The error went away but new problems cropped up so I updated the bug report.

      Thx for the help

      I just noted that my old environment was and my new environment

      My early conclusion is that the problem can lie in the fact that the problem only occurs in the 64bit Strawberry Perl environment, and not the 32 one. I will test it later-on.

        Chad Johnston is working on an update of Win32::SystemInfo. I tested an early version of it a few hours ago and provided some additional patches that appear to fix the remaining 64-bit issues.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1017850]
Approved by Athanasius
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2018-10-21 08:23 GMT
Find Nodes?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...

    Results (119 votes). Check out past polls.