[30172] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1415 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 2 16:09:54 2008

Date: Wed, 2 Apr 2008 13:09:17 -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           Wed, 2 Apr 2008     Volume: 11 Number: 1415

Today's topics:
    Re: BEGIN, INIT etc... <pgodfrin@gmail.com>
    Re: Can I iterate through a file on a CGI  page? <rich@example.net>
        CPAN commandline tool is not working <sumonsmailbox@gmail.com>
        Create two-dimensional Array from string <pjfalbe@gmail.com>
    Re: Create two-dimensional Array from string <sandy_saydakov@yahoo.com>
    Re: Create two-dimensional Array from string <ben@morrow.me.uk>
        Download A File <no@spam2.tonsjunkmail.com>
    Re: Download A File <ben@morrow.me.uk>
    Re: Download A File <cartercc@gmail.com>
    Re: Download A File <abigail@abigail.be>
    Re: every combination of Y/N in 5 positions <noreply@gunnar.cc>
        FYI - How to add CPAN as a search plugin for Firefox <usenet@davidfilmer.com>
        How to monitor keyboard inactivity from script <mmccaws@comcast.net>
    Re: How to monitor keyboard inactivity from script jjcassidy@gmail.com
    Re: How to monitor keyboard inactivity from script <google@markginsburg.com>
    Re: How to monitor keyboard inactivity from script <mmccaws@comcast.net>
    Re: How to monitor keyboard inactivity from script <mmccaws@comcast.net>
    Re: How to monitor keyboard inactivity from script <ben@morrow.me.uk>
    Re: How to monitor keyboard inactivity from script <jurgenex@hotmail.com>
    Re: mismatch between Perl 5.6 and  Perl 5.8   in printi <szrRE@szromanMO.comVE>
    Re: mismatch between Perl 5.6 and  Perl 5.8   in printi <szrRE@szromanMO.comVE>
    Re: mismatch between Perl 5.6 and Perl 5.8 in printing  <nospam-abuse@ilyaz.org>
    Re: mismatch between Perl 5.6 and Perl 5.8 in printing  <szrRE@szromanMO.comVE>
    Re: mismatch between Perl 5.6 and Perl 5.8 in printing  <szrRE@szromanMO.comVE>
    Re: Parse x.500 DN  and change order  displayed <szrRE@szromanMO.comVE>
    Re: RE Perl Pattern matching <syscjm@sumire.gwu.edu>
    Re: tricky use of print? <szrRE@szromanMO.comVE>
    Re: tricky use of print? <ela@yantai.org>
    Re: tricky use of print? <usenet@davidfilmer.com>
    Re: What is best CMS - SilverStripe, Joomla or Drupal <syscjm@sumire.gwu.edu>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 2 Apr 2008 11:26:58 -0700 (PDT)
From: pgodfrin <pgodfrin@gmail.com>
Subject: Re: BEGIN, INIT etc...
Message-Id: <da058224-b055-49c2-a90a-2c6be6a3af53@u10g2000prn.googlegroups.com>

On Mar 30, 8:20 am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> On 2008-03-27 18:36, pgodfrin <pgodf...@gmail.com> wrote:
>
> > So how prevalent is Perl in the commercial world? Do people actually
> > have full-time jobs writing perl modules?
>
> Yes.
>
> > Do people use perl to write software like Microsoft Office
>
> I doubt it.
>
> > or Quest Software's Toad? Or perhaps BMC Patrol or CA Univision?
>
> These three are probably closer. (In fact I've been considering to write
> "something like Toad" in Perl - it could save me a lot of time, but
> unfortunately I first need to find the time to write it).
>
> I doubt you'll find much "shrink-wrapped" software written in perl -
> companies which sell shrink-wrapped software don't like to give away
> their source code (the customer might see how grotty it is :-)).
>
> > What is it mostly used for?
>
> Lots of "backoffice" stuff: Converting data, producing reports, printing
> bills. Anything which has to gather and mangle lots of data from files
> or databases.
> Tools: Everything you need "in-house" to make some job easier and which
> you can't buy off the shelf.
> Web-Applications: From small cgi scripts to really large applications.
> Analysis: From Server-Logs to the human genome.
>
>         hp

Hi Peter,
Makes sense - all I've ever use Perl for is the same sort of back-
office kind of work. Mostly instead of C or COBOL. In the mainframe
world I used to use SAS a lot, instead of - well - COBOL...

cheers,
pg


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

Date: Wed, 02 Apr 2008 19:53:00 GMT
From: Rich Grise <rich@example.net>
Subject: Re: Can I iterate through a file on a CGI  page?
Message-Id: <pan.2008.04.02.19.52.30.989027@example.net>

