[27923] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9287 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 12 18:05:56 2006

Date: Mon, 12 Jun 2006 15: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           Mon, 12 Jun 2006     Volume: 10 Number: 9287

Today's topics:
    Re: Can't find syntax error <nomail@domain.tld>
    Re: CGI for collecting phone numbers <ferreira@unm.edu>
    Re: creating log file <tzz@lifelogs.com>
    Re: DBI/DBD question <sherm@Sherm-Pendleys-Computer.local>
    Re: help needed in getting output <sherm@Sherm-Pendleys-Computer.local>
    Re: help needed in getting output <sherm@Sherm-Pendleys-Computer.local>
    Re: How to retreive values from HTML to perl script <sherm@Sherm-Pendleys-Computer.local>
    Re: I received eBay Star Developer Award <jcdill@gmail.com>
        Looking for a VERY EFFICIENT module for XML <ignoramus17503@NOSPAM.17503.invalid>
    Re: Looking for a VERY EFFICIENT module for XML robic0
    Re: Looking for a VERY EFFICIENT module for XML robic0
    Re: Looking for a VERY EFFICIENT module for XML robic0
    Re: Looking for a VERY EFFICIENT module for XML <glex_no-spam@qwest-spam-no.invalid>
    Re: Looking for a VERY EFFICIENT module for XML robic0
    Re: Merging potentially undefined hashes <f__r__a__n__s@hotmail.com>
        Modifying ls manian.k@gmail.com
    Re: Modifying ls <someone@example.com>
    Re: Non-blocking Sockets with PerlScript on Win XP xhoster@gmail.com
        Open Perl IDE not compiling eugenedalt@yahoo.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 12 Jun 2006 15:01:16 -0400
From: Eric <nomail@domain.tld>
Subject: Re: Can't find syntax error
Message-Id: <128reijjl3umn5e@corp.supernews.com>

it_says_BALLS_on_your forehead wrote:
> Eric wrote:
> 
>>I've been looking at my script for a day now, and I cannot find my
>>syntax error.  It says its on line 34, and 45.
>>
> 
> 
> why do you say 34 and 45, when Perl tells you 28 and 39 below?

I had removed some comments from the top of the script before i posted.
I meant to edit that, but must have missed it.
> 
> 
>>syntax error at ./test.pl line 28, near ") {"
>>syntax error at ./test.pl line 39, near "}"
>>Execution of ./test.pl aborted due to compilation errors.
>>
>>
>>Any ideas?
>>
>>#!/usr/bin/perl -w
> 
> 
> instead of using the -w switch:
> use warnings;

I don't think it makes any difference does it?
None the less, i think it looks better your way, so i changed it.

