in reply to split question
If you are extracting data from fixed width columns as seems to be the case here then you can use any of a number of techniques:
use strict; use warnings; my $table = <<DATA; LV NAME LPs PPs DISTRIBUTION MOUNT POINT loglv51 1 1 01..00..00..00..00 N/A lvsapinst 64 64 54..10..00..00..00 /tmp/sapinst_i +nstdir lvusrsap 25 25 00..25..00..00..00 /usr/sap DATA open IN, '<', \$table; while (<IN>) { chomp; my $name = substr $_, 0, 22; my $dist = substr $_, 34, 18; my $mount = substr $_, 56; print "$name $dist $mount\n"; } close IN; open IN, '<', \$table; while (<IN>) { chomp; my ($name, $dist, $mount) = /(.{22}).{12}(.{18}).{4}(.*)/; print "$name $dist $mount\n"; } close IN; open IN, '<', \$table; while (<IN>) { chomp; my ($name, undef, $dist, undef, $mount) = unpack ('a22a12a18a4a*', + $_); print "$name $dist $mount\n"; } close IN;
Prints:
LV NAME DISTRIBUTION MOUNT POINT loglv51 01..00..00..00..00 N/A lvsapinst 54..10..00..00..00 /tmp/sapinst_instdir lvusrsap 00..25..00..00..00 /usr/sap LV NAME DISTRIBUTION MOUNT POINT loglv51 01..00..00..00..00 N/A lvsapinst 54..10..00..00..00 /tmp/sapinst_instdir lvusrsap 00..25..00..00..00 /usr/sap LV NAME DISTRIBUTION MOUNT POINT loglv51 01..00..00..00..00 N/A lvsapinst 54..10..00..00..00 /tmp/sapinst_instdir lvusrsap 00..25..00..00..00 /usr/sap
Interestingly, none of these use split.
|
|---|