[29548] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 792 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 24 21:09:46 2007

Date: Fri, 24 Aug 2007 18:09:13 -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, 24 Aug 2007     Volume: 11 Number: 792

Today's topics:
    Re: Efficiently de-duping an array <rvtol+news@isolution.nl>
    Re: FAQ 6.16 How do I efficiently match many regular ex <allergic-to-spam@no-spam-allowed.org>
    Re: How safe is $0? <bill@ts1000.us>
    Re: How to install WIN32::CGI on ActiveState Perl insta <sisyphus1@nomail.afraid.org>
    Re: ISO: What is the "best practice" for getting error  <jgibson@mail.arc.nasa.gov>
    Re: ISO: What is the "best practice" for getting error  xhoster@gmail.com
    Re: ISO: What is the "best practice" for getting error  xhoster@gmail.com
        perhaps you forgot to load "URI"? <jorg_reyes@hotmail.com>
    Re: problems with LWP & HTTP <mail@bymouth.com>
    Re: push into hashs of arrays <klaus03@gmail.com>
        quoting philosophy <larry.grant.dc@gmail.com>
    Re: quoting philosophy <bik.mido@tiscalinet.it>
    Re: quoting philosophy <g_m@remove-comcast.net>
    Re: quoting philosophy <rvtol+news@isolution.nl>
    Re: quoting philosophy xhoster@gmail.com
    Re: Regular expression use <xmikedavis@gmail.com>
        socket error <jismagic@gmail.com>
    Re: socket error xhoster@gmail.com
    Re: Split strings  chinmoy.chittaranjan@gmail.com
    Re: Split strings <rvtol+news@isolution.nl>
    Re: Starting with SOAP <scobloke2@infotop.co.uk>
    Re: Threaded Perl Processes Going to Sleep Simultaneous <Roycedot@gmail.com>
    Re: Threaded Perl Processes Going to Sleep Simultaneous xhoster@gmail.com
    Re: Threaded Perl Processes Going to Sleep Simultaneous <Roycedot@gmail.com>
        Using DBD::pNET or DBD::Proxy with DBD::Oracle <allergic-to-spam@no-spam-allowed.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 24 Aug 2007 20:43:50 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Efficiently de-duping an array
Message-Id: <fang6h.1hg.1@news.isolution.nl>

Dan Otterburn schreef:

> We learn by our mistakes - and I have made plenty here - so, if it is
> any consolation, I have learnt more than I would have done had I found
> the FAQ in the first place. I will endeavour not to make the same
> mistakes twice!

  don't_be_too_embarassed() if $seen($mistake}++;

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Sat, 25 Aug 2007 01:25:08 +0200 (CEST)
From: Jim Cochrane <allergic-to-spam@no-spam-allowed.org>
Subject: Re: FAQ 6.16 How do I efficiently match many regular expressions at once?
Message-Id: <slrnfcuq6i.f50.allergic-to-spam@no-spam-allowed.org>

