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

Re^2: How regex works here?

by nagalenoj (Friar)
on Apr 08, 2009 at 05:38 UTC ( #756234=note: print w/replies, xml ) Need Help??

in reply to Re: How regex works here?
in thread How regex works here?

yeeeah..! Fine.. I understood.,

So the problem is not with the matching and with the substitution.


Replies are listed 'Best First'.
Re^3: How regex works here?
by bart (Canon) on Apr 08, 2009 at 09:01 UTC

    There's no need at all to change the original string to extract the data you want. All you need is to match it.

    if($line =~ /^(\S+\s+\S+)/) { $match = $1; }
    or even simpler:
    ($match) = $line =~ /^(\S+\s+\S+)/;
    Note that for the latter, the assignment must be in list context, not scalar context; that's what the parens around the variable on the left hand side are for.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://756234]
[erix]: antisemitic && (pro-)russian. Makes sense :P
[shmem]: erix: what's antisemitic in there? Tell me.
[erix]: AngloZionist
[shmem]: and it is *not* pro-russian. It describes the western world.
[erix]: I'm not going to read it so I could be mistaken but it reeks of useful idiocy
[shmem]: AngloZionist is not an antisemitic term.
[shmem]: erix: be assured that we all are horribly mistaken, always. What would we write tests for, if not for that fact?
[shmem]: and then, audiatur et altera pars.
[erix]: and what's the "Vineyard"? Don't tell me it's doing supernatural stuff too.

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2018-03-19 20:57 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (246 votes). Check out past polls.