> 
> 
>>use strict;
>>use LWP::UserAgent;
>>
>> my $ua = LWP::UserAgent->new;
>> $ua->timeout(10);
>> $ua->agent("Stress Test/0.1");
>> $ua->cookie_jar({ file => "./cookies.txt", AutoSave => 1 });
>> $ua->protocols_forbidden( ['mailto'] );
>>
>>
>>
>>parse_config("./test1.conf");
>>
>>
>>
>>
>>
>>
>>sub parse_config () {
> 
> 
> remove the parens here.

Nice catch. that fixed it.
> 
> 
>>    my $conf = shift;
>>    my $response;
>>    open FILE, "< " . $conf || die("Cannot open $conf. " . $!);
> 
> 
> use a lexical file handle, and after the "<", you are concatenating.
> try using a comma operator.
> 
> open my $fh, '<', $conf or die "Cannot open $conf: $!\n";
> 
> 
>>    while(<FILE>)  {
>>        print $_;
> 
> 
> print by itself is sufficient here.
> 
> 
>>        my @commands = split("=",$_);
> 
> 
> no need to explicitly split $_ here.
> 
> my @commands = split /=/;
> 
> 
>>        print $commands[0] . " - " . $commands[1];
<snip>
as for a lot of the other comments like @commands = split /=/; and print
 rather then print $_.  I'm going to have to avoid doing some of those,
as I want it to remain as readable as possible.

Thank you, Good stuff


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

Date: 12 Jun 2006 12:05:52 -0700
From: "ferreira@unm.edu" <ferreira@unm.edu>
Subject: Re: CGI for collecting phone numbers
Message-Id: <1150139151.932073.131560@j55g2000cwa.googlegroups.com>

Tad,
 Thank you for explaining things to me. I am new to groups and solving
problems in this format. I thought that by saying what I was doing up
front, I would spark questions not criticism. I had not thought of
doing some of the things you suggested. I will start working on those
next. Please understand that I was not meaning to offend anyone, just a
dumb ape stumbling in to modern society. One thing that I would like to
know is what "program/method" works best for testing my code? Something
with good debugging? I am running  Mac OS X 10.3.9. I have looked at a
few different programs but would like to know what the pros, like you,
use. I know that many on the group said run it at the command line. Is
that the best for a beginner like me or should I look into something
with more idiot proofing.

James

Tad McClellan wrote:
> ferreira@unm.edu <ferreira@unm.edu> wrote:
>
>
> > Pual,
> > Do you just like to badger newbes or what?
>
>
> You have not correctly identified the nature of Paul's followups.
>
> It was not badgering, it was letting you in on the social dynamic
> of this group of people that you just entered.
>
> You've done a half dozen things that will be seen as rudeness by
> many here.
>
> One (probably too) common response to such a post is to killfile
> your address, and ignore you forevermore, with you not even
> knowing what has happened!
>
> Another response is to make a followup pointing out these things
> to you so that you would become aware of them before it is too late.
>
> Which approach is more helpful to you?
>
> Leaving you in ignorance, or helping you to learn what you
> need to know to participate fully?
>
>
> You were walking around with some toilet paper stuck to your shoe.
> Many people just snickered at you, Paul was courteous enough to
> say "Hey, you have some TP stuck to your shoe".
>
> Now you are acting as if you _prefer_ not knowing.
>
>
> > I don't even get paid for
> > this.
>
>
> Neither do we.
>
> So we are not likely to write complete programs to specification,
> that is what we do at work.
>
> We don't write programs here. We help people write programs here.
>
>
> > I'm just a volunteer trying to help out for a good cause.
>
>
> So are we.
>
> (But "help out" is not the same as "do it for me".)
>
> (and if your code leads to embarrassment for your client that makes
> the 6 o'clock news, your "help out" may end up costing far more
> than what was paid for the code.)
>
>
> > Here is the final code.
>
>
> I sure hope not...
>
>
> > Maybe someone wanting to submit phone numbers
> > from a form to a text file with a cgi will run across this post and
>
>
> not use the code in a cargo-cult manner, but will instead
> work to understand what it does. (and then probably decide
> to do it differently.)
>
>
> > save the hassle I went through.
>
>
> I expect the root cause of your hassle was being new to four
> different things all at the same time.
>
>    1) Usenet
>
>    2) web (CGI) programming
>
>    3) Perl
>
>    4) programmming itself (IMO)
>
>
> Lurking or reading the Posting Guidelines or even googling
> for "netiquette" would handle most of #1. (or simply listening
> to the advice that Paul gave you.)
>
> You can start on #2 with:
>
>    perldoc -q CGI
>
>        Where can I learn about CGI or Web programming in Perl?
>
>        What is the correct form of response from a CGI script?
>
>        My CGI script runs from the command line but not the browser.
>        (500 Server Error)
>
>        How can I get better error messages from a CGI program?
>
>        How do I make sure users can't enter values into a form that
>        cause my CGI script to do bad things?
>
>        How do I decode a CGI form?
>
> You can start on #3 at learn.perl.org, and finish with asking
> questions about Perl programming right here.
>
> Learning industry standard programming practices (#4) is not
> so easily addressed.
>
>
> > #!/usr/bin/perl -w
>
>    use warnings;
>
> is a much better method of enabling warnings.
>
>
> You should also enable strictures:
>
>    use strict;
>
> to get perl to help you find common bugs.
>
>
> > use CGI;
>
>
> Why did you include this module?
>
> This is not a rhetorical question.
>
> You never make use of any of the facilities that it provides,
> so it looks like you are engaging in "cargo cult programming"
> (using code even when you do not understand what it does).
>
> Your programming life will be very hard unless we can
> successfully teach you to understand code before using it.  :-)
>
>
> > if ($ENV{'REQUEST_METHOD'} eq 'POST') {
> >
> >         read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> >
> >         @pairs = split(/&/, $buffer);
> >
> >         foreach $pair (@pairs) {
> >                 ($name, $value) = split(/=/, $pair);
> >                 $value =~ tr/+/ /;
> >                 $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",
> > hex($1))/eg;
> >                 $FORM{$name} = $value;}
> >         }
>
> > my $phone = $FORM{phone};
>
>
> If you do it like in the answer to the "How do I decode a CGI form?" FAQ,
> then you can replace all of your code above with these 2 lines:
>
>    use CGI qw(:standard);
>    my $phone = param( "phone" );
>
> Not only is it a whole lot shorter, it does not contain the bugs
> that your hand-rolled (and cargo-culted I would assume) code has.
>
>
> > flock (FILE, 2) or die "cannot lock file exclusively: $!";
>                ^
>                ^
> You should avoid using system-dependent hard coded values like
> that, since the numbers can be different on different systems.
>
> You should import the constants from the Fcntl module instead:
>
>    use Fcntl qw(:flock);
>    flock (FILE, LOCK_EX) or die ...
>
>
> > print FILE $phone . "\n";
>
>
> You don't say what you are going to use this list of phone numbers
> for, but in light of #2 above I better mention a couple more things
> in case you haven't thought about them yet.
>
> The web is a wild and wooly place. There are people out there that
> just cruise around looking for an opportunity to cause trouble.
>
> They will find opportunity aplenty if you put your "final code"
> where they can find it.
>
> What will your code do if a user enters this for the "phone" form value:
>
>    http://www.pornography.com
>
> ??
>
> Do you _want_ to put that into your phone list? Probably not, so
> you'd better do some input checking:
>
>    die 'does not look like a phone number' unless $phone =~/^[0-9 -]+$/;
>
> (but don't use die() in a real CGI program...)
>
>
> Yet another thing to consider: what if the user enters all of
> his enemy's phone numbers instead of his own phone number?
>
> Be careful out there!
>
>
>
> [snip TOFU.
>  Yet another breach of standard netiquette...
> ]
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas



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

Date: Mon, 12 Jun 2006 15:28:38 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: creating log file
Message-Id: <g69irn6p40p.fsf@CN1374059D0130.kendall.corp.akamai.com>

On  9 Jun 2006, DJStunks@gmail.com wrote:

> you, and the OP, may want to check out Log::Log4perl, the preeminent
> logging module.  I used to use a subroutine I rolled my self (much like
> yours) until I discovered this module.  it is very flexible and
> powerful.

The nice thing about a consistent log()/l() function is that, when
necessary, you can make it call Log::Log4perl.  I think the vast
majority of Perl programs under 300 lines don't need a module to do
their logging, but they do need a verbosity level.

The important thing is to shorten the function name, so it's easy to
type.  It should be as easy or easier than print(), to tempt the
programmer :)