On 2007-08-17, Michele Dondi <bik.mido@tiscalinet.it> wrote:
> On Fri, 17 Aug 2007 21:40:06 +0200 (CEST), Jim Cochrane
><allergic-to-spam@no-spam-allowed.org> wrote:
>
>>Yes, I thought it was something like that.  Too bad there are no
>>lint-like tools to help keep documentation consistent.  [English is a
>>language - shouldn't we be able to compile it? :=)]
>
> I don't know, but I suppose that the following quotation, however
> harsh, may shed some light and induce a meditation:
>
>: The problem with defending the purity of the English language is that
>: English is about as pure as a cribhouse whore.  We don't just borrow
>: words; on occasion, English has pursued other languages down alleyways
>: to beat them unconscious and rifle their pockets for new vocabulary.
>: - James Nicoll
>
>
> Michele

(Sorry, late response; I've been busy.)

That's a great quote.  I hadn't heard of James Nicoll, but he sounds
like quite an interesting and creative character -

http://en.wikipedia.org/wiki/James_D._Nicoll

(Sorry for the OTP)

-- 



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

Date: Fri, 24 Aug 2007 13:47:55 -0700
From:  Bill H <bill@ts1000.us>
Subject: Re: How safe is $0?
Message-Id: <1187988475.390992.218320@l22g2000prc.googlegroups.com>

On Aug 24, 1:28 pm, an...@alumni.caltech.edu (Gary E. Ansok) wrote:
> In article <1187949633.488453.272...@q3g2000prf.googlegroups.com>,
> Bill H  <b...@ts1000.us> wrote:
>
> >If I use $0 to determine the name of the script that is running is it
> >safe to assume that it will not change within the script (as long as I
> >never intentionally try to change it? The way I am using it is setting
> >certain messages based on the the script. Somthing like this:
>
> >if ($0 eq "foo.pl")
> >{
> >$blah = "foo";
> >}
> >if ($0 eq "bar.pl")
> >{
> >$blah = "bar";
> >}
>
> Not directly related to your question, but bear in mind that it is not
> specified whether $0 will be just the script name, or might contain
> directory path information.  In my experience, Unix-based systems usually
> have $0 containing whatever was entered by the user (just "foo.pl" if the
> script was found through $PATH, or the path entered by the user), and
> Windows has $0 contain a full path to the script.  So you might want
> to use basename() (from File::Basename) on the contents of $0.
>
> Also, knowlegable users can set $0 to anything they want to at the time
> that your script is started, before any of your code runs.  So if this
> is critical to your script's functionality (or security), think twice.
>
> That said, I think it pretty safe to say that no Perl core or widely-used
> modules are likely to change $0 at all.
>
> Gary Ansok
> --
> Any attempt to brew coffee with a teapot should result in the error code
> "418 I'm a teapot". The resulting entity body MAY be short and stout.
>         -- RFC 2324, Hyper Text Coffee Pot Control Protocol (HTCPCP)/1.0

Gary

I learned this today. On my windows system testing $0 was great, on
the linux webserver, it was the full path. So the easiest thing was to
just to use index and cover both bases (ie index($0,"for.pl")).




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

Date: Sat, 25 Aug 2007 05:05:17 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: How to install WIN32::CGI on ActiveState Perl instaled on Windows XP?
Message-Id: <46cf2be9$0$13999$afc38c87@news.optusnet.com.au>


"Bond" <Bond@james.bond> wrote in message 
news:fam25p$no8$1@ss408.t-com.hr...
> How to install WIN32::CGI on ActiveState Perl instaled on Windows XP?

Does such a module exist ? I couldn't find it anywhere.

Cheers,
Rob 



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

Date: Fri, 24 Aug 2007 12:50:03 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: ISO: What is the "best practice" for getting error info from a pipeline?
Message-Id: <240820071250038920%jgibson@mail.arc.nasa.gov>

In article <20070824121510.732$L5@newsreader.com>, <xhoster@gmail.com>
wrote:

> Jim Gibson <jgibson@mail.arc.nasa.gov> wrote:
> >
> > IO::Handle::close calls close() on the pipe and returns the value
> > returned by close(). From 'perldoc close':
> >
> > "If the file handle came from a piped open, "close" will addi-
> > tionally return false if one of the other system calls involved
> > fails, or if the program exits with non-zero status.
> 
> But the handle here is *not* derived from a pipe open.  It is derived
> from IO::Pipe->new() .  So that part of the docs do not apply.

So you don't believe the documentation of IO::Handle that says:

"METHODS

   See perlfunc for complete descriptions of each of the following sup-
   ported "IO::Handle" methods, which are just front ends for the corre-
   sponding built-in functions:

       $io->close
       ..."

-- 
Jim Gibson

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: 24 Aug 2007 21:19:11 GMT
From: xhoster@gmail.com
Subject: Re: ISO: What is the "best practice" for getting error info from a pipeline?
Message-Id: <20070824171913.858$hX@newsreader.com>

Jim Gibson <jgibson@mail.arc.nasa.gov> wrote:
> In article <20070824121510.732$L5@newsreader.com>, <xhoster@gmail.com>
> wrote:
>
> > Jim Gibson <jgibson@mail.arc.nasa.gov> wrote:
> > >
> > > IO::Handle::close calls close() on the pipe and returns the value
> > > returned by close(). From 'perldoc close':
> > >
> > > "If the file handle came from a piped open, "close" will addi-
> > > tionally return false if one of the other system calls involved
> > > fails, or if the program exits with non-zero status.
> >
> > But the handle here is *not* derived from a pipe open.  It is derived
> > from IO::Pipe->new() .  So that part of the docs do not apply.
>
> So you don't believe the documentation of IO::Handle that says:
>
> "METHODS
>
>    See perlfunc for complete descriptions of each of the following sup-
>    ported "IO::Handle" methods, which are just front ends for the corre-
>    sponding built-in functions:
>
>        $io->close
>        ..."

Yep, I believe it.  And once you see the docs for close in perlfunc,
what you have still isn't from a piped open and thus the part of the doc
that says "If the file handle came from a piped open" still doesn't
apply.

But don't take me word for it, feel free to test it. (IO::Pipe version
1.123)

$ perl -lwe 'use IO::Pipe; my $pipe=IO::Pipe->new(); \
       $pipe->writer("cat -asdf >& cat"); print $pipe "lkj"; \
       print close $pipe; warn "$?";'
1
0 at -e line 1.

So the one means the close succeeded, the $? is the exit code and
also allegedly indicates success.  But if you look in "cat", you will
see it doesn't contain "lkj" but rather has complaints about bad options.


$ perl -lwe 'open my $pipe, "|cat -asdf >& cat"; print $pipe "lkj"; \
           print close $pipe; warn "$?";'

256 at -e line 1.

So the empty line means the close failed, and $? was set appropriately.


Xho

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


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

Date: 24 Aug 2007 23:38:13 GMT
From: xhoster@gmail.com
Subject: Re: ISO: What is the "best practice" for getting error info from a pipeline?
Message-Id: <20070824193816.435$6w@newsreader.com>

"Larry W. Virden" <lvirden@gmail.com> wrote:


> use strict;
> use IO::Pipe;
>
> my $send = IO::Pipe->new();
> $send->writer("/tmp/displayerr.ksh", 'REQUEST');
> $send->print("This is just some output\n");
> print "error 1 returns " . $send->error() . "\n";
> if ($send->error()) {
>         print "io error\n";
> }
> print "close returns " . $send->close() . "\n";

print "but \$? was $? (exit status " . ($?>>8). ")\n";

> print "error 2 returns " . $send->error() . "\n";

Even thought the close is allegedly successful, it still
sets $?, as long as you do '$send->close()' rather than
"close $send".  However, I would consider this behavior to
be quite fragile and would be reluctant to depend on it except
as a last resort.

Xho

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


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

Date: Fri, 24 Aug 2007 16:35:41 -0700
From:  Jorge Reyes <jorg_reyes@hotmail.com>
Subject: perhaps you forgot to load "URI"?
Message-Id: <1187998541.095137.12540@z24g2000prh.googlegroups.com>

hi, so now this is weird, first of all i want to say that this script
runs ok in windows xp, linux ubuntu 7.04 and the problem is when i put
this into a unix machine this is the code:

use SOAP::Lite qw (debug trace);

$log_folder = "logwsremedyclient";
$fechaActual = &fechaHoraFormatoDb(time);
$log_name = substr($fechaActual,0,10);
$log_name =~ tr/-//d;
$log_name = $log_name.".log";
#print $log_folder.$log_name."\n";

if (! -d $log_folder ) {
        #no existe
        mkdir($log_folder) || die "ERROR AL INTENTAR CREAR EL
DIRECTORIO: $log_folder";
}

$numArgs = $#ARGV + 1;
if($numArgs < 6) {
        $header = "INICIO.- $fechaActual\n";
        $content = "ERROR: SE RECIBIERON $numArgs COMMAND-LINE
ARGUMENTS, IMPOSIBLE CONTINUAR SE NECESITAN 6\n";
        $footer = "FINAL.- $fechaActual\n\n";
        open(WSLOG,">> $log_folder/$log_name")  || die "ERROR AL
INTENTAR ABRIR EL LOG: $log_folder/$log_name";
        print WSLOG $header.$content.$footer;
        close(WSLOG);
        exit(1);
}

my $estado = $ARGV[0];
my $remedyid = $ARGV[1];
my $usumod = $ARGV[2];
my $historial = $ARGV[3];
my $telcontacto = $ARGV[4];
my $usua_afec = $ARGV[5];

#my $estado = 'CERRADO';
#my $remedyid = 263;
#my $usumod = 'JORGE REYES';
#my $historial = 'PRUEBA 2 DESDE PERL HACIA WS EN JAVA';
#my $telcontacto = '5530304857';
#my $usua_afec = 8;

my $soap = SOAP::Lite
        -> uri('http://serviciosweb.remedyweb.iusacell.com')
        -> proxy('http://10.199.11.69:9080/remedyWeb/services/
ActualizaStatus')
        -> on_action( sub { join '', @_} );
my $s = $soap->paramRemedy(
        SOAP::Data->name('estado')->type(string => $estado),
        SOAP::Data->name('remedyid')->type(long => $remedyid),
        SOAP::Data->name('usumod')->type(string => $usumod),
        SOAP::Data->name('historial')->type(string => $historial),
        SOAP::Data->name('telcontacto')->type(string => $telcontacto),
        SOAP::Data->name('usua_afec')->type(int => $usua_afec));
unless ($s->fault) {
        #print $s->result();
        $header = "INICIO.- $fechaActual\n";
        $content = "estado: $ARGV[0]\nremedyid: $ARGV[1]\nusumod:
$ARGV[2]\nhistorial: $ARGV[3]\ntelcontacto: $ARGV[4]\nusua_afec:
$ARGV[5]\nRESPUESTA: ".$s->result()."\n";
        $footer = "FINAL.- $fechaActual\n\n";
        open(WSLOG,">> $log_folder/$log_name")  || die "ERROR AL
INTENTAR ABRIR EL LOG: $log_folder/$log_name";
        print WSLOG $header.$content.$footer;
        close(WSLOG);

}
else {
        #print "\n\nError\n";
        #print join ', ',
        #$s->faultcode,
        #$s->faultstring,
        #$s->faultdetail,"\n\n";
        $header = "INICIO.- $fechaActual\n";
        $content = "ERROR: ".join ', ',$s->faultcode, $s->faultstring,
$s->faultdetail, "\n";
        $footer = "FINAL.- $fechaActual\n\n";
        open(WSLOG,">> $log_folder/$log_name")  || die "ERROR AL
INTENTAR ABRIR EL LOG: $log_folder/$log_name";
        print WSLOG $header.$content.$footer;
        close(WSLOG);
}


sub fechaHoraFormatoDb {
        # $_[0] = Unix time, or POSIX time
        # NOTA: Al llamar a esta subrutina no poner comillas el
parametro de $_[0]
        # Ej: &fechaHoraFormatoDb(time) o &fechaHoraFormatoDb($valor)
        my ($segundo,$minuto,$hora,$dia,$mes,$anio,$diaSemana) =
(localtime($_[0]))[0,1,2,3,4,5,6];
        my @mesesNum =
('01','02','03','04','05','06','07','08','09','10','11','12');
        my $tiempo = sprintf("%02d:%02d:%02d",$hora,$minuto,$segundo);
        $anio = $anio + 1900;
        if($dia < 10) {
        $dia="0$dia";
        }
        $tiempoObtenido="$anio-$mesesNum[$mes]-$dia $tiempo";
        return $tiempoObtenido;
}

and then when i executed it the answer is:

SOAP::Lite::call: ()
SOAP::Serializer::envelope: ()
Can't locate object method "new" via package "URI" (perhaps you forgot
to load "URI"?) at /usr/perl5/5.6.1/lib/HTTP/Request.pm line 82.

so any idea suggestions or something useful, sorry but i am desperate
jeje... thanks for advanced



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

Date: Fri, 24 Aug 2007 13:54:43 -0700
From:  stephenc <mail@bymouth.com>
Subject: Re: problems with LWP & HTTP
Message-Id: <1187988883.865708.250740@l22g2000prc.googlegroups.com>

On Aug 16, 1:07 am, "Petr Vileta" <sto...@practisoft.cz> wrote:
> stephenc wrote:
> > OK, this code does compile but I have had to change my user id and
> > pasword for obvious reasons:
>
> > use LWP;
> > use Crypt::SSLeay;
> > use HTTP::Request::Common qw(POST);
>
> > my $ua = new LWP::UserAgent;
>
> > my $req = POST 'https://www.secure.cardlink.com.au/Cardlink/
> > LoginServlet',
>
> Try this script. Maybe this can help you to find reason ;-)
>
> #!/usr/bin/perl -w
> use strict;
> use LWP::UserAgent;
>
> print "Content-type: text/html\n\n";
>
> # don't forget to set right values in next line
> my $params='UserID=abc&Password=abc&Submit=Submit';
>
> my $ua = LWP::UserAgent->new(timeout => 30);
> my $req = HTTP::Request->new(POST =>
> 'https://www.secure.cardlink.com.au/Cardlink/LoginServlet');
> $req->headers->header(Accept => '*/*');
> $req->headers->header(Connection => "Keep-Alive");
> $req->headers->header(Accept_language => "en");
> $req->headers->header(Cache_Control => 'no-cache');
> $req->content_type('application/x-www-form-urlencoded');
> $req->content($params);
> my $res = $ua->request($req);
> if ($res->code != 200)
>  {
>  print "<html><body>Error: ",$res->code," ",$res->message,"<br>",
>   "Response:<br>",
>   "<nobr>&nbsp;Message:&nbsp;$res->{_msg}</nobr><br>",
>   "<nobr>&nbsp;Protocol:&nbsp;$res->{_protocol}</nobr><br>",
>   "<nobr>&nbsp;Return code: $res->{_rc}</nobr><br>",
>   "Response headers:<br>";
>  foreach (sort keys %{$res->{_headers}})
>   {
>   print "<nobr>&nbsp;$_:&nbsp;$res->{_headers}->{$_}</nobr><br>";
>   }
>  print "<br><br>Page Content:<br>$res->content" if($res->content);
>  print "</body></html>";
>  }
> else
>  {
>  print $res->content;
>  }
>
> --
>
> Petr Vileta, Czech republic
> (My server rejects all messages from Yahoo and Hotmail. Send me your mail
> from another non-spammer site please.)

I  tried this (having changed the parameters but it still hung at this
point:


C:\eventOrganizerV2>d.pl
Content-type: text/html

I tried enabling cookies and opening the preceding page to see if I
pickedany up but it didn't help.

Any further suggestions?



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

Date: Fri, 24 Aug 2007 11:33:26 -0700
From:  Klaus <klaus03@gmail.com>
Subject: Re: push into hashs of arrays
Message-Id: <1187980406.563713.228650@z24g2000prh.googlegroups.com>

On Aug 24, 8:00 pm, Jie <jiehuang...@gmail.com> wrote:
> I have a STUDENT_CLASS_FILE like below, basically a two column table
> student1 class_A
> student2 class_A
> student3 class_B
> ....
>
> now if someone gives me a class list, how I could generate the student
> lists for each class?

Could be homework, but I'll give you the benefit of the doubt.

> I thought that I could use a code like below, but I don't know exactly
> what to write for the third row...

 ...of your perl program ?

Ok, but then you'd probably better say the third *line*.

> while (STUDENT_CLASS_FILE) {

What is "STUDENT_CLASS_FILE" ? If it is a file handle, you probably
want to say while (<STUDENT_CLASS_FILE>) instead. And, if I may drop a
suggestion here, it is generally recommended to use lexical file
handles like so:

open my $STUDENT_CLASS_FILE, '<', 'data.txt' or die "Error $!";
while (<$STUDENT_CLASS_FILE>) {

>  ($student, $class) = split

you are missing the parameters for split (see perldoc -f split) and
the semicolon at the end of the line.

>  push @{$STUDENT_CLASS_HASH{$class}} ,$student ????????????

remove the question marks and put a semicolon at the end of the line.

> }
>
> foreach $class (@CLASS_LIST) {
>  $students = join ("," @{$STUDENT_CLASS_HASH{$class}} )

semicolon at the end of the line is
missing.......................................

>  print "$classs, $student\n"
> }

--
Klaus



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

Date: Fri, 24 Aug 2007 18:11:56 -0000
From:  Larry <larry.grant.dc@gmail.com>
Subject: quoting philosophy
Message-Id: <1187979116.671140.303580@q4g2000prc.googlegroups.com>

Perl gurus... What's your "philosophy" about single vs. double quotes,
where you're not using any interpolation.

i.e.

$x = 'foo';

or

$x = "foo";

I know there are weightier issues to spend time worrying about
but... :)



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

Date: Fri, 24 Aug 2007 20:29:16 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: quoting philosophy
Message-Id: <np8uc352n8e2ab1tj9pdqsb4bv4l2tlqe2@4ax.com>

On Fri, 24 Aug 2007 18:11:56 -0000, Larry <larry.grant.dc@gmail.com>
wrote:

>Perl gurus... What's your "philosophy" about single vs. double quotes,
>where you're not using any interpolation.

When I don't use interpolation or escapes, then I prefer single
quotes. But it still all depend on the context. In some specific
situations I use alternate delimiters both when I need interpolation
and when I don't.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 24 Aug 2007 17:49:02 -0400
From: "~greg" <g_m@remove-comcast.net>
Subject: Re: quoting philosophy
Message-Id: <XtOdnaGpB9qyzFLbnZ2dnUVZ_sGvnZ2d@comcast.com>


"Larry" > wrote ...
> Perl gurus... What's your "philosophy" about
> ... quotes

Philosophy about quotes? ...

-----------------------------------------------------------------------
(source: --  http://www.whimsy.org.uk/quoteindex.html )
-----------------------------------------------------------------------

Quotation, n.:  The act of repeating erroneously the words of another.
The words erroneously repeated.
~ Ambrose Bierce, The Devil's Dictionary

Quotations will tell the full measure of meaning,
if you have enough of them.
~ James Murray

The art of quotation requires more delicacy in the practice than those conceive
who can see nothing more in a quotation than an extract.
~ Benjamin Disraeli

It is my belief that nearly any invented quotation,
played with confidence, stands a good chance to deceive.
~ Mark Twain, Following the Equator

I hate quotations.  Tell me what you know.
~ Ralph Waldo Emerson, Journals and Miscellaneous Notebooks, May 1849

Quotes are nothing but inspiration for the uninspired.
~ Richard Kemph

The ability to quote is a serviceable substitute for wit.
~ Somerset Maugham

Have you ever observed that we pay much more attention to a wise passage
when it is quoted, than when we read it in the original author?
~ Philip G. Hamerton

The power of quotation is as dreadful a weapon
as any which the human intellect can forge.
~ John Jay Chapman

It is the little writer rather than the great writer who seems never to quote,
and the reason is that he is never really doing anything else.
~ Havelock Ellis

By necessity, by proclivity, and by delight, we all quote.
~ Ralph Waldo Emerson

~and~

There is a very fine line between "hobby" and "mental illness."
 ~ Dave Barry, "Things That It Took Me 50 Years to Learn"








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

Date: Sat, 25 Aug 2007 00:26:40 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: quoting philosophy
Message-Id: <fant46.1ds.1@news.isolution.nl>

Larry schreef:

> Perl gurus... What's your "philosophy" about single vs. double quotes,
> where you're not using any interpolation. i.e.
>     $x = 'foo';
> or
>     $x = "foo";

The compiler will quickly decide that no interpolation is possible for
"foo", so will treat it the same as 'foo'. So towards the compiler there
is no difference, until you write something like "test@example.com" or
qq{test@example.com} or

    $test = <<EOT;
test@example.com
EOT

In practice, the '' format is a contract that no interpolation/expansion
is meant nor will happen, and the "" format means that you have to read
much more carefully.

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: 25 Aug 2007 00:10:14 GMT
From: xhoster@gmail.com
Subject: Re: quoting philosophy
Message-Id: <20070824201018.024$Kc@newsreader.com>

Larry <larry.grant.dc@gmail.com> wrote:
> Perl gurus... What's your "philosophy" about single vs. double quotes,
> where you're not using any interpolation.
>
> i.e.
>
> $x = 'foo';
>
> or
>
> $x = "foo";

If you have a string literal which is simple, what is more likely: that it
will need to be changed to include an interpolation or newline or tab at
some point in the future; or that it will need to be changed to include
a literal @ or $ or \ in the future?  I find that the former is far
more common than the latter, so now I tend to use double quotes rather
than single quotes for simple string literals.  The main exception is
small literal hash keys (but now I tend not to quote them at all).

Xho

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


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

Date: Fri, 24 Aug 2007 21:06:21 -0000
From:  garage <xmikedavis@gmail.com>
Subject: Re: Regular expression use
Message-Id: <1187989581.752849.23840@m37g2000prh.googlegroups.com>

I work in print (book) production and i regularly use regular
expressions to parse .eps (encapsulated postscript) files for
incorrect specifications (8-bit vs. ASCII, etc), bad fonts and the
like.  Just to ensure that what's been submitted to me will actually
end up on the page.



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

Date: Fri, 24 Aug 2007 22:51:46 -0000
From:  jis <jismagic@gmail.com>
Subject: socket error
Message-Id: <1187995906.525526.85810@r23g2000prd.googlegroups.com>

use IO::Socket;

 my $sock = new IO::Socket::INET (
                                  PeerAddr => '144.xxx.31.142',
                                  PeerPort => '9000',
                                  Proto => 'tcp',
                                 );
 die "Could not create socket: $!\n" unless $sock;
 print $sock "Hello Andy!\n";
 close($sock);

The ip address belongs to a another system in the netrwork.

But i get an error "Could not create socket: Unknown error"

If i give my ip address if my own system i do not have any problems..
Is it because firewall stops me or ....

Pls help.

Cheers,
Jis



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

Date: 25 Aug 2007 00:16:43 GMT
From: xhoster@gmail.com
Subject: Re: socket error
Message-Id: <20070824201646.841$MD@newsreader.com>

jis <jismagic@gmail.com> wrote:
> use IO::Socket;
>
>  my $sock = new IO::Socket::INET (
>                                   PeerAddr => '144.xxx.31.142',
>                                   PeerPort => '9000',
>                                   Proto => 'tcp',
>                                  );
>  die "Could not create socket: $!\n" unless $sock;
>  print $sock "Hello Andy!\n";
>  close($sock);
>
> The ip address belongs to a another system in the netrwork.
>
> But i get an error "Could not create socket: Unknown error"

Try looking in $@ instead of or in addition to $!

Xho

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


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

Date: Fri, 24 Aug 2007 18:59:10 -0000
From:  chinmoy.chittaranjan@gmail.com
Subject: Re: Split strings
Message-Id: <1187981950.772988.268480@q5g2000prf.googlegroups.com>

On Aug 24, 2:56 am, Dan Otterburn <dan.otterb...@gmail.com> wrote:
> On 24 Aug, 09:29, chinmoy.chittaran...@gmail.com wrote:
>
> > E:\user\chinmoy\bsp
>
> That looks like a Windows file path. If you are trying to parse file
> paths you might want to look at File::Basename core module.

Some path is there . So actually i am trying to get the last word from
this path .like from that full string path only bsp word i want .



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

Date: Sat, 25 Aug 2007 00:30:07 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Split strings
Message-Id: <fantdk.1mk.1@news.isolution.nl>

chinmoy.chittaranjan@gmail.com schreef:
> Dan Otterburn:
>> chinmoy:

>>> E:\user\chinmoy\bsp
>>
>> That looks like a Windows file path. If you are trying to parse file
>> paths you might want to look at File::Basename core module.
>
> Some path is there . So actually i am trying to get the last word from
> this path .like from that full string path only bsp word i want .

Why do you keep calling it a "word"? What if the filename is
"C:\Program Files\Acme\READ ME FIRST!!!.txt"?

Use a module, like the already mentioned File::Basename.

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Fri, 24 Aug 2007 22:39:40 +0100
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: Starting with SOAP
Message-Id: <OKKdnScsbOWGzVLbnZ2dnUVZ8vudnZ2d@bt.com>

Amer Neely wrote:
> (thanks to the examples provided by xhoster I believe)

Sigh.

:-)


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

Date: Fri, 24 Aug 2007 19:13:01 -0000
From:  Roycedot <Roycedot@gmail.com>
Subject: Re: Threaded Perl Processes Going to Sleep Simultaneously??? Why?
Message-Id: <1187982781.001272.93120@l22g2000prc.googlegroups.com>

On Aug 24, 1:01 pm, xhos...@gmail.com wrote:
> "Royce...@gmail.com" <Royce...@gmail.com> wrote:
> > Hi,
>
> > I've written a Perl program that creates 10 threads (ithreads) and
> > each thread operates on a different part of a large array.  The large
> > array is just a file read in before the threads are started.
>
> Either this large array is marked shared, and thus you are sharing
> a large array, or you it is not marked shared and thus you are replicating
> a large array 10 times.  I don't know which one of these prospects
> is less enticing.

First off, thank you for the reply.  The array is duplicated for each
thread (not using shared).

> > Each
> > thread processes a chunk of the array and then prints the processed
> > output to a shared text file.
>
> > I run different instances of this Perl program so I can process
> > multiple files,
>
> So you have multiple processes, each of which has 10 threads?

Yes, I have two processes - and each uses 10 threads

>
> > but oddly all instances of this program go to sleep at
> > the same time and then come back at the same time.  At least this is
> > what I see with the 'top' command in Linux.
>
> I don't see why that is surprising.  Say there is some resource that all of
> your jobs are trying to use, the hard drive, the network, whatever.  If
> that resource freezes up temporarily (say, because 4 processes with 10
> threads for a total of 40 things are beating it over the head), all your
> jobs will block waiting for it to come back.
>
> Xho

So I have two processes - each with 10 threads - it seems unreasonable
that all 20 threads would try to access the hard drive at the same
time and thus all 20 are blocking.  Once the threads are started, the
threads process a block of the array, print to a file, and then come
back for the next unprocessed block.  Since the time it takes to
process a block is not going to be the same each time and the time to
process the block is at least as long as printing the output, there
should be no reason all threads are trying to print to the file at the
same time. I would think if at least 1 thread was not trying to write
to the hard drive, the process that owns that thread would be running
when I 'top'

This could be a machine-specific problem.  I ran the same two
processes on another box and they cranked along nicely once I setup
their nice levels appropriately.

I suspect it could be because I'm running a 32-bit SMP linux on a 64-
bit dual-core machine...I'm going to install the 64-bit version this
weekend as I was planning on doing it anyways.

I appreciate the response.  But, since the processes work fine on
another machine, I think this post continuing on a perl forum may be
unnecessary.

Thanks again.



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

Date: 24 Aug 2007 22:45:29 GMT
From: xhoster@gmail.com
Subject: Re: Threaded Perl Processes Going to Sleep Simultaneously??? Why?
Message-Id: <20070824184532.418$Qe@newsreader.com>

Roycedot <Roycedot@gmail.com> wrote:
> On Aug 24, 1:01 pm, xhos...@gmail.com wrote:
> >
> > I don't see why that is surprising.  Say there is some resource that
> > all of your jobs are trying to use, the hard drive, the network,
> > whatever.  If that resource freezes up temporarily (say, because 4
> > processes with 10 threads for a total of 40 things are beating it over
> > the head), all your jobs will block waiting for it to come back.
> >
> > Xho
>
> So I have two processes - each with 10 threads - it seems unreasonable
> that all 20 threads would try to access the hard drive at the same
> time and thus all 20 are blocking.  Once the threads are started, the
> threads process a block of the array, print to a file, and then come
> back for the next unprocessed block.

What kind of processing is being done to each block?  If it were CPU bound
then it seems unlikely you would want want to run this many in parallel in
the first place (Unless you are one of the very rare very lucky people
posting here have 16+ CPU boxes sitting around).  And if it isn't CPU
bound, then there must be something else that is limiting, and whatever it
is could then make all your jobs stop at the same time.

> Since the time it takes to
> process a block is not going to be the same each time and the time to
> process the block is at least as long as printing the output, there
> should be no reason all threads are trying to print to the file at the
> same time.

This seems unlikely for a simple local partition.  If it something like NFS
though, it could just freeze up for a few seconds (or even minutes, I've
seen before) and all the threads would finish their processing and go to
print, piling up there.  So if they all need to print once every few
seconds, it could easily look like they are stopping at about the same
time.

> I would think if at least 1 thread was not trying to write
> to the hard drive, the process that owns that thread would be running
> when I 'top'

Another thing to consider is swapping.  Does one of the swap processes jump
up in top when the perl processes freeze?

>
> This could be a machine-specific problem.  I ran the same two
> processes on another box and they cranked along nicely once I setup
> their nice levels appropriately.
>
> I suspect it could be because I'm running a 32-bit SMP linux on a 64-
> bit dual-core machine...I'm going to install the 64-bit version this
> weekend as I was planning on doing it anyways.
>
> I appreciate the response.  But, since the processes work fine on
> another machine, I think this post continuing on a perl forum may be
> unnecessary.

If it still could be something specific about the perl implementation, I
would still consider it on-topic.  My next step would probably be to strace
a job and see if the freezings are occurring in a particular system call,
then figuring out what part of perl is issuing that system call.

Xho

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


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

Date: Sat, 25 Aug 2007 00:10:28 -0000
From:  Roycedot <Roycedot@gmail.com>
Subject: Re: Threaded Perl Processes Going to Sleep Simultaneously??? Why?
Message-Id: <1188000628.814663.129530@i38g2000prf.googlegroups.com>

On Aug 24, 6:45 pm, xhos...@gmail.com wrote:
> Roycedot <Royce...@gmail.com> wrote:
> > On Aug 24, 1:01 pm, xhos...@gmail.com wrote:
>
> > > I don't see why that is surprising.  Say there is some resource that
> > > all of your jobs are trying to use, the hard drive, the network,
> > > whatever.  If that resource freezes up temporarily (say, because 4
> > > processes with 10 threads for a total of 40 things are beating it over
> > > the head), all your jobs will block waiting for it to come back.
>
> > > Xho
>
> > So I have two processes - each with 10 threads - it seems unreasonable
> > that all 20 threads would try to access the hard drive at the same
> > time and thus all 20 are blocking.  Once the threads are started, the
> > threads process a block of the array, print to a file, and then come
> > back for the next unprocessed block.
>
> What kind of processing is being done to each block?  If it were CPU bound
> then it seems unlikely you would want want to run this many in parallel in
> the first place (Unless you are one of the very rare very lucky people
> posting here have 16+ CPU boxes sitting around).  And if it isn't CPU
> bound, then there must be something else that is limiting, and whatever it
> is could then make all your jobs stop at the same time.

Each thread takes a string, uses the string to make a request to one
local server, transforms the string into more strings, then makes a
request to a non-local server, then applies some logic to create more
text, and finally writes the output to disk.  CPU is the main
resource, but each process is still taking less than 50% of each of my
CPUs.  I have an Xeon 3.0 Ghz dual-core.

One could argue that there is blocking happening because of the
requests to the non-local server, but, again, the processes don't
sleep when I run on another box with the same # of processes and
threads.

> > Since the time it takes to
> > process a block is not going to be the same each time and the time to
> > process the block is at least as long as printing the output, there
> > should be no reason all threads are trying to print to the file at the
> > same time.
>
> This seems unlikely for a simple local partition.  If it something like NFS
> though, it could just freeze up for a few seconds (or even minutes, I've
> seen before) and all the threads would finish their processing and go to
> print, piling up there.  So if they all need to print once every few
> seconds, it could easily look like they are stopping at about the same
> time.

These are writes of ~8,000 characters to a local partition.  I have a
10k SATA drive.

> > I would think if at least 1 thread was not trying to write
> > to the hard drive, the process that owns that thread would be running
> > when I 'top'
>
> Another thing to consider is swapping.  Does one of the swap processes jump
> up in top when the perl processes freeze?

No swap - machine goes to 0 load.

> > This could be a machine-specific problem.  I ran the same two
> > processes on another box and they cranked along nicely once I setup
> > their nice levels appropriately.
>
> > I suspect it could be because I'm running a 32-bit SMP linux on a 64-
> > bit dual-core machine...I'm going to install the 64-bit version this
> > weekend as I was planning on doing it anyways.
>
> > I appreciate the response.  But, since the processes work fine on
> > another machine, I think this post continuing on a perl forum may be
> > unnecessary.
>
> If it still could be something specific about the perl implementation, I
> would still consider it on-topic.  My next step would probably be to strace
> a job and see if the freezings are occurring in a particular system call,
> then figuring out what part of perl is issuing that system call.
>
> Xho

That's a good recommendation - I'll try strace and see what's going
on.  I just didn't want to be impolite and ask about a problem that
could very well be unrelated to Perl.

I'll try strace and then installing a 64-bit specific kernel/perl.

Thanks for the help.



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

Date: Sat, 25 Aug 2007 02:10:10 +0200 (CEST)
From: Jim Cochrane <allergic-to-spam@no-spam-allowed.org>
Subject: Using DBD::pNET or DBD::Proxy with DBD::Oracle
Message-Id: <slrnfcusr0.f50.allergic-to-spam@no-spam-allowed.org>
Keywords: DBI,DBD,database proxy

(I asked this on comp.lang.perl.modules yesterday and got one helpful
response.  Thought I'd try here, too.)

I may need to connect to an Oracle server from a Perl client on a
remote machine without using DBD::Oracle on the client (because the
"decision-makers" won't install Oracle client libraries on the client
machine).  Is anyone here familiar enough with DBD::pNET and pNETagent or
DBD::Proxy to know if they will work well (or at all) with DBD::Oracle on
the server?  I did a bit of google searching for 'DBD::pNET DBD::Oracle'
and 'pNETagent DBD::Oracle', etc. but did not succeed in finding an
answer to my question.

DBD::Proxy appears to be written by the same person as DBD::pNET.
Is DBD::Proxy intended to 'obsolete' DBD::pNET?  Anyone know if it
supports transactions?  (I was also pointed to DBD::Gofer, but it does
not support transactions.)  [Update: according to:
http://www.nntp.perl.org/group/perl.dbi.dev/2007/03/msg4909.html
DBD::Proxy supports transactions.]


Are there any other modules that provide this functionality?


Thanks!

-- 



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 792
**************************************


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