bigbot has asked for the wisdom of the Perl Monks concerning the following question:
I wanted to try using a temp file to be safe and not blow up the memory on the server. Then I ran into even more issues. I tried using an "anonymous file handle" because I thought it would be nice to have Perl handle the cleanup. Couldn't get that to work:my @results = split(/dbDelimeter/,`SQL_Query`); while(@results) { (var1,var2,var3,etc) = splice(@results, 0, 28); $var1 =~ s/\n//g; $var2 =~ s/oldDateFormat/newDateFormat/; $var3 =~ s/moreReplacements/DoneHere/; $output = sprintf (%-10s %-10s %10s,$var1,$var2,$var3); $finalOutput .= $output; } open LESS, '|less -cSRM' or die $!; print LESS $finalOutput; close LESS;
It would be great if somebody could show me different, efficient ways to output data to a less screen, both using memory and the disk if possible. Essentially I want to store all this data on the disk because of the excessive memory usage (unless I'm doing something wrong to use so much memory..) Thanks!open(my $data, "+>", undef) or die; $data = `SQL_Query`; ## Method 1 print $data `SQL_Query`; ## Method 2 ## processing to parse and format data system("less $data"); ## Output: None / Doesn't Work print $data; ## Output: GLOB(0x1c8ef430)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Print to Less Screen
by ikegami (Patriarch) on Jun 04, 2011 at 05:48 UTC | |
by bigbot (Beadle) on Jun 04, 2011 at 07:35 UTC | |
by bigbot (Beadle) on Jun 04, 2011 at 08:37 UTC | |
by bigbot (Beadle) on Jun 05, 2011 at 01:47 UTC | |
by armstd (Friar) on Jun 05, 2011 at 14:28 UTC | |
by bigbot (Beadle) on Jun 06, 2011 at 01:44 UTC | |
|
Re: Print to Less Screen
by Jenda (Abbot) on Jun 04, 2011 at 10:48 UTC | |
by bigbot (Beadle) on Jun 04, 2011 at 10:59 UTC | |
by Jenda (Abbot) on Jun 04, 2011 at 11:03 UTC |