
msds
User
Sep 3, 2002, 11:43 PM
Post #4 of 4
(1070 views)
|
Hello Dave! I've been trying( ) to write a script for this problem. Maybe I've gone about it all wrong, and the code does nothing but juggle text all around,but anyway here is the code.I have not taken all the text in the file posted by DaveC(test.txt),but a portion of it: (File attached) use strict; open SORT, 'newtest.txt' or die $!; while(<SORT>){ chomp; my @tokens=split; $len=@tokens; for($i=0;$i<=$len;$i++){ push @subtokens,$tokens[$i]; } } $leng=@subtokens; #for($k=0;$k<=$leng;$k++){ #print"\n$subtokens[$k]"; #} $delim="de"; for($l=0;$l<=$leng;$l++){ push @fields,split(/,/,$subtokens[$l]); push @fields,$delim ; } $lens=@fields; for($j=0;$j<=$lens;$j++){ #print"\n$fields[$j]"; $person=pop @fields; print "\n$person"; } close SORT; The script gives the following as contents of $person : de de de AdobeAcrobat5.05.0 126MB 850MHz MicrosoftWindows2000 PPD-65135 VidinhME de de AdobeAcrobat5.05.0 126MB 1.0GHz MicrosoftWindows2000 PPD-065156 RooplaVD de de AdobeAcrobat5.05.0 126MB 850MHz MicrosoftWindows2000 PPD-65130 PinterIJ de de AdobeAcrobat5.05.0 126MB 850MHz MicrosoftWindows2000 PPD-65240 GandhiB de de AdobeAcrobat5.05.0 128MB 300MHz MicrosoftWindows2000 PPD-054812 Deconism de de AdobeAcrobat5.05.0 126MB 850MHz MicrosoftWindows2000 PPD-65241 CorrivCA de de AdobeAcrobat5.05.0 126MB 850MHz MicrosoftWindows2000 PPD-65190 BernierH Now, how do we go about displaying details of persons, one per line, and related fields of all persons sorted columnwise, like this, from the contents of $person? BernierH PPD65190 Microsoft Windows2000 ..... CorrivCA PPD-65241 Microsoft Windows2000 ..... Deconism PPD054812 Microsoft Windows2000 ..... GandhiB PPD65240 Microsoft Windows2000 ..... . . . . Seems complicated . Would be happy to get this thing done. Am waiting for ur reply. Thanx, msds
|