in reply to Re: Looking for Perl Elegance!
in thread Looking for Perl Elegance!
Well the input will stream in line by line and will look something like this:
asdf
asdfg=4eafvasdfadsf
ashfasdf
asdf qer qwer
asd as dsasdi weeiwer dfhjTITLE#How are you#asdfads
asdfa
asdg
rt
wqrqw
re
DATA-A#item1#asdfdasfdasdasDATA-B#item2#
asdfda
dasfa
asdfdas
DATA-C#item3#
aasdfDATA-A#item1a#DATA-B#item2b#
asd
asdf
asdDATA-C#item3c#
asdf asdf3132 adsf TITLE#I am fine#ads fadsfdasfdas
The do come in order but they may not have a title. I need to store each item as it comes and I won't know when I am done until I get to the end of the stream. There will always be a DATA-A DATA-B and a DATA-C which will be associated with the last TITLE.
so I can do this:
max length of 'how are you', 'i am fine'
max length of 'item1', 'item1a', 'item4'
max length of 'item2', 'item2b', 'item5'
max length of 'item3', 'item3c', 'item6'
then use that to format the output. I can't get a good example on the forum here without using html which might be part of the confusion. No CSV, no sorting...just display it on the screen using a print statement but make it pretty like a table.
I hope that answers the questions.
THANKS for the help on this.
asdf
asdfg=4eafvasdfadsf
ashfasdf
asdf qer qwer
asd as dsasdi weeiwer dfhjTITLE#How are you#asdfads
asdfa
asdg
rt
wqrqw
re
DATA-A#item1#asdfdasfdasdasDATA-B#item2#
asdfda
dasfa
asdfdas
DATA-C#item3#
aasdfDATA-A#item1a#DATA-B#item2b#
asd
asdf
asdDATA-C#item3c#
asdf asdf3132 adsf TITLE#I am fine#ads fadsfdasfdas
ect but that doesn't strike me as an elegant way to do this. The output would be like using a print statement. I was looking at using perlform for the output. To do that, I will need to get all the data first, figure out the max length of each item like:if( $line =~ /TITLE/) { $line =~ s/TITLE#(.*)#/$1/; chomp($1); } else if ( $line =~ /DATA-A/) { $line =~ s/DATA-A#(.*)#/$1/; chomp($1); }
max length of 'how are you', 'i am fine'
max length of 'item1', 'item1a', 'item4'
max length of 'item2', 'item2b', 'item5'
max length of 'item3', 'item3c', 'item6'
then use that to format the output. I can't get a good example on the forum here without using html which might be part of the confusion. No CSV, no sorting...just display it on the screen using a print statement but make it pretty like a table.
I hope that answers the questions.
THANKS for the help on this.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Looking for Perl Elegance!
by TGI (Parson) on Jul 11, 2007 at 18:32 UTC | |
Re^3: Looking for Perl Elegance!
by dsheroh (Monsignor) on Jul 11, 2007 at 17:59 UTC | |
Re^3: Looking for Perl Elegance!
by Ploux (Acolyte) on Jul 11, 2007 at 19:45 UTC |
In Section
Seekers of Perl Wisdom