[22670] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4891 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 25 03:07:36 2003

Date: Fri, 25 Apr 2003 00:05:08 -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           Fri, 25 Apr 2003     Volume: 10 Number: 4891

Today's topics:
    Re: c.l.p.moderated eyrie.org list problem? (Don Hammond)
        call perl from javascript ?  or use php instead ? <ericosman@rcn.com>
    Re: call perl from javascript ?  or use php instead ? <matthew@weierophinney.net>
    Re: call perl from javascript ?  or use php instead ? (Jay Tilton)
        Dumping hash after sort <TruthXayer@yahoo.com>
    Re: Dumping hash after sort <tassilo.parseval@rwth-aachen.de>
        FA: The Complete PERL Training Course <briansz@sitemouse.com>
    Re: file upload not working anymore <peakpeek@purethought.com>
    Re: Getting FULL path+filename from a filehandle <uri@stemsystems.com>
    Re: Help with creating UDP sockets using IO::Socket <kalinabears@hdc.com.au>
    Re: Help with creating UDP sockets using IO::Socket <uri@stemsystems.com>
    Re: How can I hide a specific Window (Thomas B)
    Re: How can I hide a specific Window (Thomas B)
    Re: How to include data stamps in a script?? (Joe Smith)
    Re: looking for graphing program <mgjv@tradingpost.com.au>
    Re: Net::FTP delete problem <markvalls.spambox@dnainternet.net>
        non-blocking read with IO::Select <japh_klch@programmer.net>
    Re: non-blocking read with IO::Select <tassilo.parseval@rwth-aachen.de>
    Re: Problem updating data in DB2 from webserver? <dmcbride@naboo.to.org.no.spam.for.me>
    Re: Regex greediness question <REMOVEsdnCAPS@comcast.net>
    Re: Regex greediness question (Anno Siegel)
    Re: The Complete PERL Training Course <jkeen@concentric.net>
    Re: Tough question for the guru's; Grep Once, Awk Twice <uri@stemsystems.com>
    Re: {newbie} sorting  of files <uri@stemsystems.com>
    Re: {newbie} sorting  of files <REMOVEsdnCAPS@comcast.net>
    Re: {newbie} sorting  of files <tassilo.parseval@rwth-aachen.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 24 Apr 2003 22:46:27 -0500
From: throwaway-gX7yGGyqa5bC@tradersdata.com (Don Hammond)
Subject: Re: c.l.p.moderated eyrie.org list problem?
Message-Id: <3ea8a183@btitelecom.net>

Uri Guttman <uri@stemsystems.com> writes:
>>>>>> "DH" == Don Hammond <throwaway-gX7yGGyqa5bC@tradersdata.com> writes:
> 
>   DH> Thanks very much Uri.  Thanks also for the courtesy copy.  I couldn't
>   DH> find anything, probably because I can't get to c.l.p.moderated or
>   DH> eyrie.org.  I'm glad it's not my fault and appreciate you letting me
>   DH> know.
> 
> not that i would recommend it but google carries it. so at least you
> could read it there if you don't want to use their posting interface.
> 
> how anyone can use the web for mail and news is beyond me.  i need my
> all my emacs powers so i can edit stuff properly.  :)
 
Staying caught up isn't that important.  I really was more concerned
that I was causing the problem.  I'm used to messing things up for
myself, but cringe at the thought of causing a debacle for others.

I'm with you on web interfaces for mail and news, except I use client
software and vi.  But let's not go there. ;-)

Thanks again for the help.

-- 
Email address in From: header is valid  * but only for a couple of days *



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

Date: Thu, 24 Apr 2003 21:08:44 -0400
From: Eric Osman <ericosman@rcn.com>
Subject: call perl from javascript ?  or use php instead ?
Message-Id: <3EA88A9C.30601@rcn.com>



(note:  If you're a knowledgeable but lazy reader, please skip to
the last two paragraphs, as maybe you can help me.)

Hi,

I have some javascript code that wants some information from the
server.

So it seems like I want to call some perl code on the server to
obtain the information.

But maybe this isn't easy to do ?  Is it perhaps easier in php ?

Here are some more specifics of my need.

The javascript code flashes some pictures on the web page,
changing the picture every few seconds.

