Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Join multiple lines in a string based on regex.

by trippledubs (Deacon)
on Dec 16, 2014 at 04:34 UTC ( [id://1110443]=note: print w/replies, xml ) Need Help??


in reply to Join multiple lines in a string based on regex.

#!/usr/bin/env perl use strict; use warnings; use Data::Dump; my $hashRef; # See Perldoc perldsc my $lastSeen; for (<DATA>) { length or next; chomp; if (!/^physicaldrive/) { $lastSeen=$_; } else { push @{$hashRef->{$lastSeen}},$_; } } my @arrayA = @{$hashRef->{'array A'}}; dd @arrayA; my $secondDiskArrayA = $hashRef->{'array A'}[1]; dd $secondDiskArrayA; my $unassignedDisks = $hashRef->{unassigned}; dd $unassignedDisks; dd $unassignedDisks->[0];
Recommend reading perldsc

Replies are listed 'Best First'.
Re^2: Join multiple lines in a string based on regex.
by Anonymous Monk on Dec 16, 2014 at 07:29 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-19 21:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found