[30024] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1267 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 10 06:09:40 2008

Date: Sun, 10 Feb 2008 03:09:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 10 Feb 2008     Volume: 11 Number: 1267

Today's topics:
    Re: "Use of uninitialized value" warning <uri@stemsystems.com>
    Re: "Use of uninitialized value" warning <christian@altfrau.de>
    Re: "Use of uninitialized value" warning <uri@stemsystems.com>
    Re: "Use of uninitialized value" warning <m@rtij.nl.invlalid>
        Fail extracting table from .mdb file using DBI module <lev.weissman@creo.com>
    Re: Fail extracting table from .mdb file using DBI modu <uri@stemsystems.com>
        new CPAN modules on Sun Feb 10 2008 (Randal Schwartz)
        Printing to screen and to file <ldolan@thinkinghatbigpond.net.au>
    Re: Printing to screen and to file <mritty@gmail.com>
    Re: Printing to screen and to file <usenet@davidfilmer.com>
        Question about PDL <january.weiner@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 09 Feb 2008 22:22:57 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: "Use of uninitialized value" warning
Message-Id: <x74pchkbwf.fsf@mail.sysarch.com>

>>>>> "JD" == Joost Diepenmaat <joost@zeekat.nl> writes:

  JD> Christian Neumann <christian@altfrau.de> writes:
  >> Is there a more beautiful way of comparing two possibly undefined 
  >> variables beside of turning off the warning (and endless pre-comparing 
  >> like defined $var1 and ...)?

  JD> Just write your own "eq":

  JD> sub eq_undef {
  JD>   my ($s1,$s2) = @_;
  JD>   if (defined($s1) and defined($s2)) {
  JD>     $s1 eq $s2;
  JD>   }
  JD>   else {
  JD>     defined($s1) == defined($s2);
  JD>   }
  JD> }

don't use the 'value' of an if/else statement. it does have one but it
is very bad code to expect the last evaluated value to be useful. just
put return statements in there will make it much better.

but you still have a bug. what if one element is '0' and the other
undefined?

it would be much better for the OP to determine what he really wants. is
an undef to be the same as '' for comparisons? in 5.10 you can use the
new // op to make that easy:

