Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Regular expression

by lestrrat (Deacon)
on Jun 07, 2001 at 20:32 UTC ( #86637=note: print w/replies, xml ) Need Help??

in reply to Regular expression

The 1 doesn't do anything. Really

Seems weird, but in perl, just like the trailing "1;" in the end of a "require"'d file, a line consisting of a thingie ( whether it may be a scalar, array, hash, whatever ) is totally valid

So the equivalent of above code is

while( s/(\d)(\d\d\d)(?!d)/$1,$2/ ) { 1; ## do nothing, let the regex go until it no longer matche +s }

Replies are listed 'Best First'.
Re: Re: Regular expression
by alfie (Pilgrim) on Jun 07, 2001 at 20:41 UTC
    Please don't confuse the 1 in this example (which indeed is just there for there has to be something there) with the 1; at the end of a perl module!! The 1; statement at the end of a module is truly needed as a returnvalue to the require statement. Substitute it to a 0 and watch the difference. In this example here you could substitue the 1 with a 0, which would change nothing at all...
    use signature; signature(" So long\nAlfie");

      Hmm, sorry if it was misleading, but I think it's a "statement" nonetheless, no?

      package foo; sub foo { 1; } 1;

      Besides the fact that a required file needs a "true" value returned, I don't think the 1 at the end of the file is any different from the 1 in a sub or any block of code?

      Syntactically, yeah, they mean different things, but I believe the mechanism that goes behind there are the same...

      That was sort of where I was trying to get at, if it makes any sense

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2022-05-20 05:10 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (72 votes). Check out past polls.