[19790] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1985 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 22 21:05:47 2001

Date: Mon, 22 Oct 2001 18:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1003799108-v10-i1985@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 22 Oct 2001     Volume: 10 Number: 1985

Today's topics:
    Re: alarm and put a timeout on a perl program an its sh (Garry Williams)
    Re: Array of filehandles <andrew@erlenstar.demon.co.uk>
        books.perl.org? (was Re: Good Literature) <uri@sysarch.com>
        Delete spaces at the end of a string <th_gi@hotmail.com>
    Re: Delete spaces at the end of a string <ronh@iainc.com>
    Re: Delete spaces at the end of a string <rsherman@ce.gatech.edu>
    Re: Delete spaces at the end of a string <ronh@iainc.com>
        Embedding Perl in a C program <john@smithIndustries.com>
        Encrypt/Decrypt module (Anand Ramamurthy)
    Re: Good Literature (Clinton A. Pierce)
    Re: Greediness and Regular Expressions <ronh@iainc.com>
    Re: Greediness and Regular Expressions <lmaddox@us.ibm.com>
    Re: Greediness and Regular Expressions <syrag@my-deja.com>
    Re: Greediness and Regular Expressions <syrag@my-deja.com>
    Re: IE4 onLoad in .pl pages (Justin)
    Re: IO::Socket broken on win <f.galassi@e-mind.it>
    Re: Perl Vs. Java <krishna.kumar@rhii.com>
    Re: Perl Vs. Java (Chas Friedman)
    Re: Perl Vs. Java <krishna.kumar@rhii.com>
    Re: Perl Vs. Java <krishna.kumar@rhii.com>
    Re: Remove duplicates from a logfile <drl7122@yahoo.com>
    Re: Skipping following lines if the same <goldbb2@earthlink.net>
    Re: Sorting a pipe delimited database <goldbb2@earthlink.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 23 Oct 2001 00:43:15 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: alarm and put a timeout on a perl program an its shell childs ?
Message-Id: <slrn9t9f92.p7s.garry@zfw.zvolve.net>

[ post re-ordered ]