Ted


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

Date: Mon, 12 Jun 2006 17:30:38 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: DBI/DBD question
Message-Id: <m2slmaxds1.fsf@Sherm-Pendleys-Computer.local>

Huub <"v.niekerk at hccnet.nl"> writes:

> Ok, that works better. Question though: I tried to install DBD::mysql
> as well. This failed because it didn't find a running MySQL server on
> the machine..which is correct because it runs on another machine on
> the network. How can I get it installed anyway?

By following the instructions that are included with DBD::mysql showing what
needs to be done to specify what server/database should be used for the tests.

Or if you're feeling lucky, you could follow the instructions in the docs
for CPAN.pm (i.e. perldoc CPAN.pm) that specify how to disregard the test
results and force the installation.

Docs are only helpful if you read them...

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Mon, 12 Jun 2006 17:55:32 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: help needed in getting output
Message-Id: <m2hd2qxcmj.fsf@Sherm-Pendleys-Computer.local>

kbnumesh@gmail.com writes:

> i am new to this perl and CGI programming ( just a day)
>
>
> i wrote one cgi program to retreive values from html file

We heard you the first time.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Mon, 12 Jun 2006 17:56:26 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: help needed in getting output
Message-Id: <m2d5dexcl1.fsf@Sherm-Pendleys-Computer.local>

kbnumesh@gmail.com writes:

> can any one tell How to setup IIS server in my machine......

IIS is not the topic of this group. Ask in another group - probably one
in the public.microsoft.* hierarchy.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Mon, 12 Jun 2006 17:54:12 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: How to retreive values from HTML to perl script
Message-Id: <m2lks2xcor.fsf@Sherm-Pendleys-Computer.local>

kbnumesh@gmail.com writes:

> When i input some text and press submit button
>
> its printing the cgi file instead of outputing the value.....

That's a server configuration issue - it would be doing the same
thing if your script were in Python, Ruby, whatever.

