[17769] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5189 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Dec 23 14:05:31 2000

Date: Sat, 23 Dec 2000 11:05:08 -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: <977598308-v9-i5189@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 23 Dec 2000     Volume: 9 Number: 5189

Today's topics:
    Re: ??POST fails, but GET works (David Efflandt)
    Re: Active Perl/Windows ME problem? <zarathustra@enviroweb.org>
    Re: Active Perl/Windows ME problem? fallenang3l@my-deja.com
    Re: Active Perl/Windows ME problem? <bbollenbach@homenospam.com>
    Re: automatic FAQ answerer idea (David H. Adler)
        avoiding killfile entry (was Re: automatic FAQ answerer (Tad McClellan)
        FAQ asking madness (was Re: Simple REGEX question) (Tad McClellan)
    Re: FAQ asking madness (was Re: Simple REGEX question) <jdhunter@nitace.bsd.uchicago.edu>
    Re: FAQ asking madness (was Re: Simple REGEX question) <harrisr@bignet.net>
    Re: file size - outside url? <karol@imm.org.pl>
    Re: Help Bidirectional IPC with IPC::Open2 (David Efflandt)
    Re: Help with multipart form richardstands@my-deja.com
        Help: modulus problem, docs confusing richardstands@my-deja.com
    Re: Hostname? <mtaylorlrim@my-deja.com>
        infinite loop <jfdecd@execpc.com>
    Re: infinite loop (Eric Bohlman)
    Re: Need help finding a space in a string with "index" <jhelman@wsb.com>
    Re: Newbie Question...What do they mean by build a bina <brew@theMode.com>
        Perl to ksh question <unixdude@voicenet.com>
    Re: Perl to ksh question nobull@mail.com
    Re: perl vote script. (MOS NY)
        REF: Help with Hash in a loop.  Desperate! (at 72 wrap  <angel@reflex-point.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 23 Dec 2000 15:27:26 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: ??POST fails, but GET works
Message-Id: <slrn949h2j.ksf.efflandt@efflandt.xnet.com>

On Wed, 20 Dec 2000, jrogers42@hotmail.com <jrogers42@hotmail.com> wrote:
>I have a cgi script that begins with a html document that has a form in
>it with method = POST. It calls a perl script. In that perl script is
>if the conditions are met it must create another html form with method
>= POST. Now, when I do this the script hangs at the point when it
>creates the second form. When, I use GET on the html it works, but
>hangs after the second form. When I use GET for both it works fine. But
>for security reasons I need to use POST. Any help??

There could be something wrong with your method for handling POST.
Use CGI.pm to create and process your forms.  Then it does not matter if
you GET or POST.  On a system with Perl type:  perldoc CGI
And direct further questions to a cgi newsgroup.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Sat, 23 Dec 2000 17:21:43 GMT
From: "Zarathustra" <zarathustra@enviroweb.org>
Subject: Re: Active Perl/Windows ME problem?
Message-Id: <Ha516.9181$G4.405023@newsread2.prod.itd.earthlink.net>


"Buck" <mrsnitch@ksc.co.th> wrote in message
news:3a44a699.16102894@news.ksc.co.th...
> I've just installed the latest version of Active Perl on my Windows ME
> operating system but when I run the "example.pl" file in a DOS window,
> I get "Bad Command or File Name".

I'm running ME with build 620 just fine.  You shouldn't get the "Bad Command
or File Name" error if you execute "perl -w example.pl" instead of simply
typing in the script name.

> When I installed, I chose the "add to path" option, etc.

It's been a little while since I installed but I think there were quirks
with the path being added.  I would verify it just to be sure by "msconfig"
or just "path".

> is that it will work if you double-click the example.pl file but the
> "Hello World" message only flashes in a DOS window for a second.

If it flashes "Hello World" it's working.






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

Date: Sat, 23 Dec 2000 17:16:41 GMT
From: fallenang3l@my-deja.com
Subject: Re: Active Perl/Windows ME problem?
Message-Id: <922mlm$cqk$1@nnrp1.deja.com>

In article <3a44a699.16102894@news.ksc.co.th>,
  none@none.net wrote:
> I've just installed the latest version of Active Perl on my Windows ME
> operating system but when I run the "example.pl" file in a DOS window,
> I get "Bad Command or File Name".
> When I installed, I chose the "add to path" option, etc. Funny thing
> is that it will work if you double-click the example.pl file but the
> "Hello World" message only flashes in a DOS window for a second.
> Can't understand why I can't run the files from a command line in DOS.
> I've moved to the correct directory and even tried the "perl -v"
> command. Still, that same "Bad Command or File Name" message.
> Is it a Windows ME problem? Any help would be greatly appreciated!
>

 .pl is NOT an executable and that why you get "Bad command or file
name." Instead, go to dos prompt and type "perl example.pl" (w/o
quotes). If that doesn't work, add the full path like
this: "c:\perl\bin\perl.exe example.pl" (you have to be in the
example.pl directory, and if you are not then you will have to add the
full path for example.pl).


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


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

Date: Sat, 23 Dec 2000 17:50:45 GMT
From: "Brad Bollenbach" <bbollenbach@homenospam.com>
Subject: Re: Active Perl/Windows ME problem?
Message-Id: <VB516.54364$Z9.3267641@news1.rdc1.mb.home.com>

The fact that perl is in your path will not do anything to help you execute
the script (at least, in a Win32 environment where #! isn't supported),
until you've associated .pl's with the Perl interpreter.

To do this go to Start->Settings->Control Panel->Folder Options and click
the file types tabs. Adding the .pl file type, and associating the Perl
interpreter to it should be straightforward from there.

Feel free (*hint* *hint* :) to browse ActiveState's FAQ (including with your
AS Perl installation). This question was already answered in there.

Brad

----- Original Message -----
From: "Buck" <mrsnitch@ksc.co.th>
Newsgroups: comp.lang.perl.misc
Sent: Saturday, December 23, 2000 7:25 AM
Subject: Active Perl/Windows ME problem?


> I've just installed the latest version of Active Perl on my Windows ME
> operating system but when I run the "example.pl" file in a DOS window,
> I get "Bad Command or File Name".
> When I installed, I chose the "add to path" option, etc. Funny thing
> is that it will work if you double-click the example.pl file but the
> "Hello World" message only flashes in a DOS window for a second.
> Can't understand why I can't run the files from a command line in DOS.
> I've moved to the correct directory and even tried the "perl -v"
> command. Still, that same "Bad Command or File Name" message.
> Is it a Windows ME problem? Any help would be greatly appreciated!





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

Date: 23 Dec 2000 19:02:11 GMT
From: dha@panix6.panix.com (David H. Adler)
Subject: Re: automatic FAQ answerer idea
Message-Id: <slrn949tlj.ngb.dha@panix6.panix.com>

On Sat, 23 Dec 2000 09:11:42 +0100, Philip 'Yes, that's my address'
Newton <nospam.newton@gmx.li> wrote:

>perldoc perlre works fine under DOS and/or Windows (not sure about Mac). You may

MacPerl comes with a pod reader called Shuck.

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Got Perl? <www.perl.com>
Got a Perl User Group? <www.pm.org>


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

Date: Sat, 23 Dec 2000 08:02:31 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: avoiding killfile entry (was Re: automatic FAQ answerer idea)
Message-Id: <slrn9498j7.9m1.tadmc@magna.metronet.com>

Philip 'Yes, that's my address' Newton <nospam.newton@gmx.li> wrote:

>Hey eggrock, I tried to send you private email, but it bounced:


One more datapoint for avoiding killfiles:

If it had been me sending the email that bounced, it would
have earned a killfile entry for the intended recipient.

Once it becomes apparent that someone is posting with an
undeliverable address, they get scored down.


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sat, 23 Dec 2000 07:56:13 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: FAQ asking madness (was Re: Simple REGEX question)
Message-Id: <slrn94987d.9m1.tadmc@magna.metronet.com>


This thread is a classic example of the global waste of time
caused by asking a Frequently Asked Question!


'harrisr' couldn't be troubled to check the Perl FAQ before
posting to the Perl newsgroup, and so asked a question that
has been asked (and answered) here *hundreds* of times 
(that in not an exaggeration, it is literal).

'jdhunter' and 'jhelman', trying to be helpful (but not succeeding), 
followup with not-very-well-thought-out "answers".

The answers in the FAQ have been peer-reviewed by _lots_ of sets
of eyes. Mistakes and inefficiencies do not survive long in a
FAQ answer. The answers there are "better quality" than you can
get by reasking the question for that one reason alone.

'rick.delaney' and 'tadmc' must then followup to clean up the mess, 
lest lurkers pick up on the silly code.

Hundreds or thousands of newsgroup readers get to see this whole
scenario played out yet again. (multiply a few seconds times
a few thousand)

Four people who could otherwise have spent their time answering
UNanswered questions have had their time sucked into rehashing
stuff that has been hashed out hundreds of times already!

What is the point of that? I can't see one. Why are we doing it then?


'harrisr' has hurt the other members of this community by starting
this ball rolling, and drawing potential-question-answerers away
from other people's questions.

'jdhunter' and 'jhelman' have hurt the community to a lesser extent,
but have also drawn away resources. I'm sure that was not their
intent, but that was undoubtedly their effect.

Not to discourage folks who want to try and help, but answering
a Frequently Asked Question without a pointer to the FAQ answer
does a disservice to everybody here!


   Stop the madness!



Jeff Helman <jhelman@wsb.com> wrote:
>John Hunter wrote:
>> 
>> >>>>> "Randy" == Randy Harris <harrisr@bignet.net> writes:
>> 
>>     Randy> Why won't $str =~ s/^\s*()\s*$/$1/; trim both ends?
>> 
>> Is suspect that this is what you want:
>> 
>> $str =~ s/^\s*(.*)\s*$/$1/;
>
>Or better yet,
>
>$str =~ s/^\s+|\s+$//g;
>
>This has a couple of advantages.

[snip]

>Hope this helps,


C'mon man, you're doing it again!

Attempting to reanswer a FAQ rarely helps.

Your second attempt was not one of the rare ones either.

Please do not try and reanswer FAQs. Just tell them where
the FAQ is that addresses their problem.


-----------------------------------
#!/usr/bin/perl -w
use Benchmark;

timethese 1_000_000, { 
   control   => q( my $str = '   foo bar	 	';
                 ),
   memory    => q( my $str = '   foo bar	 	';
                   $str =~ s/^\s*(.*?)\s*$/$1/;
                 ),
   FAQ       => q( my $str = '   foo bar	 	';
                   $str =~ s/^\s+//;
                   $str =~ s/\s+$//;
                 ),
   Helman    => q( my $str = '   foo bar	 	';
                   $str =~ s/^\s+|\s+$//g;
                 ),
};

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

(partial) output:

    FAQ:  7 wallclock secs ( 6.54 usr +  0.08 sys =  6.62 CPU) @ 151057.40/s
 Helman: 13 wallclock secs (12.32 usr +  0.12 sys = 12.44 CPU) @ 80385.85/s
control:  1 wallclock secs ( 0.95 usr +  0.00 sys =  0.95 CPU) @ 1052631.58/s
 memory: 30 wallclock secs (28.23 usr +  0.69 sys = 28.92 CPU) @ 34578.15/s


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 23 Dec 2000 08:50:34 -0600
From: John Hunter <jdhunter@nitace.bsd.uchicago.edu>
Subject: Re: FAQ asking madness (was Re: Simple REGEX question)
Message-Id: <1rn1dnb39h.fsf@video.bsd.uchicago.edu>

>>>>> "Tad" == Tad McClellan <tadmc@metronet.com> writes:

    Tad> 'jdhunter' and 'jhelman' have hurt the community to a lesser
    Tad> extent, but have also drawn away resources. I'm sure that was
    Tad> not their intent, but that was undoubtedly their effect.

Guilty as charged.  My apologies.  Nine times out of ten, I test my
answers before replying.  This time I thought the answer so plain that
I just whipped it off.  Now I know why I test!

And it goes without saying that I should have checked the FAQ.
'perldoc -q space' isn't all that hard, is it?

Thanks,
John Hunter


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

Date: Sat, 23 Dec 2000 13:03:11 -0500
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: FAQ asking madness (was Re: Simple REGEX question)
Message-Id: <t49q5sdt0k9l7f@corp.supernews.com>

Tad McClellan <tadmc@metronet.com> wrote in message
news:slrn94987d.9m1.tadmc@magna.metronet.com...
>
> This thread is a classic example of the global waste of time
> caused by asking a Frequently Asked Question!
>
> 'harrisr' couldn't be troubled to check the Perl FAQ before
> posting to the Perl newsgroup, and so asked a question that
> has been asked (and answered) here *hundreds* of times
> (that in not an exaggeration, it is literal).

Tad, go ahead and killfile me, because your response is bullshit. You
are wrong on several counts. I did not ask a FAQ. I did search for the
answer in the FAQ before asking the question. My question was not 'what
is the most efficient way to trim spaces'.  Rick Delaney did provide a
very informative and helpful explanation of the area that had confused
me, specifically the difference between (.*) and (.*?). Yes, he could
have simply pointed to another FAQ but I don't think his answer wasted
all that much of your time.




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

Date: Sat, 23 Dec 2000 16:10:55 +0100
From: "Karol Nowakowski" <karol@imm.org.pl>
Subject: Re: file size - outside url?
Message-Id: <3a44c089@news.home.net.pl>

Uzytkownik "Jeff Helman" <jhelman@wsb.com> napisal w wiadomosci
news:3A44ADFD.BC59EAE2@wsb.com...
> Karol Nowakowski wrote:
> > Could You give some more info, maybe an example?
> Go to a command prompt (or DOS prompt or whatever) and type:
> perldoc lwpcook

thank You,
I've found them (i.e. examples)

but unfortunetaly I don't have LWP module on my ISP virtual server and I
don't have telnet connection, so I'm not able to install this module there

the command I'm getting is:
Malformed header from CGI script: Can't locate LWP/Simple.pm in @INC (@INC
contains: /usr/perl/i386-freebsd /usr/perl /usr/perl/site_perl/i386-freebsd
/usr/perl/site_perl /usr/perl/site_perl .) at /sws/temp4.pl line 3. BEGIN
failed--compilation aborted at /sws/temp4.pl line 3

