Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: 1 != split /a/, '' ?

by AnomalousMonk (Archbishop)
on Nov 03, 2015 at 11:02 UTC ( [id://1146800]=note: print w/replies, xml ) Need Help??


in reply to 1 != split /a/, '' ?

I'm also not sure I entirely understand the problem, but here's another possible (?) approach:

c:\@Work\Perl\monks>perl -wMstrict -le "use 5.010; ;; use warnings; use strict; ;; use Test::More 'no_plan'; use Test::NoWarnings; ;; my @vectors = ( [ 'Value:', '[]' ], [ 'Value:.', '[][]' ], [ 'Value:...', '[][][][]' ], [ 'Value:A', '[A]' ], [ 'Value:A.B', '[A][B]' ], [ 'Value:.A', '[][A]' ], [ 'Value:A.', '[A][]' ], ); ;; VECTOR: for my $ar_vector (@vectors) { my ($str, $expected) = @$ar_vector; ;; my $converted = join '', map qq{[$_]}, $str =~ m{ (?: Value: | [.]) \K [^.]* (?= [.] | \z) }xmsg; ;; is $converted, $expected, qq{'$str' -> '$converted'} } " ok 1 - 'Value:' -> '[]' ok 2 - 'Value:.' -> '[][]' ok 3 - 'Value:...' -> '[][][][]' ok 4 - 'Value:A' -> '[A]' ok 5 - 'Value:A.B' -> '[A][B]' ok 6 - 'Value:.A' -> '[][A]' ok 7 - 'Value:A.' -> '[A][]' ok 8 - no warnings 1..8


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1146800]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-23 11:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found