[ please don't top post ]

On Mon, 22 Oct 2001 11:09:49 +0200, Gildas PERROT
<perrot@NOSPAM.fluxus.net> wrote:

> "Garry Williams" <garry@ifr.zvolve.net> a écrit dans le message news:
> slrn9t3a7t.mts.garry@zfw.zvolve.net...
>> On Fri, 19 Oct 2001 14:50:50 +0200, Gildas PERROT
>> <perrot@NOSPAM.fluxus.net> wrote:
>>
>> > I want to put a timeout on a perl program and its shell child. In order to

[ snip ]

> Now, I use a pipe to get execute the shell script but I still have the same
> problem. Usually, with command like "ping host", when the timeout is
> reached, the program below allows to kill the ping command. With my other
> specific command, after timeout, the program exits but the command is still
> present in the running processes.
> 
> use strict;
> 
> my $timeout = 3;
> $SIG{ALRM} = sub { print "TIMEOUT\n"; die "\n"; };
> #my $cmd = "/local/pck/gateway/test/fakesmsc -m 1 from to text salut";
> my $cmd = "/bin/ping metaphore";
> 
> open(CMD, "$cmd |") or die "Can't execute \"$cmd\"\n";
> eval {
>         alarm($timeout);
>         while (<CMD>) {
>                 print $_;
>         }
>         alarm(0);
> };
> close(CMD);

The problem here is with Perl's signal handling model.  Although it's
quite adequate for many purposes, this situation needs a little bit
more attention to some of the undelying complexities of signal
handling.  

I pointed you to the FAQ about timing out stuff, but for a child
process started by the Perl open(), there is a problem.  This is
alluded to in the perlvar manual page in the %SIG section.  Perl's
%SIG model sets SA_RESTART for its signal handlers (when it uses
%sigaction() and I will assume you're on such a system).  

This means that system calls that will normally be interrupted when a
signal is delivered, will be automatically restarted.  So, in this
case, the read() that is executing on the pipe to your external
command will be interrupted when the SIGALRM is delivered to the perl
process, but as soon as your handler returns, it is restarted.  So
although you raise the exception in your handler, the <CMD> continues
to block.  

Unfortunately, the perlvar manual page seems to be in error on the
solution.  The code given there to avoid setting SA_RESTART will not
execute properly.  An error message is printed when the signal is
delivered because the POSIX::SigAction interface cannot find the
signal handler subroutine.  The POSIX manual page clears up the
problem by mentioning the POSIX::SigAction expects the fully-qualified
name of a sub which is a signal-handler.  The perlvar manual page
suggestion passes POSIX::SigAction a code reference instead.  

Here's a way to accomplish what you want: 

Here's my long-running process that I want to time out on:  

    $ cat wait_for_input 
    #!/usr/bin/perl
    use warnings;
    use strict;
    my $x = <>;
    print $x;
    $ chmod +x wait_for_input
    $


Here's my process that will open a pipe to the long-running process
and will time out, if the long running process takes too long.  (The
long-running process *will* take too long, so the time out event
*will* occur.)  

    $ cat try
    #!/usr/bin/perl
    use warnings;
    use strict;
    use POSIX ":signal_h";

    my $timeout = 3;
    my $cmd = "./wait_for_input";
    my $pid = open(CMD, "$cmd |") or die qq(Can't execute "$cmd"\n);

    sub handle_alarm { die "timeout" }

    sigaction SIGALRM, POSIX::SigAction->new("main::handle_alarm")
	or die "Error setting SIGALRM handler: $!";

    eval {
	alarm($timeout);
	local($_) = <CMD>;
	print $_;
	alarm(0);
    };

    if ( $@ ) {
	kill TERM => $pid;
	close(CMD);
	die "$cmd timed out (time out = $timeout)\n";
    }
    close(CMD) || die "error executing $cmd: ",
	$! ? "$!\n" : "status = $?\n";
    print "$cmd was successful\n";

    __END__


A couple of comments are in order.  

The eval { ... } never completed in your example because Perl is
setting SA_RESTRART and when your signal handler returns (die()s), the
read is restarted automatically and continues to block the process.  

Now, when the eval { ... } completes, you need to check the $@
variable to see if the exception that you expected was actually
raised.  If it was, your child process is *still* running and you need
to signal it to quit.  That's why we save the PID of the forked
process from open().  

Finally, if the exception was not raised, we just close the pipe and
continue.  

Here's what happened when I tested it: 

    $ perl ./try
    ./wait_for_input timed out (time out = 3)
    $ perl ./try
    hello
    hello
    ./wait_for_input was successful
    $

Hope this helps.  

-- 
Garry Williams


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

Date: 22 Oct 2001 22:57:37 +0100
From: Andrew Gierth <andrew@erlenstar.demon.co.uk>
Subject: Re: Array of filehandles
Message-Id: <87adyjbani.fsf@erlenstar.demon.co.uk>

>>>>> "Steven" == Steven Work <Steven.Work@uvm.edu> writes:

 Steven> I'm new to perl and have a (probably simple) question on
 Steven> creating an array of file handles. Basically, I'm about to
 Steven> write out to N number of separate files.

use IO::File;

for my $index (0..($maxfiles - 1))
{
    my $fn = "$filename$index$filenameext";
    my $fh = IO::File->new("< $fn");
    die "Problem: $fn $!" unless $fh;
    $ppm[$index] = $fh;
}

then use

    $ppm[$index]->print("blah blah blah");

Of course, there is more than one way to do it....

-- 
Andrew.


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

Date: Mon, 22 Oct 2001 23:20:47 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: books.perl.org? (was Re: Good Literature)
Message-Id: <x71yjv45xi.fsf_-_@home.sysarch.com>

>>>>> "JS" == Joe Schaefer <joe+usenet@sunstarsys.com> writes:

  JS> I can't see how anything short of a total rewrite would make this
  JS> book acceptible to Uri :) - does he still maintain a recommended
  JS> book list?  The learn.perl.org site recommends _CGI Programming
  JS> with Perl_ for beginners- surely that's a better resource than
  JS> this book appears to be.  I imagine Lincoln Stein's new book on
  JS> network programming is a bit too advanced for a beginner.

i wish my books site were up to date. at yapc i proposed books.perl.org
and we got a mild amount of interest but it has since
languished. perl.org was also supposed to undergo a facelift and become
more coordinated but that is not moving yet.

so if anyone wants to work on a book.perl.org site, contact me and i can
point you in the right direction and offer some ideas. we have the
domain books.perl.org and access to the perl.org servers so what we is
need web design, DB backend stuff (DBI based of course), and related
stuff. then we need content including book info (i can help with that),
reviews, ratings, etc.

email me if you want to help and i will get you on our mailing
list. this is something that is long past due. my old books page were a
small attempt at this.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


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

Date: Tue, 23 Oct 2001 00:16:43 +0200
From: TGI <th_gi@hotmail.com>
Subject: Delete spaces at the end of a string
Message-Id: <3BD49ACB.1070502@hotmail.com>

Hi

How can I delete spaces at the end of a string.
I tried with
$string =~ tr/[ ]+$//d    and
$string =~ tr/ +$//d
but these deletes all spaces in the string.
I want only delete the spaces at the end.

Tom



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

Date: Mon, 22 Oct 2001 22:28:22 GMT
From: "Ron Hartikka" <ronh@iainc.com>
Subject: Re: Delete spaces at the end of a string
Message-Id: <a41B7.23053$bK.270855@typhoon.mw.mediaone.net>

$string =~ s/\s*$//; # substitute (0 or more white spaces at the end) with
nothing

$question =~ 'FAQ';

"TGI" <th_gi@hotmail.com> wrote in message
news:3BD49ACB.1070502@hotmail.com...
> Hi
>
> How can I delete spaces at the end of a string.
> I tried with
> $string =~ tr/[ ]+$//d    and
> $string =~ tr/ +$//d
> but these deletes all spaces in the string.
> I want only delete the spaces at the end.
>
> Tom
>




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

Date: Mon, 22 Oct 2001 18:28:02 +0500
From: Robert Sherman <rsherman@ce.gatech.edu>
Subject: Re: Delete spaces at the end of a string
Message-Id: <3BD41EE2.B27FCE06@ce.gatech.edu>

TGI wrote:
> 
> Hi
> 
> How can I delete spaces at the end of a string.
> I tried with
> $string =~ tr/[ ]+$//d    and
> $string =~ tr/ +$//d
> but these deletes all spaces in the string.
> I want only delete the spaces at the end.
> 
> Tom

s/\s+$//

-- 
robert sherman
css, cee
georgia institute of technology
atlanta, ga, usa


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

Date: Mon, 22 Oct 2001 22:54:20 GMT
From: "Ron Hartikka" <ronh@iainc.com>
Subject: Re: Delete spaces at the end of a string
Message-Id: <ws1B7.23179$bK.272768@typhoon.mw.mediaone.net>

Oh, my. I'm wrong.

$string =~ s/\s+$//; # substitute (1 or more white spaces at the end) with
nothing

Don't yell, please.


"Ron Hartikka" <ronh@iainc.com> wrote in message
news:a41B7.23053$bK.270855@typhoon.mw.mediaone.net...
> $string =~ s/\s*$//; # substitute (0 or more white spaces at the end) with
> nothing
>
> $question =~ 'FAQ';
>
> "TGI" <th_gi@hotmail.com> wrote in message
> news:3BD49ACB.1070502@hotmail.com...
> > Hi
> >
> > How can I delete spaces at the end of a string.
> > I tried with
> > $string =~ tr/[ ]+$//d    and
> > $string =~ tr/ +$//d
> > but these deletes all spaces in the string.
> > I want only delete the spaces at the end.
> >
> > Tom
> >
>
>




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

Date: Tue, 23 Oct 2001 01:34:55 +0100
From: "John Smith" <john@smithIndustries.com>
Subject: Embedding Perl in a C program
Message-Id: <9r2dt9$asb$3@news6.svr.pol.co.uk>

Hi All,

I have writtrn a C application. However I would like to add scripting
functionality to it - by way of embedding a Perk interpreter. I managed to
get this working, but much to my chagrin, Whenever I try to run a Perl
script that requires a Perl module, the  applicatiojn crashes and the
following error message is displayed:

"Can't load module Socket, dynamic loading not available in this perl"


1. Can some one shed some light on what this means and how to fix it (some
sample code will be nice)
2. I have a set of C library routines that I would like to call from Perl.
Any ideas how to do this (pref with sample code) will be most welcome.

Thanks in advance - please reply to perl_redhat_hacker@hotmail.com

PS:
I am building on Win32 (Windows 2000 )




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

Date: 22 Oct 2001 16:54:52 -0700
From: anand_ramamurthy@yahoo.com (Anand Ramamurthy)
Subject: Encrypt/Decrypt module
Message-Id: <761041e6.0110221554.22b8b815@posting.google.com>

Which is the simplest and easy to use module for encrypt and decrypt
of text strings? Any sample code is also welcome.


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

Date: Mon, 22 Oct 2001 23:47:24 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Good Literature
Message-Id: <ge2B7.195766$K6.93300626@news2>

[Posted and mailed to thread originator]

In article <9d3debce.0110220538.1c5d5618@posting.google.com>,
	dave@dave.org.uk (Dave Cross) writes:
> Uri Guttman <uri@sysarch.com> wrote in message 
> [about www.cgi101.com]
>> i can't go on reading this. please don't recommend this site to anyone.
> [...]
> It's very easy to just point out the errors in these books, but I
> think it's far more positive to do something about it. From my
> experience many of these authors are happy to work with more
> experienced programmers to improve their books.

I'm of the "do-something-just-don't-complain" crowd, myself.   :)

My Teach Yourself book is a very solid introduction to Perl and later 
to CGI programming.  The techniques are sound, the code works, the method
is proven.  

In production I put the book through a LOT of hands.  Not just at the 
publisher, but anyone who wanted to look at it.  Some bad stuff got
weeded out.  I highly recommend this to anyone considering authoring a 
book.  All those mistakes that people point and laugh at are easily
avoided by passing it around.  [Why don't more people do this?!?]

I've even reviewed (mildly) competing books from other publishers
to help weed out mistakes.  If they're gonna sell a book, it might as well
be a good one whether or not I get money from it.

Unfortunately a publisher like SAMS gets little respect because of some 
long past mistakes.  The upside is that they sell books by the bajillions.  
Their books are EVERYWHERE, they're inexpensive, and sometimes they're 
really good.

-- 
    Clinton A. Pierce            Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org                Perl Developer's Dictionary
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Mon, 22 Oct 2001 22:51:16 GMT
From: "Ron Hartikka" <ronh@iainc.com>
Subject: Re: Greediness and Regular Expressions
Message-Id: <Ep1B7.23178$bK.271989@typhoon.mw.mediaone.net>

while (<DATA>){
 chomp;
 last if /END/;
 @line = split;
 @last = split '', $line[-1];
 shift @last while $#last >= 4;
 print "$_: ",join "", "\t", @last, "\n";

}


__DATA__
stuff: 6837 abcd1234
stuff: 6837 1234
stuff: 6837

 ... prints...

stuff: 6837 abcd1234:  1234
stuff: 6837 1234:  1234
stuff: 6837 34:  34


"Syrag" <syrag@my-deja.com> wrote in message
news:9r243g$gko$1@tilde.csc.ti.com...
> I have a problem where I need to match 1 to 4 characters at the end of a
> string that string that might be 1 to 8 characters long.
>
> So I might have any of the following and want to match upto 4 characters
at
> the end of the line.
>
> stuff: 6837 abcd1234  #want 1234
> stuff: 6837 1234  #want 1234
> stuff: 6837 34  #want 34
>
> I tried this:
> m/^\s*stuff: 5936837\s*\S*(\S{1,4})\s*\r?$/i
> but this seems to be greedy and gets nothing unless there are more than 4
> characters total.  (note, the part I want to match could be anything
> aphanumeric, 1234 is just used above)
>
> Is there any way to match this?  Or, is there any way to change the
> greediness to be right to left or get around this?  I am sure there is
> something silly I am missing somewhere.
>
> Thanks,
> Syrag
>
>




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

Date: 22 Oct 2001 17:41:32 -0500
From: Ren Maddox <lmaddox@us.ibm.com>
Subject: Re: Greediness and Regular Expressions
Message-Id: <m3itd7s3fn.fsf@dhcp9-161.support.tivoli.com>

On Mon, 22 Oct 2001, syrag@my-deja.com wrote:

> I have a problem where I need to match 1 to 4 characters at the end
> of a string that string that might be 1 to 8 characters long.
> 
> So I might have any of the following and want to match upto 4
> characters at the end of the line.
> 
> stuff: 6837 abcd1234  #want 1234
> stuff: 6837 1234  #want 1234
> stuff: 6837 34  #want 34
> 
> I tried this:
> m/^\s*stuff: 5936837\s*\S*(\S{1,4})\s*\r?$/i
> but this seems to be greedy and gets nothing unless there are more
> than 4 characters total.  (note, the part I want to match could be
> anything aphanumeric, 1234 is just used above)
> 
> Is there any way to match this?  Or, is there any way to change the
> greediness to be right to left or get around this?  I am sure there
> is something silly I am missing somewhere.

You can use the non-greedy version of the '*' quantifier, '*?'.

  m/^\s*stuff: 5936837\s*\S*?(\S{1,4})\s*$/i

Note that with '{1,4}', it should never have gotten "nothing" unless
the match failed.  However, it would only ever get one character,
rather than four.  Also, "\r" is included by "\s" (and probably
handled by '$' as well, depending on the OS), so I've left if off.

-- 
Ren Maddox
lmaddox@us.ibm.com


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

Date: Mon, 22 Oct 2001 18:41:01 -0500
From: "Syrag" <syrag@my-deja.com>
Subject: Re: Greediness and Regular Expressions
Message-Id: <9r2anh$4gi$1@tilde.csc.ti.com>

Thanks!  Comments below.

"Ren Maddox" <lmaddox@us.ibm.com> wrote in message
news:m3itd7s3fn.fsf@dhcp9-161.support.tivoli.com...
> On Mon, 22 Oct 2001, syrag@my-deja.com wrote:
>
> > I have a problem where I need to match 1 to 4 characters at the end
> > of a string that string that might be 1 to 8 characters long.
> >
> > So I might have any of the following and want to match upto 4
> > characters at the end of the line.
> >
> > stuff: 6837 abcd1234  #want 1234
> > stuff: 6837 1234  #want 1234
> > stuff: 6837 34  #want 34
> >
> > I tried this:
> > m/^\s*stuff: 5936837\s*\S*(\S{1,4})\s*\r?$/i
> > but this seems to be greedy and gets nothing unless there are more
> > than 4 characters total.  (note, the part I want to match could be
> > anything aphanumeric, 1234 is just used above)
> >
> > Is there any way to match this?  Or, is there any way to change the
> > greediness to be right to left or get around this?  I am sure there
> > is something silly I am missing somewhere.
>
> You can use the non-greedy version of the '*' quantifier, '*?'.
>
>   m/^\s*stuff: 5936837\s*\S*?(\S{1,4})\s*$/i
>
> Note that with '{1,4}', it should never have gotten "nothing" unless
> the match failed.  However, it would only ever get one character,
> rather than four.  Also, "\r" is included by "\s" (and probably
> handled by '$' as well, depending on the OS), so I've left if off.
>
> --
> Ren Maddox
> lmaddox@us.ibm.com

I did not know about the non-greedy quantifiers.  The book I was looking in
did not have theses; it turns out to be an old one.  perlretut has it
though.

Thank you Mr. Maddox for pointing this out!
Thank you Mr. Wall for including this!

Sorry, {1,4} was matching one character (not nothing).

The \r \s and such was all included because I was haveing a problem with my
scripts being compatible with UNIX and DOS versions of perl; this seemed to
fix that.  It may not be needed anymore.

Thanks again,
Syrag






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

Date: Mon, 22 Oct 2001 18:43:44 -0500
From: "Syrag" <syrag@my-deja.com>
Subject: Re: Greediness and Regular Expressions
Message-Id: <9r2asj$4od$1@tilde.csc.ti.com>

Thanks for your response.  This is the way I was going to do it; however I
was looking for the slick way (which there usually is in Perl).  The
non-greedy *? fixed my problem the slick way.

I learn something new from this group every time I look here.

Thanks again.
- Syrag

"Ron Hartikka" <ronh@iainc.com> wrote in message
news:Ep1B7.23178$bK.271989@typhoon.mw.mediaone.net...
> while (<DATA>){
>  chomp;
>  last if /END/;
>  @line = split;
>  @last = split '', $line[-1];
>  shift @last while $#last >= 4;
>  print "$_: ",join "", "\t", @last, "\n";
>
> }
>
>
> __DATA__
> stuff: 6837 abcd1234
> stuff: 6837 1234
> stuff: 6837
>
> ... prints...
>
> stuff: 6837 abcd1234:  1234
> stuff: 6837 1234:  1234
> stuff: 6837 34:  34
>
>
> "Syrag" <syrag@my-deja.com> wrote in message
> news:9r243g$gko$1@tilde.csc.ti.com...
> > I have a problem where I need to match 1 to 4 characters at the end of a
> > string that string that might be 1 to 8 characters long.
> >
> > So I might have any of the following and want to match upto 4 characters
> at
> > the end of the line.
> >
> > stuff: 6837 abcd1234  #want 1234
> > stuff: 6837 1234  #want 1234
> > stuff: 6837 34  #want 34
> >
> > I tried this:
> > m/^\s*stuff: 5936837\s*\S*(\S{1,4})\s*\r?$/i
> > but this seems to be greedy and gets nothing unless there are more than
4
> > characters total.  (note, the part I want to match could be anything
> > aphanumeric, 1234 is just used above)
> >
> > Is there any way to match this?  Or, is there any way to change the
> > greediness to be right to left or get around this?  I am sure there is
> > something silly I am missing somewhere.
> >
> > Thanks,
> > Syrag
> >
> >
>
>




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

Date: 22 Oct 2001 15:39:48 -0700
From: amiwebguy@yahoo.com (Justin)
Subject: Re: IE4 onLoad in .pl pages
Message-Id: <19caa707.0110221439.21e1e446@posting.google.com>

Jeff & Alan,

First off, thank you for responding to my posting.
Second, I think this issue was one deeper than what it appears.

I have since found the culprit of my angst.
Another member of our development team was writing debugging messages
right after the print "Content-type: text/html\n"; line and before the
<HTML> tag.
So it seems that these messages in the Perl script were causing the
JavaScript onLoad event not to execute because the page never loaded
completely. The odd part is that only IE4 had a problem with this.

Thanks for your assistance.

Justin



"Alan J. Flavell" <flavell@mail.cern.ch> wrote in message news:<Pine.LNX.4.30.0110222026080.32046-100000@lxplus023.cern.ch>...
> On Oct 22, Jeff Zucker inscribed on the eternal scroll:
> 
> > > triggered from a Javascript onLoad event in the body tag
> >
> > Perl has nothing to do with Javascript,
> 
> right
> 
> > see a newsgroup about Javascript
> 
> right
> 
> > or CGI.
> 
> I don't think so: an "onload event" happens client-side, but CGI
> happens server-side.  There does exist such a thing as server-side
> Javascript, but I don't think that's relevant here.
> 
> > And please do not respond that since your script is written in perl it
> > is therefore a perl issue.
> 
> I think we all know what happens next in this kind of scenario.
> But I suppose it's possible that I'm mistaken.
> 
> > Perl is only the intermediary and irrelevant
> > to what the browser expects to see.
> 
> An important principle, indeed.
> 
> all the best.


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

Date: Mon, 22 Oct 2001 22:21:26 GMT
From: Fe <f.galassi@e-mind.it>
Subject: Re: IO::Socket broken on win
Message-Id: <pm69tt0h31jhlu2bcnn9jnidvghicvloir@4ax.com>

On Mon, 22 Oct 2001 19:11:51 GMT, garry@ifr.zvolve.net (Garry
Williams) wrote:

>On Mon, 22 Oct 2001 06:25:27 -0400, Benjamin Goldberg
><goldbb2@earthlink.net> wrote:
>
>What happened when you tried it? 
>
>    $ perl -MErrno -wle 'print EWOULDBLOCK()'
>    Undefined subroutine &main::EWOULDBLOCK called at -e line 1.
>    $ perl -MErrno=EWOULDBLOCK -wle 'print EWOULDBLOCK()' 
>    11
>    $ perl -MPOSIX -wle 'print EWOULDBLOCK()'     
>    11
>    $
>
>See the Errno manual page.  

EWOULDBLOCK, EINPROGRESS, ECONNRESET, ECONNABORTED, ESHUTDOWN, etc..
they all die with :
undefined subroutine (Errno) 
not defined by vendor (POSIX 'errno_h')


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

Date: Mon, 22 Oct 2001 15:14:27 -0700
From: "Krishna Kumar" <krishna.kumar@rhii.com>
Subject: Re: Perl Vs. Java
Message-Id: <ABM8rb0WBHA.169@hqp_news_nt1.corp.rhalf.com>

First of all my apologies for inadvertently replying to you directly instead
of the group.

The problem is it is like the French Law (you know guilty until proven
innocent)

A decision was made that all new development will be done in Perl. Now I
have to prove to my superiors that Java is not a replacement for Perl.

"Ron Reidy" <rereidy@indra.com> wrote in message
news:3BD48E1E.F3B1DC69@indra.com...
> Krishna Kumar wrote:
> >
> > Folks at my work are talking about using Java as a standard instead of
Perl.
> >
> > I have no knowledge of Java to agree or disagree with this.
> >
> > They are trying to convince me that Java can do everything that Perl
can.
> >
> > I know enough Perl to know what it is capable of.  Hence I am taking
their
> > statement with a pinch of salt.
> >
> > I suspect that Perl can do certain things much better than Java and vice
> > versa.
> >
> > I also suspect that thay are comparing apples with oranges.
> >
> > Can someone help me with this please? Or point me to a website which
brings
> > out the differences between Java and Perl?
> >
> > Thanks in advance
> >
> > Regards
> > KK
> So if Java can do everything Perl does, and you already use Perl, why
> change (aka - if it ain't broke, don't fix it)?
> --
> Ron Reidy
> Oracle DBA
> Reidy Consulting, L.L.C.




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

Date: Mon, 22 Oct 2001 22:50:15 GMT
From: friedman@math.utexas.edu (Chas Friedman)
Subject: Re: Perl Vs. Java
Message-Id: <3bd49ed9.8238398@news.itouch.net>

On Mon, 22 Oct 2001 14:59:34 -0700, "Krishna Kumar"
<krishna.kumar@rhii.com> wrote:

>No I think the assumption is Java is easier to learn than Perl.
>
 I couldn't help commenting on this. I have been programming for many
years and have written many thousands of lines of Pascal, LISP, Perl,
C/C++. 
  About a year ago, I decided to learn Java. I studied for weeks and
found it quite difficult. I had to carry several references books of
classes around with me to look up definitions and dependencies.
Eventually, I learned enough to write some stand alone applications
and also some applets. I became somewhat disenchanted with the fact
that my applications didn't run OS independently without a lot of
tweaking, and realized that I still had a huge amount to learn (and
what I had learned hadn't been any fun at all.)
I basically stopped using Java and then quickly forgot most of what I
learned - it seemed quite forgettable. 
 Recently, I took over managing my math department's webpage and
wanted to write/rewrite some scripts. I tried C which worked, but felt
I should really learn Perl. So I bought Learning Perl and Programming
Perl. After about 1 weekend of study, I rewrote all the scripts in
Perl, and everything worked well. I also wrote myself a webmail
program and lots of other utilities that I use every day. Learning
Perl (which continues) was one of the best decisions I've made in my
life. (I'm not getting paid to say this, by the way.)
 Sorry if this is a tiny bit off topic. I couldn't help myself...
                      cf


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

Date: Mon, 22 Oct 2001 15:38:02 -0700
From: "Krishna Kumar" <krishna.kumar@rhii.com>
Subject: Re: Perl Vs. Java
Message-Id: <lNsf3o0WBHA.221@hqp_news_nt1.corp.rhalf.com>

Thank you. I found quite a bit useful info at these sites.

And duh! my ggogle search for "Perl Vs. Java" had not returned enough info
unitl I changed it to "differences between Perl and Java"

:-)

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn9t8qou.dsk.tadmc@tadmc26.august.net...
> Krishna Kumar <krishna.kumar@rhii.com> wrote:
>
> >Folks at my work are talking about using Java as a standard instead of
Perl.
>
> >Can someone help me with this please? Or point me to a website
>
>
> This one may help some:
>
>    http://www.perl.org/phbs/
>
>
> >which brings
> >out the differences between Java and Perl?
>
>
> But I don't know that it does that.
>
> There is also a mailing list for discussing Perl advocacy:
>
>    http://lists.perl.org/showlist.cgi?name=advocacy
>
>
> I also see that a google.com search for your Subject: above
> finds 163 hits  :-)
>
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas




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

Date: Mon, 22 Oct 2001 15:53:46 -0700
From: "Krishna Kumar" <krishna.kumar@rhii.com>
Subject: Re: Perl Vs. Java
Message-Id: <dIhfpx0WBHA.169@hqp_news_nt1.corp.rhalf.com>

I havent yet attempted to learn Java . Bust considering the concepts of OO
still escape me
I suspect it would not be pleasant experience for me either.

And it is true I learnt Perl looking at someone else's script and was able
to whip out code quite easily
after the first few days of  trial and error and have fallen in love with it
ever since.

I will ceratinly bring this comment to the notice of my superiors.

Thanks

"Chas Friedman" <friedman@math.utexas.edu> wrote in message
news:3bd49ed9.8238398@news.itouch.net...
> On Mon, 22 Oct 2001 14:59:34 -0700, "Krishna Kumar"
> <krishna.kumar@rhii.com> wrote:
>
> >No I think the assumption is Java is easier to learn than Perl.
> >
>  I couldn't help commenting on this. I have been programming for many
> years and have written many thousands of lines of Pascal, LISP, Perl,
> C/C++.
>   About a year ago, I decided to learn Java. I studied for weeks and
> found it quite difficult. I had to carry several references books of
> classes around with me to look up definitions and dependencies.
> Eventually, I learned enough to write some stand alone applications
> and also some applets. I became somewhat disenchanted with the fact
> that my applications didn't run OS independently without a lot of
> tweaking, and realized that I still had a huge amount to learn (and
> what I had learned hadn't been any fun at all.)
> I basically stopped using Java and then quickly forgot most of what I
> learned - it seemed quite forgettable.
>  Recently, I took over managing my math department's webpage and
> wanted to write/rewrite some scripts. I tried C which worked, but felt
> I should really learn Perl. So I bought Learning Perl and Programming
> Perl. After about 1 weekend of study, I rewrote all the scripts in
> Perl, and everything worked well. I also wrote myself a webmail
> program and lots of other utilities that I use every day. Learning
> Perl (which continues) was one of the best decisions I've made in my
> life. (I'm not getting paid to say this, by the way.)
>  Sorry if this is a tiny bit off topic. I couldn't help myself...
>                       cf




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

Date: Mon, 22 Oct 2001 18:50:48 -0500
From: "jdcfan" <drl7122@yahoo.com>
Subject: Re: Remove duplicates from a logfile
Message-Id: <9r2bbi$np7$1@slb6.atl.mindspring.net>

"Garry Williams" <garry@ifr.zvolve.net> wrote in message
news:slrn9t8e52.oua.garry@zfw.zvolve.net...
> While this is a clever way to get just the IP address printed, the OP
> showed that he wanted the whole line.

You are correct Garry.  Maybe I did not make it completely clear
originally...  You had to read through my ugly code to figure it out.

Dan




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

Date: Mon, 22 Oct 2001 20:43:59 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Skipping following lines if the same
Message-Id: <3BD4BD4F.97302A15@earthlink.net>

Laird wrote:
> 
> Hi everyone,
> 
> I've got this array
> 
> aaa
> aaa
> bbbbb
> cccc
> cccc
> c
> ddd
> ddd
> fff
> fff
> fff
> ffff
> ffff
> 
> and would like to transform it into this
> 
> aaa
> bbbbb
> cccc
> c
> ddd
> fff
> ffff
> 
> skipping following lines if the same.
> But only following lines.

[untested]:
my %seen;
while(<IN>) {
    next if exists $seen{$_} && $seen{$_} == $. - 1;
    print;
    $seen{$_} = $.;
}

-- 
Klein bottle for rent - inquire within.


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

Date: Mon, 22 Oct 2001 20:41:02 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Sorting a pipe delimited database
Message-Id: <3BD4BC9E.62416020@earthlink.net>

Diehard Duck wrote:
> 
> Hi All,
> 
> I'm fairly new to this Perl business and there are somethings I don't
> understand and some I do!
> 
> I am 'adapting' a free script, Database Doctor, to my own needs. 

Given how poorly written the script is, I would suggest you buy a couple
perl books, read them, and write a new script from scratch which does
what you need.

> Everything works fine but there is one tweak I want to make.
> 
> Here is the situation:
> 
> I've got a pipe delimited flat-file database, which stores details on
> our product range. The field headers are stored in the '@table_fields'
> array. display.cgi is called, usually with searchterms. display.cgi
> searches the database and displays the results in no particular order.
> What I want is the results to be shown in order of 'procass-price',
> the 14th Col of the database.  However the order of the records in the
> flatfile database has no effect on the display of the results, so I
> can't just sort that.
> 
> So:
> 
> I want the displayed results to be shown in order of 'procass-price'.
> I have read about sort $a <=> $b etc, but I don't really know how to
> apply that to my needs.
[snip ugly code]
> I've included everything.  Sorry if it's caused any inconvenience.

Yes, it is an inconvenience.  Generally, when you have a problem, you
should post the smallest complete program which displays the problem.

You posted a gargantuan monster, most of which you probably don't
understand.  None of us want to read through something that long and
ugly.  Also, because the comments were line-wrapped, it is completely
and utterly illegible, even if we did want to read through such ugly
code.

> Basically any light you can shed would be much appreciated...just post
> any questions you might have and I'll do my best to reply.

Yes, my question is why didn't you first read "Posting Guidelines for
comp.lang.perl.misc" before posting here?

"Ask perl to help you" [-w and use strict]
"Do not provide too much information" [don't post the whole script]
"Asking a question easily answered by a cursory doc search" [how do I
sort by...]


-- 
Klein bottle for rent - inquire within.


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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


------------------------------
End of Perl-Users Digest V10 Issue 1985
***************************************


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