Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^2: bareword error

by hipowls (Curate)
on Mar 14, 2008 at 10:49 UTC ( #674176=note: print w/replies, xml ) Need Help??

in reply to Re: bareword error
in thread bareword error

Good answer, one error though, m// is not an empty pattern, it is the last pattern to successfully match, split gets special dispensation so that split m//, $stuff does split on an empty pattern.

From the split reference:

As a special case for split, using the empty pattern // specifically matches only the null string, and is not be confused with the regular use of // to mean "the last successful pattern match". So, for split, the following:
print join(':', split(//, 'hi there'));
produces the output 'h:i: :t:h:e:r:e'.

Replies are listed 'Best First'.
Re^3: bareword error
by johngg (Abbot) on Mar 14, 2008 at 11:16 UTC
    Cripes, I'd never realised that, thanks for pointing it out. I had to write a little piece of code to prove it to myself.

    $ perl -le ' > $s1 = q{catDOGfish}; > $s2 = q{xxYYYzz}; > print $1 if $s1 =~ m{([A-Z]+)}; > print $1 if $s1 =~ m{([0-9]+)}; > print $1 if $s2 =~ m{};' DOG YYY $

    Fancy not knowing that after all this time!

    Thanks again,


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://674176]
[marto]: jetlag has really done a number on the kids, it's been a tough week
choroba played with the band on Saturday, so Sunday was very sleepy
[choroba]: managed to release Syntax::Construct with 5.28 support in the night, though
[Corion]: choroba: Whee ;)
[Corion]: marto: Ouch - I would've thought that kids adapt much better, but that's obviously not the case...
[marto]: well, their mother let them sleep till 15:00 & 12:00 last week, which didn't help them adjust :P
[Corion]: I was "productive" over the weekend in the sense that I revived my old "Perlmonks on SQLite" code, which likely means I can get a test instance back up running on my webhost. Small steps :)
[Corion]: marto: Ow, no, that doesn't help at all :)
[choroba]: Related to the new release, anyone could explain this or this tester report?
[Discipulus]: hello crew! marto thanks for the message: but I how can I help? i'm testing cpan Padre atm problem with Client::Debug

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (13)
As of 2018-06-25 08:37 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.