($var1 // '') eq ($var2 // '')

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Architecture, Development, Training, Support, Code Review  ------
-----------  Search or Offer Perl Jobs  ----- http://jobs.perl.org  ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: 9 Feb 2008 23:37:16 GMT
From: Christian Neumann <christian@altfrau.de>
Subject: Re: "Use of uninitialized value" warning
Message-Id: <616rpcF1uai4eU2@mid.dfncis.de>

Am Sat, 09 Feb 2008 22:22:57 +0000 schrieb Uri Guttman:

> it would be much better for the OP to determine what he really wants. is
> an undef to be the same as '' for comparisons?
no, undef should only equal undef.

Christian


------------------------------

Date: Sun, 10 Feb 2008 04:38:19 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: "Use of uninitialized value" warning
Message-Id: <x7k5ldifyc.fsf@mail.sysarch.com>

>>>>> "CN" == Christian Neumann <christian@altfrau.de> writes:

  CN> Am Sat, 09 Feb 2008 22:22:57 +0000 schrieb Uri Guttman:
  >> it would be much better for the OP to determine what he really wants. is
  >> an undef to be the same as '' for comparisons?
  CN> no, undef should only equal undef.

undef doesn't equal anything, let alone undef. two things can
both be undefined but they aren't 'equal' to each other.

you can use ^ to find when both or neither value is undef and then fine
tune the comparison. or do an ugly (but short) if/else tree to return a
boolean.

i leave those as exercises to the reader as i am too gronked at the
moment to code them up.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Architecture, Development, Training, Support, Code Review  ------
-----------  Search or Offer Perl Jobs  ----- http://jobs.perl.org  ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Sun, 10 Feb 2008 08:41:34 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: "Use of uninitialized value" warning
Message-Id: <pan.2008.02.10.07.41.34@rtij.nl.invlalid>

On Sat, 09 Feb 2008 22:22:57 +0000, Uri Guttman wrote:

>>>>>> "JD" == Joost Diepenmaat <joost@zeekat.nl> writes:
> 
>   JD> Christian Neumann <christian@altfrau.de> writes:
>   >> Is there a more beautiful way of comparing two possibly undefined
>   >> variables beside of turning off the warning (and endless
>   >> pre-comparing like defined $var1 and ...)?
> 
>   JD> Just write your own "eq":
> 
>   JD> sub eq_undef {
>   JD>   my ($s1,$s2) = @_;
>   JD>   if (defined($s1) and defined($s2)) { JD>     $s1 eq $s2;
>   JD>   }
>   JD>   else {
>   JD>     defined($s1) == defined($s2); JD>   }
>   JD> }
> 
> don't use the 'value' of an if/else statement. it does have one but it
> is very bad code to expect the last evaluated value to be useful. just
> put return statements in there will make it much better.

I think that's a matter of style. I would write:

sub eq_undef {
  (defined($_[0]) and defined($_[1])) ?
      $s1 eq $s2;
    : defined($s1) == defined($s2);
}

> 
> but you still have a bug. what if one element is '0' and the other
> undefined?

I don't see it.

M4


------------------------------

Date: Sat, 9 Feb 2008 21:53:11 -0800 (PST)
From: MoshiachNow <lev.weissman@creo.com>
Subject: Fail extracting table from .mdb file using DBI module
Message-Id: <eb05a696-a8c1-42e7-840d-07a9e91b7550@s19g2000prg.googlegroups.com>

HI,

The following sub extracts data nicely from all tables,just one table
comes up empty.
Will appreciate ideas on possible issues in the code.
thanks
=======================
sub exportMDB {
    my $database = shift;
    my $driver = "Microsoft Access Driver (*.mdb)";
    print "$database\n";
    print "---------------------------------\n\n";
    my $dsn = "dbi:ODBC:driver=$driver;dbq=$database";
    my $dbh = DBI->connect("$dsn") or warn "Couldn't open database:
$DBI::errstr; stopped";

    my $sth = $dbh->table_info( "", "", "", "TABLE" );

    while ( my ($catalog, $schema, $table, $type) = $sth-
>fetchrow_array() )  {
        if ($table)  {
            print "\n$table :\n";
            print "--------\n";
            my $sql = "select * from $table";

            # Prepare the SQL query for execution
            my $sth = $dbh->prepare($sql) or warn "Couldn't prepare
statement:$DBI::errstr; stopped";

            # Execute the query
            $sth->execute() or warn "Couldn't execute statement:
$DBI::errstr; stopped";

            # Fetch each row and print it
            while ( my (@row) = $sth->fetchrow_array() )  {
                print "$_\t"  foreach (@row);
                print "\n";
            }
        }
    }
    $dbh->disconnect();                            # Disconnect from
the database
}


------------------------------

Date: Sun, 10 Feb 2008 06:14:15 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Fail extracting table from .mdb file using DBI module
Message-Id: <x7ir0xgwy1.fsf@mail.sysarch.com>

>>>>> "M" == MoshiachNow  <lev.weissman@creo.com> writes:

  M> The following sub extracts data nicely from all tables,just one table
  M> comes up empty.
  M> Will appreciate ideas on possible issues in the code.
  M> thanks

i don't think i can help with the db issue but here are some general
coding comments.

  M> =======================
  M> sub exportMDB {
  M>     my $database = shift;
  M>     my $driver = "Microsoft Access Driver (*.mdb)";

that is a fixed value so assign it outside the sub if it is called more
than once.
  M>     print "$database\n";
  M>     print "---------------------------------\n\n";

you can use a single print call for that. either pass it a list of thise
strings, or make then a single string or use a here document. all are
cleaner and faster than 2 (or more) calls to print 

  M>     my $dsn = "dbi:ODBC:driver=$driver;dbq=$database";
  M>     my $dbh = DBI->connect("$dsn") or warn "Couldn't open database:


don't quote single variables like $dsn as it is useless and may actually
cause bugs.


  M>     my $sth = $dbh->table_info( "", "", "", "TABLE" );

you should comment lines like that since you ignore several
args. explain why you make this call and why you chose this list of
args.

  M>     while ( my ($catalog, $schema, $table, $type) = $sth-
  >> fetchrow_array() )  {
  M>         if ($table)  {

you have no else clause on that if. so reverse the if and do the next
loop. this is best done with a simple statement modifier

	next unless $table ;

otherwise you fall through to the rest of the code which needs no block
so you save an indent, the expensive braces and all those wasted
pixels. 

  M>             print "\n$table :\n";
  M>             print "--------\n";

multi print call again. bad habit you should break.

  M>             my $sql = "select * from $table";

  M>             # Prepare the SQL query for execution
  M>             my $sth = $dbh->prepare($sql) or warn "Couldn't prepare
  M> statement:$DBI::errstr; stopped";

wrap long lines like that. general style calls for lines < 80 or so. i
don't want to start a war over long code lines.

  M>             # Execute the query
  M>             $sth->execute() or warn "Couldn't execute statement:
  M> $DBI::errstr; stopped";

  M>             # Fetch each row and print it
  M>             while ( my (@row) = $sth->fetchrow_array() )  {
  M>                 print "$_\t"  foreach (@row);

that calls print each time in the loop. map is usually better when you
want output for print

		print map "$_\t", @row ;

  M>                 print "\n";

combine that with the previous print:

		print map( "$_\t", @row ), "\n";

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Architecture, Development, Training, Support, Code Review  ------
-----------  Search or Offer Perl Jobs  ----- http://jobs.perl.org  ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Sun, 10 Feb 2008 05:42:17 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Feb 10 2008
Message-Id: <Jw0D6H.1u50@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Acme-BabyEater-0.04
http://search.cpan.org/~zoffix/Acme-BabyEater-0.04/
Baby eating has never been easier! 
----
Acme-Greeting-0.0.1
http://search.cpan.org/~gugod/Acme-Greeting-0.0.1/
Greeting from Perl. 
----
CIAO-Lib-Param-0.08
http://search.cpan.org/~djerius/CIAO-Lib-Param-0.08/
an interface to the CIAO parameter library. 
----
CMS-MediaWiki-0.8013
http://search.cpan.org/~retoh/CMS-MediaWiki-0.8013/
Perl extension for creating, reading and updating MediaWiki pages 
----
Cache-Historical-0.03
http://search.cpan.org/~mschilli/Cache-Historical-0.03/
Cache historical values 
----
Config-Validate-0.2.3
http://search.cpan.org/~cmo/Config-Validate-0.2.3/
Validate data structures generated from configuration files. (Or anywhere else) 
----
Config-Validate-0.2.4
http://search.cpan.org/~cmo/Config-Validate-0.2.4/
Validate data structures generated from configuration files. (Or anywhere else) 
----
Continuity-0.97
http://search.cpan.org/~awwaiid/Continuity-0.97/
Abstract away statelessness of HTTP, for stateful Web applications 
----
DBI-1.602
http://search.cpan.org/~timb/DBI-1.602/
Database independent interface for Perl 
----
Data-CPAN-DSLIP-Explain-0.03
http://search.cpan.org/~zoffix/Data-CPAN-DSLIP-Explain-0.03/
"decrypts" CPAN module DSLIP code 
----
ExtUtils-PkgConfig-1.10
http://search.cpan.org/~tsch/ExtUtils-PkgConfig-1.10/
simplistic interface to pkg-config 
----
Fey-DBIManager-0.02
http://search.cpan.org/~drolsky/Fey-DBIManager-0.02/
Manage a set of DBI handles 
----
Fey-DBIManager-0.03
http://search.cpan.org/~drolsky/Fey-DBIManager-0.03/
Manage a set of DBI handles 
----
Fey-ORM-0.01
http://search.cpan.org/~drolsky/Fey-ORM-0.01/
A Fey-based ORM 
----
File-chdir-0.1001
http://search.cpan.org/~dagolden/File-chdir-0.1001/
a more sensible way to change directories 
----
Geo-Query-LatLong-0.8008
http://search.cpan.org/~retoh/Geo-Query-LatLong-0.8008/
Uniform interface to query latitude and longitude from a city. 
----
Geo-Query-LatLong-0.8009
http://search.cpan.org/~retoh/Geo-Query-LatLong-0.8009/
Uniform interface to query latitude and longitude from a city. 
----
Geo-Query-LatLong-0.8010
http://search.cpan.org/~retoh/Geo-Query-LatLong-0.8010/
Uniform interface to query latitude and longitude from a city. 
----
HTML-WikiConverter-DokuWikiFCK-0.13
http://search.cpan.org/~turnermm/HTML-WikiConverter-DokuWikiFCK-0.13/
A WikiConverter Dialect supporting the FCKeditor in DokuWiki 
----
Hook-Output-File-0.04
http://search.cpan.org/~schubiger/Hook-Output-File-0.04/
Redirect STDOUT/STDERR to a file 
----
IO-CaptureOutput-1.0801
http://search.cpan.org/~dagolden/IO-CaptureOutput-1.0801/
capture STDOUT and STDERR from Perl code, subprocesses or XS 
----
IO-Ppoll-0.07
http://search.cpan.org/~pevans/IO-Ppoll-0.07/
Object interface to Linux's ppoll() call 
----
Image-Magick-Thumbnail-0.06
http://search.cpan.org/~lgoddard/Image-Magick-Thumbnail-0.06/
Produces thumbnail images with ImageMagick 
----
Image-Magick-Thumbnail-0.06b
http://search.cpan.org/~lgoddard/Image-Magick-Thumbnail-0.06b/
Produces thumbnail images with ImageMagick 
----
Image-Seek-0.02
http://search.cpan.org/~kenwu/Image-Seek-0.02/
A port of ImgSeek to Perl 
----
JavaScript-Writer-0.2.0
http://search.cpan.org/~gugod/JavaScript-Writer-0.2.0/
JavaScript code generation from Perl. 
----
KSx-Analysis-StripAccents-0.02
http://search.cpan.org/~sprout/KSx-Analysis-StripAccents-0.02/
Remove accents and fold to lowercase 
----
KSx-Highlight-Summarizer-0.01
http://search.cpan.org/~sprout/KSx-Highlight-Summarizer-0.01/
KinoSearch Highlighter subclass that provides more comprehensive summaries 
----
List-Extract-0.02
http://search.cpan.org/~lodin/List-Extract-0.02/
grep and splice combined 
----
Log-Handler-0.38_09
http://search.cpan.org/~bloonix/Log-Handler-0.38_09/
Log messages to one or more outputs. 
----
POE-Component-CPAN-SQLite-Info-0.07
http://search.cpan.org/~zoffix/POE-Component-CPAN-SQLite-Info-0.07/
non-blocking wrapper around CPAN::SQLite::Info with file fetching abilities. 
----
Safe-Caller-0.08
http://search.cpan.org/~schubiger/Safe-Caller-0.08/
A nicer interface to the built-in caller() 
----
Time-HiRes-1.9712
http://search.cpan.org/~jhi/Time-HiRes-1.9712/
High resolution alarm, sleep, gettimeofday, interval timers 
----
Video-Dumper-QuickTime-1.0000
http://search.cpan.org/~grandpa/Video-Dumper-QuickTime-1.0000/
Dump QuickTime movie file structure 
----
WWW-Mixi-Scraper-0.12
http://search.cpan.org/~ishigaki/WWW-Mixi-Scraper-0.12/
yet another mixi scraper 
----
YAML-YuyuPress-0.05_1
http://search.cpan.org/~jmerelo/YAML-YuyuPress-0.05_1/
Tool for making presentacions out of YAML files. 
----
cpan_bot-0.02
http://search.cpan.org/~zoffix/cpan_bot-0.02/
----
cpan_bot-0.03
http://search.cpan.org/~zoffix/cpan_bot-0.03/
an IRC CPAN Info bot 
----
eGuideDog-Dict-Cantonese-0.1
http://search.cpan.org/~hgneng/eGuideDog-Dict-Cantonese-0.1/
an informal Jyutping dictionary. 
----
list_versions-0.04
http://search.cpan.org/~zoffix/list_versions-0.04/
"easify" writing Makefile.PL and Build.PL by easily listing versions of modules. 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Sun, 10 Feb 2008 00:09:18 GMT
From: "Peter Jamieson" <ldolan@thinkinghatbigpond.net.au>
Subject: Printing to screen and to file
Message-Id: <Ogrrj.12962$421.11462@news-server.bigpond.net.au>

I can print to a file by using:

open(STDOUT, ">>tmp.txt");

and print warnings to a file

open(STDERR, ">>tmp.txt");

But what I would like to do is both print STDOUT and STDERR to a file
but also to still view both on screen.

I looked in perldoc and elsewhere but could not see how to do this.
Any help appreciated! 




------------------------------

Date: Sat, 9 Feb 2008 17:19:32 -0800 (PST)
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Printing to screen and to file
Message-Id: <618543b6-6dc7-4b15-95db-89e95d42f76f@l32g2000hse.googlegroups.com>

On Feb 9, 7:09=A0pm, "Peter Jamieson" <ldo...@thinkinghatbigpond.net.au>
wrote:
> I can print to a file by using:
>
> open(STDOUT, ">>tmp.txt");
>
> and print warnings to a file
>
> open(STDERR, ">>tmp.txt");
>
> But what I would like to do is both print STDOUT and STDERR to a file
> but also to still view both on screen.
>
> I looked in perldoc and elsewhere but could not see how to do this.
> Any help appreciated!

Use the IO::Tee module from CPAN to create a filehandle that prints to
both the file and STDOUT, select() that filehandle, and then setup a
warn handler to print to the default filehandle rather than STDERR:

$ perl -MIO::Tee -le'
open my $fh, ">", "log.txt" or die $!;
my $tee =3D IO::Tee->new(\*STDOUT, $fh);
select $tee;
$SIG{__WARN__} =3D sub { print @_ };
print "Info";
warn "Warning";
'
Info
Warning at -e line 7.

$ cat log.txt
Info
Warning at -e line 7.



Hope this helps,
Paul Lalli


------------------------------

Date: Sat, 09 Feb 2008 22:06:21 -0800
From: David Filmer <usenet@davidfilmer.com>
Subject: Re: Printing to screen and to file
Message-Id: <B-2dnchC_O6ACTPaRVn_vwA@giganews.com>

Peter Jamieson wrote:

> But what I would like to do is both print STDOUT and STDERR to a file
> but also to still view both on screen.

If you want to get really fancy and versatile you can do this with a 
logging module.

My favorite is Log::Dispatch. Here is some sample code that I use in my
"skeleton" boilerplate starter script to do all the work of setting up
the logging methods (you need to do a bunch of stuff up-front, but once
it's done, the actual logging is VERY simple, as you will see):

######################################################################
### LOGGING. Levels are: #############################################
###     debug info notice warning error critical alert emergency    ##
######################################################################
                                                                     ##
use Mail::Sendmail;                                                 ##
use Log::Dispatch;                                                  ##
use Log::Dispatch::Screen;                                          ##
use Log::Dispatch::File;                                            ##
use Log::Dispatch::Email::MailSendmail;                             ##
                                                                     ##
my  $log;                                                           ##
                                                                     ##
LOG_METHODS: { #lexically isolate variables in a block              ##
my $logdir = $cfg{'dir'}{'log'} || "/var/tmp";                      ##
my @admin_email = @{$cfg{'email'}{'admin'}}  ||                     ##
                   sprintf('%s@%s', scalar getpwuid($<), hostname);  ##
                                                                     ##
unshift @{$Mail::Sendmail::mailcfg{'smtp'}},                        ##
                      $cfg{'email'}{'smtp'} || 'localhost';          ##
                                                                     ##
my $add_lf        = sub { my %p = @_; "$p{'message'}\n"};           ##
my $add_indent = sub {my %p = @_; "   $p{'message'}"}; #for Outlook ##
my $add_timestamp = sub { my %p = @_;                               ##
                           sprintf "%s - %s", scalar(localtime),     ##
                                              $p{'message'}; };      ##
my $add_level     = sub { my %p = @_;                               ##
                       sprintf "%-10s %s", ($p{'level'} =~ /debug/i) ##
                                                    ? lc $p{'level'} ##
                                                    : uc $p{'level'},##
                                               $p{'message'} };      ##
                                                                     ##
$log = Log::Dispatch->new ( callbacks => [$add_level, $add_lf] );   ##
                                                                     ##
$log ->add( Log::Dispatch::Screen ->new(                            ##
                name      => 'screen',                               ##
                min_level => 'debug',                                ##
                stderr    => 0, )                                    ##
           );                                                        ##
$log ->add( Log::Dispatch::File ->new(                              ##
                name      => 'file',                                 ##
                min_level => 'info',                                 ##
                filename  => sprintf ( "%s/%s.log",                  ##
                                $logdir,                             ##
                                $FindBin::Script ),                  ##
                mode      => 'append',                               ##
                callbacks => $add_timestamp,                         ##
           ));                                                       ##
$log ->add( Log::Dispatch::Email::MailSendmail ->new(               ##
                name      => 'email',                                ##
                min_level => 'error',                                ##
                to        => \@admin_email,                          ##
                subject   => "ERROR in $PROGRAM_NAME",               ##
                callbacks => $add_indent,                            ##
                from      => sprintf ("SERVER<%s\@%s>",              ##
                               (hostname =~ /^([^\.]*)/)[0],         ##
                               'do-not-reply.com' )  ,               ##
                smtp      => $cfg{'email'}{'smtp'} || 'localhost',   ##
            ));                                                      ##
}; #do                                                              ##

#dispatch our very first message - print all the runtime info       ##
$log -> debug(sprintf                                               ##
                  "[%s] Begin %s\n\tVersion %s on %s as %s\n"        ##
                 ."\tConfigFile: %s\n\tKillfile(s):\n%s",            ##
                      __LINE__, __FILE__,                            ##
                      $main::VERSION,                                ##
                      hostname(),                                    ##
                      "$REAL_USER_ID ($ENV{'USER'})",                ##
                      $cfg{'inifile'},                               ##
                      map {"\t\t$_\n"} keys %{$cfg{'killfile'}},     ##
               );                                                    ##
######################################################################

(I'm using a configuration hash (%cfg) which is populated earlier, and
I'm allowing for numerous default values within my method definitions)

This creates three different types of logging methods (console, file,
and e-mail). When we pass a message to the logger, it will fire ANY and
ALL methods which are at (or above) the log level specified for the
various methods.  For example,

    $log -> debug("This message goes to the screen only");
    $log -> info("This message goes to BOTH screen and file.");
    $log -> error("This goes to screen, file, AND e-mail");

I could add many other methods as well (database logging, multiple
levels of file logging, etc).

As you can see, I've added several callback functions to do things like
add a timestamp and automatically add linefeeds. I've found that
Outlook can do some funny things with wrapping, so I add an indention
to e-mail messages to avoid Outlook reformatting.

Check it out; it's an amazing module:

http://search.cpan.org/~drolsky/Log-Dispatch-2.11/lib/Log/Dispatch.pm


------------------------------

Date: Sun, 10 Feb 2008 09:57:27 +0100 (CET)
From: January Weiner <january.weiner@gmail.com>
Subject: Question about PDL
Message-Id: <fome9n$4l1$1@sagnix.uni-muenster.de>

Hello,

in my program, I am using a matrix which has usually a size of 2000x2000 or
similar. It contains short integers.  The matrix is filled in one by one in
a loop over rows and columns.

The only calculation that I am doing with this matrix is averaging
over a window sliding along the diagonals. Finally, I need to access each
matrix element one after another in a loop to calculate something.

At first, I used a regular Perl matrix, constructed as [ [ .... ], [ ... ],
 .... ]. This was quite slow and took a lot of memory (the memory footprint
of my program grews up by roughly 50MB), so I googled and found PDL -- Perl
Data Language.

PDL is supposed to be much faster and to have a smaller memory footprint.

While I can see the latter (the footprint is now negligible compared to the
whole program), it is roughly three to four times slower than the regular
perlish way. I am creating the matrix as follows [please bear with me -- I
am not posting actual code, because it is rather complex, and you will see
that answering my question doesn't require finding out whether my code is
correct]:

  $matrix = short(zeroes($l1, $l2)) ;

(where $l1 and $l2 are dimensions of the matrix), and accessing / setting
the elements using at() and set():

  set( $matrix, $i, $j, $value ) ;
  $value = at( $matrix, $i, $j ) ;

There is another way of doing it using PDL::NiceSlice, which uses
constructs like $matrix->($i, $j), but I found it to be even slower.

QUESTION: Is this a normal behaviour? Is it normal that a standard perlish
matrix is few times faster than the PDL implementation? Or should I start
finding out where I messed things up?

Thank you in advance,

January




------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 1267
***************************************


home help back first fref pref prev next nref lref last post