If you could post me your code , That will be helpful.

I hope it will be helpful :)

#!/usr/bin/perl -- ## hpacucli-something-fun.pl ## ## ## 2014-12-23-18:40:42 first step ## ## ## ## perltidy -olq -csc -csci=3 -cscl="sub : BEGIN END if while " -otr +-opr -ce -nibc -i=4 -pt=0 "-nsak=*" #!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd /; Main( @ARGV ); exit( 0 ); sub Main { my %Map; my $cmd = "hpacucli ctrl slot=0 pd all show"; #~ http://perlmonks.com/?abspart=1;displaytype=displaycode;node_id=111 +0713;part=2 my $data = q{ Smart Array P410i in Slot 0 (Embedded) array A physicaldrive 2C:1:1 (port 2C:box 1:bay 1, SAS, 1 TB, OK) physicaldrive 2C:1:2 (port 2C:box 1:bay 2, SAS, 1 TB, OK) array B physicaldrive 2C:1:3 (port 2C:box 1:bay 3, SAS, 1 TB, OK) physicaldrive 2C:1:4 (port 2C:box 1:bay 4, SAS, 1 TB, OK) array C physicaldrive 3C:1:5 (port 3C:box 1:bay 5, SAS, 1 TB, OK) physicaldrive 3C:1:6 (port 3C:box 1:bay 6, SAS, 1 TB, OK) array D physicaldrive 3C:1:7 (port 3C:box 1:bay 7, SAS, 1 TB, OK) physicaldrive 3C:1:8 (port 3C:box 1:bay 8, SAS, 1 TB, OK) array E physicaldrive 4C:2:1 (port 4C:box 2:bay 1, SAS, 1 TB, OK) physicaldrive 4C:2:2 (port 4C:box 2:bay 2, SAS, 1 TB, OK) array F physicaldrive 4C:2:3 (port 4C:box 2:bay 3, SAS, 1 TB, OK) physicaldrive 4C:2:4 (port 4C:box 2:bay 4, SAS, 1 TB, OK) array G physicaldrive 5C:2:5 (port 5C:box 2:bay 5, SAS, 1 TB, OK) physicaldrive 5C:2:6 (port 5C:box 2:bay 6, SAS, 1 TB, OK) array H physicaldrive 5C:2:7 (port 5C:box 2:bay 7, SAS, 1 TB, OK) physicaldrive 5C:2:8 (port 5C:box 2:bay 8, SAS, 1 TB, OK) array I physicaldrive 6C:3:1 (port 6C:box 3:bay 1, SAS, 1 TB, OK) physicaldrive 6C:3:2 (port 6C:box 3:bay 2, SAS, 1 TB, OK) array J physicaldrive 6C:3:3 (port 6C:box 3:bay 3, SAS, 1 TB, OK) physicaldrive 6C:3:4 (port 6C:box 3:bay 4, SAS, 1 TB, OK) array K physicaldrive 7C:3:5 (port 7C:box 3:bay 5, SAS, 1 TB, OK) physicaldrive 7C:3:6 (port 7C:box 3:bay 6, SAS, 1 TB, OK) unassigned physicaldrive 7C:3:7 (port 7C:box 3:bay 7, SAS, 1 TB, OK) physicaldrive 7C:3:8 (port 7C:box 3:bay 8, SAS, 1 TB, OK) }; ## open my $fd, "$cmd|" or die $!; open my $fd, '<', \$data or die $!; FillMap( $fd, \%Map ); dd( \%Map ); } ## end sub Main sub GetName { my( $name ) = $_[0] =~ m{^\s+(?:array)?\s(\S+)}; return $name; } ## end sub GetName sub FillMap { my( $fd, $MapRef ) = @_; my $name = ""; while( my $line = <$fd> ) { $line =~ /^\s*$/ and next; ## skip empty/whitespace if( $line =~ /^\S/ ) { ## skip header next; } elsif( $line =~ /^\s\s\s\S/ ) { ## array NAME my( $newName ) = GetName( $line ); $name = $newName; next; } elsif( $line =~ /^\s\s\s\s\s\s\S/ ) { ## array VALUE push @{ $MapRef->{$name} }, $line; next; } } ## end while( my $line = <$fd> ) close $fd; return $MapRef; } ## end sub FillMap __END__ { A => [ " physicaldrive 2C:1:1 (port 2C:box 1:bay 1, SAS, 1 TB, OK)\n +", " physicaldrive 2C:1:2 (port 2C:box 1:bay 2, SAS, 1 TB, OK)\n +", ], B => [ " physicaldrive 2C:1:3 (port 2C:box 1:bay 3, SAS, 1 TB, OK)\n +", " physicaldrive 2C:1:4 (port 2C:box 1:bay 4, SAS, 1 TB, OK)\n +", ], C => [ " physicaldrive 3C:1:5 (port 3C:box 1:bay 5, SAS, 1 TB, OK)\n +", " physicaldrive 3C:1:6 (port 3C:box 1:bay 6, SAS, 1 TB, OK)\n +", ], D => [ " physicaldrive 3C:1:7 (port 3C:box 1:bay 7, SAS, 1 TB, OK)\n +", " physicaldrive 3C:1:8 (port 3C:box 1:bay 8, SAS, 1 TB, OK)\n +", ], E => [ " physicaldrive 4C:2:1 (port 4C:box 2:bay 1, SAS, 1 TB, OK)\n +", " physicaldrive 4C:2:2 (port 4C:box 2:bay 2, SAS, 1 TB, OK)\n +", ], F => [ " physicaldrive 4C:2:3 (port 4C:box 2:bay 3, SAS, 1 TB, OK)\n +", " physicaldrive 4C:2:4 (port 4C:box 2:bay 4, SAS, 1 TB, OK)\n +", ], G => [ " physicaldrive 5C:2:5 (port 5C:box 2:bay 5, SAS, 1 TB, OK)\n +", " physicaldrive 5C:2:6 (port 5C:box 2:bay 6, SAS, 1 TB, OK)\n +", ], H => [ " physicaldrive 5C:2:7 (port 5C:box 2:bay 7, SAS, 1 TB, OK)\n +", " physicaldrive 5C:2:8 (port 5C:box 2:bay 8, SAS, 1 TB, OK)\n +", ], I => [ " physicaldrive 6C:3:1 (port 6C:box 3:bay 1, SAS, 1 TB, OK)\n +", " physicaldrive 6C:3:2 (port 6C:box 3:bay 2, SAS, 1 TB, OK)\n +", ], J => [ " physicaldrive 6C:3:3 (port 6C:box 3:bay 3, SAS, 1 TB, OK)\n +", " physicaldrive 6C:3:4 (port 6C:box 3:bay 4, SAS, 1 TB, OK)\n +", ], K => [ " physicaldrive 7C:3:5 (port 7C:box 3:bay 5, SAS, 1 TB, OK)\n +", " physicaldrive 7C:3:6 (port 7C:box 3:bay 6, SAS, 1 TB, OK)\n +", ], unassigned => [ " physicaldrive 7C:3:7 (port 7C:box 3:bay 7, SAS, 1 TB, OK)\n +", " physicaldrive 7C:3:8 (port 7C:box 3:bay 8, SAS, 1 TB, OK)\n +", ], }

In reply to Re^15: Join multiple lines in a string based on regex. by Anonymous Monk
in thread Join multiple lines in a string based on regex. by pr33

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.