C:\perlscripts>more 3par.txt
Id Name Persona -WWN/iSCSI_Name- Port
2 hpux-host2 HPUX-legacy 1122334455667788 2:3:1
1122334455667799 ---
1122334455667788 ---
1122334455667799 4:3:1
3 hpux-host3 HPUX-legacy 1122334455667788 2:3:1
1122334455667799 ---
1122334455667788 ---
1122334455667799 ---
4 hpux-host4 HPUX-legacy 1122334455667788 ---
1122334455667799 3:3:1
1122334455667788 1:3:1
1122334455667799 4:3:1
5 hpux-host5 HPUX-legacy 1122334455667788 2:3:1
1122334455667799 3:3:1
1122334455667788 1:3:1
1122334455667799 4:3:1
5 hpux-host6 HPUX-legacy 1122334455667788 2:3:1
1122334455667799 3:3:1
1122334455667788 1:3:1
1122334455667799 4:3:1
7 hpux-host HPUX-legacy 1122334455667788 2:3:1
1122334455667799 3:3:1
1122334455667788 ---
1122334455667799 4:3:1
####
#!/usr/bin/perl
use warnings;
use strict;
my $space_sep_FH;
my @para;
open($space_sep_FH,'>', 'space_sep.txt') or die "Error:$!.$^E";
while (<>) {
next if /Id Name Persona -WWN\/iSCSI_Name- Port/;
s/(^[ 0-9])+/\n\n$1/;
print $space_sep_FH "$_";
}
print "Done writing to space_sep.txt.\n";
$/ = "\n\n";
open($space_sep_FH,'<', 'space_sep.txt') or die "Error:$!.$^E";
@para = <$space_sep_FH>;
foreach my $para (@para)
{
print "$para" if $para =~ /---/;
}
##
##
C:\perlscripts>perl test_3par_tp.pl 3par.txt
Done writing to space_sep.txt.
2 hpux-host2 HPUX-legacy 1122334455667788 2:3:1
1122334455667799 ---
1122334455667788 ---
1122334455667799 4:3:1
3 hpux-host3 HPUX-legacy 1122334455667788 2:3:1
1122334455667799 ---
1122334455667788 ---
1122334455667799 ---
4 hpux-host4 HPUX-legacy 1122334455667788 ---
1122334455667799 3:3:1
1122334455667788 1:3:1
1122334455667799 4:3:1
7 hpux-host HPUX-legacy 1122334455667788 2:3:1
1122334455667799 3:3:1
1122334455667788 ---
1122334455667799 4:3:1
C:\perlscripts>
##
##
use Learning::Perl;
use Beginning::Perl::Ovid;
print "Awesome Books";