Right now the names of the picture files are "hard-coded" right
into my javascript.

Instead of hard-coding them in, I'd like to call some perl code
on the server to ~ask~ what the file names are.

Here's some actual existing javascript:

var holidayPics = new Array(
     "images_new/tea_party/tp518.jpg",
     "images_new/tea_party/tp520.jpg",
     "images_new/crescent_moon/cm020.jpg"
     );
var holidayIndex = -1;
function holidayFlipper(millis){
   var nPics = holidayPics.length;
   if (nPics <= ++holidayIndex)
       holidayIndex = 0;
    document.holiday.src=holidayPics[holidayIndex];
    setTimeout("holidayFlipper(2000)",millis);
  }


See that holidayPics array ?  Instead of hardcoding that in, I'd like to
call a perl function on the server to obtain the list of files.

The basic conceptual problem I'm having is that all the perl I've used
so far is triggered by a form action.  And that perl in turn uses print
to generate an entirely new web page.

So I don't know how to call perl on an as-needed basis from javascript
to obtain information.  Perhaps this just isn't possible and that php
is designed for this purpose ?

Thanks.  /Eric



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

Date: Fri, 25 Apr 2003 01:42:01 GMT
From: Matthew Weier O'Phinney <matthew@weierophinney.net>
Subject: Re: call perl from javascript ?  or use php instead ?
Message-Id: <slrnbah4ja.1a8.matthew@kavalier.weierophinney.net>

* Eric Osman <ericosman@rcn.com>:
<snip>
> The javascript code flashes some pictures on the web page,
> changing the picture every few seconds.
> 
> Right now the names of the picture files are "hard-coded" right
> into my javascript.
> 
> Instead of hard-coding them in, I'd like to call some perl code
> on the server to ~ask~ what the file names are.
<snip>
> See that holidayPics array ?  Instead of hardcoding that in, I'd like to
> call a perl function on the server to obtain the list of files.
> 
> The basic conceptual problem I'm having is that all the perl I've used
> so far is triggered by a form action.  And that perl in turn uses print
> to generate an entirely new web page.

You should explore a little more. Perl as a CGI language can be used to
build entire sites -- the URL determines how the script(s) execute(s).
As such, yes, it does generate the entire page, and I'm guessing that
this might be overkill for your needs.

> So I don't know how to call perl on an as-needed basis from javascript
> to obtain information.  Perhaps this just isn't possible and that php
> is designed for this purpose ?

PHP is great for this sort of thing, but you might also check out PLP at
CPAN -- it's an embedded form of perl for use with HTML pages, and works
in similar ways to PHP but has all the advantages of perl. 

    http://search.cpan.org/author/JUERD/PLP-3.18/PLP.pm

-- 
Matthew Weier O'Phinney
matthew@weierophinney.net
http://matthew.weierophinney.net


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

Date: Fri, 25 Apr 2003 05:36:34 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: call perl from javascript ?  or use php instead ?
Message-Id: <3ea8be67.133020086@news.erols.com>

Eric Osman <ericosman@rcn.com> wrote:

: (note:  If you're a knowledgeable but lazy reader, please skip to
: the last two paragraphs, as maybe you can help me.)

Nice.  :)

: var holidayPics = new Array(
:      "images_new/tea_party/tp518.jpg",
:      "images_new/tea_party/tp520.jpg",
:      "images_new/crescent_moon/cm020.jpg"
:      );
:
: See that holidayPics array ?  Instead of hardcoding that in, I'd like to
: call a perl function on the server to obtain the list of files.
: 
: The basic conceptual problem I'm having is that all the perl I've used
: so far is triggered by a form action.

Form submission is just another name for requesting a document from
the server.  The only thing special is that the document is generated
by an executable program, and that's the server's problem.

Use the standard markup for loading client-side scripts from a URL,

    <script type='text/javascript' src='/cgi-bin/foo.pl'></script>

then have the server pump out javascript when that URL is requested,

    #!perl
    print <<EOF;
    Content-type: text/javascript

    var holidaypics = new Array(
         "images_new/tea_party/tp518.jpg",
         "images_new/tea_party/tp520.jpg",
         "images_new/crescent_moon/cm020.jpg"
         );
    EOF



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

