I just started using the program Pal its a unix terminal emulator. I wanted to wrap it with a perl script so that I could sort events based on A1 codes. So A1 A2 A3 C3 D4 C2 would get sorted in order of priority. So i wrote a quick little perl script to pipe the output of pal to have it resort it and then display it. I have cron email me and print a copy 3 times a day. To help keep me on track. Its easy in IT to get stuck on the web or in email all day :)
At any rate the wrapper works great but it seems that depeneding on the size of the terminal window that pal is actually inserting line breaks rather then letting the line wrap. This makes my wrapper not work for print jobs and for smaller terminal windows. Granted I could just keep my pal files at a certain width and avoid the problem but that wouldn't be very perlish. Below is my code. Below that is the output. Now this is hard to show because when I redirect output to a file it doesn't break it up. So below the redirected out put is just a copy paste of the terminal window. TIA, Paul D. Kraus ~=~=~=~=~=~=~=~=~=~=~=~=~ ~ Network Administrator ~ ~ PEL Supply Company ~ ~ 216.267.5775 Voice ~ ~ 216.267.6176 Fax ~ ~=~=~=~=~=~=~=~=~=~=~=~=~ ~ www.pelsupply.com ~ ~=~=~=~=~=~=~=~=~=~=~=~=~ Code ----- #!/usr/bin/perl use strict; my ( @cal, %events ); getdata ( [EMAIL PROTECTED], \%events ); printcal ( [EMAIL PROTECTED] ); printevents ( \%events ); sub getdata { # Capture Data my ( $cal, $events ) = ( shift, shift ); my $key; my %weekname = ( "Mon" => 1, "Tue" => 2, "Wed" => 3, "Thu" => 4, "Fri" => 5, "Sat" => 6, "Sun" => 7 ); while ( <> ) { chomp; unless ( ( /Mon|Tue|Wed|Thu|Fri|Sat|Sun|\*/ ) or ( $key ) ) { next unless ( $_ ); push ( @$cal, $_ ); } else { $key = $weekname{ $1 } if ( /\e\[1m(Mon)/ ); $key = $weekname{ $1 } if ( /\e\[1m(Tue)/ ); $key = $weekname{ $1 } if ( /\e\[1m(Wed)/ ); $key = $weekname{ $1 } if ( /\e\[1m(Thu)/ ); $key = $weekname{ $1 } if ( /\e\[1m(Fri)/ ); $key = $weekname{ $1 } if ( /\e\[1m(Sat)/ ); $key = $weekname{ $1 } if ( /\e\[1m(Sun)/ ); push ( @{$$events{$key}}, $_ ); } } } sub printcal { # Print Calendars my $cal = shift; print "$_\n" foreach ( @{ $cal } ) ; print "\n"; } sub printevents { # Print Events my $events = shift; my %weeknum = ( 1 => "Mon", 2 => "Tue", 3 => "Wed", 4 => "Thu", 5 => "Fri", 6 => "Sat", 7 => "Sun" ); foreach my $key ( sort keys %{ $events } ) { next unless ( $key ); print "$$events{$key}[0]"; foreach my $event (sort @{ $$events{ $key} } [EMAIL PROTECTED]) { print "$event\n"; } print "\n"; } } Output of pal ------------- [1;32m Su Mo Tu We Th Fr Sa [0m[2;33m|[0m[1;32m Su Mo Tu We Th Fr Sa [0m[1;32mMay [0m 25 26 27 28 29 30 01 [2;33m|[0m[1;32mJun [0m[1;35mC[0m30[1;35mC[0m [1;31mU[0m31[1;31mS[0m 01 02 03 04 05 02 03 04 [1;31mP[0m05[1;31mE[0m 06 [1;[EMAIL PROTECTED];[EMAIL PROTECTED] 08 [2;33m|[0m [1;35mC[0m06[1;35mC[0m 07 08 09 [1;35mC[0m10[1;35mC[0m 11 12 [1;31mU[0m09[1;31mS[0m 10 [1;31mP[0m11[1;31mE[0m 12 [1;31mP[0m13[1;31mE[0m 14 [1;31mU[0m15[1;31mS[0m[2;33m|[0m 13 [1;31mU[0m14[1;31mS[0m 15 16 17 18 19 [1;35mC[0m16[1;35mC[0m 17 18 19 [1;35mC[0m20[1;35mC[0m 21 22 [2;33m|[0m [1;31mU[0m20[1;31mS[0m 21 22 23 24 25 26 23 24 25 26 27 28 29 [2;33m|[0m[1;32mJul [0m 27 28 29 30 01 02 03 [1mFri 7 May 2004[0m - [1;31mToday[0m [1;31m* [0mPK Events: Meeting - Record Retention ( 9:00AM ) Seminar Room [1;34m* [0mHistory: Germany surrenders after WWII, 1945 [1;33m* [0mPK ToDoList: D1: Advertising - Pel E-Gram Sales Analysis (Waiting Kelly & Ronelle) [1;33m* [0mPK ToDoList: D1: Kelly Luiere - Who is not buying liners (Waiting Kelly) [1;33m* [0mPK ToDoList: D1: Viv Walsh - Add Credit Card Banner to Pick Tickets (Waiting Viv) [1;33m* [0mPK ToDoList: D1: Paulette Vaughn - Copier will not work (Waiting parts) [1;33m* [0mPK ToDoList: D1: Add Attention Field to PEL E-Gram Fax's (Waiting PAV) [1;33m* [0mPK ToDoList: C4: Bev - Give Money to Bev for Danniele - House Warming Gift [1;33m* [0mPK ToDoList: A1: Paulette Vaughn - Add Children Customers to new Cust Class Code [1;33m* [0mPK ToDoList: A1: Bob Boff - Buy Laptop [1mSat 8 May 2004[0m - [1;33mTomorrow[0m [1;34m* [0mHistory: US institutes mining of Haiphong Harbor, 1972 [1mSun 9 May 2004[0m - 2 days away [1;31m* [0mUSA: Mother's Day [1;34m* [0mHistory: 94 degrees, New York, 1979 [1mMon 10 May 2004[0m - 3 days away [1;34m* [0mHistory: Germany invades Low Countries, 1940 [1;34m* [0mHistory: Nazi bookburning, 1933 Output (Cust Paste Term Window piped through script) ---------------------------------------------------- Su Mo Tu We Th Fr Sa May 25 26 27 28 29 30 01 02 03 04 P05E 06 @07@ 08 U09S 10 P11E 12 P13E 14 U15S C16C 17 18 19 C20C 21 22 23 24 25 26 27 28 29 Mon 10 May 2004 - 3 days away * History: Germany invades Low Countries, 1940 * History: Nazi bookburning, 1933 Fri 7 May 2004 - Today * PK Events: Meeting - Record Retention ( 9:00AM ) Seminar Room * PK ToDoList: A1: Bob Boff - Buy Laptop * PK ToDoList: A1: Paulette Vaughn - Add Children Customers to new Cust * PK ToDoList: C4: Bev - Give Money to Bev for Danniele - House Warming * PK ToDoList: D1: Add Attention Field to PEL E-Gram Fax's (Waiting PAV) * PK ToDoList: D1: Advertising - Pel E-Gram Sales Analysis (Waiting Kelly & * PK ToDoList: D1: Kelly Luiere - Who is not buying liners (Waiting Kelly) * PK ToDoList: D1: Paulette Vaughn - Copier will not work (Waiting parts) * PK ToDoList: D1: Viv Walsh - Add Credit Card Banner to Pick Tickets * History: Germany surrenders after WWII, 1945 (Waiting Viv) Class Code Gift Ronelle) Sat 8 May 2004 - Tomorrow * History: US institutes mining of Haiphong Harbor, 1972 Sun 9 May 2004 - 2 days away * USA: Mother's Day * History: 94 degrees, New York, 1979 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>