[22681] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4902 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 27 21:05:49 2003

Date: Sun, 27 Apr 2003 18:05:07 -0700 (PDT)
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, 27 Apr 2003     Volume: 10 Number: 4902

Today's topics:
    Re: Can Perl enter data into web page form fields?  "Fa <mbudash@sonic.net>
    Re: Can Perl enter data into web page form fields?  "Fa <usenet@tinita.de>
    Re: Conditional use of perl modules <goldbb2@earthlink.net>
    Re: Curses and perl5.8 <goldbb2@earthlink.net>
    Re: Curses and perl5.8 <goldbb2@earthlink.net>
    Re: French ascii characters? <goldbb2@earthlink.net>
    Re: Function to get directory separator char? <goldbb2@earthlink.net>
    Re: Help: ? $next_one == ${next_one} <goldbb2@earthlink.net>
    Re: Just curous about this- are REGEXes rigorously dete <goldbb2@earthlink.net>
        Multidimensional Arrays <argonhigh@hotmail.com>
    Re: Multidimensional Arrays <argonhigh@hotmail.com>
    Re: Multidimensional Arrays <REMOVEsdnCAPS@comcast.net>
    Re: Multidimensional Arrays <argonhigh@hotmail.com>
    Re: non-blocking read with IO::Select <goldbb2@earthlink.net>
    Re: number of elements in an array that is part of a ha <goldbb2@earthlink.net>
    Re: perl hash - help request <krahnj@acm.org>
    Re: Perl on JVM -- any links? <goldbb2@earthlink.net>
    Re: Perl on JVM -- any links? <goldbb2@earthlink.net>
    Re: Regex greediness question <pa@brick.invalid>
    Re: Running a perl script (Duane L)
    Re: Storable running VERY slowly <goldbb2@earthlink.net>
    Re: Style: Using 'no warnings' in a module <tassilo.parseval@rwth-aachen.de>
    Re: Style: Using 'no warnings' in a module <noreply@gunnar.cc>
    Re: Tough question for the guru's; Grep Once, Awk Twice (Agrapha)
    Re: Tough question for the guru's; Grep Once, Awk Twice (Agrapha)
        WTB: Programming PERL DBI noipont@mailcity.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 27 Apr 2003 19:03:34 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Can Perl enter data into web page form fields?  "Fake" key strokes?
Message-Id: <mbudash-2702E8.12033427042003@typhoon.sonic.net>

In article <lkUqa.42604$ey1.3967699@newsread1.prod.itd.earthlink.net>,
 "John" <SeeMessageBody@nospam.com> wrote:

> Anybody know a way to get Perl to enter data into fields on a web page form?

elaborate, pls. your own form, or a remote site's form?

-- 
Michael Budash


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

Date: 27 Apr 2003 22:39:57 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: Can Perl enter data into web page form fields?  "Fake" key strokes?
Message-Id: <b8hm7t$aba6g$1@ID-24002.news.dfncis.de>

John <SeeMessageBody@nospam.com> wrote:
> Anybody know a way to get Perl to enter data into fields on a web page form?

an easy way: WWW::Mechanize::Shell

hth, tina
-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
http://www.tinita.de/peace/link.html - Spread Peace


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

Date: Sun, 27 Apr 2003 20:52:19 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Conditional use of perl modules
Message-Id: <3EAC7B43.7B01AE3C@earthlink.net>

012 wrote:
> 
> Hi
> Is it possible to make the defintion "use modulename" conditional?
> Something like:
> if ($usewin32)
> {
>        use Win32::OLE qw
> }

A couple of fairly standard ways:

   1/ Use the 'if' module from CPAN.

   use if $usewin32, Win32::OLE => qw(....);

   2/ Use a BEGIN block and require and import.

   BEGIN {
      if( $usewin32 ) {
         require Win32::OLE;
         import  Win32::OLE qw(....);
      }
   }

The reason the BEGIN block is needed, is because otherwise, the require
and import would happen at run-time, not compile-time, and you wouldn't
get any of the subroutines pre-recognized (so you'd need to use parens
in all cases), nor would perl know of the prototypes that the
subroutines might have, nor would any constants defined by Win32::OLE
get properly inlined.

