Skip Menu |

This queue is for tickets about the String-Random CPAN distribution.

Report information
The Basics
Id: 86894
Status: open
Priority: 0/
Queue: String-Random

People
Owner: Nobody in particular
Requestors: IKEGAMI [...] cpan.org
Cc:
AdminCc:

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



Subject: Spurious warnings
Issuing the warning '\.' being treated as literal '.' makes no sense. The snippet } else { carp "'\\$tmp' being treated as literal '$tmp'"; push(@{$string}, [$tmp]); } should be } else { carp "'\\$tmp' being treated as literal '$tmp'" if $tmp =~ /\w/; push(@{$string}, [$tmp]); }
Workaround: sub _random_regex { local $SIG{__WARN__} = sub { return if $_[0] =~ /^'\\(\W)' being treated as literal '\1'/; print(STDERR $_[0]); }; return &String::Random::random_regex(@_) };
Hi, On Fri Jul 12 14:08:53 2013, ikegami wrote: Show quoted text
> Issuing the warning > > '\.' being treated as literal '.' > > makes no sense. > > The snippet > > } else { > carp "'\\$tmp' being treated as literal '$tmp'"; > push(@{$string}, [$tmp]); > } > > should be > > } else { > carp "'\\$tmp' being treated as literal '$tmp'" if $tmp =~ /\w/; > push(@{$string}, [$tmp]); > }
This should be fixed in version 0.24 of String-Random. Please test it, and let us know if this bug report can be closed. Regards, -- Shlomi Fish
CC: IKEGAMI [...] cpan.org
Subject: Re: [rt.cpan.org #86894] Spurious warnings
Date: Wed, 4 Dec 2013 21:53:13 -0500
To: bug-String-Random [...] rt.cpan.org
From: Eric Brine <ikegami [...] adaelis.com>
$ perl -MString::Random=random_regex -E'say random_regex(q{\d\d\d\m});' '\m' being treated as literal 'm' at -e line 1. 023m $ perl -MString::Random=random_regex -E'say random_regex(q{\d\d\d\.});' 083. Good :)
CC: IKEGAMI [...] cpan.org
Subject: Re: [rt.cpan.org #86894] Spurious warnings
Date: Wed, 4 Dec 2013 21:56:45 -0500
To: bug-String-Random [...] rt.cpan.org
From: Eric Brine <ikegami [...] adaelis.com>
Though I just noticed the problem is present elsewhere too $ perl -MString::Random=random_regex -E'say random_regex(q{[abc.]});' '.' will be treated literally inside [] at -e line 1. b ok, so I'll escape... $ perl -MString::Random=random_regex -E'say random_regex(q{[abc\.]});' '\' will be treated literally inside [] at -e line 1. '.' will be treated literally inside [] at -e line 1. c ack!
$ cpanm String::Random String::Random is up to date. (0.26) my $pattern = '\d\d[-,\. ]'; say random_regex($pattern); $ perl foo.pl '-' will be treated literally inside [] at foo.pl line 11. ',' will be treated literally inside [] at foo.pl line 11. '\' will be treated literally inside [] at foo.pl line 11. '.' will be treated literally inside [] at foo.pl line 11. ' ' will be treated literally inside [] at foo.pl line 11. \
My Workaround package MyApp::String::Random; use strict; use warnings; use String::Random qw/ random_regex /;; use Exporter (); our @ISA = qw/ Exporter /; our @EXPORT = qw/ rand_regex /; sub rand_regex { my ($pattern) = @_; local $SIG{__WARN__} = sub { return if $_[0] =~ m/^'.'\ will\ be\ treated\ literally\ inside\ \[\]/xms; CORE::warn($_[0]); }; random_regex($pattern); } 1; # usage: #!/usr/bin/env perl use strict; use warnings; use feature qw/ say /; use MyApp::String::Random; my $rand = '[-,. ]{5}'; say rand_regex($rand); On Mon May 26 05:59:27 2014, DAVEWOOD wrote: Show quoted text
> $ cpanm String::Random > String::Random is up to date. (0.26) > > my $pattern = '\d\d[-,\. ]'; > say random_regex($pattern); > > $ perl foo.pl > '-' will be treated literally inside [] at foo.pl line 11. > ',' will be treated literally inside [] at foo.pl line 11. > '\' will be treated literally inside [] at foo.pl line 11. > '.' will be treated literally inside [] at foo.pl line 11. > ' ' will be treated literally inside [] at foo.pl line 11. > \
CC: IKEGAMI [...] cpan.org
Subject: Re: [rt.cpan.org #86894] Spurious warnings
Date: Mon, 23 Jun 2014 10:52:15 -0400
To: bug-String-Random [...] rt.cpan.org
From: Eric Brine <ikegami [...] adaelis.com>
Note that it doesn't work around aforementioned C<< my $pattern = '\d\d[-,\. ]'; >> returning C<< 12\ >>. On Mon, Jun 23, 2014 at 9:48 AM, David Schmidt via RT < bug-String-Random@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=86894 > > > My Workaround > > package MyApp::String::Random; > > use strict; > use warnings; > use String::Random qw/ random_regex /;; > > use Exporter (); > our @ISA = qw/ Exporter /; > our @EXPORT = qw/ rand_regex /; > > sub rand_regex { > my ($pattern) = @_; > local $SIG{__WARN__} = sub { > return if $_[0] =~ m/^'.'\ will\ be\ treated\ literally\ inside\ > \[\]/xms; > CORE::warn($_[0]); > }; > random_regex($pattern); > } > > 1; > > # usage: > > #!/usr/bin/env perl > use strict; > use warnings; > use feature qw/ say /; > use MyApp::String::Random; > my $rand = '[-,. ]{5}'; > say rand_regex($rand); > > > On Mon May 26 05:59:27 2014, DAVEWOOD wrote:
> > $ cpanm String::Random > > String::Random is up to date. (0.26) > > > > my $pattern = '\d\d[-,\. ]'; > > say random_regex($pattern); > > > > $ perl foo.pl > > '-' will be treated literally inside [] at foo.pl line 11. > > ',' will be treated literally inside [] at foo.pl line 11. > > '\' will be treated literally inside [] at foo.pl line 11. > > '.' will be treated literally inside [] at foo.pl line 11. > > ' ' will be treated literally inside [] at foo.pl line 11. > > \
> > > >