On Wed, 02 Apr 2008 04:07:42 +0000, xhoster wrote:
> Rich Grise <rich@example.net> wrote:
>> Apologies to Perl purists - comp.infosystems.www.authoring.cgi doesn't
>> work on my newsreader, and this is a CGI question:
>>
>> What I want to do is, I've got a large collection of image files:
>> $ wc gallery-pix
>>   37448   62619 3218967 gallery-pix
>>
>> and what I'd like to do is look at each of the 37488 image files on
>> some kind of page, with buttons like "Keep", "Skip", and "Quit",
>> so I can page through all of these images, which are strewn all
>> over the Samba server, and decide which ones might look good on
>> the website.
>>
>> So, is it possible to do something like (in pseudocode):
>>
>> for each $line in <file> {
> 
> In CGI, your program won't survive for the loop to iterate.  Unless
> you are making one page with all 37448 files on it.
> 
>>  show webpage with <img> tag, and the three buttons;
>>  get button response, decide what to do with file;
> 
> What would you do with the file in each case?
> 
>>  if button == "Quit", save place in source file;
>> next;
> 
> Make one directory with all the files (or with a symbolic links for each
> file).  Each time the program is invoked, take the first entry in the
> directory and display it.  Based on the response, either move it to the
> accept directory or the reject directory (or move it to accept vs delete
> it, whatever.)  Since the file is no longer there, place is inherently
> saved. Quit doesn't have to do anything, nor even have to exist--closing
> the browser without responding is a form of quiting.

Thanks - I really like this answer - I hadn't even consider loading up
a directory with symlinks. 

I'm going to try this next, as a way to avoid slurping the whole file.

So, anybody got a quick and dirty script that will make 38,000 symlinks?
;-) 

I'm not too worried about how long it will take - I'm  doing this in
my "spare" time, and the boss doesn't bother me much as long as I look
busy. :-)

Thanks!
Rich




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

Date: Wed, 2 Apr 2008 13:02:05 -0700 (PDT)
From: skywriter14 <sumonsmailbox@gmail.com>
Subject: CPAN commandline tool is not working
Message-Id: <68bd8d9a-7554-44ed-a756-d1ff72329099@m71g2000hse.googlegroups.com>

Dear Group,

I am using Perl in my Ubuntu machine where CPAN commandline tool is
acting very strange. Looks like, it is getting false response form all
or any CPAN mirror. I reconfigured cpan 'urllist' few times with
different sets of 7/8 urls. But it always stalls and keeps getting 404
and 500 status from all the mirrors.

My net connection is OK, I downloaded the same files with wget
manually, for which cpan gets 404 (01mailrc etc). I cannot do 'install
Bundle::CPAN' successfully for the same reason, keep getting 404 and
500 status from all mirrors. I have been downloading source for
different modules that in need for my current project, one by one all
day and building them manually, as cpan command is not helping.
Following dependencies and doing same thigs over and over for each
module is very frustrating. So it was a very stressful day for me.

Can anyone suggest what might be the reason and how can I fix my CPAN
commandline tool? Thanks in advance.

regards,
Sumon


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

Date: Wed, 2 Apr 2008 10:21:23 -0700 (PDT)
From: "pjfalbe@gmail.com" <pjfalbe@gmail.com>
Subject: Create two-dimensional Array from string
Message-Id: <084df03f-a367-4aba-ba8b-4841e6315499@8g2000hsu.googlegroups.com>


I'm looking for the most efficient way to create a two dimensional
array from strings such as

