[17984] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 144 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 25 18:26:55 2001

Date: Thu, 25 Jan 2001 15:05:16 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <980463916-v10-i144@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 25 Jan 2001     Volume: 10 Number: 144

Today's topics:
    Re: Any suggestions on how to improve this  script? (Mark Jason Dominus)
    Re: bidirectional communication using sockets mmustafa@my-deja.com
    Re: CGI  Question <tore@extend.no>
    Re: CGI  Question (Gregory Spath)
    Re: change tmp dir for file upload in cgi (Martin Vorlaender)
    Re: Comparing multiple values <tore@extend.no>
    Re: Comparing multiple values <uri@sysarch.com>
    Re: Comparing multiple values <aqumsieh@hyperchip.com>
    Re: Comparing multiple values (Craig Berry)
    Re: Comparing multiple values <bart.lateur@skynet.be>
    Re: Confussed on IPC <bas@integrators.demon.nl>
    Re: Converting text to html (Craig Berry)
        Dealing with x1b character hparks@my-deja.com
    Re: Dealing with x1b character <anonymous@anonymous.anonymous>
    Re: Does 'system' function work on Win32 ActivePerl? <jdf@pobox.com>
    Re: FAQ 1.14:   Where can I get a list of Larry Wall wi <wolfmtn@mindspring.com>
    Re: FAQ 1.3:   Which version of Perl should I use? (Peter J. Acklam)
    Re: FAQ 1.5:   What is perl6? <uri@sysarch.com>
        FAQ status and reposts, was Re: FAQ 1.5:   What is perl <flavell@mail.cern.ch>
    Re: Finding HTTP status code for a URL <g.soper@soundhouse.co.uk>
    Re: hash to java <jdf@pobox.com>
    Re: How to do this regular expression? <elijah@workspot.net>
        HTTP status codes <g.soper@soundhouse.co.uk>
    Re: HTTP status codes <comdog@panix.com>
    Re: Iterating through matches to a regexp ? <mjcarman@home.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 25 Jan 2001 21:00:09 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Any suggestions on how to improve this  script?
Message-Id: <3a7093d9.1be8$7b@news.op.net>

In article <3A6EEC21.AFE34F01@coventry.ac.uk>,
John Tutchings  <ccx138@coventry.ac.uk> wrote:
>OK, what ever, it is still bad which ever way :)

It makes a big difference.  Suppose that the largest file you can
handle practically has a certain number of lines.  Then you buy a new
computer that is twice as fast as the old computer.  

If the program has quadratic behavior, it will be practical to handle
files that are up to 50% larger than the old files.

If the program has exponential behavior, it will be practical to
handle files that are up to 3 lines larger than the old files.

Exponential is much, much worse than quadratic.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Thu, 25 Jan 2001 21:40:47 GMT
From: mmustafa@my-deja.com
Subject: Re: bidirectional communication using sockets
Message-Id: <94q6gt$78a$1@nnrp1.deja.com>