Check the documentation for your server about how to correctly set
up a cgi-bin/ directory. If you still have questions about it, try
asking in a group for the server you're using.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 12 Jun 2006 21:19:48 +0200
From: JC Dill <jcdill@gmail.com>
Subject: Re: I received eBay Star Developer Award
Message-Id: <fhfr82t74oam6cnass8gpqqqt33k851s6l@4ax.com>

On Sat, 10 Jun 2006 19:32:37 GMT, Ignoramus14786
<ignoramus14786@NOSPAM.14786.invalid> wrote:

>I am at eBay developers conference right now, and they gave me a Star
>Developer Award for writing a Net::eBay perl module.

Congrats!

jc
-- 

"The nice thing about a mare is you get to ride a lot
 of different horses without having to own that many."  
     ~ Eileen Morgan of The Mare's Nest, PA

Inviato da X-Privat.Org - Registrazione gratuita http://www.x-privat.org/join.php


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

Date: Mon, 12 Jun 2006 21:25:22 GMT
From: Ignoramus17503 <ignoramus17503@NOSPAM.17503.invalid>
Subject: Looking for a VERY EFFICIENT module for XML
Message-Id: <6Zkjg.13931$wt4.305@fe29.usenetserver.com>

Right now I use XML::Simple. As it turns out, this module is
relatively slow to parse big XML texts. 

Is there another perl module, I need something very fast.

That's for my Net::eBay module. 

Thanks

i



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

Date: Mon, 12 Jun 2006 14:29:32 -0700
From: robic0
Subject: Re: Looking for a VERY EFFICIENT module for XML
Message-Id: <u4nr825e1nbfpvh8gtc3p4balvvjd3s5om@4ax.com>

On Mon, 12 Jun 2006 21:25:22 GMT, Ignoramus17503 <ignoramus17503@NOSPAM.17503.invalid> wrote:

>Right now I use XML::Simple. As it turns out, this module is
>relatively slow to parse big XML texts. 
>
>Is there another perl module, I need something very fast.
>
>That's for my Net::eBay module. 
>
>Thanks
>
>i

Use RXParse.pm (posted in this ng) by robic0!


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

Date: Mon, 12 Jun 2006 14:30:24 -0700
From: robic0
Subject: Re: Looking for a VERY EFFICIENT module for XML
Message-Id: <17nr821t7037g72bjn5bdnsae18musjqfs@4ax.com>

On Mon, 12 Jun 2006 14:29:32 -0700, robic0 wrote:

>On Mon, 12 Jun 2006 21:25:22 GMT, Ignoramus17503 <ignoramus17503@NOSPAM.17503.invalid> wrote:
>
>>Right now I use XML::Simple. As it turns out, this module is
>>relatively slow to parse big XML texts. 
>>
>>Is there another perl module, I need something very fast.
>>
>>That's for my Net::eBay module. 
>>
>>Thanks
>>
>>i
>
>Use RXParse.pm (posted in this ng) by robic0!
use v.91 only.....


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

Date: Mon, 12 Jun 2006 14:37:35 -0700
From: robic0
Subject: Re: Looking for a VERY EFFICIENT module for XML
Message-Id: <ngnr82deves7rvtoqovdeg1sb8tfavjhsg@4ax.com>

On Mon, 12 Jun 2006 14:30:24 -0700, robic0 wrote:

>On Mon, 12 Jun 2006 14:29:32 -0700, robic0 wrote:
>
>>On Mon, 12 Jun 2006 21:25:22 GMT, Ignoramus17503 <ignoramus17503@NOSPAM.17503.invalid> wrote:
>>
>>>Right now I use XML::Simple. As it turns out, this module is
>>>relatively slow to parse big XML texts. 
>>>
>>>Is there another perl module, I need something very fast.
>>>
>>>That's for my Net::eBay module. 
>>>
>>>Thanks
>>>
>>>i
>>
>>Use RXParse.pm (posted in this ng) by robic0!
>use v.91 only.....


Hey wait, xml simple doesent parse xml!!!
Simple uses one of a few seperate parse module's availabe
to congeil data into a hash.
Don't you know Perl?


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

Date: Mon, 12 Jun 2006 16:35:06 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Looking for a VERY EFFICIENT module for XML
Message-Id: <Kaljg.23$TH5.4643@news.uswest.net>

Ignoramus17503 wrote:
> Right now I use XML::Simple. As it turns out, this module is
> relatively slow to parse big XML texts. 
> 
> Is there another perl module, I need something very fast.