the program is simple:

----------------------------------------------------------------------------
----------------
print "Content-type: text/plain\n\n";

use LWP::Simple;
  $doc = get 'http://www.sn.no/libwww-perl/';
print "$doc";
exit;
----------------------------------------------------------------------------
----------------

does it mean that I don't have a module or does it mean that I'm giving
wrong catalogues?

Thank You very much for help

With best Regards,
Karol Nowakowski





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

Date: Sat, 23 Dec 2000 16:02:00 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Help Bidirectional IPC with IPC::Open2
Message-Id: <slrn949j3c.ksf.efflandt@efflandt.xnet.com>

On Thu, 21 Dec 2000 11:58:46 -0800, Bill Moseley <usenet@hank.org> wrote:
>I've used IPC::Open2 before without problem.   But, now I'm trying to 
>create a client/server setup with Open2.  Basically, I want to emulate 
>in a pipe http -- but with "Keep Alives".
>
>I'm want to open another process, then send it a set of headers, get a 
>set of headers in response, and repeat the process for another request -
>- yet never close the pipe.  I also will need to send to the server and 
>receive back some content (just like a POST).
>
>Can someone help?
>
>
>> cat client.pl
>
>#!/usr/local/bin/perl -w
>use strict;
>use IPC::Open2;
>use IO::Select;
>use IO::Handle;
>
>my ( $rh, $wh );