PS: For your code, that you showed later in this thread, I would
suggest:

   use constant IS_WIN => $^O eq "MSWin32";
   BEGIN { if( IS_WIN ) {
      require Win32::OLE;
      import  Win32::OLE qw(in with);
      require Win32::OLE::Const;
      import  Win32::OLE::Const 'Microsoft Excel';
      require Win32::OLE::Variant;
      import  Win32::OLE::Variant;
      require Win32::OLE::NLS;
      import  Win32::OLE::NLS qw(:LOCALE :DATE);
   } }

PPS: I would advise that for all subroutines (including constants) which
may be imported only conditionally, (including the subs in() and
with()), you always add parens -- this avoids the problems that will
arise on those occasions when by chance you *don't* import the sub.

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Sun, 27 Apr 2003 17:36:38 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Curses and perl5.8
Message-Id: <3EAC4D66.DDA45BF7@earthlink.net>



"Tassilo v. Parseval" wrote:
> 
> Also sprach David Formosa (aka ? the Platypus):
> 
> > The error message was a long and spammy[1] one if installing Curses
> > was inpossable for everyone then I wasn't willing to waste bandwidth
> > posting it.  However since its something new I'll include it in this message.
> >
> >> don't submit a bug, post the error then someone may be able to help.
> >
> > I haven't programed in c for the longest time, however I think that
> > Curses.c:275 is the scean killer.  However the warnings worry me and
> > make me think that there is something deeply wrong.
> >
> > cc -c  -I/usr/include/ncurses -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2   -DVERSION=\"1.06\" -DXS_VERSION=\"1.06\" -fpic "-I/usr/local/lib/perl5/5.8.0/i586-linux-thread-multi-64all-ld/CORE"   Curses.c
> > Curses.c: In function `c_sv2field':
> > Curses.c:148: warning: cast to pointer from integer of different size
> [...]
> 
> That looks like a 32bit versus 64bit issue. Your perl appears to be
> compiled with -Duse64bitint. Line 148 is
> 
>     if (sv_isa(sv, "Curses::Field")) { return (FIELD*)SvIV((SV*)SvRV(sv)); }
> 
> so the IV returned by SvIV is larger than a pointer to FIELD (that is
> what the warning implies).
> 
> That's the diagnostic part. I have no fix. You should send a message to
> the author of the module and ask him whether he's aware of any such
> problem.

How about:

   if (sv_isa(sv, "Curses::Field")) {
      return INT2PTR( FIELD*, SvIV((SV*)SvRV(sv)) );
   }

Instead of a simple cast?

[snip]
> > Curses.c: In function `c_sv2window':
> > Curses.c:275: warning: passing arg 1 of `Perl_sv_isa' from incompatible pointer type
> > Curses.c:275: warning: passing arg 2 of `Perl_sv_isa' from incompatible pointer type
> > Curses.c:275: too few arguments to function `Perl_sv_isa'
> 
> This is not clear to me at all. The line in question looks fine to me:
> 
>     if (Perl_sv_isa(sv, "Curses::Window")) {
> 
> sv is a proper 'SV*' and the second argument is a 'const char*' as
> described by perlapi.pod.

That should be either:

      if (Perl_sv_isa(aTHX_ sv, "Curses::Window")) {

Or:

      if (sv_isa(sv, "Curses::Window")) {

You shouldn't use the Perl_ version without having aTHX_ in front of the
first argument.

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Sun, 27 Apr 2003 17:50:20 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Curses and perl5.8
Message-Id: <3EAC509C.EFB36628@earthlink.net>

"Tassilo v. Parseval" wrote:
> 
> Also sprach Eric J. Roode:
> 
> > "David Formosa (aka ? the Platypus)" <dformosa@dformosa.zeta.org.au>
> > wrote in news:slrnbahp8p.phe.dformosa@dformosa.zeta.org.au:
> >
> >> I'm trying to install Curses.pm under perl5.8 however when I try it
> >> fails to compile.  I can't see anything on deja-google about it is
> >> this a know problem or something I should submit a bug report on.
> >
> > Let me guess:  Perl_sv_isa?
> >
> > This is a known problem, although I don't know why there isn't more
> > Net noise about it.
> >
> > You need to change the above symbol to "sv_isa".  The compiler
> > message tells you where the error is -- some .c file, line 250 or 275
> > (I forget exactly).  Just change that one line and re-run make.
> > It'll work.
> 
> Are you sure that this is the cause? Compilation worked fine for me
> when I tried it yesterday on Perl5.8.0, despite the Perl_sv_isa thing.
> Also looking at the perl-headers, sv_isa is eventually #defined as
> Perl_sv_isa so it should be the same thing.

If PERL_IMPLICIT_CONTEXT isn't defined, then sv_isa and Perl_sv_isa are
interchangable.

But when it *is* defined, then Perl_sv_isa *needs* to get a
thread/interpreter object as it's first argument.

Depending on whether or not PERL_IMPLICIT_CONTEXT is defined, the macro
"aTHX_" becomes either "" or another macro, which expands into something
providing an interpreter object.

If you're building for a non-threaded perl, and don't have MULTIPLICITY
defined, then you probably don't have PERL_IMPLICIT_CONTEXT defined --
thus, this "wrong" code will compile ok for you.

(One would generally have MULTIPLICITY defined only when compiling with
ithreads, or when embedding perl in another application, and want to be
able to have multiple embedded perl interpreters.)

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Sun, 27 Apr 2003 16:51:15 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: French ascii characters?
Message-Id: <3EAC42C3.365BC630@earthlink.net>

"Mihai N." wrote:
> 
> > When the output is sent to a text file (instead of the command line),
> > all of the accented characters are displayed correctly.
>
> Well, then this is your answer.
> Windows uses cp1252 for GUI applications and cp850 command line.
> Actualy 850 is for French, but if you do your tests on a US system
> it will be 437 in the console. I agree, this is a mess.
> But I just hope (for you) the desired output is 1252. At lease
> you will have the same code page for US and French systems.
> Since the text looks ok in notepad, I just assume you receive 1252
> and output 1252. This is ok, if you don't need any case conversions
> or other processing.
> 
> As for conversion (in case you need it), if you are using Perl 5.8
> you need nothing else. You can open a file or use binmode to specify
> the encoding.

Just make sure that when you do so, you specify the encoding of the
output, as well as the input.

Oh, and you might be able to avoid seeing the differences between
printing to a console and printing to a file, by using a different
encoding when printing to the console.

   # all text files are cp1252
   # Also, as a default, make the STD{IN,OUT,ERR} handles cp1252
   use open qw(IO :std :encoding(cp1252));
   BEGIN {
      # But if STD{IN,OUT,ERR} are terminals, they
      # should actually be cp850
      -T $_ and binmode($_, ":encoding(cp850)")
         for *STDIN, *STDOUT, *STDERR;
   }
   # Oh, and what encoding should this program itself have?
   use encoding (__FILE__ eq "-" && -T STDIN) ? "cp850" : "cp1252";

[untested]

You'd probably want to put this in a module and load it with the -M
commandline option, through the PERL5OPTS environment variable.

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Sun, 27 Apr 2003 20:33:20 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Function to get directory separator char?
Message-Id: <3EAC76D0.708B652C@earthlink.net>



"D. Alvarado" wrote:
> 
> Hi,
>    Does anyone have a quick one-liner for getting the directory
> separator character?  Thanks - Dave

Instead of parsing paths yourself, let File::Spec do it for you.

Otherwise, your program will barf on systems where the directory
seperator character is used in an unusual way (VAX, for example).

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Sun, 27 Apr 2003 17:15:59 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Help: ? $next_one == ${next_one}
Message-Id: <3EAC488F.C37DD36A@earthlink.net>

Villy Kruse wrote:
[snip]
> > "abc$next_one\Edef"
> >
> 
> "abc" . $next_one . "def"
> 
> is also a posible way; which may result in the same compiled bytecode.

IIRC, string interpolation results in a join() on a list, whereas the .
form produces two concatenation operations.

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Sun, 27 Apr 2003 18:03:52 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Just curous about this- are REGEXes rigorously deterministic
Message-Id: <3EAC53C8.B79E971D@earthlink.net>



Sara wrote:
> 
> OK, probably just the "scientist" in me, but with such an enormously
> large set of possibilities, I wonder if regex results
> deterministically map into a 1:1 into set of correct solutions (1
> input, 1 regex = 1 result?).

Ignoring code embedded inside of the regex ... yes.

[snip]
> Are regexes *theory*, that is a proposal that cannot be proven, or are
> they proven to map 1:1 from the input to the output domains?

*Real* regexes ("Regular Expression") are provably equivilant to
Deterministic Finite Automata.  There's quite a bit of proven theories
about DFAs, and, equivilantly, Regular Expressions.

But due to things like capturing parens, and backreferences, perl's
regexen are not *quite* DFAs -- I would guess that (still ignoring
embedded code) their capabilities are closer to pushdown automata.

I'm not quite sure how much lookaheads (?=), lookbehinds (?<), and
independent subexpressions (?>) effect the capabilities of perl's
regexen.

> Just a curiosity, sorry for the interruption.. Oh by the way I have
> this COBOL program can someone write it in Perl for me?? *duck*

Sure -- I charge a $25/hr consulting fee.  Want to hire me? :)

> Have a good fin de semana everyone!

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Sun, 27 Apr 2003 17:44:20 -0400
From: "James" <argonhigh@hotmail.com>
Subject: Multidimensional Arrays
Message-Id: <maYqa.257$Jy3.84677@news20.bellglobal.com>

Hello, I need to find the number of elements in one level of my
multidimensional array

$runs[0]=['a','47','f'];
$runs[1]=['b','12','g'];
$runs[2]=['c','16','z','9991','1','0.25'];

I need to find how many elements are in
$runs[0]
which would be 3

$runs[1]
which would be 3

$runs[2]
which would be 6


How can I do this?, I read perldata, and searched on google.
I tried the following with no luck

$amount=scalar(@runs[2]);
and
$amount=scalar($runs[2]);

Thanks.




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

Date: Sun, 27 Apr 2003 18:18:45 -0400
From: "James" <argonhigh@hotmail.com>
Subject: Re: Multidimensional Arrays
Message-Id: <GGYqa.1359$EC.109097@news20.bellglobal.com>

"James" <argonhigh@hotmail.com> wrote in message
news:maYqa.257$Jy3.84677@news20.bellglobal.com...
> Hello, I need to find the number of elements in one level of my
> multidimensional array
>

I found my own way to do it, thanks anyways.




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

Date: Sun, 27 Apr 2003 18:32:36 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Multidimensional Arrays
Message-Id: <Xns936AC6C2E7B4Bsdn.comcast@216.166.71.239>

"James" <argonhigh@hotmail.com> wrote in news:maYqa.257$Jy3.84677
@news20.bellglobal.com:

> How can I do this?, I read perldata, and searched on google.
> I tried the following with no luck
> 
> $amount=scalar(@runs[2]);
> and
> $amount=scalar($runs[2]);

Close.   scalar(@{$runs[2]})

-- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;


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

Date: Sun, 27 Apr 2003 20:02:11 -0400
From: "James" <argonhigh@hotmail.com>
Subject: Re: Multidimensional Arrays
Message-Id: <sh_qa.337$Jy3.105721@news20.bellglobal.com>

"Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote in message
news:Xns936AC6C2E7B4Bsdn.comcast@216.166.71.239...
> "James" <argonhigh@hotmail.com> wrote in news:maYqa.257$Jy3.84677
> @news20.bellglobal.com:
>
> > How can I do this?, I read perldata, and searched on google.
> > I tried the following with no luck
> >
> > $amount=scalar(@runs[2]);
> > and
> > $amount=scalar($runs[2]);
>
> Close.   scalar(@{$runs[2]})

Thanks so much, this way it much better then what I was doing.




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

Date: Sun, 27 Apr 2003 17:29:30 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: non-blocking read with IO::Select
Message-Id: <3EAC4BBA.99176D39@earthlink.net>

"Tassilo v. Parseval" wrote:
> 
> Also sprach ILoveP:
> 
> > I have to read some data piped into my program but the source of the
> > data might have some delay. I wrote a script which use IO::Select so
> > I can check for timeouts. However, I got weird results.
> >
> > Below is my script:
> > -----------
> > #!/usr/bin/perl
> >
> > use IO::Select;
> > use IO::File;
> >
> > $| = 1;    # autoflush
> >
> > $timeout = 2;    # timeout in 2 secs
> >
> > $fh = IO::File->new("./datasrc.pl |") or die $!;
> > $sel = IO::Select->new($fh);
> >
> > while (!$fh->eof) {
> >         @ready = $sel->can_read($timeout);
> >         unless (@ready) {
> >                 warn "timeout!\n";
> >                 last;
> >         }
> >         print $fh->getline;
> > }
> 
> There are two problems in your code. One is a general thing: You should
> only read from handles in @ready. In your case there's naturally only
> one handle (namely $fh), but nonetheless.
> 
> The source of your problem is probably that you are using getline()
> together with select. From 'perldoc -f select':
> 
>     WARNING: One should not attempt to mix buffered I/O (like "read"
>     or <FH>) with "select", except as permitted by POSIX, and even
>     then only on POSIX systems. You have to use "sysread" instead.
> 
> So you need unbuffered reading:
> 
>     while (...) {
>         for my $h ($sel->can_read($timeout)) {
>             my $data;
>             while ($h->sysread(my $buf, 4096) {
>                 $data .= $buf;
>             }
>             # do something with $data
>         }
>     }

Another thing to remember when writing this, the "eof" operator is part
of the buffered IO stuff -- if there's data buffered, it returns false
(not eof, since there's more to read), and if there isn't data buffered,
it attempts to read some data into the buffer to find out if the handle
is at eof.  Thus, you can't mix "eof" with "select".

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Sun, 27 Apr 2003 15:21:57 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: number of elements in an array that is part of a hash
Message-Id: <3EAC2DD5.3456B91A@earthlink.net>

Andras Malatinszky wrote:
> 
> Bart Lateur wrote:
[snip]
> >       $Elements = @{$Person[$i]{children}};
> >
> > which is the answer to your problem.
> >
> >
> Suppose I wanted to know the number of *all* the children in this data
> structure. Is there some quick way of finding that, other than actually
> generating $Elements for each $i and summing up the values?

my $total = 0;
$total += @{ $_->{children} } for @Person;

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Sun, 27 Apr 2003 23:36:30 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: perl hash - help request
Message-Id: <3EAC695D.F435CCD6@acm.org>

shree wrote:
> 
> I'm a novice perl programmer and run into difficulties in writing code
> that involves hash and am hoping that someone can guide me with a
> snipett. Any help/guidance will be greatly appreciated. Thanks
> 
> I have log file of dates in MM/DD/YYYY format that looks like this and
> would like to extract totals of each type for each month
> 
> Input Log File
> ID      Submitted       Required        Implemented
> 1       02/16/2003      02/20/2003      02/21/2003
> 2       02/22/2003      02/24/2003      03/04/2003
> 3       03/05/2003      03/06/2003      03/10/2003
> 4       03/05/2003      03/15/2003      03/10/2003
> 5       03/07/2003      03/10/2003      03/11/2003
> 6       04/04/2003      04/05/2003      04/07/2003
> 7       04/08/2003      04/12/2003      04/12/2003
> 
> Desired Output File (Totals of each type per month)
> Month   Tot_Sub Tot_Req Tot_Impl
> Feb 2003        2       2       1
> Mar 2003        3       3       4
> Apr 2003        2       2       2
> 
> Note that in each row, Submitted date will always be the earliest. It
> would be nice (if possible), to provide overall totals of target
> completion. i.e.
> No. of ID completed ahead of time:      1
> No. of ID completed on time: 1
> No. of ID completed later than requested time: 5


This should do what you want:

#!/usr/bin/perl
use warnings;
use strict;

my @mons = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/;
my $logfile = 'something.log';

open F, $logfile or die "Cannot open $logfile: $!";

my ( $ahead, $ontime, $behind, %stats );
while ( <F> ) {
    next unless /\d/;
    my @dates = grep s!(\d+)/(\d+)/(\d+)!$3$1$2!, split;
    $stats{ substr $dates[ $_ ], 0, 6 }[ $_ ]++ for 0 .. $#dates;
    $behind += $dates[ 1 ] lt $dates[ 2 ];
    $ahead  += $dates[ 1 ] gt $dates[ 2 ];
    $ontime += $dates[ 1 ] eq $dates[ 2 ];
    }

print "Month      Tot_Sub   Tot_Req  Tot_Impl\n";
for my $date ( sort keys %stats ) {
    my ( $year, $mon ) = unpack 'A4 A2', $date;
    printf "%s %d %9d %9d %9d\n", $mons[ $mon - 1 ], $year, @{$stats{ $date }};
    }
print "No. of ID completed ahead of time: $ahead\n";
print "No. of ID completed on time: $ontime\n";
print "No. of ID completed later than requested time: $behind\n";

__END__


John
-- 
use Perl;
program
fulfillment


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

Date: Sun, 27 Apr 2003 17:25:01 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Perl on JVM -- any links?
Message-Id: <3EAC4AAD.F7C50DD2@earthlink.net>

saket wrote:
> 
> Kindly let me know if such a thing exists?
> 
> or something like Netrexx-Java ?

Not yet, and not likely for a long time.

However... the perl6 language is designed to compile to the parrot VM.
And there will be a perl5 compiler which also produces bytecode for the
parrot VM.

It's concievable that there will be, in the far distant future, a Parrot
bytecode => Java bytecode compiler.  Or, an implementation of the Parrot
virtual machine in Java.

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Sun, 27 Apr 2003 20:30:26 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Perl on JVM -- any links?
Message-Id: <3EAC7622.F682D14F@earthlink.net>

saket wrote:
> 
> Kindly let me know if such a thing exists?
> 
> or something like Netrexx-Java ?

Oh, I forgot -- there's JPL, Inline::Java, Java.pm, Jvm.pm, PBJ::JNI,
all of which allow perl/java interaction... though you aren't really
getting the perl bytecode interpreted by the JVM.

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Sun, 27 Apr 2003 15:45:50 -0400
From: Pierre Asselin <pa@brick.invalid>
Subject: Re: Regex greediness question
Message-Id: <e1ch8b.u42.ln@brick.verano.sba.ca.us>

Kevin Shay <kevin_shay@yahoo.com> wrote:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<b89fe6$3bn$1@mamenchi.zrz.TU-Berlin.DE>...

> What do you think of this approach?

> $html =~ s[(<table>.*?</table>)][ deal_with_a_table($1) ]egi;

> sub deal_with_a_table {
> ...
> }

What if the tables are nested?  It's quite legal to do so in HTML.



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

Date: 27 Apr 2003 16:56:53 -0700
From: dewed@dewed.com (Duane L)
Subject: Re: Running a perl script
Message-Id: <896f17fd.0304271556.5fbab273@posting.google.com>

filmstar@blueyonder.co.uk (LondonDeveloper) wrote in message news:<642b74a7.0304270559.1a70ad73@posting.google.com>...
> Hi
> I'm new to Perl scripting.  I've taken a perl test script from
> cgi101.com and uploaded it (making sure its an Ascii upload) onto my
> test website.  I've checked the website and it enables perl to be run
> on it. I've updated the permissions on the script to 755.  However
> when I access the test script all it does is displays the script, it
> doesn't run.  Should it be compiled?  Does it need a parameter?  I'm a
> confused newboy
> 
> Cheers
> And
> 
> The test script is:
> 
> #!/usr/local/bin/perl
> 
> print "Status: 200\r\nContent-type: text/plain\r\n\r\n";
> 
> print "I'm a Perl Script :-)\n";

Depending on how the server is set up, your script may need to be owned
by the same owner as the httpd process.

Find"who" owns the httpd process with:
ps -aux|grep http

you should get something like this..
root       826  0.0  5.2 17516 6624 ?        S    Mar19   0:16 /usr/sbin/httpd
apache    8989  0.0  6.6 18752 8424 ?        S    04:02   0:01 /usr/sbin/httpd
apache    8990  0.0  6.6 18644 8336 ?        S    04:02   0:00 /usr/sbin/httpd
apache    8991  0.0  6.8 18916 8600 ?        S    04:02   0:00 /usr/sbin/httpd
myuname  13759  0.0  0.5  3284  636 pts/0    S    17:10   0:00 grep http

So mine is owned by "apache", I've often see it as "www"

Now just chown the file to the apropriate owner, so it gets the 7XX privledge.
chown apache filename


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

Date: Sun, 27 Apr 2003 15:33:39 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Storable running VERY slowly
Message-Id: <3EAC3093.931F54D0@earthlink.net>

Simon Andrews wrote:
> 
> I am using the Storable module to save a complex data structure which I
> later wish to retrieve.  The structure itself is an object based on a
> hash of hashes (all containing scalar data, no sub-objects or circular
> references or anything like that).
> 
> The problem I'm getting is that storing this object is proving to be
> VERY slow (often 5+ mins at 100% CPU).  The stored data runs to about
> 8Mb once saved, and retrieves in a couple of seconds.  I'd like to know
> what I could do to speed this up.

Given that all the values are plain strings, you don't need Storable at
all.

sub write_hash_to_file {
   my ($filename, $hashref) = @_;
   open( my($fh), ">", $filename ) or die horribly;
   while( my ($key, $value) = each %$hashref ) {
      print $fh pack("N/a*N/a*", $key, $value);
   }
   close $fh or die horribly;
}
sub read_hash_from_file {
   my $filename = shift;
   open( my($fh), "<", $filename ) or die horribly;
   my ($key, %hash);
   local $/ = \4;
   while( my $len = <$fh> ) {
      local $/ = \unpack "N", $len;
      if( defined($key) ) {
         $hash{$key} = <$fh>;
         undef $key;
      } else {
         $key = <$fh>;
      }
   }
   eof($fh) or die horribly;
   return \%hash;
}
__END__
[untested]

PS: No, I've no idea why Storable is taking so long to write.  Try
running it under a C profiler to see where the bottleneck is.

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}



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

Date: 27 Apr 2003 20:02:18 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Style: Using 'no warnings' in a module
Message-Id: <b8hd0a$lp8$1@nets3.rz.RWTH-Aachen.DE>

Also sprach JS Bangs:

> I've got a questions about proper Perl style for a module I'm writing. I
> always use strict, of course, but when testing my module with use
> warnings, a handful of trivial warnings crop up. The cases that these
> warnings describe are expected and unimportant for the overall execution
> of the module.
> 
> So, should simply ignore the warnings? Or should I sprinkle 'no warnings'
> throughout the module to temporarily disable warnings for the offending
> sections? Which is worse Perl style: a handful of trivial errors, or
> constantly overriding the users wish to be warned?

Who is the user in your case? Is this module eventually to be released
on the CPAN? If so, I might be a user of it and here are two things that
I absolutely detest about modules. When they are...

1) ...emitting warnings.

2) ...making use of insignificant 5.6.x features. I consider the warnings
   pragma insignificant in module context.

So, yes, the warnings should go away by all means. But you should not do
this by sprinkling 'no warnings 'CATEGORY'' into the offending places if
your module otherwise worked fine under pre5.6.0 perls.

Not using warnings at all is no solution either because someone might be
using the -w switch in a program using your module and the warnings would
be back (unlike warnings, the -w switch is not scopeable).

Therefore try to change the code so that no warnings would ever be
produced. This is usually just a matter of a few cosmetic changes.

Disclaimer: Others might not agree with me here. There has been a
similar thread a couple of months ago. The relevant bits started with this
posting, I think:

    <slrnb4j3vt.qnk.abigail@alexandra.abigail.nl>

Consult groups.google.com to see it in context and some of the ideas
brought forth in this thread by several people.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Mon, 28 Apr 2003 00:16:35 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Style: Using 'no warnings' in a module
Message-Id: <b8hkq5$9s114$1@ID-184292.news.dfncis.de>

Tassilo v. Parseval wrote:
> There has been a similar thread a couple of months ago. The
> relevant bits started with this posting, I think:
> 
> <slrnb4j3vt.qnk.abigail@alexandra.abigail.nl>
> 
> Consult groups.google.com to see it in context and some of the
> ideas brought forth in this thread by several people.

It was two threads, actually (I was 'guilty' to them):

strict and warnings
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&th=2ba26e4c27043b34&seekm=wQ32a.10539%24LY2.628422%40newsc.telia.net#link1

Warnings in modules
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&th=4485748bb9ec0158&seekm=15B2a.70%24qB6.286%40newsc.telia.net&frame=off

I agree with Tassilo, those threads cover 'all possible views' on this
subject.

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: 27 Apr 2003 14:18:35 -0700
From: brian@box201.com (Agrapha)
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <11aabb15.0304271318.4c7a0fd3@posting.google.com>

"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in message news:<b8g39n$cjo$1@nets3.rz.RWTH-Aachen.DE>...
  

> Why do you need the date-calculation at all? From your above pattern it
> looks as though you want to open files that match the pattern
> 
>     /^proxyLogs\..*$/
> 

Tassilo thats brilliant. The glob will work exactly as I need. 

Thank you very much. 

At 3:00am this morning I couldn't think anymore. I got the rest of my
program working pretty good. Extremely fast compared to the shell
script. You will see a lot of your style in my program. I will do my
best to make it a permanent part of my perling as well.

Thanks again. 

I'll post a copy of the complete program for your critique later
today. The technique I used probably can be simplified, sort of an old
sift filter. However perl is so fast I thought I made a mistake the
first time it ran!!

I'll try the glob style first. Make sure I understand it. When I give
this tirage.pl  to my Tier 3 they will also ask who will maintain my
program. I need to comprehend it well enough to tell them I can do it.


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

Date: 27 Apr 2003 14:33:25 -0700
From: brian@box201.com (Agrapha)
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <11aabb15.0304271333.63f5dae6@posting.google.com>

brian@box201.com (Agrapha) wrote in message news:<11aabb15.0304241505.6636e807@posting.google.com>...
> "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in message news:<b89ai6$ud$1@nets3.rz.RWTH-Aachen.DE>...
> 
> 
> > 'perl -v'. As far as I know, FreeBSD 4.7 comes with 5.00303 (the version
> > prior to 5.6.0). Not sure when the FAQ in question was introduced.
> 

I found something that might be useful to other new people. Usually
when I install a new program on my FreeBSD machine I go to /usr/ports/
and look for the program I need. Then I type "make install clean" . My
problem is after doing that in the perl5.8 directory I would try the
"perl -v" and get "perl version 5.00503" every time.

then I typed make, then make install, and make clean. Thats when I saw
this:

To install as the default perl type "use.perl port". 

I typed "use.perl port" in on the command line, hit return, and that
command changed my system. Now I can read some of the perldocs and
perlfaqs that everyone was talking about. Like "perldoc -f duplicate"
 . It all works now.


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

Date: Sun, 27 Apr 2003 19:26:57 -0400
From: noipont@mailcity.com
Subject: WTB: Programming PERL DBI
Message-Id: <LEZqa.220$fg3.85817@news20.bellglobal.com>

Does anybody know where I can find this book? Possibly a used
one in. TIA.. George


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

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.  

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 V10 Issue 4902
***************************************


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