[28158] in Perl-Users-Digest
Perl-Users Digest, Issue: 9522 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 25 14:05:52 2006
Date: Tue, 25 Jul 2006 11:05:06 -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 Tue, 25 Jul 2006 Volume: 10 Number: 9522
Today's topics:
bop OLTP server, has anyone tried this thing? <bootiack@yahoo.com>
counting number of uniques in a multidimensional array <jack_posemsky@yahoo.com>
Re: fontsize and/or space between lines <"v.niekerk at hccnet.nl">
Re: fontsize and/or space between lines <scobloke2@infotop.co.uk>
Re: fontsize and/or space between lines <"v.niekerk at hccnet.nl">
Re: Handling KILL signal in a perl script <mritty@gmail.com>
Re: Handling KILL signal in a perl script <rvtol+news@isolution.nl>
Re: Handling KILL signal in a perl script <1usa@llenroc.ude.invalid>
Re: Handling KILL signal in a perl script <1usa@llenroc.ude.invalid>
Re: Handling KILL signal in a perl script <glennj@ncf.ca>
Re: Handling KILL signal in a perl script anno4000@radom.zrz.tu-berlin.de
Re: Handling KILL signal in a perl script xhoster@gmail.com
Re: Handling KILL signal in a perl script <hjp-usenet2@hjp.at>
HTTP::Response and gzip adiakin@gmail.com
Re: method connecting outlook express to webmail script <1usa@llenroc.ude.invalid>
Noob threading question <slinberg@crocker.com>
Re: Noob threading question <aukjan@gmail.com>
Re: Noob threading question <slinberg@crocker.com>
Re: Noob threading question <benmorrow@tiscali.co.uk>
Re: perl + regex bug? <CSB001@gmail.com>
Re: Questions about (non-blocking) sockets <benmorrow@tiscali.co.uk>
Re: RExp matchs many times,how can i get the matched co <benmorrow@tiscali.co.uk>
Re: Semantics of threads <blgl@stacken.kth.se>
Re: Use MSXML in perl without registration <benmorrow@tiscali.co.uk>
Re: using session managment in perl rajeev.networld@gmail.com
Re: using session managment in perl narra.madan@gmail.com
Re: using session managment in perl <1usa@llenroc.ude.invalid>
Re: using session managment in perl <noreply@gunnar.cc>
Re: using session managment in perl <1usa@llenroc.ude.invalid>
Re: using session managment in perl <noreply@gunnar.cc>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 25 Jul 2006 10:04:18 -0700
From: "gavino" <bootiack@yahoo.com>
Subject: bop OLTP server, has anyone tried this thing?
Message-Id: <1153847058.155335.278370@h48g2000cwc.googlegroups.com>
http://www.bivio.biz/hm/why-bOP
looks killer
anyone tried it?
------------------------------
Date: 25 Jul 2006 11:00:09 -0700
From: "Jack" <jack_posemsky@yahoo.com>
Subject: counting number of uniques in a multidimensional array column
Message-Id: <1153850408.732411.295060@m79g2000cwm.googlegroups.com>
Hi I have data in a multidim array and DONT want to create another
array representing just 1 column from this multidim array.. I want to
determine the number of uniques, I did this easily with just a regular
array (code below), does anyone know how to do this over just 1 column
of a multidim array (in other words, number of uniques across 1 column
of the multi dim defined as: multidim[0][0],multidim[1][0],
multidim[2][0].... etc)
sort @$columnarray;
@out = grep($_ ne $prev && ($prev = $_, 1), @$columnarray);
if ($#out == -1) { $#out = 0; }
$out = $#out +1; # makes $#out of 0 = 1 so it gets counted !
push @distinctcounts, $out;
Thanks!
Jack
------------------------------
Date: Tue, 25 Jul 2006 15:16:34 +0200
From: Huub <"v.niekerk at hccnet.nl">
Subject: Re: fontsize and/or space between lines
Message-Id: <44c619b4$0$18566$e4fe514c@dreader32.news.xs4all.nl>
> exit;
>
> sub pclstart {
> print OUT "${Esc}E", # reset
> "${Esc}&l0S", # Simplex (1 side per sheet)
> "${Esc}&l2H", # Manual feed
> "${Esc}&l26A", # A4
> "${Esc}&k2G", # LF -> CR+LF
> "${Esc}&l6D", # 6 lpi
> "${Esc}&l0O", # Portrait
> "${Esc}&l0E", # Top Margin (lines)
> "${Esc}&l70F", # Text length (lines)
> "${Esc}&a0L", # left Margin (columns)
> "${Esc}(0N", # Character set: 0N = Latin 1
> "${Esc}(s10v", # 10 point
> "0s", # upright
> "3b", # bold
> "3t", # Courier
> "2Q", # Letter Quality
> "";
> }
Looks like what I need. What is your source of PCL codes? I can only
find some codes of PCL5 online, but that's certainly too new for the 520.
------------------------------
Date: Tue, 25 Jul 2006 16:20:40 +0100
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: fontsize and/or space between lines
Message-Id: <utWdnWVMHK9Tq1vZRVnytg@bt.com>
Huub wrote:
>> exit;
>>
>> sub pclstart {
>> print OUT "${Esc}E", # reset
>> "${Esc}&l0S", # Simplex (1 side per sheet)
>> "${Esc}&l2H", # Manual feed
>> "${Esc}&l26A", # A4
>> "${Esc}&k2G", # LF -> CR+LF
>> "${Esc}&l6D", # 6 lpi
>> "${Esc}&l0O", # Portrait
>> "${Esc}&l0E", # Top Margin (lines)
>> "${Esc}&l70F", # Text length (lines)
>> "${Esc}&a0L", # left Margin (columns)
>> "${Esc}(0N", # Character set: 0N = Latin 1
>> "${Esc}(s10v", # 10 point
>> "0s", # upright
>> "3b", # bold
>> "3t", # Courier
>> "2Q", # Letter Quality
>> "";
>> }
>
>
> Looks like what I need. What is your source of PCL codes?
PCL PJL Quick Reference bpl13205.pdf
PCL 5 Tech Ref bpl13210.pdf
Downloaded from HP's web site. Don't ask me the URL, I used Google and
lots of clicking around HP's web site. <later> The Wikipedia article
referred to below has links to PCL technical reference manuals.
> I can only
> find some codes of PCL5 online, but that's certainly too new for the 520.
It's not that PCL5 is new, its just that the DeskJet range implement a
subset called PCL3. See
http://en.wikipedia.org/wiki/Printer_Command_Language#PCL_levels_1_through_5_overview
This is now completely off-topic for comp.lang.perl so I'm exiting this
discussion here.
------------------------------
Date: Tue, 25 Jul 2006 17:34:31 +0200
From: Huub <"v.niekerk at hccnet.nl">
Subject: Re: fontsize and/or space between lines
Message-Id: <44c63a05$0$18047$e4fe514c@dreader27.news.xs4all.nl>
>
>
> This is now completely off-topic for comp.lang.perl so I'm exiting this
> discussion here.
You're right. Thank you for helping.
------------------------------
Date: 25 Jul 2006 06:48:26 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Handling KILL signal in a perl script
Message-Id: <1153835306.539633.129170@h48g2000cwc.googlegroups.com>
Swarup Baran wrote:
> What i need to handle is if this perl process gets a kill process
> either because of a manual kill or machine reboot etc. I should be
> able to trap it, clean up if any resources and then EXIT.
My understanding is that SIGKILL is very specifically *not* trappable.
Otherwise, it would be possible to write a program that simply cannot
be stopped (short of rebooting the machine). To wit:
$ perl -e'$SIG{$_} = sub { print "Caught SIG$_[0]\n" } for keys %SIG; 1
while 1' &
[1] 18338
$ kill -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL
5) SIGTRAP 6) SIGABRT 7) SIGEMT 8) SIGFPE
9) SIGKILL 10) SIGBUS 11) SIGSEGV 12) SIGSYS
13) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGUSR1
17) SIGUSR2 18) SIGCHLD 19) SIGPWR 20) SIGWINCH
21) SIGURG 22) SIGIO 23) SIGSTOP 24) SIGTSTP
25) SIGCONT 26) SIGTTIN 27) SIGTTOU 28) SIGVTALRM
29) SIGPROF 30) SIGXCPU 31) SIGXFSZ 32) SIGWAITING
33) SIGLWP 34) SIGFREEZE 35) SIGTHAW 36) SIGCANCEL
37) SIGLOST
$ kill -1 18338
Caught SIGHUP
$ kill -2 18338
Caught SIGINT
$ kill -3 18338
Caught SIGQUIT
$ kill -4 18338
Caught SIGILL
$ kill -9 18338
[1]+ Killed perl -e'$SIG{$_} = sub { print "Caught SIG$_[0]\n"
} for keys %SIG; 1 while 1'
$ ps -u plalli
PID TTY TIME CMD
17896 pts/4 0:00 bash
$
> Is it possible to do so? An urgent reply would be appreciated.
That's just plain rude. If you need urgency, you hire a consultant.
If you want free help, you accept it whenever someone feels like giving
it to you.
Paul Lalli
------------------------------
Date: Tue, 25 Jul 2006 15:54:24 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Handling KILL signal in a perl script
Message-Id: <ea5evk.1h8.1@news.isolution.nl>
anno4000@radom.zrz.tu-berlin.de schreef:
> "Urgent" and "Usenet" don't go together.
But they can!
Isn't there a Perl-sponsor-site where people can Pal-Pay there
donations?
http://donate.perl-foundation.org/
Poster should mention the URL of the confirmed payment, to speed up the
answers.
;)
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Tue, 25 Jul 2006 14:11:09 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Handling KILL signal in a perl script
Message-Id: <Xns980B679D29325asu1cornelledu@132.236.56.8>
"Paul Lalli" <mritty@gmail.com> wrote in news:1153835306.539633.129170
@h48g2000cwc.googlegroups.com:
> Swarup Baran wrote:
>> What i need to handle is if this perl process gets a kill process
>> either because of a manual kill or machine reboot etc. I should be
>> able to trap it, clean up if any resources and then EXIT.
>
> My understanding is that SIGKILL is very specifically *not* trappable.
> Otherwise, it would be possible to write a program that simply cannot
> be stopped (short of rebooting the machine).
IIRC, On the *nix machines I have run, issuing the reboot command from the
prompt, results in the OS sending a SIGHUP, followed by a KILL. Presumably,
the SIGHUP is to allow processes to clean up.
I must admit, I am rather ignorant in these areas.
Sinan
------------------------------
Date: Tue, 25 Jul 2006 14:13:19 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Handling KILL signal in a perl script
Message-Id: <Xns980B67FB247DFasu1cornelledu@132.236.56.8>
"Dr.Ruud" <rvtol+news@isolution.nl> wrote in news:ea5evk.1h8.1
@news.isolution.nl:
> anno4000@radom.zrz.tu-berlin.de schreef:
>
>> "Urgent" and "Usenet" don't go together.
>
> But they can!
>
> Isn't there a Perl-sponsor-site where people can Pal-Pay there
> donations?
> http://donate.perl-foundation.org/
>
> Poster should mention the URL of the confirmed payment, to speed up the
> answers.
> ;)
>
As an economist, I very much like that idea.
There would have to be a disclaimer of warranty specifically crafted for
this purpose, to reflect the fact that the donation really is just a
donation, not a fee-for-service. The donation would provide us with a
motivation to help the donor as quickly as we can if we know the answer.
Sinan
------------------------------
Date: 25 Jul 2006 14:36:40 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: Handling KILL signal in a perl script
Message-Id: <slrneccb3o.m92.glennj@smeagol.ncf.ca>
At 2006-07-25 09:48AM, Paul Lalli <mritty@gmail.com> wrote:
> Swarup Baran wrote:
> > What i need to handle is if this perl process gets a kill process
> > either because of a manual kill or machine reboot etc. I should be
> > able to trap it, clean up if any resources and then EXIT.
>
> My understanding is that SIGKILL is very specifically *not* trappable.
Indeed. My Camel book says: "Some signals can be neither trapped nor
ignored, such as the KILL and STOP signals."
--
Glenn Jackman
Ulterior Designer
------------------------------
Date: 25 Jul 2006 15:45:12 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Handling KILL signal in a perl script
Message-Id: <4imsk8F4gtipU1@news.dfncis.de>
A. Sinan Unur <1usa@llenroc.ude.invalid> wrote in comp.lang.perl.misc:
> "Paul Lalli" <mritty@gmail.com> wrote in news:1153835306.539633.129170
> @h48g2000cwc.googlegroups.com:
>
> > Swarup Baran wrote:
> >> What i need to handle is if this perl process gets a kill process
> >> either because of a manual kill or machine reboot etc. I should be
> >> able to trap it, clean up if any resources and then EXIT.
> >
> > My understanding is that SIGKILL is very specifically *not* trappable.
> > Otherwise, it would be possible to write a program that simply cannot
> > be stopped (short of rebooting the machine).
>
> IIRC, On the *nix machines I have run, issuing the reboot command from the
> prompt, results in the OS sending a SIGHUP, followed by a KILL. Presumably,
> the SIGHUP is to allow processes to clean up.
SIGHUP isn't universal, I think, but the procedure is: First send
a catchable signal and wait a bit, then SIGKILL all processes that
haven't got the hint.
Anno
------------------------------
Date: 25 Jul 2006 16:14:55 GMT
From: xhoster@gmail.com
Subject: Re: Handling KILL signal in a perl script
Message-Id: <20060725122122.636$SO@newsreader.com>
xx087+news@ncf.ca wrote:
> At 2006-07-25 09:48AM, Paul Lalli <mritty@gmail.com> wrote:
> > Swarup Baran wrote:
> > > What i need to handle is if this perl process gets a kill process
> > > either because of a manual kill or machine reboot etc. I should be
> > > able to trap it, clean up if any resources and then EXIT.
> >
> > My understanding is that SIGKILL is very specifically *not* trappable.
>
> Indeed. My Camel book says: "Some signals can be neither trapped nor
> ignored, such as the KILL and STOP signals."
I don't think the OP was considering SIGKILL specifically, but rather using
the generic term for any signal generated by (Perl or unix) kill commands,
which by default in fact or not SIGKILL. He would probably want to trap
HUP, INT, and QUIT, and TERM.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Tue, 25 Jul 2006 18:43:46 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Handling KILL signal in a perl script
Message-Id: <pan.2006.07.25.16.43.45.846111@hjp.at>
On Tue, 25 Jul 2006 14:11:09 +0000, A. Sinan Unur wrote:
> "Paul Lalli" <mritty@gmail.com> wrote in news:1153835306.539633.129170
> @h48g2000cwc.googlegroups.com:
>> Swarup Baran wrote:
>>> What i need to handle is if this perl process gets a kill process
>>> either because of a manual kill or machine reboot etc. I should be
>>> able to trap it, clean up if any resources and then EXIT.
>>
>> My understanding is that SIGKILL is very specifically *not* trappable.
>> Otherwise, it would be possible to write a program that simply cannot
>> be stopped (short of rebooting the machine).
>
> IIRC, On the *nix machines I have run, issuing the reboot command from the
> prompt, results in the OS sending a SIGHUP, followed by a KILL. Presumably,
> the SIGHUP is to allow processes to clean up.
I think you mean SIGTERM. SIGHUP is usually used to tell daemons to
reload their configuration.
hp
--
_ | Peter J. Holzer | > Wieso sollte man etwas erfinden was nicht
|_|_) | Sysadmin WSR | > ist?
| | | hjp@hjp.at | Was sonst wäre der Sinn des Erfindens?
__/ | http://www.hjp.at/ | -- P. Einstein u. V. Gringmuth in desd
------------------------------
Date: 25 Jul 2006 09:46:24 -0700
From: adiakin@gmail.com
Subject: HTTP::Response and gzip
Message-Id: <1153845984.365470.194760@m79g2000cwm.googlegroups.com>
Hello, I have a trouble with using HTTP::Response with decoding gzipped
data
lwp-request -H "Accept-Encoding: gzip, deflate" -SUed host.com return
Content-Encoding: gzip,
but when I write
$ua->agent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
$ua->default_header("Accept-Encoding" => "gzip, deflate");
my $response = $ua->get($baseUrl . $aid);
print $response->decoded_content;
I get that $response->decoded_content not defined at all
$response->content_encoding returns gzip
LWP version 5.803
Can anybody help me?
------------------------------
Date: Tue, 25 Jul 2006 14:32:49 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: method connecting outlook express to webmail script
Message-Id: <Xns980B6B494BA78asu1cornelledu@132.236.56.8>
"lloydie" <lloyde@dodo.com.au> wrote in news:1153786756.616277.284160
@p79g2000cwp.googlegroups.com:
>
> A. Sinan Unur wrote:
Please preserve attributions correctly. I did not write any of the words
below. Stating otherwise is lying. That lie gets preserved for ever.
> I dont want to setup a pop3 or smtp server.
> The webmail script connects with mail servers for different email
> addresses and then downloads all the files from each one to be stored
> on the http server....from there they can log in with username and
> password to read their mail....ie Webmail
>
> They have the option of deleting all messages downloaded or leaving
> them on their server for someone else to download and delete at a later
> date.
>
> What I am requiring is the ability for Outlook Express to be able to
> login to the cgi via http protocol and download all messages.
>
> Thanks in advance.
> Lloyd Etheridge
>
>
------------------------------
Date: Tue, 25 Jul 2006 09:34:58 -0400
From: Steve Linberg <slinberg@crocker.com>
Subject: Noob threading question
Message-Id: <slinberg-44AC0B.09345725072006@comcast.dca.giganews.com>
OK, OK, I've never really messed with threads and suddenly have a reason
to. I'm trying to grok it all and get a little sample code going that
carries out some basic mechanics, and I'm having one problem that is
probably very simple but I can't figure it out. Any dope-slaps
appreciated, I've FAQ'd and Googled and Camel'ed for a few hours to no
avail so far.
This sample code launches $num_threads threads via async that just count
to random numbers, and get collected by the parent. That part works
fine, the threads spawn, do their thing, and end, but what I can't get
them to do, with or without locking, is increment a lexical (or global)
variable defined above their scope.
I just want the async process to modify something above it. The original
idea was to have the main process wait until all of the threads were
done before collecting them, and in this case therefore, waiting until
$proc_count reached $num_threads, but $proc_count never gets
incremented. Or, rather, it does, but only in the scope of the thread,
and then it "resets". I've also tried dereferencing $proc_count inside
the thread, but the same thing happens.
I must be doing something dumb or making a dumb and false assumption,
but I can't see it. Argh.
Here's the code:
-------------------------------------------------------
#!/usr/bin/perl -w
use strict;
use Thread qw/async yield/;
my @t = ();
my $num_procs = 3;
my $proc_count = 0;
for my $i (1..$num_procs) {
push @t, async {
my $num = int(rand(100000));
my $j = 0;
do {
$j++;
yield unless $j % 1000;
} until ($j > $num);
print qq(Thread $i is done.\n);
{
lock $proc_count;
$proc_count++;
print qq(proc_count inside thread $i: $proc_count\n);
}
qq(Thread $i counted to $num\n);
};
}
for (@t) {
my $ret = $_->join();
print $ret;
}
print qq(proc_count = $proc_count\n);
-------------------------------------------------------
Here's some sample output:
-------------------------------------------------------
Thread 1 is done.
proc_count inside thread 1: 1
Thread 1 counted to 13191
Thread 3 is done.
proc_count inside thread 3: 1
Thread 2 is done.
proc_count inside thread 2: 1
Thread 2 counted to 70326
Thread 3 counted to 35370
proc_count = 0
-------------------------------------------------------
With or without the "lock" of $proc_count, it's always zero at the end.
What am I doing wrong?
TIA for any ideas.
------------------------------
Date: Tue, 25 Jul 2006 15:51:01 +0200
From: Aukjan van Belkum <aukjan@gmail.com>
Subject: Re: Noob threading question
Message-Id: <6660$44c6219c$c2abfc64$3982@news1.tudelft.nl>
Steve Linberg wrote:
>
> This sample code launches $num_threads threads via async that just count
> to random numbers, and get collected by the parent. That part works
> fine, the threads spawn, do their thing, and end, but what I can't get
> them to do, with or without locking, is increment a lexical (or global)
> variable defined above their scope.
>
This is because you are not using shared threads (use threads::shared).
You should read:
perldoc perlthrtut
perldoc threads::shared
Aukjan.
------------------------------
Date: Tue, 25 Jul 2006 10:07:23 -0400
From: Steve Linberg <slinberg@crocker.com>
Subject: Re: Noob threading question
Message-Id: <slinberg-34EA2A.10072325072006@comcast.dca.giganews.com>
In article <6660$44c6219c$c2abfc64$3982@news1.tudelft.nl>,
Aukjan van Belkum <aukjan@gmail.com> wrote:
> Steve Linberg wrote:
> >
> > This sample code launches $num_threads threads via async that just count
> > to random numbers, and get collected by the parent. That part works
> > fine, the threads spawn, do their thing, and end, but what I can't get
> > them to do, with or without locking, is increment a lexical (or global)
> > variable defined above their scope.
> >
>
> This is because you are not using shared threads (use threads::shared).
>
> You should read:
>
> perldoc perlthrtut
> perldoc threads::shared
Ah! Thanks for the tip.
------------------------------
Date: Tue, 25 Jul 2006 16:15:08 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Noob threading question
Message-Id: <s4php3-na4.ln1@osiris.mauzo.dyndns.org>
Quoth Steve Linberg <slinberg@crocker.com>:
> OK, OK, I've never really messed with threads and suddenly have a reason
> to. I'm trying to grok it all and get a little sample code going that
> carries out some basic mechanics, and I'm having one problem that is
> probably very simple but I can't figure it out. Any dope-slaps
> appreciated, I've FAQ'd and Googled and Camel'ed
The Camel will be no help here. The threading model described there
(5005threads) is obsolete and no longer part of perl. Read perl's own
docs (perlthrtut, first).
> Here's the code:
> -------------------------------------------------------
> #!/usr/bin/perl -w
>
> use strict;
> use Thread qw/async yield/;
use threads qw/yield/;
use threads::shared;
Ben
--
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes, [ Heracles shoots Vulture with arrow. Vulture bursts into ]
'Alcestis') [ flame, and falls out of sight. ] benmorrow@tiscali.co.uk
------------------------------
Date: 25 Jul 2006 08:27:09 -0700
From: "CsB" <CSB001@gmail.com>
Subject: Re: perl + regex bug?
Message-Id: <1153841229.787658.285970@75g2000cwc.googlegroups.com>
You should use caution when assigning variables from a regular
expressions when it is not necessary.
There were several instances in your script where you're using paren to
assign ($1, $2, etc.) but you are not actually using (or even needing)
that data.
I removed all unnecessary variable assignments from your regular
expressions, commented out the "$index--; $index++;" line and all seems
to work well. At least it matches your posting for what good results
should look like.
Since it seems to work well now, the extraneous variable assignments
must have been trampling your data. How the "$index--; $index++;"
controlled that problem, I haven't a clue...
Here are the changes I made to the script you made available via the
web:
30c30
< if ($line =~ /(\s+)(\d+) Orbital
Energy\s+([\-0-9.]+)\s+Occupation\s+([\-0-9.]+)/){
---
> if ( $line =~ /\s+(\d+)\sOrbital\sEnergy\s+([\-0-9.]+)\s+Occupation\s+([\-0-9.]+)/ ) {
32,34c32,34
< if($4 > 0.0){
< $num_protons += 2.0*$4;
< print "Orbital $2 has occupation $4 and energy $3\n";
---
> if($3 > 0.0){
> $num_protons += 2.0*$3;
> print "Orbital $1 has occupation $3 and energy $2\n";
43c43
< if ($line =~ /(\s+)(\d+) Orbital
Energy\s+([\-0-9.]+)\s+Occupation\s+([\-0-9.]+)/){
---
> if ( $line =~ /\s+\d+\sOrbital\sEnergy\s+[\-0-9.]+\s+Occupation\s+[\-0-9.]+/ ) {
53c53
< if ($line =~ /(\s+)(\d+) Orbital
Energy\s+([\-0-9.]+)\s+Occupation\s+([\-0-9.]+)/){
---
> if ( $line =~ /\s+\d+\sOrbital\sEnergy\s+[\-0-9.]+\s+Occupation\s+[\-0-9.]+/ ) {
105,107c105,107
< print "index=$index before: \$index = x'", unpack('H*',
$index), "' ";
< $index--; $index++;
< print "after : \$index = x'", unpack('H*', $index), "'\n";
---
> #print "index=$index before: \$index = x'", unpack('H*', $index), "' ";
> #$index--; $index++;
> #print "after : \$index = x'", unpack('H*', $index), "'\n";
If you should have any questions or comments, let me know.
------------------------------
Date: Tue, 25 Jul 2006 02:18:47 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Questions about (non-blocking) sockets
Message-Id: <n48gp3-rh.ln1@osiris.mauzo.dyndns.org>
Quoth xhoster@gmail.com:
> Holger <spam.trap.never.read@mailinator.com> wrote:
>
> > Should I use sysread instead of recv?
>
> The tradition I've seen is to recv only for UDP. So I would say yes, use
> sysread. I don't know if there is a basis beyond tradition for this.
The only difference between sysread snd recv is that recv allows you to
determine where the packet was from. Since a TCP socket (indeed, a
SOCK_STREAM socket in general) only has one 'other end', there's no need
to use recv. OTOH, there's no real reason not to beyond preserving the
analogy to pipes.
Ben
--
Outside of a dog, a book is a man's best friend.
Inside of a dog, it's too dark to read.
benmorrow@tiscali.co.uk Groucho Marx
------------------------------
Date: Tue, 25 Jul 2006 15:43:09 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: RExp matchs many times,how can i get the matched content?
Message-Id: <t8nhp3-na4.ln1@osiris.mauzo.dyndns.org>
Quoth Aukjan van Belkum <aukjan@gmail.com>:
> firenet wrote:
>
> > print foreach($buf =~/<img>(.*?)<\/img>/sg);
>
> my @array = ($buf =~/<img>(.*?)<\/img>/sg);
>
> > By the program above , i can print the content i wanted;but i want to
> > get it directly.
>
> You are traversing an array with 'foreach', you should have then noticed
> that you could also just assing this array to another array...
It's not an array, it's a list.
Ben
--
The cosmos, at best, is like a rubbish heap scattered at random.
Heraclitus
benmorrow@tiscali.co.uk
------------------------------
Date: Tue, 25 Jul 2006 15:07:14 +0200
From: Bo Lindbergh <blgl@stacken.kth.se>
Subject: Re: Semantics of threads
Message-Id: <ea5522$uot$1@news.su.se>
In article <20060724143437.507$9O@newsreader.com>, xhoster@gmail.com
wrote:
> Bo Lindbergh <blgl@stacken.kth.se> wrote:
> > perldoc perlthrtut says:
> > > Thinking of mixing fork() and threads? Please lie down and wait until
> > > the feeling passes. Be aware that the semantics of fork() vary between
> > > platforms. For example, some UNIX systems copy all the current threads
> > > into the child process, while others only copy the thread that called
> > > fork(). You have been warned!
> >
> > Does this mean that if more than one thread exists, the qx operator,
> > the system function, and the open function in pipe mode all have
> > undefined behaviour?
>
> Excluding bugs, no, the behaviour is not undefined. Those operations are
> not implemented merely as naive forks. They are implemented in different
> ways on different machines, and (attempt to) take care of such issues.
Really? I looked at the source and found no attempts to block other
threads from running between the fork and the exec.
/Bo Lindbergh
------------------------------
Date: Tue, 25 Jul 2006 02:29:18 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Use MSXML in perl without registration
Message-Id: <eo8gp3-rh.ln1@osiris.mauzo.dyndns.org>
Quoth "Sisyphus" <sisyphus1@nomail.afraid.org>:
>
> "Vinay" <shah.vinay@gmail.com> wrote in message
> news:1153782403.410656.21810@75g2000cwc.googlegroups.com...
> > I would like to use MSXML4.0 in my perl script, but not have it
> > register on my machine. The way to do that is explained for C++ at this
> > link:
> > http://www.perfectxml.com/articles/msxml/TipsAugust02.asp
> > I am finding it difficult to port it over to perl. Anyone has any clue
> > for the same? What steps do I need to take?
> >
>
> You could use Inline::CPP to run that code from perl .... but only if you
> have a C++ compiler.
But what would be the point of that? The point is to write Perl :).
Note you could probably make mingw work with some effort... and you can
precompile the module. I would probably *not* use Inline, but just write
an XS module in C++ if I was going down that route.
> Otherwise you can use the Win32::API module.
>
> With Win32::API, I envisage that there's no need to call LoadLibrary,
> GetProcessAddress, and FreeLibrary. Instead you just access the functions
> from the dll directly. (However, I'm not sure if that's correct - given that
> you're dealing with COM objects.)
That is correct insofar as calling Win32 APIs (or: C functions in DLLs
with the __stdcall calling convention) goes: the Win32::API
instantiation process does the LoadLibrary for you. However, you can't
call C++ member functions at all, so you can't translate that code.
The whole concept seems a little dodgy to me: why can't you just
register the component from your script
(system "regsvr32 $ENV{SYSTEMROOT}\\system32\\msxml4.dll"; IIRC; perhaps
in a BEGIN block) and then use it properly with Win32::OLE?
Ben
--
The cosmos, at best, is like a rubbish heap scattered at random.
Heraclitus
benmorrow@tiscali.co.uk
------------------------------
Date: 25 Jul 2006 06:08:51 -0700
From: rajeev.networld@gmail.com
Subject: Re: using session managment in perl
Message-Id: <1153832931.713288.223000@h48g2000cwc.googlegroups.com>
why dont u use cookies?
madan wrote:
> hi all,
> i have created a user screen which when one logs in can access some
> applications and logs out..
> but my problem is when i press back button on my browser i am going
> back to my user page..this should not happen..i must get a error
> message that u are logged out or login screen must appear...
> can any one please guide me how should i approch for such kind of
> conditions..
> thanks in advance
> madan chowdary
------------------------------
Date: 25 Jul 2006 06:37:48 -0700
From: narra.madan@gmail.com
Subject: Re: using session managment in perl
Message-Id: <1153834667.772755.248810@p79g2000cwp.googlegroups.com>
yep...i want to create sessions rether than going for cookies...
------------------------------
Date: Tue, 25 Jul 2006 14:16:27 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: using session managment in perl
Message-Id: <Xns980B68832AB6Dasu1cornelledu@132.236.56.8>
narra.madan@gmail.com wrote in news:1153834667.772755.248810
@p79g2000cwp.googlegroups.com:
> yep...i want to create sessions rether than going for cookies...
What does that even mean?
Please quote an appropriate amount of context.
* Cookies and session management go hand in hand in most cases.
* CGI questions are off-topic in this newsgroup. Methods for managing CGI
sessions are independent of the particular language used to implement them,
and should be discussed in a CGI group.
* On the other hand, if you have some Perl code that is, say, using
CGI::Session, and is not behaving as you expect, then by all means, ask a
specific question, *AFTER* reading the posting guidelines for this group.
Sinan
------------------------------
Date: Tue, 25 Jul 2006 18:21:42 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: using session managment in perl
Message-Id: <4imuqmF4gnj6U1@individual.net>
A. Sinan Unur wrote:
> * CGI questions are off-topic in this newsgroup.
Only if they have no Perl content.
> Methods for managing CGI
> sessions are independent of the particular language used to implement them,
> and should be discussed in a CGI group.
How to do it in Perl is well as on-topic here as are e.g.
- how to send emails using Perl,
- how to access a database using Perl, or
- how to parse a text file using Perl.
> * On the other hand, if you have some Perl code that is, say, using
> CGI::Session, and is not behaving as you expect, then by all means, ask a
> specific question, *AFTER* reading the posting guidelines for this group.
Precisely.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 25 Jul 2006 17:14:23 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: using session managment in perl
Message-Id: <Xns980B86AF1B02asu1cornelledu@132.236.56.8>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in
news:4imuqmF4gnj6U1@individual.net:
> A. Sinan Unur wrote:
>> * CGI questions are off-topic in this newsgroup.
>
> Only if they have no Perl content.
There was no Perl content in the OP:
http://groups.google.com/group/comp.lang.perl.misc/msg/c81bcc45d6684b5b
Sinan
------------------------------
Date: Tue, 25 Jul 2006 19:38:28 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: using session managment in perl
Message-Id: <4in3alF4clkvU1@individual.net>
A. Sinan Unur wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in
> news:4imuqmF4gnj6U1@individual.net:
>>A. Sinan Unur wrote:
>>>
>>>* CGI questions are off-topic in this newsgroup.
>>
>>Only if they have no Perl content.
>
> There was no Perl content in the OP:
>
> http://groups.google.com/group/comp.lang.perl.misc/msg/c81bcc45d6684b5b
True, but that does not make the above unqualified statement correct.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
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 9522
***************************************