Date: Thu, 24 Apr 2003 20:00:10 -0700
From: TruthXayer <TruthXayer@yahoo.com>
Subject: Dumping hash after sort
Message-Id: <3EA8A4BA.FAB1E0A4@yahoo.com>


Is there a way to include a sort routine when dumping a hash
through 
Data::Dumper module.

I am currently dumping it thru
	my $dump = Data::Dumper->new([\%HugeHash], [qw(HugeHash)]);



thanks,


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

Date: 25 Apr 2003 05:56:25 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Dumping hash after sort
Message-Id: <b8aim9$oiv$1@nets3.rz.RWTH-Aachen.DE>

Also sprach TruthXayer:

> Is there a way to include a sort routine when dumping a hash
> through 
> Data::Dumper module.
> 
> I am currently dumping it thru
> 	my $dump = Data::Dumper->new([\%HugeHash], [qw(HugeHash)]);

You mean, dumping a hash in a sorted manner? According to the docs, it
should be enough to set

    $Data::Dumper::Sortkeys = 1;

to force sorted output. If you need a different way of sorting, you have
to provide a function-reference:

    $Data::Dumper::Sortkeys = sub {
        # reverse numerical sort
        my @keys = keys %{ $_[0] };
        [ sort { $b <=> $a } @keys ];
    };

The function-ref thing is quite flexible so you could even sort on
values etc.

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: 24 Apr 2003 21:32:42 -0500
From: Brian Zurbach <briansz@sitemouse.com>
Subject: FA: The Complete PERL Training Course
Message-Id: <3ea89e4a_2@corp-goliath.newsgroups.com>

By Ellie Quigley, brand new, sealed.  Includes training and binaries CDs 
plus a hard copy of PERL by Example.  Sold for $99.95 new, minimum bid is 
$9.99 plus shipping.  Training software is compatible with Windows 9x, NT, 
UNIX.

http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&category=21255&item=
2924281358&rd=1

Please cut and paste the url above if it is longer than one line in your 
newsreader window.

TIA!

Brian Zurbach
briansz@sitemouse.com




-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


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

Date: Fri, 25 Apr 2003 04:41:22 +0000
From: Sharon Grant <peakpeek@purethought.com>
Subject: Re: file upload not working anymore
Message-Id: <tcbhav0bdbcvftrj94pav8ib5ao908nkp3@4ax.com>

On Wed, 23 Apr 2003 14:05:35 +0200, in comp.lang.perl.misc, Andy Meier <andy@mindpilot.ch> wrote:

>The Perl part of my problem looks like this but a I mentioned I "fear" that
>the script is O.K.

 ...

>#--- save directory
>my $dir = "$ENV{'DOCUMENT_ROOT'}";

I would not rely on this. It is better to specify the exact 
location. However that would not cause zero-size files, more 
likely that the files would not be created at all

CGI.pm temporarily puts uploaded files in /tmp  It is possible 
that your Web host no longer allows you to write to /tmp  Read 
the CGI.pm documentation to see how to specify a private 
location for temporary files

Otherwise, follow Xho's suggestion that your host may have 
installed a bad (ie old or modified) version of CGI.pm  Find 
out which version they have and/or install your own copy of 
a reliable version

-- 
Sharon


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

Date: Fri, 25 Apr 2003 02:04:33 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Getting FULL path+filename from a filehandle
Message-Id: <x74r4njpse.fsf@mail.sysarch.com>

>>>>> "MPB" == Michael P Broida <michael.p.broida@boeing.com> writes:

  MPB> 	I've been digging through the Camel book and haven't been
  MPB> 	able to find out how to get the FULL path+filename from a
  MPB> 	filehandle.

you can't.

  MPB> 	At the time the file was opened, I had "current directory"
  MPB> 	and the "filename" (with possible partial/relative path).
  MPB> 	So the "open" worked just fine.  And I could, at that point,
  MPB> 	build the full path from that info.

so do it there and keep it associated with the handle in a tied object,
a hash or whatever.


  MPB> 	I know the OS has that info, but I can't seem to find any
  MPB> 	way to get it in Perl.  Any ideas/pointers??

