Skip Menu |

This queue is for tickets about the IO-Socket-IP CPAN distribution.

Report information
The Basics
Id: 101954
Status: resolved
Priority: 0/
Queue: IO-Socket-IP

People
Owner: Nobody in particular
Requestors: quanah.gibsonmount [...] gmail.com
Cc:
AdminCc:

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



Subject: IO::Socket::IP errors on non-numeric versions of IO::Socket
IO::Socket::IP assumes that all versions of IO::Socket are numeric. However, that is not the case. For example, the version of IO::Socket in SLES is: perl -le 'eval "require $ARGV[0]" and print $ARGV[0]->VERSION' IO::Socket 1.30_01 This causes IO::Socket::IP to throw an error every time it is loaded at this line: if( $IO::Socket::VERSION < 1.35 ) { Argument "1.30_01" isn't numeric in numeric lt (<) at IO/Socket/IP.pm line 920, <DATA> line 290.
On Thu Feb 05 14:06:41 2015, MISHIKAL wrote: Show quoted text
> IO::Socket::IP assumes that all versions of IO::Socket are numeric. > However, that is not the case. For example, the version of IO::Socket > in SLES is:
Here's a quick dirty hack: --- IP.pm.orig 2015-02-05 13:22:31.000000000 -0600 +++ IP.pm 2015-02-05 13:23:10.000000000 -0600 @@ -917,7 +917,9 @@ # Versions of IO::Socket before 1.35 may leave socktype undef if from, say, an # ->fdopen call. In this case we'll apply a fix BEGIN { - if( $IO::Socket::VERSION < 1.35 ) { + my $socket_version = $IO::Socket::VERSION; + $socket_version =~ s/_.*//; + if( $socket_version < 1.35 ) { *socktype = sub { my $self = shift; my $type = $self->SUPER::socktype;
On Thu Feb 05 14:06:41 2015, MISHIKAL wrote: Show quoted text
> IO::Socket::IP assumes that all versions of IO::Socket are numeric. > However, that is not the case. For example, the version of IO::Socket > in SLES is: > > perl -le 'eval "require $ARGV[0]" and print $ARGV[0]->VERSION' > IO::Socket > 1.30_01 > > This causes IO::Socket::IP to throw an error every time it is loaded > at this line: > > if( $IO::Socket::VERSION < 1.35 ) { > > Argument "1.30_01" isn't numeric in numeric lt (<) at IO/Socket/IP.pm > line 920, <DATA> line 290.
Ref: http://perldoc.perl.org/perlmodstyle.html#Version-numbering If you want to release a 'beta' or 'alpha' version of a module but don't want CPAN.pm to list it as most recent use an '_' after the regular version number followed by at least 2 digits, eg. 1.20_01. If you do this, the following idiom is recommended: $VERSION = "1.12_01"; $XS_VERSION = $VERSION; # only needed if you have XS code $VERSION = eval $VERSION; With that trick MakeMaker will only read the first line and thus read the underscore, while the perl interpreter will evaluate the $VERSION and convert the string into a number. Later operations that treat $VERSION as a number will then be able to do so without provoking a warning about $VERSION not being a number. Based on that, one might argue that IO::Socket might have the 'bug' here (assuming there's no $VERSION = eval $VERSION;). Of course, there's plenty of room for debate there.
On Thu Feb 05 14:33:53 2015, PLOBBES wrote: Show quoted text
> On Thu Feb 05 14:06:41 2015, MISHIKAL wrote:
Show quoted text
> $VERSION = "1.12_01"; > $XS_VERSION = $VERSION; # only needed if you have XS code > $VERSION = eval $VERSION;
Simplified patch based on the above: --- IP.pm.orig 2015-02-05 13:22:31.000000000 -0600 +++ IP.pm 2015-02-05 13:46:02.000000000 -0600 @@ -917,7 +917,8 @@ # Versions of IO::Socket before 1.35 may leave socktype undef if from, say, an # ->fdopen call. In this case we'll apply a fix BEGIN { - if( $IO::Socket::VERSION < 1.35 ) { + my $socket_version=eval $IO::Socket::VERSION; + if( $socket_version < 1.35 ) { *socktype = sub { my $self = shift; my $type = $self->SUPER::socktype;
Thanks; patch applied. Will be in next release. -- Paul Evans
Released in 0.37 -- Paul Evans
On Fri Mar 13 07:10:52 2015, PEVANS wrote: Show quoted text
> Released in 0.37
Thank you for the quick turnaround!