MULTISET{ROW(1     ,'  3667 ','WARREN    ','OH'),ROW(2     ,'  2948
','SHAKER HTS','OH')}

In this case MULTISET is a collection of rows from a DB.  What I want
todo is efficiently
transform into a 2-dimensional array,  where each row is an array.
And then collect those arrays
into 1 array of arrays.  I'm currently doing this but not very
efficiently.  Any help would be appreciated.


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

Date: Wed, 2 Apr 2008 10:58:38 -0700 (PDT)
From: Sandy <sandy_saydakov@yahoo.com>
Subject: Re: Create two-dimensional Array from string
Message-Id: <82e6dd27-86d7-460d-9bd5-2bfecdd452f2@s19g2000prg.googlegroups.com>

On Apr 2, 10:21 am, "pjfa...@gmail.com" <pjfa...@gmail.com> wrote:
> I'm looking for the most efficient way to create a two dimensional
> array from strings such as
>
> MULTISET{ROW(1     ,'  3667 ','WARREN    ','OH'),ROW(2     ,'  2948
> ','SHAKER HTS','OH')}
>
> In this case MULTISET is a collection of rows from a DB.  What I want
> todo is efficiently
> transform into a 2-dimensional array,  where each row is an array.
> And then collect those arrays
> into 1 array of arrays.  I'm currently doing this but not very
> efficiently.  Any help would be appreciated.

Why don't you clarify what do you mean by 'efficiently'. Are you
optimizing the speed of adding records or finding a record in the
collection (based on which fields?) or what? How are you doing this
currently and what appears to be a problem?

It is hard to suggest any particular approach without such details. In
general it is simple:

my $record1 = [1, 3667, 'WARREN', 'OH'];
my $record2 = [2, 2948, 'SHAKER HTS', 'OH'];

my @records = ();

push @records, $record1;
push @records, $record2;

/sandy
http://myperlquiz.com/


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

Date: Wed, 2 Apr 2008 19:05:19 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Create two-dimensional Array from string
Message-Id: <vfucc5-9vm.ln1@osiris.mauzo.dyndns.org>


Quoth "pjfalbe@gmail.com" <pjfalbe@gmail.com>:
> 
> I'm looking for the most efficient way to create a two dimensional
> array from strings such as
> 
> MULTISET{ROW(1     ,'  3667 ','WARREN    ','OH'),ROW(2     ,'  2948
> ','SHAKER HTS','OH')}
> 
> In this case MULTISET is a collection of rows from a DB.  What I want
> todo is efficiently
> transform into a 2-dimensional array,  where each row is an array.
> And then collect those arrays
> into 1 array of arrays.  I'm currently doing this but not very
> efficiently.  Any help would be appreciated.

You haven;t given your code, and you haven't specified the format
accurately. For instance, can those single-quoted strings contain
commas?

I would start with something like

    my @multiset;
    my $multiset = q{MULTISET{ROW(...)}};

    $multiset =~ /MULTISET \{ ROW \( (.*) \) \}/x
        or die "bad string: $multiset";

    for my $row (split / \) , ROW \( /x, $1) {
        push @multiset, [split /,/, $row];
    }

possibly using something like Text::CSV_XS if the comma-separated
section is more complicated than that.

Ben



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

Date: Wed, 2 Apr 2008 11:01:02 -0500
From: "M" <no@spam2.tonsjunkmail.com>
Subject: Download A File
Message-Id: <4fGdnYBx67IlMG7anZ2dnUVZ_viunZ2d@haugcommunications>

I have a script in /cgi-bin/.  I want it when called to download a dynamic 
file, actually an image to a file on the server.  Basically pull a graph 
from whats actually a router of mine, save it to /temp_images.

I have tried using: "system "/usr/bin/wget..." with no luck.

Can someone give me a shove in the right direction?  I cannot seem to find 
where the perl "get" command supports simply saving to a directory but I may 
have missed something and many times do.

Thanks.

Matt




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

Date: Wed, 2 Apr 2008 17:13:09 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Download A File
Message-Id: <ltncc5-e0e.ln1@osiris.mauzo.dyndns.org>


Quoth "M" <no@spam2.tonsjunkmail.com>:
> I have a script in /cgi-bin/.  I want it when called to download a dynamic 
> file, actually an image to a file on the server.  Basically pull a graph 
> from whats actually a router of mine, save it to /temp_images.
> 
> I have tried using: "system "/usr/bin/wget..." with no luck.

An actual error message is more use than 'no luck'. Does your wget live
in /usr/bin (mine doesn't)?

> Can someone give me a shove in the right direction?  I cannot seem to find 
> where the perl "get" command supports simply saving to a directory but I may 
> have missed something and many times do.

See LWP::Simple::getstore.

Ben



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

Date: Wed, 2 Apr 2008 09:33:55 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Download A File
Message-Id: <75515378-8745-4665-b60a-5ab620630e9e@e67g2000hsa.googlegroups.com>

On Apr 2, 12:01 pm, "M" <n...@spam2.tonsjunkmail.com> wrote:
> I have a script in /cgi-bin/.  I want it when called to download a dynamic
> file, actually an image to a file on the server.  Basically pull a graph
> from whats actually a router of mine, save it to /temp_images.
>
> I have tried using: "system "/usr/bin/wget..." with no luck.
>
> Can someone give me a shove in the right direction?  I cannot seem to find
> where the perl "get" command supports simply saving to a directory but I may
> have missed something and many times do.
>
> Thanks.
>
> Matt

We have successfully used pscp for going on several years to upload
and download all kinds of files, large and small.

www.chiark.greenend.org.uk/~sgtatham/putty/download.html

CC


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

Date: 02 Apr 2008 16:57:34 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Download A File
Message-Id: <slrnfv7ent.nld.abigail@alexandra.abigail.be>

                                       _
M (no@spam2.tonsjunkmail.com) wrote on VCCCXXVIII September MCMXCIII in
<URL:news:4fGdnYBx67IlMG7anZ2dnUVZ_viunZ2d@haugcommunications>:
\\  I have a script in /cgi-bin/.  I want it when called to download a dynamic 
\\  file, actually an image to a file on the server.  Basically pull a graph 
\\  from whats actually a router of mine, save it to /temp_images.
\\  
\\  I have tried using: "system "/usr/bin/wget..." with no luck.

Perhaps /usr/bin/wget... doesn't exist? I dunno, just guessing as you
don't give any clue what so ever what goes wrong. Perhaps you are working
on a Windows machine?



Abigail
-- 
perl -e 'for (s??4a75737420616e6f74686572205065726c204861636b65720as?;??;??) 
             {s?(..)s\??qq \?print chr 0x$1 and q ss\??excess}'


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

Date: Wed, 02 Apr 2008 22:06:37 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: every combination of Y/N in 5 positions
Message-Id: <65i7ejF2f3g2iU1@mid.individual.net>

Abigail wrote:
> David Harmon (source@netcom.com) wrote on VCCCXXVIII September MCMXCIII
> in <URL:news:fb6dnc-9EJLmcm_anZ2dnUVZ_rSrnZ2d@earthlink.com>:
> []  On Mon, 31 Mar 2008 23:23:25 +0200 in comp.lang.perl.misc, Gunnar
> []  Hjalmarsson <noreply@gunnar.cc> wrote,
> [] >I do, I hope. :)
> [] >
> [] >     foreach my $num ( 0 .. 0b11111 ) {
> [] >         local *_ = \ sprintf '%05b', $num;
> []  
> []  What is *_ ?  It looks like one of those magic perl variables,  but
> []  I don't find any documentation on it.
> 
> It's a silly attempt to obfuscate the code.

I didn't do it for the sake of it; please see the sub-thread starting 
with 
http://groups.google.com/group/comp.lang.perl.misc/browse_frm/thread/1c6904d6a4774258/e56a5cb3831212df 
and the advice provided there by Ben and Brian.

See also Ben's reply in this thread. 
http://groups.google.com/group/comp.lang.perl.misc/msg/3c4e0ee726c4cded

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


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

Date: Wed, 02 Apr 2008 10:42:37 -0700
From: David Filmer <usenet@davidfilmer.com>
Subject: FYI - How to add CPAN as a search plugin for Firefox
Message-Id: <ys6dnXyLoLbAWG7a4p2dnAA@giganews.com>


FWIW, Firefox comes with a several search plugins (Google, Yahoo, etc). 
These plugins are just XML files, and you can write your own.  I wrote 
one to make it just a little bit easier to search CPAN - I figured I'd 
put it out here for anyone that's interested.

Name the file CPAN.xml and put it in your Firefox searchplugins 
directory.  On my OpenSUSE Linux box that is
    /usr/lib/firefox/searchplugins
On Windows it should be something like
    C:\Program Files\Mozilla Firefox\searchplugins
I dunno about Mac, though there should be a searchplugins directory 
wherever Firefox itself is installed.

The encoded stuff is the little camel favicon.  It should be all on one 
line.

Here is the CPAN search plugin:

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>CPAN</ShortName>
<Description>Comprehensive Perl Archive Network</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" 
height="16">data:image/x-icon,%00%00%01%00%01%00%10%10%00%00%00%00%00%00(%01%00%00%16%00%00%00(%00%00%00%10%00%00%00%20%00%00%00%01%00%04%00%00%00%00%00%C0%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%FF%FF%FF%00%7B%00%00%00%00%7B%00%00%7B%7B%00%00%00%00%7B%00%7B%00%7B%00%00%7B%7B%00%BD%BD%BD%00%7B%7B%7B%00%FF%00%00%00%00%FF%00%00%FF%FF%00%00%00%00%FF%00%FF%00%FF%00%00%FF%FF%00%00%00%00%00%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%F0%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF%FF3l%FC%BF%EF%18%E6%D7%EB%F0%F6%DB%00%00%FA%E9%00%02%F8%C3al%FC%03te%F8%02Co%F0%02r%20%E0%01%5C%D0%E0%03%11%00%E6%0F%BF%E6'%1F%00%02%07%FF%00%06%87%FF2%80%E3%FF1%E0</Image>
<Url type="text/html"
	method="GET"
template="http://search.cpan.org/search?mode=all&amp;query={searchTerms}"/>
<moz:SearchForm>searchFormURL</moz:SearchForm>
</OpenSearchDescription>



Cheers!


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

Date: Wed, 2 Apr 2008 09:11:02 -0700 (PDT)
From: mmccaws2 <mmccaws@comcast.net>
Subject: How to monitor keyboard inactivity from script
Message-Id: <d9902424-8fdf-47a9-a18e-7276c3c49914@n58g2000hsf.googlegroups.com>

I have a user interface script that makes changes in a db or makes db
queries.  I don't want the user to just leave the script running all
the time.  what is the best way to monitor if the script has had no
actiivty for 20 minutes?

Thanks

Mike


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

Date: Wed, 2 Apr 2008 09:22:48 -0700 (PDT)
From: jjcassidy@gmail.com
Subject: Re: How to monitor keyboard inactivity from script
Message-Id: <e7889bcf-b601-41f5-8982-cc95e989783b@c65g2000hsa.googlegroups.com>

On Apr 2, 12:11=A0pm, mmccaws2 <mmcc...@comcast.net> wrote:
> I have a user interface script that makes changes in a db or makes db
> queries. =A0I don't want the user to just leave the script running all
> the time. =A0what is the best way to monitor if the script has had no
> actiivty for 20 minutes?
>
> Thanks
>
> Mike

You'd need to use *some kind* of persistence. Cheapest NIX-ish way is
to have a dummy file that you "touch" when you exit the program--or
whenever a significant event occurs, if you occasionally "sleep". If
you "stat" the file, you know how long it's been since it's been
"touch-ed".

Other than that, it's your choice of persistence: write and read time
to and from a file; use Storable or YAML to dump a hash with all the
values you care about; use a database....


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

Date: Wed, 2 Apr 2008 11:59:10 -0700 (PDT)
From: Mark <google@markginsburg.com>
Subject: Re: How to monitor keyboard inactivity from script
Message-Id: <674d0117-e561-4e8c-9517-5ad6dd716aa1@c19g2000prf.googlegroups.com>

On Apr 2, 9:11=A0am, mmccaws2 <mmcc...@comcast.net> wrote:
> I have a user interface script that makes changes in a db or makes db
> queries. =A0I don't want the user to just leave the script running all
> the time. =A0what is the best way to monitor if the script has had no
> actiivty for 20 minutes?
>
> Thanks
>
> Mike

Perhaps this sample code (works on my Linux box but doesn't work on my
Windows XP box) may help:

use strict ;
use warnings ;

$| =3D 1 ;
my $timeout =3D 20 * 60 ; # twenty minutes

my $rin =3D '' ;
vec($rin,fileno(STDIN),1) =3D 1;
my $ein =3D $rin ;

while () {
    print "waiting for input\n" ;
    my $nfound =3D select(my $rout=3D$rin, undef, my $eout=3D$ein,$timeout);=

    if (vec($eout,fileno(STDIN),1)) {
        die "error detected on STDIN" ;
    }
    elsif (vec($rout,fileno(STDIN),1)) {
        my $ans =3D <STDIN> ;
        print "got: $ans\n" ;
    }
    else {
        print "timed out\n" ;
    }
}


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

Date: Wed, 2 Apr 2008 12:07:44 -0700 (PDT)
From: mmccaws2 <mmccaws@comcast.net>
Subject: Re: How to monitor keyboard inactivity from script
Message-Id: <bf6a2008-2ac0-405f-b044-098c47e6837c@f63g2000hsf.googlegroups.com>

On Apr 2, 9:22 am, jjcass...@gmail.com wrote:
> On Apr 2, 12:11 pm, mmccaws2 <mmcc...@comcast.net> wrote:
>
> > I have a user interface script that makes changes in a db or makes db
> > queries.  I don't want the user to just leave the script running all
> > the time.  what is the best way to monitor if the script has had no
> > actiivty for 20 minutes?
>
> > Thanks
>
> > Mike
>
> You'd need to use *some kind* of persistence. Cheapest NIX-ish way is
> to have a dummy file that you "touch" when you exit the program--or
> whenever a significant event occurs, if you occasionally "sleep". If
> you "stat" the file, you know how long it's been since it's been
> "touch-ed".
>
> Other than that, it's your choice of persistence: write and read time
> to and from a file; use Storable or YAML to dump a hash with all the
> values you care about; use a database....

so everytime enter is hit log it and have the same script check that
or a different script monitor it?  I'm not familiar with storable or
yaml, what keyword search would I use to help narrow down the choices?

Thanks

Mike


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

Date: Wed, 2 Apr 2008 12:12:19 -0700 (PDT)
From: mmccaws2 <mmccaws@comcast.net>
Subject: Re: How to monitor keyboard inactivity from script
Message-Id: <9bd0c27d-a9f1-42f3-89c8-4c4799603cfe@f63g2000hsf.googlegroups.com>

On Apr 2, 12:07 pm, mmccaws2 <mmcc...@comcast.net> wrote:
> On Apr 2, 9:22 am, jjcass...@gmail.com wrote:
>
>
>
> > On Apr 2, 12:11 pm, mmccaws2 <mmcc...@comcast.net> wrote:
>
> > > I have a user interface script that makes changes in a db or makes db
> > > queries.  I don't want the user to just leave the script running all
> > > the time.  what is the best way to monitor if the script has had no
> > > actiivty for 20 minutes?
>
> > > Thanks
>
> > > Mike
>
> > You'd need to use *some kind* of persistence. Cheapest NIX-ish way is
> > to have a dummy file that you "touch" when you exit the program--or
> > whenever a significant event occurs, if you occasionally "sleep". If
> > you "stat" the file, you know how long it's been since it's been
> > "touch-ed".
>
> > Other than that, it's your choice of persistence: write and read time
> > to and from a file; use Storable or YAML to dump a hash with all the
> > values you care about; use a database....
>
> so everytime enter is hit log it and have the same script check that
> or a different script monitor it?  I'm not familiar with storable or
> yaml, what keyword search would I use to help narrow down the choices?
>
> Thanks
>
> Mike

Mark

our posts crossed, I'll try that

Mike


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

Date: Wed, 2 Apr 2008 20:13:50 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: How to monitor keyboard inactivity from script
Message-Id: <eg2dc5-cb41.ln1@osiris.mauzo.dyndns.org>


Quoth mmccaws2 <mmccaws@comcast.net>:
> I have a user interface script that makes changes in a db or makes db
> queries.  I don't want the user to just leave the script running all
> the time.  what is the best way to monitor if the script has had no
> actiivty for 20 minutes?

perldoc -f alarm

Set an alarm for 20 minutes every time you do something. Then if the
user doesn't do anything for 20 minutes, your process gets SIGALARM: if
you just let the system handle it, your process dies; if you catch it
yourself you can do something more graceful.

Ben


> 
> Thanks
> 
> Mike




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

Date: Wed, 02 Apr 2008 19:24:13 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: How to monitor keyboard inactivity from script
Message-Id: <b2n7v39kuffm9pvnafbbcsnm9cal0rei1p@4ax.com>

mmccaws2 <mmccaws@comcast.net> wrote:
>I have a user interface script that makes changes in a db or makes db
>queries.  I don't want the user to just leave the script running all
>the time.  what is the best way to monitor if the script has had no
>actiivty for 20 minutes?

I can think of basically 2 different approaches:
A: the script monitors its own time ==> do not have the script wait for
user input, but check in regular intervals if input is available. If no
input, then go to sleep() again for another x seconds unless the total
wait time already exceeds those 20 minutes.
B: use a second process as the watchdog ==> whenever the script
processes some user input it will also signal the watchdog process which
will reset its internal timer. If the timer hasn't been reset for 20
minutes (perldoc -q timeout) then kill() the master script.

jue


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

Date: Wed, 2 Apr 2008 08:53:25 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: mismatch between Perl 5.6 and  Perl 5.8   in printing high precision  values.
Message-Id: <ft0a5l01ck7@news4.newsguy.com>

RedGrittyBrick wrote:
> vivekanand.naik@gmail.com wrote:
>> printf("%.32g\n",0.99999999976716936);
>>
>> Perl 5.6.1 output:
>> 0.99999999976716936  --> GOOD
>>
>> Perl 5.8.6 output:
>> 0.99999999976716925  --> ERROR
>>
>>
>> Any reason for such mismatch ?
>> Please let me know how to avoid that or any alternative approach if
>> any.
>>
>
> print Math::BigFloat->new("0.99999999976716936")->bstr();


The version of Math::BigFloat that shipped with 5.6.1, which the op 
seems to need, doesn't seem to support ->bstr()

$ perlall -MMath::BigFloat -e 'print 
Math::BigFloat->new("0.99999999976716936")->bstr(), "\n";'
<perl5.10.0> 0.99999999976716936
<perl5.8.8 > 0.99999999976716936
<perl5.8.2 > 0.99999999976716936
<perl5.8.0 > 0.99999999976716936
Can't locate object method "bstr" via package "Math::BigFloat" (perhaps 
you forgot to load "Math::BigFloat"?) at -e line 1.
<perl5.6.1 >


Perhaps ->ffround(17) could be used instead?

$ perl5.6.1 -MMath::BigFloat -e 'print 
Math::BigFloat->new("0.99999999976716936")->ffround(-17), "\n";'
+99999999976716936E-17

You could always update your Math::* modules if you must use 5.6.1, 
else, it would better to just install a newer Perl :-)

-- 
szr 




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

Date: Wed, 2 Apr 2008 08:41:53 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: mismatch between Perl 5.6 and  Perl 5.8   in printing high precision values.
Message-Id: <ft09ho01brd@news4.newsguy.com>

vivekanand.naik@gmail.com wrote:
> printf("%.32g\n",0.99999999976716936);
>
> Perl 5.6.1 output:
> 0.99999999976716936  --> GOOD
>
> Perl 5.8.6 output:
> 0.99999999976716925  --> ERROR

I get:

$ perlall -e 'printf("%.32g\n",0.99999999976716936);'
<perl5.10.0> 0.99999999976716935997820764892019
<perl5.8.8 > 0.99999999976716935997820764892019
<perl5.8.2 > 0.9999999997671692453238279085781
<perl5.8.0 > 0.9999999997671692453238279085781
<perl5.6.1 > 0.99999999976716935634613037109375

-- 
szr 




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

Date: Wed, 2 Apr 2008 19:58:34 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: mismatch between Perl 5.6 and Perl 5.8 in printing high precision  values.
Message-Id: <ft0oha$si4$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
sisyphus 
<sisyphus359@gmail.com>], who wrote in article <28eff3d6-c1b4-4679-9838-38c295b4da66@i7g2000prf.googlegroups.com>:
> Since 0.99999999976716936 =3D=3D 9.9999999976716936e-1

Why this would be so?  At best, one is 0.99999999976716936, another is
9.9999999976716936/10.  I know no axiom of FP arithmetic which would
make them equal...

(In principle, one could impose a condition on atof() that all strings
are first normalized IN DECIMAL to the e00 exponent, THEN translated
to binary.  But given that, AFAIK, atof() is not documented to satisfy
ANY requirement, however reasonable, this is a pipe dream.)

[I have, on a backburner, some plans to make Perl use "the best"
 string-to-FP-to-string conversions (so that a lot of verbiage can be
 removed from perlnumber.pod).  But my improve-perl plans do not get a
 lot of timeslices recently.]

Yours,
Ilya


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

Date: Wed, 2 Apr 2008 09:02:34 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: mismatch between Perl 5.6 and Perl 5.8 in printing high precision values.
Message-Id: <ft0amq01d2f@news4.newsguy.com>

sisyphus wrote:
> On Apr 2, 9:21 pm, vivekanand.n...@gmail.com wrote:
>> printf("%.32g\n",0.99999999976716936);
>>
>> Perl 5.6.1 output:
>> 0.99999999976716936 --> GOOD
>>
>> Perl 5.8.6 output:
>> 0.99999999976716925 --> ERROR
>>
>> Any reason for such mismatch ?
>
> I believe it's a bug in perl 5.8 (which has been carried through to
> perl 5.10):
>
> C:\_32\pscrpt>perl -e "printf(\"%.32g\n\",0.99999999976716936);"
> 0.99999999976716925
>
> C:\_32\pscrpt>perl -e "printf(\"%.32g\n\",9.9999999976716936e-1);"
> 0.99999999976716936
>
> Since 0.99999999976716936 == 9.9999999976716936e-1, I can think of no
> good reason that that those 2 one-liners should produce different
> output - and I believe the first one liner produces an incorrect
> result.
>
> I'll submit a bug report about this - unless someone can convince me
> that it's *not* a bug (or unless someone else wants to submit the
> report).
>
> Cheers,
> Rob

Interesting, I get these values:

$ perlall -e 'printf("%.32g\n",99999999976716936e-1);'
<perl5.10.0> 9999999997671693.599609375
<perl5.8.8 > 9999999997671693.599609375
<perl5.8.2 > 9999999997671692
<perl5.8.0 > 9999999997671692
<perl5.6.1 > 9999999997671694

-- 
szr 




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

Date: Wed, 2 Apr 2008 09:05:59 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: mismatch between Perl 5.6 and Perl 5.8 in printing high precision values.
Message-Id: <ft0ata01d73@news4.newsguy.com>

sisyphus wrote:
> On Apr 2, 9:21 pm, vivekanand.n...@gmail.com wrote:
>> printf("%.32g\n",0.99999999976716936);
>>
>> Perl 5.6.1 output:
>> 0.99999999976716936 --> GOOD
>>
>> Perl 5.8.6 output:
>> 0.99999999976716925 --> ERROR
>>
>> Any reason for such mismatch ?
>
> I believe it's a bug in perl 5.8 (which has been carried through to
> perl 5.10):
>
> C:\_32\pscrpt>perl -e "printf(\"%.32g\n\",0.99999999976716936);"
> 0.99999999976716925
>
> C:\_32\pscrpt>perl -e "printf(\"%.32g\n\",9.9999999976716936e-1);"
> 0.99999999976716936
>
> Since 0.99999999976716936 == 9.9999999976716936e-1, I can think of no
> good reason that that those 2 one-liners should produce different
> output - and I believe the first one liner produces an incorrect
> result.
>
> I'll submit a bug report about this - unless someone can convince me
> that it's *not* a bug (or unless someone else wants to submit the
> report).
>
> Cheers,
> Rob

Please disregard my previous reply, I made a dump typo.

This is what I get:

$ perlall -e 'printf("%.32g\n",9.9999999976716936e-1);'
<perl5.10.0> 0.99999999976716935997820764892019
<perl5.8.8 > 0.99999999976716935997820764892019
<perl5.8.2 > 0.99999999976716935634613037109375
<perl5.8.0 > 0.99999999976716935634613037109375
<perl5.6.1 > 0.99999999976716935634613037109375

-- 
szr 




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

Date: Wed, 2 Apr 2008 09:23:53 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: Parse x.500 DN  and change order  displayed
Message-Id: <ft0bup01eb3@news4.newsguy.com>

Hallvard B Furuseth wrote:
> szr writes:
>> Hallvard B Furuseth wrote:
>>> SecureIT writes:
>>>> I am trying to change this
>>>> "cn=Bob Smith+serialNumber=CR013120080827,o=ICM,c=US"
>>>> to this:
>>>> "serialNumber=CR013120080827+cn=Bob Smith,o=ICM,c=US"
>>>
>>> Without escape sequences like "\," and "\+" in the DNs (if that's
>>> allowed anyway, I don't remember the details of X.500 Dn syntax),
>>> this moves serialNumber first in each RDN:
>>>
>>> s/(^|,)([^,]*)\+(serialNumber=[^+,]*)(?=[+,])/$1$3+$2/gi;
>>> die "didn't catch all 'foo+serialNumber's" if /\+serialNumber=/i;
>>
>> Using this regex will take care of \, and \+ escapes:
>>
>> s/(^|(?<!\\),)((?:[^,]|\\,)*)\+(serialNumber=(?:[^+,]|\\[+,])*)(?=(?<!\\)[+,])/$1$3+$2/gi;
>
> Nope...  not if I can create naughty "cn" values:
>
> this:      cn=a\\,cn=b+serialNumber=c,o=x
> becomes    serialNumber=c+cn=a\\,cn=b,o=x
> instead of cn=a\\,serialNumber=c+cn=b,o=x
>
> this:      cn=b\+serialNumber=c,o=x
> contains no serialNumber attribute but is modified anyway.
>
> Not that it matters much when the OP's problem is solved anyway.
> Just pointing out that once you are going to accept things that need
> nontrivial parsing like escape sequences, you have to be careful to
> parse it correctly.  Though my variant missed out too, it should
> have ended with (?=$|[+,]) to cover the last component as well.

Well, my example assumed proper checks would already by done by the time 
it was invoked. But good points nonetheless.

-- 
szr 




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

Date: Wed, 02 Apr 2008 10:53:34 -0500
From: Chris Mattern <syscjm@sumire.gwu.edu>
Subject: Re: RE Perl Pattern matching
Message-Id: <slrnfv7avu.q3r.syscjm@sumire.gwu.edu>

On 2008-04-02, Deepan Perl XML Parser <deepan.17@gmail.com> wrote:
> Hi,
<much XML snipped>
>
>
> But not getting anything. Can anyone find out the fault in it?

You're trying to parse XML with regular expressions.  Don't do that.
Perl has a large selection of excellent modules for processing XML.
Use them.


-- 
             Christopher Mattern

NOTICE
Thank you for noticing this new notice
Your noticing it has been noted
And will be reported to the authorities


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

Date: Wed, 2 Apr 2008 09:11:04 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: tricky use of print?
Message-Id: <ft0b6o01dg6@news4.newsguy.com>

David Filmer wrote:
> Ela wrote:
>> $newline = '\n'
>
> In Perl, single-quotes are not interpolated (meaning $newline is set
> to backslash-n).  You would need to use double-quotes (or qq{}) to
> interpolate \n as a newline.

Or a heredoc :-)

print <<_EOF_;
$foo $bar
_EOF_

-- 
szr 




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

Date: Thu, 3 Apr 2008 00:20:56 +0800
From: "Ela" <ela@yantai.org>
Subject: Re: tricky use of print?
Message-Id: <ft0bpb$ok2$1@ijustice.itsc.cuhk.edu.hk>

> Or a heredoc :-)
>
> print <<_EOF_;
> $foo $bar
> _EOF_
>
> -- 
> szr
>

There are too few words in your example and I'm unable to follow/Google. I 
guess maybe you are telling something important? thx 




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

Date: Wed, 02 Apr 2008 10:28:54 -0700
From: David Filmer <usenet@davidfilmer.com>
Subject: Re: tricky use of print?
Message-Id: <ys6dnX2LoLa7X27a4p2dnAA@giganews.com>

Ela wrote:
>> Or a heredoc :-)
>>
>> print <<_EOF_;
>> $foo $bar
>> _EOF_
>>
> 
> There are too few words in your example and I'm unable to follow/Google. I 
> guess maybe you are telling something important? thx 

szr is just showing you an example of how to use a heredoc, which 
recognizes the \n at the end of any lines within it (so it's just 
another way of printing newlines).

You could do the same thing like this:

print "$foo $bar
";

but that's questionable programming style (whereas a heredoc is 
generally accepted, though I personally dislike them).


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

Date: Wed, 02 Apr 2008 10:46:10 -0500
From: Chris Mattern <syscjm@sumire.gwu.edu>
Subject: Re: What is best CMS - SilverStripe, Joomla or Drupal
Message-Id: <slrnfv7ai2.q3r.syscjm@sumire.gwu.edu>

On 2008-04-01, Mayuri.4469@gmail.com <Mayuri.4469@gmail.com> wrote:
> Hi,
>
> I am a student of ICT and doing my final project of website
> development.
>
> I wants to do coding in PHP & MySql. I am confused about the Content
> Management System.
>
> Which CMS is good for using & reliable SilverStripe, Joomla or Drupal?
>
> Cheers
> Mayuri

What was your Perl question again?  I seemed to have missed it.


-- 
             Christopher Mattern

NOTICE
Thank you for noticing this new notice
Your noticing it has been noted
And will be reported to the authorities


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

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 1415
***************************************


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