I think you need to assign something useful to the above variables.
From perldoc IPC::Open2:

WARNING
       It will not create these file handles for you.  You have
       to do this yourself.  So don't pass it empty variables
       expecting them to get filled in for you.

See the open2 example in perldoc perlipc.

>my $pid = open2($rh, $wh, './server.pl');
>$pid || die "Failed to open";
>
>my $read = IO::Select->new( $rh );
>
>$rh->autoflush;
>$wh->autoflush;
>
>for (1..2) {
>    print "\n>>$0: Sending Headers:$_\n";
>
>    print $wh "Header-number: $_\n",
>              "Content-type: perl/test\n",
>              "Header: test\n\n";
>
>
>    # Now read the response
>    while ( 1 ) {
>
>        my $fh;
>        
>        if ( ($fh) = $read->can_read(0) ) {
>            print "Can read!\n";
>
>            my $buffer = <$rh>;
>            #$fh->read( $buffer, 1024 );
>
>            last unless $buffer;
>
>            print "<<$0: Read $buffer";
>        } else {
>            print "Can't read sleeping...\n";
>            sleep 1;
>        }
>    }
>    print "$0: All done!\n";
>}
>            
>    
>
>> cat server.pl 
>
>#!/usr/local/bin/perl -w
>use strict;
>
>$|=1;
>
>warn "In $0 pid=$$\n";
>
>while (1) {
>    my @headers = ();
>    while ( <> ) {
>        chomp;
>        if ( $_ ) {
>            warn "$0: Read '$_'\n";
>            
>            push @headers, $_;
>        } else {
>            for ( @headers ) {
>                warn "$0: Sending $_\n";
>                print $_,"\n";
>            }
>            print "\n";
>            last;
>        }
>    }
>}
>    
>
>-- 
>Bill Moseley