Start with the FAQ, which is listed in XML::Simple's documentation: 
http://perl-xml.source-forge.net/faq/

Also, you can use a search engine, on your own time, to help you find 
answers to these types of questions.


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

Date: Mon, 12 Jun 2006 14:46:18 -0700
From: robic0
Subject: Re: Looking for a VERY EFFICIENT module for XML
Message-Id: <74or8298ihb4uuq0q3fqn1fqnmu5ab8s32@4ax.com>

On Mon, 12 Jun 2006 16:35:06 -0500, "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid> wrote:

>Ignoramus17503 wrote:
>> Right now I use XML::Simple. As it turns out, this module is
>> relatively slow to parse big XML texts. 
>> 
>> Is there another perl module, I need something very fast.
>
>Start with the FAQ, which is listed in XML::Simple's documentation: 
>http://perl-xml.source-forge.net/faq/
>
>Also, you can use a search engine, on your own time, to help you find 
>answers to these types of questions.

Your an idiot, you offer absolutely no constructive help at all


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

Date: Mon, 12 Jun 2006 20:44:17 +0200
From: farans <f__r__a__n__s@hotmail.com>
Subject: Re: Merging potentially undefined hashes
Message-Id: <pan.2006.06.12.18.44.14.534518@hotmail.com>

On Fri, 09 Jun 2006 11:46:17 -0700, Brian McCauley wrote:

> 
> Derek Basch wrote:
>> Hi everyone,
>>
>> I have several functions (getBillingDatabaseAttributes, etc...) that
>> can either return a hash reference or undefined. They just return a DBI
>> selectrow_hashref function such as:
>>
>> $hash_ref = $dbh->selectrow_hashref($statement);
>>
>> How can I merge these hashes and undefined values?
>>
>> If I do this:
>>
>> %hash1 = (%$hash2, %$hash3);
>>
>> I get a 'cant reference undefined value' error.
> 
> My preferred idiom is:
> 
> %hash1 = (%{ $hash2 || {} }, %{ $hash3 || {} });
> 
> Or:
> 
> %hash1 = (%{\%$hash2}, %{\%$hash3});

I don't uderstand the last one, but I think I prefer this to
"merge hashes and undefined values":

%hash1=(defined $hash2 and defined $hash3) ? (%$hash2, %$hash3) : undef;



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

Date: 12 Jun 2006 13:13:37 -0700
From: manian.k@gmail.com
Subject: Modifying ls
Message-Id: <1150143217.480813.52320@f6g2000cwb.googlegroups.com>

I want to some how modify the contents of a ls listing to only display
the filename and the time it was modified.

Example if I do ls -lt
drwx------+ 1 mkrishnamoorthy  Domain Users         0 Feb 16 17:32
Application Data
-rwx------+ 1 mkrishnamoorthy  Domain Users    188757 Feb  8 16:12
trial.pdf
-rwx------+ 1 mkrishnamoorthy  Domain Users    349544 Feb  8 15:55
IEEEtran.tar.

I just want the time and the file name, that is

Feb 16 17:32 Application Data

How can I push that information into an array.
$array = 'ls -t'
and usr array[1] to get the latest file.

Thanks



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

Date: Mon, 12 Jun 2006 20:40:27 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Modifying ls
Message-Id: <%ikjg.36425$I61.3991@clgrps13>

manian.k@gmail.com wrote:
> I want to some how modify the contents of a ls listing to only display
> the filename and the time it was modified.
> 
> Example if I do ls -lt
> drwx------+ 1 mkrishnamoorthy  Domain Users         0 Feb 16 17:32
> Application Data
> -rwx------+ 1 mkrishnamoorthy  Domain Users    188757 Feb  8 16:12
> trial.pdf
> -rwx------+ 1 mkrishnamoorthy  Domain Users    349544 Feb  8 15:55
> IEEEtran.tar.
> 
> I just want the time and the file name,

Then don't use ls.

> that is
> 
> Feb 16 17:32 Application Data
> 
> How can I push that information into an array.
> $array = 'ls -t'

$array is a scalar not an array.

> and usr array[1] to get the latest file.

If you did that then the latest file would be in $array[0] not $array[1].


Here's how to do it without calling an external program like ls:


opendir DIR, '.' or die "Cannot open '.' directory: $!";

my $latest = [ '', 0 ];

while ( my $file = readdir DIR ) {

    my $mtime = ( stat $file )[ 9 ];

    $latest = [ $file, $mtime ] if $latest->[ 1 ] < $mtime;
    }