how do you know the OS has this? which OS? most actually don't have
it. in fact the whole idea of handles is so you don't need to keep it
around in the OS. and with unix, multiple paths could point to the same
file so which is the correct one?

the only proper solution is to track it yourself. but needing a path
later on for a handle tells me you have a design problem. you should
have been tracking that all along in a higher level structure and not
expecting perl or the OS to do it for you.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 25 Apr 2003 11:44:30 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Help with creating UDP sockets using IO::Socket
Message-Id: <3ea893f8$0$17012@echo-01.iinet.net.au>


"Justin" <imarine@bigpond.net.au> wrote in message
news:1dugav0sa62dvph8s6mtvqpn99r42c7hqm@4ax.com...
> Here is what I have:
>
> my $wb_server = IO::Socket::INET->new(LocalPort => $wb_server_port,
> Proto => "tcp",
> Type => SOCK_STREAM,
> Listen => 250 );
>
> my $lc_server = IO::Socket::INET->new(LocalPort => $lc_server_port,
>            Proto => "udp",
>            Type => SOCK_DGRAM,
>            Listen => 10);
>
>
> The first socket connection using TCP works, but the second for UDP does
not.
>
> Any ideas???
>

I think the problem lies with specifying 'Type' and/or 'Listen'.

I put up some basic tcp and udp client and server scripts at
http://robgil.hypermart.net/scripts.html

Please treat them with a grain of salt. Iirc they were basically functional
on windows, but I lost interest in them when trying to get them to work on
both 2k and 98 - I can't be sure what bugs you'll find, especially if you're
not on windows.

I don't intend looking at them again - but they're still there and might
contain some code that is useful to you.

Cheers,
Rob




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

Date: Fri, 25 Apr 2003 02:04:59 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Help with creating UDP sockets using IO::Socket
Message-Id: <x71xzrjpro.fsf@mail.sysarch.com>


already answered so why the repost?

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 24 Apr 2003 18:22:07 -0700
From: thomas@shurflo.com (Thomas B)
Subject: Re: How can I hide a specific Window
Message-Id: <866f534e.0304241722.57454f2f@posting.google.com>

I'm almost there - but not quite.  I don't see any reference to the
Window handle in the the Process object.  I need it to pass to the
command that hides the window.

The following code will hide the current window.  But I need to get
the Window Handle of the process I launch, not the process that is
executing the Perl script.

BEGIN
{
  ( $hWnd, $hInstance ) = GUI::GetPerlWindow();
  GUI::Hide( $hWnd );
}



This is the entire program, and as you can see (hopefully), the HIDE
method at the bottom does not hide the Window.

Anyone know how to get the Windows Handle of a specific process.




use Win32::Process;
use Win32::GUI;

sub ErrorReport{
                print Win32::FormatMessage( Win32::GetLastError() );
        }


Win32::Process::Create($ProcessObj,
	"c:\\winnt\\system32\\notepad.exe",
	"",
        0,
        NORMAL_PRIORITY_CLASS,
        ".")|| die ErrorReport();

Win32::GUI::Hide($ProcessObj->GetProcessID());
sleep 10;
Win32::GUI::Show($ProcessObj->GetProcessID());


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

Date: 24 Apr 2003 18:27:34 -0700
From: thomas@shurflo.com (Thomas B)
Subject: Re: How can I hide a specific Window
Message-Id: <866f534e.0304241727.294df4af@posting.google.com>

"Sisyphus" <kalinabears@hdc.com.au> wrote in message news:<3ea49dd3$0$12447@echo-01.iinet.net.au>...
> "Thomas B" <thomas@shurflo.com> wrote in message
> news:866f534e.0304211550.3bb6e960@posting.google.com...
> > I actually want to launch a separate process and hide it.
> >
> 
> You'll want to 'use Win32::Process;'.
> The module is part of libwin32, and you probably already have it.
> 
> Cheers,
> Rob

The CREATE_NO_WINDOW option doesn't seem to work...


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

Date: Fri, 25 Apr 2003 06:25:45 GMT
From: inwap@inwap.com (Joe Smith)
Subject: Re: How to include data stamps in a script??
Message-Id: <Jx4qa.9469$io.306922@iad-read.news.verio.net>

