Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Nested grouping or capturing inside capturing

by ww (Bishop)
on Nov 22, 2011 at 19:47 UTC ( #939526=note: print w/ replies, xml ) Need Help??

in reply to Nested grouping or capturing inside capturing

This is another case (IMO) where two statements would be both

  1. more elegant (because more readable & maintainable)
  2. and...less subject to brain-cramp, whilst originally writing it

Why not use split as the first; then s/"// each element of the resultant (split) array as the second step prior to printing. Yes, you can argue that that adds two steps (and you would not be UNjustified in making that argument) and thus slows the operation, IMO, the clarity is worth the cost.

Comment on Re: Nested grouping or capturing inside capturing
Download Code
Replies are listed 'Best First'.
Re^2: Nested grouping or capturing inside capturing
by eddor1614 (Beadle) on Nov 22, 2011 at 20:01 UTC

    That was exactly what I did a few months ago. And today I spend a few minutes trying to find out why I put s/"//g:

    foreach (<DATA>) { ($a,$b,$c) = ($3,$2,$1) if /^(\w+)\s(\S+)\s("([^"]+)"|(\w+))/; $a =~ s/"//g; . .

    I thought that if I need to match 3 fields, there should by a regexp that sets $1, $2 and $3. Just as a mental exercise. Thanks for your answer.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2016-02-11 01:31 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (358 votes), past polls