-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Sat, 23 Dec 2000 16:56:18 GMT
From: richardstands@my-deja.com
Subject: Re: Help with multipart form
Message-Id: <922lfg$bvi$1@nnrp1.deja.com>

In article <91vmbc$6p8$1@nnrp1.deja.com>,
  RUATurtle <jack.haberle@bigfoot.com> wrote:
> Rich,
>
> I also wondered about the web server.
>
> Had to work around this but hope to revisit it later.  Will post if I
> have any success.
>
> -Jack
>
> Sent via Deja.com
> http://www.deja.com/
>
Jack,

Update:

Turns out that apparently the problem I was having was with the fact
that the remote CGI was a Java servlet and supposedly "as such you
can't pass it parameters in the URL"; at least that's what their IT
people told me. I don't know enough about servlets to doubt their claim
but considering it worked with my Perl script but not their Java it may
be the whole problem.

I too have a workaround in the form of their finally exposing their FTP
server to me ;o) I would still like to get the Perl HTTP thingy to work
as I can think of other instances where it would be useful...

-Rich


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


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

Date: Sat, 23 Dec 2000 18:38:32 GMT
From: richardstands@my-deja.com
Subject: Help: modulus problem, docs confusing
Message-Id: <922rf9$g2m$1@nnrp1.deja.com>