In article <500f84f3.0303200917.1a140710@posting.google.com>,
John Smith <clearguy02@yahoo.com> wrote:
>"Tore Aursand" <tore@aursand.no> wrote in message
>> For the date part, you'll get going with 'localtime()'.
>
>Would you pl. elaborate your explanation (by writing the code)?

1) Pull out your perl documentation.
2) Look at perl's builtin function localtime().
3) Write a simple program that uses localtime().
4) Make sure you know when it is appropriate to use '+=1900' and '+=1'.

If that does not solve your problem, there is no hope.
	-Joe

-- 
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Fri, 25 Apr 2003 11:20:11 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: looking for graphing program
Message-Id: <slrnbah3ab.1k0.mgjv@martien.heliotrope.home>

On 24 Apr 2003 13:18:56 GMT,
	Abigail <abigail@abigail.nl> wrote:
> Chris (chris_12003@yahoo.com) wrote on MMMDXXIII September MCMXCIII in
><URL:news:vaekga867vgj9d@corp.supernews.com>:
> ()  Does anyone know of any graphing scripts that I can use that'll take the
> ()  input from a text file and display a graph to the user.  The graph can
> ()  either update automatically or through a crontab once a day.  I'm trying to
> ()  create a bar chart with 2 values to plot and maybe 3 if thats possible.
> 
> 
> I do the majority of my plotting with the help of the gnuplot program.
> No Perl module needed, just open a pipe to the program.

Note that the OP specifically asked for bar charts. gnuplot, without a
bit of work, doesn't do that easily. There is some information out there
on the web on what you can do to make gnuplot create bar charts. Google
knows.

Martien
-- 
                        | 
Martien Verbruggen      | System Administration is a dirty job, but
                        | someone said I had to do it.
                        | 


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

Date: Fri, 25 Apr 2003 08:24:58 +0300
From: Marko Vallius <markvalls.spambox@dnainternet.net>
Subject: Re: Net::FTP delete problem
Message-Id: <aetmn-4kf.ln1@sethlans.mine.nu>

On Thu, 24 Apr 2003 21:34:47 +0300, Arde wrote:
> I've got a weird problem when I'm trying to delete a file with
> $ftp->delete($_); in my script.
> Deleting a file takes forever and it seems to fail (if I use
> '$ftp->delete($_) or die;' the script dies) but the file is deleted

This can happen with some firewalls. You send the remote server a
request to delete a file, the file is deleted but the server's answer
disappears on the way back (it's probably blocked). So, Net::FTP times
out and returns false. If this is the case, GETs and PUTs should also
fail in the same way.

You might want to check that your firewall does not block ports 20-21. 
Both are needed for ftp. Alternatively, try using passive mode ftp by 
adding Passive=>1 to your Net::FTP->new constructor (you may need to 
allow incoming traffic in ports 1024-65535 in your firewall). 

-- 
Marko Vallius   #  http://iki.fi/markvall/


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

Date: Fri, 25 Apr 2003 14:09:48 +0800
From: "ILoveP" <japh_klch@programmer.net>
Subject: non-blocking read with IO::Select
Message-Id: <3ea8d145@newsgate.imsbiz.com>

Hi,

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;
}

close $fh;
__END__


Below is the simulated data source, datasrc.pl
-----------
#!/usr/bin/perl

$| = 1;    # autoflush

for $i (0..9) {
        print "This is line $i\n";
}

sleep 3;
print "This is the last line\n";
__END__


I expect that, when I run my script, I would get:
-----------
This is line 0
This is line 1
This is line 2
This is line 3
This is line 4
This is line 5
This is line 6
This is line 7
This is line 8
This is line 9
timeout!
-----------

However, I got:
-----------
This is line 0
(delay 3 sec)
timeout!
-----------


If I change "sleep 3" to "sleep 1", I got:
-----------
This is line 0
(delay 1 sec)
This is line 1
This is line 2
This is line 3
This is line 4
This is line 5
This is line 6
This is line 7
This is line 8
This is line 9
(the delay should appear here!)
This is the last line
-----------


Shouldn't those lines got flushed before "sleep"? Now they appear only after
it wakes up!
Is there anything wrong in my code?

Thanks,
Kenneth





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

