[16058] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3470 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 24 00:10:25 2000

Date: Fri, 23 Jun 2000 21:10:12 -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: <961819812-v9-i3470@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 23 Jun 2000     Volume: 9 Number: 3470

Today's topics:
    Re: Passing filehandles to subroutines (Greg Bacon)
    Re: perl2C compiler <jllawhead@sunherald.com>
    Re: perl2C compiler <jllawhead@sunherald.com>
    Re: POST requests in Perl <hackless@hotmail.com>
    Re: REGEX Mystery (Steven Smolinski)
        Running Perl CGI Scripts <mikes@escape.com>
    Re: Running Perl CGI Scripts <memmett@fraser.sfu.ca>
        Using cgi-lib.pl to upload a file <cdillis@denver.autometric.com>
    Re: Who is the Perl Princess ? martinagoo@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 23 Jun 2000 19:47:27 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Passing filehandles to subroutines
Message-Id: <SL7FMFOAE7F68@CORP.SUPERNEWS.COM>

In article <slrn8l63ek.s06.tcsh@faure.cs.colostate.edu>,
    Mike <tcsh@holly.colostate.edu> wrote:

: gbacon@HiWAAY.net (Greg Bacon):
:
: > You need to upgrade.  It's often easier to just grep the pods.  Do
: > you know how to find the pods in your Perl installation?
:
: I'm not the sysadmin and have a tight disk usage quota so an upgrade isn't
: possible.  But thanks for the grepping the pods idea, I'll surely use that
: in the future.

Another advantage to reading the FAQ: you'd have seen

    How can I convince my sysadmin/supervisor/employees to use version
    (5/5.004/Perl instead of some other language)?

at <URL:http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html#How_can_I_convince_my_sysadmin_s>.

Greg
--
Of course, this is a heuristic, which is a fancy way of saying that it
doesn't work.
    -- mjd


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

Date: Fri, 23 Jun 2000 22:30:06 GMT
From: Joel <jllawhead@sunherald.com>
Subject: Re: perl2C compiler
Message-Id: <sl7p7elce7f75@corp.supernews.com>

Check out the "B" module at CPAN. Documentation on the Internet is scarce 
and most people seem to hate it but some people say it works just fine. I 
think there are some other modules associated with it. You can find the most 
information on it if you search for "compiler" at Perl.com. It's not clearly 
stated in the docs but you will need a working compiler on  your machine 
before you install the modules.



Michael Branch wrote:
> 
> 
> --------------9DC291A80FEE8807D424AFB5
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> 
> hi,
> 
>   is there a perl to C program to be found?
> 
> thanks,
> 
> Mike
> 
> --
> 150157167040155141156171040155157162145040164162
> 151154151157156040144157154154141162163040167151
> 
>    Michael A. Branch
>    "I turn big problems into little problems."
> 
>    ViaWest Internet Services
>    Denver, CO
> 
> 154154040171157165040154145164040116101123101040
> 142165162156040125123040146157162077012000000000
> 
> 
> 
> --------------9DC291A80FEE8807D424AFB5
> Content-Type: text/html; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> 
> <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
> <html>
> 
> <pre>hi,</pre>
> 
> <pre>  is there a perl to C program to be found?</pre>
> 
> <pre></pre>
> 
> <pre>thanks,</pre>
> 
> <pre>Mike</pre>
> 
> <pre></pre>
> 
> <pre>-- 
> 150157167040155141156171040155157162145040164162
> 151154151157156040144157154154141162163040167151
> 
>    Michael A. Branch
>    "I turn big problems into little problems."
> 
>    ViaWest Internet Services
>    Denver, CO
> 
> 154154040171157165040154145164040116101123101040
> 142165162156040125123040146157162077012000000000</pre>
>  </html>
> 
> --------------9DC291A80FEE8807D424AFB5--
> 


--
Posted via CNET Help.com
http://www.help.com/


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

Date: Fri, 23 Jun 2000 22:30:06 GMT
From: Joel <jllawhead@sunherald.com>
Subject: Re: perl2C compiler
Message-Id: <sl7p7eehe7f125@corp.supernews.com>

Check out the "B" module at CPAN. Documentation on the Internet is scarce 
and most people seem to hate it but some people say it works just fine. I 
think there are some other modules associated with it. You can find the most 
information on it if you search for "compiler" at Perl.com. It's not clearly 
stated in the docs but you will need a working compiler on  your machine 
before you install the modules.