Hi all,

I was working on a progress bar for an FTP upload and got all tangled
up in figuring the percentage and wound up using the modulus operator
(math is not my strong suit). Am I losing it or am I just missing
something(obvious) here!? I am using ActiveState Perl 5.6.0. The
documentation for the modulus operator states:

"If $b is positive, then $a % $b is $a minus the largest multiple of $b
that is not greater than $a."

given code:

print( ( 100.123 % 23 ), "\n" );

I get:

8

What I don't understand is why the result is 8 and not 8.123 i.e.
100.123 - (23 * 4). This makes no sense if you take the documentation
literally plus it's screwing up my calculations as I am doing something
like:

if ( $percent % $incr ) == 0;

Ugh, thanks for any clarity that you can lend. Oh, and happy
holidays ;o)

-Rich


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


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

Date: Sat, 23 Dec 2000 14:07:36 GMT
From: Mark <mtaylorlrim@my-deja.com>
Subject: Re: Hostname?
Message-Id: <922bj6$555$1@nnrp1.deja.com>

In article <92275e$5h2e1$1@ID-26625.news.dfncis.de>,
  "Bernhard Rittirsch" <rittirsch@gmx.de> wrote:
> Hello!
>
> I have a script which collects the IP-addresses of my homepage-
visitors.
>
> Can someone tell me how I can automatically (with a perl-script)
resolve the
> hostname of these IPs?
>
> Regards,
> Bernhard
>
> -----
> Bernhard Rittirsch - Am Eisberg 10 - 86476 Neuburg - Deutschland
> Tel.: +49/(0)8283/1324 - Mobile: +49/(0)174/9136870
> E-Mail: rittirsch@gmx.de - Homepage: www.uni-ulm.de/~s_britti/
>
>
The hostname is stored in the environment variable $REMOTE_HOST but
remote host lookups must be on for the httpd server. Otherwise other
response methods must be used.

Mark
--
Please reply to this newsgroup as my Deja mail
is used as a spam catcher only!


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


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

Date: Sat, 23 Dec 2000 11:49:08 +0600
From: "Jerry F. Davis" <jfdecd@execpc.com>
Subject: infinite loop
Message-Id: <3a44e5b1$0$77887$272ea4a1@news.execpc.com>

learning perl and i have what amounts to an infinite loop here

what is wrong, 

how can i code it so that i don't get this infinite loop

in perl can i do something like try catch?

here is the code:
--------------------------------
#!/usr/bin/perl

use warnings;
use strict;

open LYNX, "lynx -source http://www.perl.com/ |" or die "couldn't open lynx: $!";

# define $_ and skip through file until "standard.def"

$_ = "";

my $stop = 0;
do {
  $_ = <LYNX> until /standard\.def/;     # <<< here is where i get error
  exit if (not defined $_); 
  $_ = <LYNX> until /<A HREF/;
  
  # having found the "standard.def" line, now get the next line
  my $head = $_;
 
  if (not defined $head) {
    $stop = 1;
  }
  else {
    # get rid of all the HTML crap
    $head =~ m|^<A HREF=[^>]+>(.*?)</a>|i;

    print "Today's perl headline is: $1\n";
  }
} until ($stop);


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

Date: 23 Dec 2000 18:36:20 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: infinite loop
Message-Id: <922rb4$hs7$1@bob.news.rcn.net>

Jerry F. Davis <jfdecd@execpc.com> wrote:
> learning perl and i have what amounts to an infinite loop here

> what is wrong, 

> how can i code it so that i don't get this infinite loop

> in perl can i do something like try catch?

Yes, but you don't need it here.  You can simply restructure your loops.

> here is the code:
> --------------------------------
> #!/usr/bin/perl

> use warnings;
> use strict;

> open LYNX, "lynx -source http://www.perl.com/ |" or die "couldn't open lynx: $!";

> # define $_ and skip through file until "standard.def"

