Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jplindstrom (594)

jplindstrom
  (email not shown publicly)

Journal of jplindstrom (594)

Thursday September 05, 2002
03:57 PM

Practical extracting and reporting

[ #7552 ]
I rarely use Perl for what Perl was originally (like in the 16:th century or something) built for; extracting and reporting. But today I did. And it was cool in all it's simplicity and usefulness.

Read through some files based on a filename regexp, identify the file, find some values, and summarize them in a table using MoinMoin (it's a Wiki) formatting. 20 minutes, including blocking some values, and providing aliases for some, and tweaking the table formatting. No longer than it would have taken me to do it manually, only:
  * It wasn't boring
  * It was correct, no chance to slip up
  * It can be done again at any time with updated files.

Oh, the joy of small scale automation :)

BTW, I also re-coded my canonical read-contents-of-a-file for the n:th time (I tend to do that in sooo many small scripts).

sub loadFile {
        my ($file) = @_;
        local $/;
        open(my $fh, $file) or return("");
        return(<$fh>);
}

File::Slurp isn't in the distribution, right? Well... it should.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • You could use IO::File for your slurp
    use IO::File;

    my @lines = IO::File->new(shift)->getlines;
    Or something not entirely dissimilar to that.
    --

    broquaint out