Date: 25 Apr 2003 06:48:40 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: non-blocking read with IO::Select
Message-Id: <b8alo8$qkh$1@nets3.rz.RWTH-Aachen.DE>

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
        }
    }
    
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: Fri, 25 Apr 2003 02:21:49 GMT
From: Darin McBride <dmcbride@naboo.to.org.no.spam.for.me>
Subject: Re: Problem updating data in DB2 from webserver?
Message-Id: <1Z0qa.54541$ja.2195615@news2.calgary.shaw.ca>

Hemant Shah wrote:

> I am using CGI.pm to render HTML pages and I also use DBI and DBD::DB2
> to query the database. The script that queries the database is working
> O.K. But the script I use to update the table is giving me problems.
> 
> When I try to insert or delete a row from the table, I get error message
> that I am violating constraint 1. I checked all the constraints on the
> table but I cannot see it violating any constraints. Funny thing is that
> the insert or delete is done successfully. I have turned off AutoCommit so
> it should not commit anything. Couple of other things I noticed is that
> when the update of the table fails, I cannot use the database, I cannot
> even do the queries on the command line unless I run "force application
> all".
> 
> I also noticed that even though I execute $dbh->disconnect, the connection
> is still there, "list applications" show all the connection with UOW
> waiting.
> 
> I have written many perl script with DBD::DB2 and I have never encountered
> such problem. This the first time I am writing perl script that is execute
> from a web server using mod_perl.
> 
> Are there any tricks to writing DBD:DB2 scripts while running under
> mod_perl?

Probably.  However, I would guess that they are the same tricks that you 
need under any DBI-based driver (Oracle, Sybase, Informix, etc.), and the 
DBI mailing list may be a better place for this question.  Personally, I've 
not yet used mod_perl for my DBI-based CGI scripts, so I can't really help, 
although I've seen many mod_perl-related questions on the DBI list.  See 
the documentation for the DBI module (perldoc DBI) for how to join.

Also, may I recommend trying without mod_perl to see if that actually is the 
problem?  I understand you've written without mod_perl before, but perhaps 
it's something specific to this application other than mod_perl.  It's 
always nice to be able to confirm the cause of the problem before solving 
it ;-)

Oh, and if you find a solution other than on the DBI list, please post back 
here - I'd love to know the gotchas before I go down that route.  I'm 
hoping to go to mod_perl (to learn it), but just haven't had the time 
and/or the guts :-)



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

Date: Thu, 24 Apr 2003 21:17:20 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Regex greediness question
Message-Id: <Xns9367E2C8F18C4sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"Tman" <nerdy1@snet.net> wrote in
news:Z8Rpa.1172$Hg4.279561317@newssvr10.news.prodigy.com: 

> Trvial example, yes, but it is reduced from a real-world problem. 
(I
> am trying to match the <TABLE>..... </TABLE> element in a page
that
> contains a certain string, and only match that single table).

It is very very hard (nigh impossible) to parse general HTML by using
regular expressions.  You really should consider using a HTML parser,
such as HTML::TokeParser.

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE+qJq+Y96i4h5M0egRApwNAKD3jVYMP8Moso3ZoJ76TFcpy/XTXQCfXuJO
YuNa2nUm3d/YOUFRyZLJ9KI=
=pEY0
-----END PGP SIGNATURE-----


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

Date: 25 Apr 2003 07:01:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regex greediness question
Message-Id: <b8amgq$p3r$1@mamenchi.zrz.TU-Berlin.DE>

Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
>
> > I'd code it along these lines:
> > 
> >     while ( $html =~ m[(<table>.*?</table>)]sg ) {
> >         my $table = $1;
> >         if ( ... ) {}
> >     }
> 
> Thanks for your comments; I see your points. A while loop is obviously 
> more straight forward, provided that you don't want to change the 
> value of $html. For some reason - don't ask me why ;-) - I assumed 
> that OP wanted to do that.

Yes, it occured to me, too, that we might have misunderstood the OP
in different ways :)


Anno


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

Date: 25 Apr 2003 03:21:47 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: The Complete PERL Training Course
Message-Id: <b8a9kb$l90@dispatch.concentric.net>