> $_ = "";

This is useless.  It's not necessary to "define" Perl built-in variables.

> my $stop = 0;
> do {
>   $_ = <LYNX> until /standard\.def/;     # <<< here is where i get error

That's a rather dangerous style of loop, since if the retrieved document
doesn't contain any occurrences of "standard.def" it will sit there
happily reading undef from the file handle and trying to match it against
"standard.def."

>   exit if (not defined $_); 
>   $_ = <LYNX> until /<A HREF/;
>   
>   # having found the "standard.def" line, now get the next line
>   my $head = $_;
>  
>   if (not defined $head) {
>     $stop = 1;
>   }
>   else {
>     # get rid of all the HTML crap
>     $head =~ m|^<A HREF=[^>]+>(.*?)</a>|i;

>     print "Today's perl headline is: $1\n";
>   }
> } until ($stop);

I'd do something like [UNTESTED]:

my @markers=('standard\.def','<a href');
my $state=0;
while (<LYNX>) {
  next unless /$markers[$state]/i;
  if (++$state==2) {
    $state=0;
    if (m|^<A HREF=[^>]+>(.*?)</a>|i) {
      print "Today's perl headline is: $1\n";
    }
  }
}

The usual caveats about trying to parse HTML with regexen apply; in
particular, this code will fail if the anchor spans more than one line.



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

Date: Sat, 23 Dec 2000 14:08:34 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Need help finding a space in a string with "index"
Message-Id: <3A44B1FD.3F86493D@wsb.com>

Ryan & Treena Carrier wrote:

> I'm trying to determine the first occurrence of a space character in a
> string. It seems to me
> 
> my $string = "Hello World";
> my $spaceLocation = index($string, " ");
> 
> should give 5 to $string, but it doesn't work.

No, it should give 5 to $spaceLocation (and it does).

JH


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

Date: Sat, 23 Dec 2000 16:22:23 GMT
From: Bruce Schiller <brew@theMode.com>
Subject: Re: Newbie Question...What do they mean by build a binary
Message-Id: <3j416.402$%42.5741@news3.voicenet.com>

Mike Lin <mikelin6@home.com> wrote:
: I've seen this mentioned several times on the perl and apache websites.
: Why do you have to build software.  I know that when you make C++
: programs you have to "build" or "compile" them to make them
: executables.

Exactly.  Apache and perl are written in C, you build (or compile) them
before you can run them.

brew

-- 
 ==========================================================================
                  Strange Brew   (brew@theMode.com)
     Check out my Musician's Online Database Exchange (The MODE Pages)
                        http://www.TheMode.com
 ==========================================================================



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

Date: Sat, 23 Dec 2000 14:17:38 GMT
From: "Ed Murray" <unixdude@voicenet.com>
Subject: Perl to ksh question
Message-Id: <6u216.318$U3.28613@news2.voicenet.com>


  Not being a scripter I have a question for the group, is there a utility
or
an easy way to take a script that was written in Perl and convert it to run
in a ksh enviornment ?  I am only a dumb systems engineer :-)  But I do have
extensive knowledge of unix only lacking in the scripting enviornment.

Thanks

Ed Murray





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

Date: 23 Dec 2000 15:29:21 +0000
From: nobull@mail.com
Subject: Re: Perl to ksh question
Message-Id: <u93dffupf2.fsf@wcl-l.bham.ac.uk>

"Ed Murray" <unixdude@voicenet.com> writes:

>   Not being a scripter I have a question for the group, is there a
> utility or an easy way to take a script that was written in Perl and
> convert it to run in a ksh enviornment ?

No.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 23 Dec 2000 14:37:49 GMT
From: mosny@aol.com (MOS NY)
Subject: Re: perl vote script.
Message-Id: <20001223093749.03122.00002141@ng-mg1.aol.com>

>You can find any number of polling scripts at resources like
>www.cgi-resources.com.

Since this thread was so recent I figured I would place my question here
instead of starting a new thread:

I'm looking for a perl script that takes the results of a numerical poll (i.e:
rate from 1-10), averages in the users new number, and spits back the current
average (i.e: 5.6 as an answer).

There are an enormous amount of pre-made vote/poll scripts out there, but I've
yet been able to find one that takes numerical data and averages it. (i.e: they
all show what percentage of people voted for each choice, but none takes the
result as data and spits out a single number).

Any help/reccomendation is greatly appreciated, apologies for the newbie
question,

mike


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

Date: Sat, 23 Dec 2000 12:34:06 -0600
From: "angel" <angel@reflex-point.com>
Subject: REF: Help with Hash in a loop.  Desperate! (at 72 wrap as requested)
Message-Id: <9b616.374$Dv3.18921@nnrp3.sbc.net>