closedir DIR;

print "The latest file is $latest->[0].\n";




John
-- 
use Perl;
program
fulfillment


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

Date: 12 Jun 2006 18:42:23 GMT
From: xhoster@gmail.com
Subject: Re: Non-blocking Sockets with PerlScript on Win XP
Message-Id: <20060612144232.383$XY@newsreader.com>

"Tresh" <Tresh909@gmail.com> wrote:
> Hello !
>
> I'm developping an application for testing purpose which is based on a
> HTML page with perlScript.
> This application communicates thru sockets (i'm coding both client and
> server version of the application)
>
> Basically, it waits for some message and do some actions when the
> correct message has been received.
> these actions include a reply to the received message.
> perlScript is used here to create powerful scenarios, which can be made
> by the users of the application.
>
> The main problem here comes from the blocking read of the socket.

I don't think that that is the main problem.  AFAICT, PerlScript is not
interuptible whether they are blocking on a socket, sleeping, or just
counting to a zillion.

> For
> example, a scenario is launched from the HTML interface. This scenario
> connects the client socket to a server and then waits for a message
> from this socket. When perl executes this, while waiting, the HTML
> interface freezes, so we can't click on the "stop button" of the
> scenario.
> That's the problem.

I suspect you have an ActiveX problem, or an ActiveState problem, or
a Microsoft problem, or an ActiveX Scripting problem, or an integration
problem of all of the above.

What you have showed is pure Perl.  It doesn't reproduce your problem, as
(to start with) there is no "stop button" in Perl.  Some might argue that
this is the not correct place to ask PerlScript questions.  I'm not sure if
I agree with that or not, but it certainly isn't the place to ask
PerlScript questions which don't actually show any PerlScript!

Anyway, from my minimal playing, I couldn't get an incredibly simple
PerlScript to yield.  It simply locked up until it completed, with no
response to hitting the stop button.  This makes me think that the problem
is not Perl related, but higher up the stack.

<html>
<head>
<title>PerlScript Hello World!</title>
</head>
<body bgcolor="#ffffff">
<h2>PerlScript Hello world!</h2>
<script language="PerlScript">
foreach (101..200) {
  $window->document->write("Hello world $_!<br>\n");
  select undef,undef,undef,0.1;
}
</script>
</body>
</html>



>
> I'm giving a part of the code :
> function testSocket which checks during 100ms if there is some data to
> read on the socket.
> function waitMsg which calls testSocket and handles a timeout
>
> sub testSocket()
> {
>   # timeout 100 ms
>   my $timeout = 0.1;
>   @ready = $sel->can_read($timeout);
>   if (@ready > 0)
>   {
>     foreach $fh (@ready)
>     {
>         if ($fh == $sock)
>          {
>           return 1; #data ok : will read it
>         }
>         else
>          {
>           # Maybe we have finished with the socket
>           $sel->remove($fh);
>           $fh->close;

This doesn't make sense to me.  What are you stuffing in $sel that is
going to become readable but is not going to be equal to $sock?  And since
you don't care what it is, why are you stuffing it into $sel in the first
place?

>         }
>     }
>   }
>   return 0;
> }
>
> sub waitMsg(;$)
> {
>         #timeout in ms (now must be a multiple of 100)
>         my $timeout = shift;

     REDO: {

>         my $res = testSocket();
>         if ($res == 1)
>         {
>                 return getMsg();
>         }
>         else
>         {
>                 if ($timeout eq "")
>                 {
>                         # no timeout, infinite wait
>                         return waitMsg();

Possibly infinite recursion is bad.  Do this instead:

                          redo REDO;
>                 }
>                 else
>                 {
>                         if ($timeout == 0)
>                         {
>                                 #timeout !!!
>                                 return (-1, "");
>                         }
>                         #recursive call
>                         return waitMsg($timeout - 100);

Again, avoid infinite/deep recursion.

                          $timeout-=100;
                          redo REDO;

Also, there is no guarentee that an unsuccessful select actually
waited the full time, so that subtraction may not be accurate.

>                 }
>         }
>

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 12 Jun 2006 14:53:24 -0700
From: eugenedalt@yahoo.com
Subject: Open Perl IDE not compiling
Message-Id: <1150149204.583097.237280@g10g2000cwb.googlegroups.com>


 I installed the Open Perl IDE  two weeks ago to run some perl scripts.
This week, the compile button doesn't work ... any help?  Cheers -
Eugene



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

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


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