in reply to Reading a file as an multi dimensional array Please help
All the strings in each of the rows and columns are of fixed length.In that case it may be worth considering unpack. This way if you have a blank field represented by a space it will still work.
I've assumed each field is separated by a space (the x). You may have to adjust the field widths to taste.
output:#!/bin/perl5 use strict; use warnings; my $rec = q{maps_c7 360_925_RV 3195943 00 56 0K9048}; my @flds = unpack qq{A10xA14xA7xA5xA6xA6}, $rec; print qq{*$_*\n} for @flds;
See also perlpacktut:*maps_c7* *360_925_RV* *3195943* *00* *56* *0K9048*
two of the most misunderstood and most often overlooked functions that Perl provides:-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reading a file as an multi dimensional array Please help
by sas429s (Novice) on Feb 03, 2008 at 17:35 UTC | |
by Not_a_Number (Prior) on Feb 03, 2008 at 19:07 UTC | |
by stiller (Friar) on Feb 03, 2008 at 20:33 UTC | |
by wfsp (Abbot) on Feb 04, 2008 at 06:10 UTC |