Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Regex copy and paste help

by CountZero (Bishop)
on Sep 01, 2012 at 13:17 UTC ( #991154=note: print w/replies, xml ) Need Help??

in reply to Regex copy and paste help

I would do it this way:
use Modern::Perl; while (<DATA>) { my @record = split; if ($record[1]=~s/-$//) { while (<DATA>) { my ($continuation) = split; $record[1] .= $continuation; last unless $record[1]=~s/-$//; } } say join ' ', @record; } __DATA__ A00002 \\a00002\c$ 2 WinNT NTFS Yes 73,626MB 42.5 A00003 / 1 Linux86 EXT3 No 38,289MB 29.8 A00004 A00004 \Sys- 1 WinNT VSS Yes 0 KB 0.0 temState\- NULL\Syst- em A00005 /xyz 4 Linux86 EXT2 No 12,345MB 30
And yes, you get a few "Use of uninitialized value $record1" warnings because of the anomalous third record which has only one filed "A00004" in it. You can safely ignore these warnings or add another test to drop such record if you do not need it.


A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991154]
and snow settles gently...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2017-09-24 00:58 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (273 votes). Check out past polls.