Michael Branch wrote:
> 
> 
> --------------9DC291A80FEE8807D424AFB5
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> 
> hi,
> 
>   is there a perl to C program to be found?
> 
> thanks,
> 
> Mike
> 
> --
> 150157167040155141156171040155157162145040164162
> 151154151157156040144157154154141162163040167151
> 
>    Michael A. Branch
>    "I turn big problems into little problems."
> 
>    ViaWest Internet Services
>    Denver, CO
> 
> 154154040171157165040154145164040116101123101040
> 142165162156040125123040146157162077012000000000
> 
> 
> 
> --------------9DC291A80FEE8807D424AFB5
> Content-Type: text/html; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> 
> <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
> <html>
> 
> <pre>hi,</pre>
> 
> <pre>  is there a perl to C program to be found?</pre>
> 
> <pre></pre>
> 
> <pre>thanks,</pre>
> 
> <pre>Mike</pre>
> 
> <pre></pre>
> 
> <pre>-- 
> 150157167040155141156171040155157162145040164162
> 151154151157156040144157154154141162163040167151
> 
>    Michael A. Branch
>    "I turn big problems into little problems."
> 
>    ViaWest Internet Services
>    Denver, CO
> 
> 154154040171157165040154145164040116101123101040
> 142165162156040125123040146157162077012000000000</pre>
>  </html>
> 
> --------------9DC291A80FEE8807D424AFB5--
> 


--
Posted via CNET Help.com
http://www.help.com/


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

Date: Fri, 23 Jun 2000 15:02:00 -0700
From: "xin zhou" <hackless@hotmail.com>
Subject: Re: POST requests in Perl
Message-Id: <8j0mns$eqd$1@sunami.kla-tencor.com>

I wrote a small POST program to look up Webster's dictionary. Everything is
under the sun here, no CGI.pm or LWP modules. Save it as an executable named
"mw". Hope this helps.

#!/usr/bin/perl -w
use Socket;
use strict;

my $word = $ARGV[0] or die "Usage: mw word\n";
my $host = "www.m-w.com";
my $port = 80;
my $socketaddr;
my $content = "jump=$word"; # This seems to work with white space in word
my $wholePage = "";
my $form = "";
my $buf = "";
my @listvalue = ();
my @option = ();
my $selections = 0;
my $count = 0;

while ($content) {

openSock();
post ($content);

$wholePage = "";
while ( <SOCK> ) {
 $wholePage .= $_;
}
close SOCK;

# pick out the form, /s matches newline with '.' /g is greedy
# /m matches internal newline
$wholePage =~ /(<form .*<\/form>)/gs;
$form = $1 or die "Can not find the word\n";

# this is heavy duty kludge, geared toward www.m-w.com, needs maintenance
# find out if the form has a selection of options
$selections = 0;
if ($form =~ s/^To view.*?GO TO.$//m) {
 $selections = 1;
 @option = ($form =~ /^<option.*>(.*)$/mg);
 @listvalue = ($form =~ /name=list value="(.*)">/g);
}

# convert html into something more readable
$form =~ s/<br>/\n/g;       # change html linebreak to newline
$form =~ s/<option.*?\n//mg;# delete the selection list, to be shown later
$form =~ s/<[^>]*>//g;      # delete all the other html tags
$form =~ s/&gt;/>/g;        # make visible the greater-than sign
$form =~ s/&lt;/</g;        # make visible the less-than sign
$form =~ s/&amp;/&/g;       # make visible the less-than sign
$form =~ s/\n+/\n/g;       # delete multiple newlines
print $form;
print "\n";

# prompt the user for further actions: look up another word or stop here
$content = "";
if ($selections) {
 print "Here are the related words:\n";
 for (my $i=0;$i<@option;$i++){
  print "$i: $option[$i]\n";
 }
 print "\nEnter a number to select from the list, or enter . to quit\n";

 $buf = <STDIN>; # don't know how to use "read"
 chomp $buf;
 if ($buf eq '.') {
  $content = "";
 }
 elsif ($buf !~ /\d/ or $buf >= @option) {
  print "What did you just do?\n";
  $content = "";
 }
 else{
  $content = "hdwd=$word&book=Dictionary&jump=";
  $content .= urlencode ($option[$buf]);
  $content .= "&list=";
  $content .= urlencode ($listvalue[0]);
 }
} # end of if selections

} # end of while content


###########
# subroutine: open a socket at SOCK
###########