Good Samaritan:
    I can't seem to understand why the following statement will only
work once in any loop:
my $fext = $mime{$ext};
Anytime I try to print $fext in a loop it will only print once no matter
the size of the loop.  What am I missing here?
Sincerely,
ANGEL
#!/usr/bin/perl5.004
require "cgi-lib.pl";
&ReadParse;
#!/usr/bin/perl5.004
require "cgi-lib.pl";
&ReadParse;
print &PrintHeader;


open(X2,"<X2.txt") || &ShitBiskits;
@FILELIST = <X2>;
close(X2);

while (@FILELIST)
{
undef $mime{$ext};
undef $fext;
undef %mime;
my %mime = (
#-------------------------------------<TEXT>-----
'HTML', "text/html",
'HTM', "text/html",
'STM', "text/html",
'SHTML', "text/html",
'TXT', "text/plain",
'PREF', "text/plain",
'AIS', "text/plain",
'RTX', "text/richtext",
'CSV', "text/comma-separated-values",
'TSV', "text/tab-separated-values",
'NFO', "text/warez-info",
'ETX', "text/x-setext",
'SGML', "text/x-sgml",
'SGM', "text/x-sgml",
'TALK', "text/x-speech",
'CGI', "text/plain", # we want these two as text files
'PL', "text/plain", # and not application/x-httpd-cgi
#-------------------------------------<IMAGE>----
'COD', "image/cis-cod",
'FID', "image/fif",
'GIF', "image/gif",
'ICO', "image/ico",
'IEF', "image/ief",
'JPEG', "image/jpeg",
'JPG', "image/jpeg",
'JPE', "image/jpeg",
'PNG', "image/png",
'TIF', "image/tiff",
'TIFF', "image/tiff",
'MCF', "image/vasa",
'RAS', "image/x-cmu-raster",
'CMX', "image/x-cmx",
'PCD', "image/x-photo-cd",
'PNM', "image/x-portable-anymap",
'PBM', "image/x-portable-bitmap",
'PGM', "image/x-portable-graymap",
'PPM', "image/x-portable-pixmap",
'RGB', "image/x-rgb",
'XBM', "image/x-xbitmap",
'XPM', "image/x-xpixmap",
'XWD', "image/x-xwindowdump",
#-------------------------------------<APPS>-----
'EXE', "application/octet-stream",
'BIN', "application/octet-stream",
'DMS', "application/octet-stream",
'LHA', "application/octet-stream",
'CLASS', "application/octet-stream",
'DLL', "application/octet-stream",
'AAM', "application/x-authorware-map",
'AAS', "application/x-authorware-seg",
'AAB', "application/x-authorware-bin",
'VMD', "application/vocaltec-media-desc",
'VMF', "application/vocaltec-media-file",
'ASD', "application/astound",
'ASN', "application/astound",
'DWG', "application/autocad",
'DSP', "application/dsptype",
'DFX', "application/dsptype",
'EVY', "application/envoy",
'SPL', "application/futuresplash",
'IMD', "application/immedia",
'HQX', "application/mac-binhex40",
'CPT', "application/mac-compactpro",
'DOC', "application/msword",
'ODA', "application/oda",
'PDF', "application/pdf",
'AI', "application/postscript",
'EPS', "application/postscript",
'PS', "application/postscript",
'PPT', "application/powerpoint",
'RTF', "application/rtf",
'APM', "application/studiom",
'XAR', "application/vnd.xara",
'ANO', "application/x-annotator",
'ASP', "application/x-asap",
'CHAT', "application/x-chat",
'BCPIO', "application/x-bcpio",
'VCD', "application/x-cdlink",
'TGZ', "application/x-compressed",
'Z', "application/x-compress",
'CPIO', "application/x-cpio",
'PUZ', "application/x-crossword",
'CSH', "application/x-csh",
'DCR', "application/x-director",
'DIR', "application/x-director",
'DXR', "application/x-director",
'FGD', "application/x-director",
'DVI', "application/x-dvi",
'LIC', "application/x-enterlicense",
'EPB', "application/x-epublisher",
'FAXMGR', "application/x-fax-manager",
'FAXMGRJOB', "application/x-fax-manager-job",
'FM', "application/x-framemaker",
'FRAME', "application/x-framemaker",
'FRM', "application/x-framemaker",
'MAKER', "application/x-framemaker",
'GTAR', "application/x-gtar",
'GZ', "application/x-gzip",
'HDF', "application/x-hdf",
'INS', "application/x-insight",
'INSIGHT', "application/x-insight",
'INST', "application/x-install",
'IV', "application/x-inventor",
'JS', "application/x-javascript",
'SKP', "application/x-koan",
'SKD', "application/x-koan",
'SKT', "application/x-koan",
'SKM', "application/x-koan",
'LATEX', "application/x-latex",
'LICMGR', "application/x-licensemgr",
'MAIL', "application/x-mailfolder",
'MIF', "application/x-mailfolder",
'NC', "application/x-netcdf",
'CDF', "application/x-netcdf",
'SDS', "application/x-onlive",
'SGI-LPR', "application/x-sgi-lpr",
'SH', "application/x-sh",
'SHAR', "application/x-shar",
'SWF', "application/x-shockwave-flash",
'SPRITE', "application/x-sprite",
'SPR', "application/x-sprite",
'SIT', "application/x-stuffit",
'SV4CPIO', "application/x-sv4cpio",
'SV4CRC', "application/x-sv4crc",
'TAR', "application/x-tar",
'TARDIST', "application/x-tardist",
'TCL', "application/x-tcl",
'TEX', "application/x-tex",
'TEXINFO', "application/x-texinfo",
'TEXI', "application/x-texinfo",
'T', "application/x-troff",
'TR', "application/x-troff",
'TROFF', "application/x-troff",
'MAN', "application/x-troff-man",
'ME', "application/x-troff-me",
'MS', "application/x-troff-ms",
'TVM', "application/x-tvml",
'TVM', "application/x-tvml",
'USTAR', "application/x-ustar",
'SRC', "application/x-wais-source",
'WKZ', "application/x-wingz",
'ZIP', "application/x-zip-compressed",
'ZTARDIST', "application/x-ztardist",
#-------------------------------------<AUDIO>----
'AU', "audio/basic",
'SND', "audio/basic",
'ES', "audio/echospeech",
'MID', "audio/midi",
'KAR', "audio/midi",
'MPGA', "audio/mpeg",
'MP2', "audio/mpeg",
'TSI', "audio/tsplayer",
'VOX', "audio/voxware",
'AIF', "audio/x-aiff",
'AIFC', "audio/x-aiff",
'AIFF', "audio/x-aiff",
'MID', "audio/x-midi",
'MP3', "audio/x-mpeg",
'MP2A', "audio/x-mpeg2",
'MPA2', "audio/x-mpeg2",
'M3U', "audio/x-mpegurl",
'MP3URL', "audio/x-mpegurl",
'PAT', "audio/x-pat",
'RAM', "audio/x-pn-realaudio",
'RPM', "audio/x-pn-realaudio-plugin",
'RA', "audio/x-realaudio",
'SBK', "audio/x-sbk",
'STR', "audio/x-str",
'WAV', "audio/x-wav",
#-------------------------------------<VIDEO>----
'MPEG', "video/mpeg",
'MPG', "video/mpeg",
'MPE', "video/mpeg",
'QT', "video/quicktime",
'MOV', "video/quicktime",
'VIV', "video/vivo",
'VIVO', "video/vivo",
'MPS', "video/x-mpeg-system",
'SYS', "video/x-mpeg-system",
'MP2V', "video/x-mpeg2",
'MPV2', "video/x-mpeg2",
'AVI', "video/x-msvideo",
'MV', "video/x-sgi-movie",
'MOVIE', "video/x-sgi-movie",
#-------------------------------------<EXTRA>----
'PDB', "chemical/x-pdb",
'XYZ', "chemical/x-pdb",
'CHM', "chemical/x-cs-chemdraw",
'SMI', "chemical/x-daylight-smiles",
'SKC', "chemical/x-mdl-isis",
'MOL', "chemical/x-mdl-molfile",
'RXN', "chemical/x-mdl-rxn",
'SMD', "chemical/x-smd",
'ACC', "chemical/x-synopsys-accord",
'ICE', "x-conference/x-cooltalk",
'SVR', "x-world/x-svr",
'WRL', "x-world/x-vrml",
'VRML', "x-world/x-vrml",
'VRJ', "x-world/x-vrt",
'VRJT', "x-world/x-vrt",
);
my $file = (pop @FILELIST);
print "<br>File = $file";
my ($ext) = $file =~ m,\.([^\.]*)$,;
print "<br>Ext = $ext";
$ext =~ tr,a-z,A-Z,;
print "<br>Again, $ext";
my $fext = $mime{$ext};
print "---$fext\n";
}

print "<br>All Done!";




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

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 V9 Issue 5189
**************************************


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