"Brian Zurbach" <briansz@sitemouse.com> wrote in message
news:3ea89e4a_2@corp-goliath.newsgroups.com...
> By Ellie Quigley, brand new, sealed.  Includes training and binaries CDs
> plus a hard copy of PERL by Example.  Sold for $99.95 new, minimum bid is

Any training course that spells Perl in ALL CAPS isn't worth $.99.




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

Date: Fri, 25 Apr 2003 01:58:10 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <x7adefjq31.fsf@mail.sysarch.com>

>>>>> "A" == Agrapha  <brian@box201.com> writes:

  A> "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in message news:<b88igv$rc2$1@nets3.rz.RWTH-Aachen.DE>...
  >> Could we please put an end to all this noise? I think it has been
  >> pointed out to the OP clearly enough what he did wrong (and he seems to
  >> have understood). We should rather focus on the Perl-content of this
  >> thread (now that it finally has such a thing).
  >> 

  A> Agreed. A few less flame throwers will be much appreciated. I will do
  A> my best not to antagonize the jackles predisposed to derision and
  A> mayhem. I should have had higher standards.

you just refuse to get it. YOU are the one who started on the wrong foot
and you still haven't owned up to it. so stop this holier than thou act
and apologize for your (perceived) request for free coding. 

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 25 Apr 2003 02:01:27 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: {newbie} sorting  of files
Message-Id: <x77k9jjpxk.fsf@mail.sysarch.com>

>>>>> "BS" == Bill Smith <wksmith@optonline.net> writes:

  BS> "Uri Guttman" <uri@stemsystems.com> wrote in message
  BS> news:x765p3lh0y.fsf@mail.sysarch.com...
  >> >>>>> "o" == oracle1  <santyspamsharma@hotmail.com> writes:
  >> 
  o> sub by_time_and_files {
  o> $file_hash{b} <=> $file_hash{a}
  >> $b                $a


  BS> This is the kind of error that use strict usually finds.  I understand
  BS> that this is a special casek and it would not have helped, but my advice
  BS> is still "always use strict".

what does strict have to do with this? $foo{a} is valid at all times in
perl. nothing could detect that bug automatically since barewords are
legal keys. what people are confusing is that $a and $b need not be
declared under strict and that is because of sort. but he didn't use
them there (the second compare clause did). he forgot the $ sigils and
strict won't show that.

now warnings might have shown up since $file_hash{a} (and b) were
probably undef and <=> would barf under -w.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Thu, 24 Apr 2003 21:25:58 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: {newbie} sorting  of files
Message-Id: <Xns9367E43F490B8sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"Bill Smith" <wksmith@optonline.net> wrote in
news:o3_pa.120670$MB4.40452999@news4.srv.hcvlny.cv.net:

> "Uri Guttman" <uri@stemsystems.com> wrote in message
> news:x765p3lh0y.fsf@mail.sysarch.com...
>> >>>>> "o" == oracle1  <santyspamsharma@hotmail.com> writes:
>>
>>   o> sub by_time_and_files {
>>   o>  $file_hash{b} <=> $file_hash{a}
>>                  $b                $a
> 
> 
> This is the kind of error that use strict usually finds.

Why would 'use strict' have found this error?

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE+qJzBY96i4h5M0egRApouAJ0X/YzFqUDdaKTB+N+A9Ukzobpg5QCg7+AI
b0v59T/Y2HlqhNRl5lMDoUY=
=kOl5
-----END PGP SIGNATURE-----


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

Date: 25 Apr 2003 05:37:44 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: {newbie} sorting  of files
Message-Id: <b8ahj8$o09$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Uri Guttman:

>>>>>> "TM" == Tad McClellan <tadmc@augustmail.com> writes:
> 
>  TM>    programming Perl without "use strict"
> 
>  TM> If you'd done the 2nd, then perl itself would have pointed
>  TM> out the problem in milliseconds.
> 
> actually i disagree there. he had this:
> 
>   o>  $file_hash{b} <=> $file_hash{a}
> 
> which doesn't break strict or warn AFAIK (not tested).

If the OP had two files called 'a' and 'b' it would not even warn. But if
either of one or both are undef (which is likely for average data) this
will issue a warning about uninitialized values that he could have
inspected further. Strictures, however, wouldn't have helped me. But
wouldn't have hurt either. :-)

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: 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 4891
***************************************


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