Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Howto print multiple matches in a line

by ikegami (Patriarch)
on Nov 11, 2008 at 03:39 UTC ( [id://722775]=note: print w/replies, xml ) Need Help??


in reply to Howto print multiple matches in a line

Replace if (/.../) with while (/.../g) to get all matches. Use parens around what you want to capture. Use $1 to get what's in the parens, not $_.

In this, case you can write it concisely as

while (<FH>) { print( join( "\t", /\w\s+\w+\s+\w+\s+\w+\s+\w+/g ), "\n" ); }

Replies are listed 'Best First'.
Re^2: Howto print multiple matches in a line
by ashnator (Sexton) on Nov 11, 2008 at 04:11 UTC
    Thanks a lot dear... ;)

Log In?
Username:
Password:

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

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

    No recent polls found