sub openSock {
$socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or die "Bad
socket\n";
connect SOCK, $socketaddr or die "Bad connection\n";
select((select(SOCK), $| = 1)[0]);
}


###########
# subroutine: urlencode a string
###########

sub urlencode {

my $ask = shift @_;
my @a2 = unpack "C*", $ask;
my $s2 = "";
while (@a2) {
    $s2 .= sprintf "%%%X", shift @a2;
}
return $s2;

}


###########
# subroutine: send post request to target web site
###########

sub post {

my $content = shift @_;
print SOCK "POST http://www.m-w.com/cgi-bin/dictionary HTTP/1.0\n";
print SOCK "Content-type: application/x-www-form-urlencoded\n";
#print SOCK "Content-length: 213\n";
my $contentLength = length $content;
print SOCK "Content-length: $contentLength\n";
print SOCK "\n";
print SOCK "$content";
#print SOCK
"hdwd=address&book=Dictionary&jump=address%5B2%2Cnoun%5D&list=address%5B1%2C
verb%5D%3D10405%3Baddress%5B2%2Cnoun%5D%3D10425%3Binside+address%3D548015%3B
keynote+address%3D581517%3Bpublic%2Daddress+system%3D865110%22\n";

}


# list of unprintable characters:
# %22 "
# %2C ,
# %2D -
# %3B ;
# %3D =
# %5B [
# %5D ]




"Phil" <root@phil-the-nerd.org> wrote in message
news:slrn8l6j2j.8i4.root@Enigma.RedBrick.DCU.IE...
> There are some forms on the web, I want to write a small perl gateway to.
Now
> I know how to use a GET request to get the data, but I want to use POST.
Could
> anyone shed any light on how you would go about doing such a thing?
> Appreciated,
> Phil.




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

Date: Fri, 23 Jun 2000 23:05:26 GMT
From: sjs@yorku.ca (Steven Smolinski)
Subject: Re: REGEX Mystery
Message-Id: <slrn8l7r8q.5r5.sjs@john.sympatico.ca>

Kip Hampton <khampton@totalcinema.com> wrote:
>Steven Smolinski wrote:

>> I agree, it could be more explicitly and simply stated near the beginning
>> of the m//g description, but it's there for anyone who carefully reads the
>> man page.  Otherwise, what are all those examples for?

>Point conceded. It's just that the "save position even though the string
>has changed" behavior seems really backwards to me.

It doesn't save the position when one changes the string.  See below:

--------------8<------------------------
#!/usr/bin/perl -w
 
use strict;
 
$_ = "test string with lots of t's";
 
/t/g and print "$`$&\n";
/t/g and print "$`$&\n";
/t/g and print "$`$&\n";
/t/g and print "$`$&\n";
 
# change the string
$_ = "new string, with a few t's as well";
 
/t/g and print "$`$&\n"; 
__END__
--------------8<------------------------
Output:
t
test
test st
test string wit
new st 


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

Date: Fri, 23 Jun 2000 22:38:37 -0400
From: mike <mikes@escape.com>
Subject: Running Perl CGI Scripts
Message-Id: <39541F2D.27995169@escape.com>


Hi,
    I am trying to learn CGI scripting and Perl and using Apache
on a Slackware 7.0 Linux box. The scripts that I am having
trouble with are the ones that create or write to files. The
scripts seem to run through, but no file is created or written
to. In the error_log file, I get the message: cannot create
regular file /path/filename  Permission denied. Do I have
to in some way tell Apache to allow creation and writing to
files in its config file?
                                                Thanks
                                                            Mike



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

Date: 23 Jun 2000 20:10:56 -0700
From: Matt Emmett <memmett@fraser.sfu.ca>
Subject: Re: Running Perl CGI Scripts
Message-Id: <yvw9ituz7ozj.fsf@fraser.sfu.ca>


Mike,

Check the permissions of the directory that you want to write to.
Apache is most likely running the CGI script as the user "www" (or,
depending on the setup, "www-data" or "nobody" etc etc).  Apache does
this for security reasons.  If "www" doesn't have write permissions to
the directory, then would get a "Permission denied" message.  

To find out what user Apache is running the CGI script as, check the
apache config files.  Look for the "User" and "Group" options.

Matt


mike <mikes@escape.com> writes:

> Hi,
>     I am trying to learn CGI scripting and Perl and using Apache
> on a Slackware 7.0 Linux box. The scripts that I am having
> trouble with are the ones that create or write to files. The
> scripts seem to run through, but no file is created or written
> to. In the error_log file, I get the message: cannot create
> regular file /path/filename  Permission denied. Do I have
> to in some way tell Apache to allow creation and writing to
> files in its config file?
>                                                 Thanks
>                                                             Mike


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

Date: Fri, 23 Jun 2000 16:01:25 -0700
From: cdillis <cdillis@denver.autometric.com>
Subject: Using cgi-lib.pl to upload a file
Message-Id: <02efc50a.5b94b6a8@usw-ex0109-069.remarq.com>

Hey all,
   I have a webpage with a form on it.  The form has several
fields including a file upload field, which is optional.
I'm trying to use cgi-lib.pl to handle the form processing.
Everything works fine when a user enters a file to upload,
but cgi-lib.pl crashes when the user does not enter a file.
   The problem occurs when my cgi script (basically a copy
of the example available at http://cgi-lib.berkeley.edu/)
calls the following line: $ret =
&ReadParse(\%cgi_data,\%cgi_cfn,\%cgi_ct,\%cgi_sfn);  The
act of parsing the form data using this command causes
cgi-lib.pl to try to upload the file. If there is no file to
upload, cgi-lib.pl crashes.
    I thought I could get around the problem by first doing
a simple "&ReadParse()", and then checking $in{uploadfile}
to see if it had a value.  If it had a value, then I would
execute the full
"&ReadParse(\%cgi_data,\%cgi_cfn,\%cgi_ct,\%cgi_sfn)"
command.  That didn't work.  Calling &ReadParse more than
once produces an error from cgi-lib.pl.
    Any ideas on how I might get around this problem?

Thanks,
Chris Dillis


* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is Beautiful


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

Date: Fri, 23 Jun 2000 22:52:27 GMT
From: martinagoo@my-deja.com
Subject: Re: Who is the Perl Princess ?
Message-Id: <8j0pn6$oto$1@nnrp1.deja.com>



> You think I'm stupid enough to look ?
You might be stupid enough NOT to look!

"perl princess" is the number 2 searched for term on the internet.
See below - I've been searching around and I think she's the next mahir
- remember that turkish speedo guy?
Check it out.  I went to Snap.com and got lots of results - people are
adding it to their code.
http://home.snap.com/search/directory/results/1,61,-0,00.html?tag=st.v2.
fdsb.1&keyword=perl+princess


Here's the full list of top 50 words:
=============================================================
 W  O  R  D  T  R  A  C  K  E  R                            Weekly Top
500 Keyword Report
 =============================================================

 Wordtracker Top 500 Keywords Report for Wednesday, 21st June 2000 with
all pornographic search terms left in.

 This information has been compiled from a database of approximately 30
million queries over a rolling period of 2 months.

 Brought to you by Andy & Mike Mindel of Wordtracker
 (www.wordtracker.com)

 =============================================================

 /// DEFINITION OF TERMS ///

 Nos      : Position according to popularity
 Current  : No. times keyphrase has appeared in current data
 Predict  : Rough prediction daily searches for this keyphrase

 =============================================================

 1. LONG TERM SEARCH RESULTS

 Taken from a total of 32203273 search terms, these are the
 top 500 long term searches from various metacrawlers and search engine
voyeurs across the internet.

 ===========================================================
 Nos    Current    Predict        Keyword/Keyphrase
 ===========================================================
 1          52711    281454      sex
 2          48170    257207      perl princess
 3          44051    235213      cars
 4          41030    219083      games
 5          39313    209915      mp3
 6          35805    191183      music
 7          34074    181941      travel
 8          25208    134600      hotmail
 9          21784    116317      health
 10        21645    115575      yahoo
 11        18248    97437        software
 12        17496    93421        pokemon
 13        16184    86416        chat
 14        16112    86031        computer
 15        13952    74498        porn
 16        13706    73184        jobs
 17        13502    72095        warez
 18        13284    70931        lyrics
 19        12314    65751        maps
 20        11944    63776        jokes
 21        11672    62323        free porn
 22        11661    62265        ebay
 23        11543    61635        napster
 24        10900    58201        winzip
 25        10774    57529        stock
 26        10277    54875        ampland
 27        9803      52344        britney spears
 28        9418      50288        porno
 29        9349      49920        0
 30        9327      49802        weather
 http://oozinggoo.com/perlprincess


Sent via Deja.com http://www.deja.com/
Before you buy.


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

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


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