I pretty much cut and paste this code in unix machine ( expect the
header directives , replace by #!/usr/bin/perl and the machine name ).
The server starts, but when the client connects , both complain 'Cant
recv' . Any ideas ...

Thanks



In article <94hdaa$soe$1@news2.isdnet.net>,
  "Sébastien Cottalorda" <sebastien.cottalorda@mageos.com> wrote:
> Hi,
>
> Here are sample of bidirectionnal client/server.
>
> Client:
> #!c:\perl\bin\perl -w
> use IO::Socket;
> $socket = IO::Socket::INET->new(PeerAddr=> '190.197.10.217',
>     PeerPort=> '123456',
>     Proto=> "tcp",
>     Type=> SOCK_STREAM)
>  or die "Couln\'t connect to 190.197.10.217:123456 $@\n";
> $phrase = "Comment vas-tu ?";
> $socket->send("$phrase"."FIN",'') or die "Can\'t send $!\n";
> print "> $phrase \n";
> $data_read='seb';
> ITER: while ($data_read) {
>      $socket->recv($data_read,'256') or die "Can\'t recv $!\n";
>      print "< $data_read \n" unless ($data_read=~/FIN/);
>      last ITER if ($data_read=~/FIN/);
> }
> $data_read=~s/FIN//;
> print "< $data_read \n";
> exit 0;
>
> Server:
> #!c:\perl\bin\perl -w
> use IO::Socket;
> use Carp;
> use POSIX qw(strftime);
> $port_recep='123456';
> $server= IO::Socket::INET->new(LocalPort=> $port_recep,
>     Type=> SOCK_STREAM,
>     Reuse=>1,
>     Listen=>10)
>  or die "Couln\'t be a tcp server on $port_recep $@\n";
> while ($client=$server->accept()) {
>      $data_read='seb';
>      ITER: while ($data_read) {
>             $client->recv($data_read,'256') or die "Can\'t recv $!\n";
>             print "< $data_read \n" unless ($data_read=~/FIN/);
>             last ITER if ($data_read=~/FIN/);
>      }
>      $data_read=~s/FIN//;
>      print "< $data_read \n";
>      $phrase = 'Je vais bien Merci';
>      $client->send($phrase."FIN",'') or die "Can\'t send $!\n";
>      print "> $phrase \n";
> }
> exit 0;
>
> The client connect using a socket to the server.
> It send block of 256 bytes.
> When it has finished, it end a special word "FIN" (you can choose
what you
> like for example : "\r")
> Then the client listen the socket instead of writing into it.
> The server receive datas, but send an answer just after it received
the word
> "FIN".
> Then both programs ends.
>
> Be very Carefull, it's very easy to make deadlock (server and client
both
> listenning and waiting other part datas send).
>
> Hope this helps
>
> Sebastien
>
> <mmustafa@my-deja.com> a écrit dans le message :
> 942bgq$aj5$1@nnrp1.deja.com...
> > Hi,
> >    I am trying to write a PERL program using sockets. One side (
which
> > we call client ) is communicating with the listener ( which we call
> > server) thru a specific port. This is working fine.
> > The problem i am running into is after sending a couple of strings
> > (haven't been able to pass an array), the listener/ server reads it,
> > and does some processing. But if the listener wants to send some
> > response back to the client, the client can't read it. I will give a
> > brief code summnary here ( rather then the whole thing ) , this
didn't
> > work :
> > CLIENT CODE :
> > #socket initializination, $port and $server are arguments
> > socket(SOCKET, PF_INET, SOCK_STREAM, (getprotobyname('tcp'))[2]);
> > connect (SOCKET, pack('Sna4x8', AF_INET, $port,
> >         (gethostbyname($server))[4]))
> >         || die "Can't connect to server $server on port $port .\n";
> > SOCKET->autoflush();
> >
> >
> > print SOCKET "Command1 \r\n";
> > print SOCKET "Command2 \r\n";
> >
> > # I need to read response from the server :
> > # did NOT WORK
> > #       shutdown(SOCKET,1);
> > #       while (<SOCKET>) {
> > #       while (defined ($string = <SOCKET>) ) {
> >         recv(SOCKET,$string,100,0);
> >         if ($string) {
> >                 $string = $_;
> >                 print "STRING : ****($string)****\n";
> >                 if ($string == 1) {
> >
> >
> > I tried threading the process , which created further problems (
maybe
> > programing error).
> > I tried shutdown , which also on the server side, so that the client
> > doesn't keep on waiting ( according to the documentation , recv will
> > keep on waiting).
> >
> >
> > Here is a snippet of SERVER CODE :
> > $server = IO::Socket::INET->new( Proto     => 'tcp',
> >                                   LocalPort => $DEFAULT_PORT,
> >                                   Listen    => SOMAXCONN,
> >                                   Reuse     => 1);
> >
> > while(<$server>)
> >   {
> >         chomp($_);
> >         print "Value of i = $i and this is what I got
> >         from the other machine: **($_)** \n";
> >         autoflush $server 5;
> >         $i++;
> >         if ($i == 1) {
> >                 $input = $_ ;
> >                 chomp($input);
> >                 print "\tRELEASE OR DROP = ($input) \n";
> >         }
> >
> >
> > If anyone knows how to do it...  please post something....
> > I apologise if the message is cryptic or vague, I would love to
explain
> > further if anyone has interest to help.
> >
> > Thanks a lot in advance
> > Farooq
> >
> >
> > Sent via Deja.com
> > http://www.deja.com/
>
>


Sent via Deja.com
http://www.deja.com/


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

Date: Thu, 25 Jan 2001 21:37:46 +0100
From: Tore Aursand <tore@extend.no>
Subject: Re: CGI  Question
Message-Id: <MPG.14daad00be1af7fa989864@news.online.no>

In article <3A706E95.4A620648@skio.peachnet.edu>, 
cason@skio.peachnet.edu says...
> I am writing a cgi reservation system in perl for where i work and i was
> curious is there anyway to get perl to save the values in the form if
> there is an error so the user doesnt have to enter all the data again.

What's the problem?  This is really simple.  Let's say to have a 
navigate() sub-routine in your script;

sub navigate {

	# Was the 'login' button pressed?
	if (defined $cgi->param('login.x')) {
		if (authenticate_user()) {
			show_welcome_screen();
		}
		else {
			show_login_screen();
		}
      }
	else {
		show_login_screen();
	}
}

sub authenticate_user {
	my $username = $cgi->param('password');
	my $password = $cgi->param('username');

	# Check if the entered data is correct
}

sub show_login_screen {
	my $username = $cgi->param('username');

	if (defined $username) {
		# Show error message
	}

	# Show login screen

}

You could make this example a little better if you have a global error 
flag which is set to '1' if/when authentication fails.


-- 
Tore Aursand - tore@extend.no - http://www.extend.no/~tore/


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

Date: Thu, 25 Jan 2001 21:09:17 -0000
From: gspath@freefall.homeip.net (Gregory Spath)
Subject: Re: CGI  Question
Message-Id: <slrn9715cg.2g5.gspath@freefall.homeip.net>

In <3A706E95.4A620648@skio.peachnet.edu>, Horace J. Cason (cason@skio.peachnet.edu) wrote:
>I am writing a cgi reservation system in perl for where i work and i was
>curious is there anyway to get perl to save the values in the form if
>there is an error so the user doesnt have to enter all the data again.
>I would find it irritating to have to do that myself. I have tried using
>the self_url() method to get it to save the values but it ends up just
>resetting the form. I use the print qq! way to create the forms and i
>save the parameters coming off the form into variables. The script is
>working right just wanting to get some error detection involved. Also is
>there a way to prevent 2 or more users from reserving an item at the
>same time?
>
>
>

In addition to all the suggestions already made, you could also use
HTML::Embperl.  It automatically keeps track of everything for you in a hash,
and when a form is loaded again, all the "selected" junk gets done
automatically for you.

Note that this module is for embedding perl within your HTML (although it can
also be used as a CGI or offline)

Worth a look, as it makes creating web-based applications very simple.

-- Greg


-- 
Gregory Spath              
gspath@freefall.homeip.net   http://freefall.homeip.net/
SCHeckler on IRC ----------> http://freefall.homeip.net/javairc/
Team YBR ------------------> http://www.yellowbreechesracing.org/


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

Date: Thu, 25 Jan 2001 19:46:34 +0100
From: martin@radiogaga.harz.de (Martin Vorlaender)
Subject: Re: change tmp dir for file upload in cgi
Message-Id: <3a707489.524144494f47414741@radiogaga.harz.de>

soleblazer@my-deja.com wrote:
> martin@radiogaga.harz.de wrote:
> > To set it, use
> >
> >   BEGIN { $TempFile::TMPDIRECTORY = '/your/directory' }
> >   use CGI;
> >
> > or see the comment at the beginning of CGI.pm to set it system-wide.
>
> Hello, I am looking at my Cgi.pm file but do not see a comment to tell
> me how to send my cgi requests to another location besides /tmp.  Do
> you think you could tell me how to do it or paste your comment section
> into a post?

It's line 48 in my version of CGI.pm (v2.36):

  # HARD-CODED LOCATION FOR FILE UPLOAD TEMPORARY FILES.
  # UNCOMMENT THIS ONLY IF YOU KNOW WHAT YOU'RE DOING.
  # $TempFile::TMPDIRECTORY = '/usr/tmp';

Hard to miss, or is it?

cu,
  Martin


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

Date: Thu, 25 Jan 2001 21:28:05 +0100
From: Tore Aursand <tore@extend.no>
Subject: Re: Comparing multiple values
Message-Id: <MPG.14daaac493b804c4989863@news.online.no>

In article <94pocs$osn$1@nnrp1.deja.com>, datastar@my-deja.com says...
> ...but what if I want to test if $somevar equals 3,4,8 or 9?

if ($number =~ /[1|2|3|4]/) {
	...
}


-- 
Tore Aursand - tore@extend.no - http://www.extend.no/~tore/


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

Date: Thu, 25 Jan 2001 21:52:14 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Comparing multiple values
Message-Id: <x7wvbjuwoh.fsf@home.sysarch.com>

>>>>> "TA" == Tore Aursand <tore@extend.no> writes:

  TA> In article <94pocs$osn$1@nnrp1.deja.com>, datastar@my-deja.com says...
  >> ...but what if I want to test if $somevar equals 3,4,8 or 9?

  TA> if ($number =~ /[1|2|3|4]/) {

please read perlre in more detail. the | in the char class are not
correct. in fact that means that will match '|'.  also you don't have
any anchors in there so that will match ANY string with 1-4 or | in it.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Thu, 25 Jan 2001 22:12:55 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Comparing multiple values
Message-Id: <7au26n702e.fsf@merlin.hyperchip.com>


Tore Aursand <tore@extend.no> writes:

> In article <94pocs$osn$1@nnrp1.deja.com>, datastar@my-deja.com says...
> > ...but what if I want to test if $somevar equals 3,4,8 or 9?
> 
> if ($number =~ /[1|2|3|4]/) {
> 	...
> }

Perhaps you meant:

	if ($number =~ /[1234]/) {
		...
	}

or maybe even:

	if ($number =~ /1|2|3|4/) {
		...
	}

Still, none of those is the correct answer.

--Ala


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

Date: Thu, 25 Jan 2001 22:21:27 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Comparing multiple values
Message-Id: <t719n74kcfuv79@corp.supernews.com>

datastar@my-deja.com wrote:
: I can say:
: 
:   if ($somevar==3) {  } # do something
: 
: ...but what if I want to test if $somevar equals 3,4,8 or 9?

  if (grep { $_ == $somevar } qw(3 4 8 9)) {

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "The hills are burning, and the wind is raging; and the clock
   |   strikes midnight in the Garden of Allah." - Don Henley


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

Date: Thu, 25 Jan 2001 22:46:48 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Comparing multiple values
Message-Id: <b5b17tg9bc5eus0ch30u2lvg1brdv5jkqn@4ax.com>

Tore Aursand wrote:

>if ($number =~ /[1|2|3|4]/) {

Are you guys blind, or just plain lazy? The OP explicitely wrote:

:I know I can accomplish this using pattern matching, but I'd rather
:avoid that for simplicity if possible.

So this is definitely the wrong tree.

;-)

-- 
	Bart.


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

Date: Thu, 25 Jan 2001 22:56:03 +0100
From: "Bas A. Schulte" <bas@integrators.demon.nl>
Subject: Re: Confussed on IPC
Message-Id: <bas-D46E43.22560325012001@news.demon.nl>

In article <slrn9702co.krh.abigail@tsathoggua.rlyeh.net>, 
abigail@foad.org wrote:

> Can someone tell me how to set a broken bone? The documentation on
> bones is not very clear to me. I am not a doctor by trade.

ROTFL!

My thoughts exactly; don't do IPC with perl/Unix if you don't know what 
it is. 

I've been working with the stuff the past few evenings, and there sure 
is a lot out there to bite ya (SIGPIPE's, blockin' when you didn't 
expect it, and then perl's internal buffering that doesn't happen with C 
(perl read != syscall read),etc. etc.).

Bas.


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

Date: Thu, 25 Jan 2001 22:11:29 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Converting text to html
Message-Id: <t7194h8g3vh945@corp.supernews.com>

pularis@my-deja.com wrote:
:    I was trying to convert a text file to html file using my limited
: perl skills. It seems to work fine, with minor issues. I am using the
: <pre> tah and then I use the following to copy the contents of one file
: to another.
: 
: while(<FILEONE>)
: {
: chomp;
: print FILETWO "$_ \n";
: }

Is there really some reason why you want to insert a single space
character at the end of each line?  If not, you can replace all of the
above with

  print FILETWO while <FILEONE>;

 ...though this is harder to extend to more general cases, such as what
follows.

:   If a line begins with certain words ( i.e Server ) I want the line to
: be centred ( by including the line between <center> tags ) how can I do
: this ?.
:  Also I would like to make all numbers bold ( by including em in
: <b>,</b> tag.

while (<FILEONE>) {
  chomp;
  s!(\d+)!<b>$1</b>!g;
  print FILETWO (/^Server/ ? "<center>$_</center>" : $_), "\n";
}

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "The hills are burning, and the wind is raging; and the clock
   |   strikes midnight in the Garden of Allah." - Don Henley


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

Date: Thu, 25 Jan 2001 22:17:28 GMT
From: hparks@my-deja.com
Subject: Dealing with x1b character
Message-Id: <94q8le$952$1@nnrp1.deja.com>

I have a simple perl program (source below) which I use scan a text
file containing multiple reports. The program pulls out reports with a
particular header, ---070---, and puts them in a file.  After working
for months, it stopped working 2 weeks ago.  Some debugging showed the
program was exiting when an escape character (hex 1B) was encountered.
My first attempt to get around this was to look at each line as it is
read and replace the character, but I think this does not work because
the escape appears to be terminating the while (<INFILE>) loop.
Another approach I thought of was reading in the file as a single
variable and using search-and-replace, but if the 1B makes makes the
read terminate, that won't work either.  I don't mind RTFM if someone
will point me to the right manual.  The environment is WinNT4.

Here is the source:
$infile = $a;
$lcnt = 0; $twcnt = 0; $thcnt = 0; $scnt = 0;
open(INFILE,"<$infile") or die ("Input file error");
open(OUTFILE,">>c:/perl/sterl070.dat") or die ("Output file error");
while (<INFILE>)
{ $line = $_;
  $lcnt += 1;
  if ($line =~ /---\d\d\d/)  {
      $lastheader = $line;
      if ($lastheader =~ /---020---/) {
         $twcnt += 1;}
      if ($lastheader =~ /---030---/)  {
         $thcnt += 1;}
      if ($lastheader =~ /---070---/)  {
         $scnt += 1;}
  }
  if ($lastheader =~ /---070---/) {
      print OUTFILE $line;
  }
}
close(INFILE);
close(OUTFILE);
print "020:", $twcnt;
print ", 030:", $thcnt;
print ", 070:", $scnt,"\n";
print $lcnt,"\n";
------------ end of source ------------

Howard Parks
1 Peter 4:10


Sent via Deja.com
http://www.deja.com/


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

Date: Thu, 25 Jan 2001 18:13:57 -0500
From: Anonymous <anonymous@anonymous.anonymous>
Subject: Re: Dealing with x1b character
Message-Id: <1nc17tkm44fpaev4ckj48conm9dtaekvr4@4ax.com>

On Thu, 25 Jan 2001 22:17:28 GMT, hparks@my-deja.com wrote:

>I have a simple perl program (source below) which I use scan a text
>file containing multiple reports. The program pulls out reports with a
>particular header, ---070---, and puts them in a file.  After working
>for months, it stopped working 2 weeks ago.  Some debugging showed the
>program was exiting when an escape character (hex 1B) was encountered.
>My first attempt to get around this was to look at each line as it is
>read and replace the character, but I think this does not work because
>the escape appears to be terminating the while (<INFILE>) loop.
>Another approach I thought of was reading in the file as a single
>variable and using search-and-replace, but if the 1B makes makes the
>read terminate, that won't work either.  I don't mind RTFM if someone
>will point me to the right manual.  The environment is WinNT4.
>
>Here is the source:
>$infile = $a;
>$lcnt = 0; $twcnt = 0; $thcnt = 0; $scnt = 0;
>open(INFILE,"<$infile") or die ("Input file error");
>open(OUTFILE,">>c:/perl/sterl070.dat") or die ("Output file error");
>while (<INFILE>)
>{ $line = $_;
>  $lcnt += 1;
>  if ($line =~ /---\d\d\d/)  {
>      $lastheader = $line;
>      if ($lastheader =~ /---020---/) {
>         $twcnt += 1;}
>      if ($lastheader =~ /---030---/)  {
>         $thcnt += 1;}
>      if ($lastheader =~ /---070---/)  {
>         $scnt += 1;}
>  }
>  if ($lastheader =~ /---070---/) {
>      print OUTFILE $line;
>  }
>}
>close(INFILE);
>close(OUTFILE);
>print "020:", $twcnt;
>print ", 030:", $thcnt;
>print ", 070:", $scnt,"\n";
>print $lcnt,"\n";
>------------ end of source ------------
>
>Howard Parks
>1 Peter 4:10
>
>
>Sent via Deja.com
>http://www.deja.com/


Have you tried using sysread() to get the data instead of using the text based <> approach?  That
should allow you to get the full string into a variable, although depending on size of data, that
could present its own problems.

  --------== Posted Anonymously via Newsfeeds.Com ==-------
     Featuring the worlds only Anonymous Usenet Server
    -----------== http://www.newsfeeds.com ==----------


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

Date: 25 Jan 2001 15:37:05 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Does 'system' function work on Win32 ActivePerl?
Message-Id: <8znz5pxq.fsf@pobox.com>

matthias.ferber@bwise.com (Matthias Ferber) writes:

> The problem is that the system call doesn't seem to be doing
> anything -- I get no output, even if I use backticks instead.  I'm
> at a loss.

Forgive *me* if this question seems silly, but does the program in
question normally produce any output?  You said "even if I use
backticks instead", which implies that you thought that system() would
in some way give you the output of the program in question.

system() works just fine on Win32.

Are you checking the return value of system()?  Are you checking $!
and $? ?

> I've seen elsewhere in this newsgroup that fork() may not be well
> implemented on Win32

You misunderstand. fork() is not implemented *at all* in the Win32
operating system.  It is *emulated* in the Win32 port of perl.  That
emulation is "good enough" for some purposes, though in saying so, I
am repeating hearsay.  I've never used it.  When I've needed to do
process manipulation I've used the Win32 modules.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Thu, 25 Jan 2001 11:18:45 -0800
From: "Richard Alan Beemer, Jr." <wolfmtn@mindspring.com>
Subject: Re: FAQ 1.14:   Where can I get a list of Larry Wall witticisms?
Message-Id: <wolfmtn-A116B3.11184525012001@enews.newsguy.com>

How to tell if you're a loser.

1) Do you still live with Mom & Dad?
2) Do your Pjs have feet sewn onto them?
3) Do you quote Larry Wall?


(More self-exam questions to follow...)

-- 
Richard Alan Beemer Jr
2255 Ne 71st St
Kansas City, MO 64118-7816
(816)455-8154


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

Date: 26 Jan 2001 00:06:30 +0100
From: jacklam@math.uio.no (Peter J. Acklam)
Subject: Re: FAQ 1.3:   Which version of Perl should I use?
Message-Id: <wkzogffczt.fsf@math.uio.no>

Lou Moran <lmoran@wtsg.com> writes:

> jacklam@math.uio.no (Peter J. Acklam) wrote wonderful things
> about sparkplugs: 
> 
> > $\="\n";$_='The quick brown fox jumps over the lazy dog';print +(split
> > //)[20,5,24,31,3,36,14,12,31,1,2,11,9,23,33,29,35,15,32,36,7,8,28,29];
> 
> cool...  They ought to have an FAQ on how this works

Huh?  That JAPH is nothing compared to what some other people in
this news group have presented.  :-)

I did, however, port the JAPH idea to Matlab, a language I know
pretty well.  And my JAMHs (Just another Matlab hacker) has "helped"
me getting a kind of reputation in that culture.

Peter

-- 
$\="\n";$_='The quick brown fox jumps over the lazy dog';print +(split
//)[20,5,24,31,3,36,14,12,31,1,2,11,9,23,33,29,35,15,32,36,7,8,28,29];

(One billion seconds since the epoch at 2001-09-09 03:46:40)


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

Date: Thu, 25 Jan 2001 21:27:39 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: FAQ 1.5:   What is perl6?
Message-Id: <x71ytrwcdw.fsf@home.sysarch.com>

>>>>> "PS" == PerlFAQ Server <faq@denver.pm.org> writes:

  PS>   What is perl6?

  PS>     Perl6 is a semi-jocular reference to the Topaz project. Headed
  PS>     by Chip Salzenberg, Topaz is yet-another ground-up rewrite of
  PS>     the current release of Perl, one whose major goal is to create
  PS>     a more maintainable core than found in release 5. Written in
  PS>     nominally portable C++, Topaz hopes to maintain 100%
  PS>     source-compatibility with previous releases of Perl but to run
  PS>     significantly faster and smaller. The Topaz team hopes to
  PS>     provide an XS compatibility interface to allow most XS modules
  PS>     to work unchanged, albeit perhaps without the efficiency that
  PS>     the new interface would allow. New features in Topaz are as
  PS>     yet undetermined, and will be addressed once compatibility and
  PS>     performance goals are met.

  PS>     If you are a hard-working C++ wizard with a firm command of
  PS>     Perl's internals, and you would like to work on the project,
  PS>     send a request to perl6-porters-request@perl.org to subscribe
  PS>     to the Topaz mailing list.

  PS>     There is no ETA for Topaz. It is expected to be several years
  PS>     before it achieves enough robustness, compatibility,
  PS>     portability, and performance to replace perl5 for ordinary use
  PS>     by mere mortals.

well, this is highly out of date. topaz is defunct and there is a real
perl6 project in the works which has nothing to do with it (other than
to learn from it).

so this should be changed to a mention and link to
http://www.perl.org/perl6/

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Thu, 25 Jan 2001 23:17:31 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: FAQ status and reposts, was Re: FAQ 1.5:   What is perl6?
Message-Id: <Pine.LNX.4.30.0101252305540.16428-100000@lxplus003.cern.ch>

On Thu, 25 Jan 2001, Uri Guttman wrote:

> >>>>> "PS" == PerlFAQ Server <faq@denver.pm.org> writes:

[...]

> well, this is highly out of date. topaz is defunct and there is a real
> perl6 project in the works which has nothing to do with it (other than
> to learn from it).

Well, this is another symptom of a general problem.  AFAICS, our
friend the FAQ-reposter is posting extracts from the FAQs that are
distributed with a released version of Perl.  But those are out of
date in a number of respects.

On the other hand if he were to take the FAQs that come at the
bleeding edge, they might well have stuff in them that refers to
new features of Perl that aren't in the versions that readers are
using.

What seems to be needed in this regard are timely patches that go with
the release distribution(s), in addition to (in parallel with) the
updates that are being built at the bleeding edge.  I suppose that
would be a lot to ask the developers for, but without it, this is what
the users are getting (with their release distributions), and I think
the faq reposter is only acting as the messenger of that fact.

On the one hand, most of the reposted FAQs are doing a good job (in so
much as reposted FAQs ever do a good job - it's a pity they're needed,
but reality is that they are).

But on the other hand, some of the FAQs are stale and would be best
left out.  But who's willing to do the work to identify which those
are, bearing in mind that they won't get patched (in that form)
anyway?  If the work was going to be done at all, it would be better
done by patching the stable distribution, where it'll leverage to all
users of that distibution.  And our friendly FAQ reposter would I'm
sure then be happy to start using the patched distribution.

But we can't ask him to build his own FAQ out of the bits and pieces
of different versions, that simply wouldn't scale.

Practical suggestions?

all the best.



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

Date: Thu, 25 Jan 2001 20:47:46 +0000 (GMT)
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: Re: Finding HTTP status code for a URL
Message-Id: <4a42920896g.soper@soundhouse.co.uk>

In article <comdog-A84377.14072024012001@news.panix.com>,
   brian d foy <comdog@panix.com> wrote:
> HTTP::SimpleLinkChecker doesn't do what you want?

> http://search.cpan.org/search?mode=module&query=HTTP%3A%3ASimple

Yes, precisely. However I'm stopping learning Perl until I can learn to
use a search engine to find what I require!

Thanks

-- 
Geoff Soper
g.soper@soundhouse.co.uk
Take a look at the Soundhouse page http://www.soundhouse.co.uk/


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

Date: 25 Jan 2001 15:11:21 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: hash to java
Message-Id: <lmrz5r4m.fsf@pobox.com>

"Géry" <ducateg@info.bt.co.uk> writes:

> I want to stream the hash from a perl script to populate a hash
> table in a java piece of code.

What do you mean?  Is there a Java applet running on a web browser
communicating via sockets with a server written in Perl?  Is the Java
program an application running on the same machine as the Perl
program, communicating via pipes?

> Can I simply pass the object reference and expect that the perl hash
> structure will turn into a valid java hash table

No, whatever you're doing!

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 25 Jan 2001 22:16:50 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: How to do this regular expression?
Message-Id: <eli$0101251710@qz.little-neck.ny.us>

In comp.lang.perl.misc,
Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote:
> On Wed, 24 Jan 2001 08:23:37 GMT, Anthony Mak <tony@lis.co.jp> wrote:
> >I want to search for a string NOT ended with a ';' mark.
> $_ = "My string";
> print "Yipee" if /[^;]$/;

That prints 'Yippee' for  $_ = "My string;\n"; and Anthony's post
was vague enough that he might not want that. This might work better:

	print "Yipee" if /[^;\s]\s*$/;

> #requires 5.6.0
> perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'

Clever. But it fails if JAPH is a program on your path.

Elijah
------
echo 'echo Not just another perl hacker,' > ~/bin/JAPH && chmod 755 ~/bin/JAPH


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

Date: Thu, 25 Jan 2001 21:38:31 +0000 (GMT)
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: HTTP status codes
Message-Id: <4a4296ae16g.soper@soundhouse.co.uk>

I'm just writing a script to handle external links. I want the script to
check the URL's HTTP status code and if it's OK send the user there but if
it's not (404 etc.) to e-mail the webmaster and display a 'sorry' page. 
I need to know what HTTP status codes to treat as being OK and which to
treat as being no good (apart from 404). 

I realise this isn't the place to ask but there doesn't seem to be a HTTP
newsgroup, does anyone have a suggestion of where to ask this question or
even have a quick answer?

I've found the relavent RFC (2616) but would like to know which of all the
codes are 'bad'.

Many thanks

-- 
Geoff Soper
g.soper@soundhouse.co.uk
Take a look at the Soundhouse page http://www.soundhouse.co.uk/


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

Date: Thu, 25 Jan 2001 16:48:27 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: HTTP status codes
Message-Id: <comdog-ABFB76.16482725012001@news.panix.com>

In article <4a4296ae16g.soper@soundhouse.co.uk>, Geoff Soper 
<g.soper@soundhouse.co.uk> wrote:

> I've found the relavent RFC (2616) but would like to know which of all the
> codes are 'bad'.

the RFC is pretty clear on that.

-- 
brian d foy <comdog@panix.com>
no longer for hire ;)


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

Date: Thu, 25 Jan 2001 11:31:19 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: Iterating through matches to a regexp ?
Message-Id: <3A7062E7.29D0027F@home.com>

tmark@my-deja.com wrote:
> 
> I have a regexp - say, 'A{1,}B{1,}', and a target string (say,
> 'AAABBB'). Is there a way to iterate through possible matches to this
> regexp, returning, for instance, 'AB', 'AAB', 'AABB', etc. ?

Hrm. You can use backreferences to capture what a regex actually did
match, and you can make your regex greedy or non-greedy, but I don't
think there's a (direct) way of getting anything in between. Not without
hacking into the source code, anyway.

The only way I can think of to do this is brute force. First create a
list of all possible substrings of your target string, and then see how
many of those match your pattern. It's going to scale horribly, though.
You can perform one minor optimization by only taking substrings that
are at least two chars long, since that's the minimum your regex would
match.

#!/usr/local/bin/perl5 -w
use strict;

my $string     = 'AAABBB';
my $str_length = length($string);
my $min_length = 2;

my @subs;
for my $i (0 .. $str_length - 1) {
    my $j = $str_length - $i;
    for my $k ($min_length .. $j) {
        push(@subs, substr($string, $i, $k));
    }
}

my @matches = grep {/A{1,}B{1,}/} @subs;
print join("\n", @matches);

__END__
AAAB
AAABB
AAABBB
AAB
AABB
AABBB
AB
ABB
ABBB

Perhaps someone else can come up with a better approach.

-mjc


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 144
**************************************


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