[19057] in Perl-Users-Digest
Perl-Users Digest, Issue: 1252 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 5 21:07:54 2001
Date: Thu, 5 Jul 2001 18:05:10 -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: <994381510-v10-i1252@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 5 Jul 2001 Volume: 10 Number: 1252
Today's topics:
Re: Access Access <bart.lateur@skynet.be>
Re: arrays in XS... (j a p h)
Re: Correct way to open a .jpg image and save? (Tad McClellan)
DBI/MySQL: finding ID of an added record <stumo@bigfoot.com>
Re: DBI/MySQL: finding ID of an added record ctcgag@hotmail.com
eval function - performance (allan)
Re: eval function - performance (Eric Bohlman)
Re: Get ownership info in NT OS <a@b.c.d>
Re: Get ownership info in NT OS <a@b.c.d>
how do you move a created file <shop@wehug.com>
How to delete consecutive blank lines <james.mctiernan@rcn.com>
Re: How to delete consecutive blank lines (Craig Berry)
how to read multipart/form-data <mail@enricong.com>
Re: how to read multipart/form-data <stumo@bigfoot.com>
I am at a loss as to which database solution to use.... <miscellaneousemail@yahoo.com>
Re: I am at a loss as to which database solution to use (Clinton A. Pierce)
Re: I am at a loss as to which database solution to use <stumo@bigfoot.com>
Re: Need a start or direction for PERL Program (SMS Bul (Vlad)
Re: Newbie Question (Eric Bohlman)
OT: The Evils of Posting to comp.lang.perl (Tim Hammerquist)
Re: OT: The Evils of Posting to comp.lang.perl (Tad McClellan)
Re: OT: The Evils of Posting to comp.lang.perl <flavell@mail.cern.ch>
Re: passing information between mutiple forms <vrdoljak@uclink.berkeley.edu>
Re: Perl *is* strongly typed (was Re: Perl description) <mischief@velma.motion.net>
Re: perl and progress DB <buggs-clpm@splashground.de>
Perl CGI problem with library file (Smiley)
Re: Perl method for finding current working dir <bart.lateur@skynet.be>
Re: regular expression ..doh ! <stumo@bigfoot.com>
Re: Vapo-Rub (Tim Hammerquist)
Wants to use Ftp functions <julien.carosi@club-internet.fr>
Re: web fetching <buggs-clpm@splashground.de>
Will using DB_File work for this?? <miscellaneousemail@yahoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 05 Jul 2001 19:54:35 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Access Access
Message-Id: <iah9kt85qnvnnbtm11o307bv49sl30a5at@4ax.com>
Trevor Ward wrote:
>I have just been given an access mdb file.
>
>Can I use perl to get at the data.
>
>If so which module do I need to install (guess its dbi)
>and how do I connect ?.
Assuming you have a Windows machine and the Access engine: DBI+DBD::ODBC
Go to control panels, open ODBC data sources, add a new system DSN,
select your database as the source and give it a name. Close.
In perl, you can now connect with
use DBI;
my $dbh = new DBI("DBI:ODBC:$dsn", $user, $pwd);
where $dsn is the name you entered in the ODBC control panel, $user and
$pwd is an existing username and password combination.
--
Bart.
------------------------------
Date: Thu, 05 Jul 2001 19:59:50 GMT
From: dont@mailme.com (j a p h)
Subject: Re: arrays in XS...
Message-Id: <3b44a6ee.2057968802@news.erols.com>
On Mon, 02 Jul 2001 16:30:49 +0100, Jim Lewis <jrl@ast.cam.ac.uk>
wrote:
>Anno Siegel wrote:
>
>> According to Jim Lewis <jrl@ast.cam.ac.uk>:
>> > Hi,
>> >
>> > Consider the following:
>> >
>> > a C subroutine...
>> >
>> > extern int aaa(char *a[]) {
>> > .
>> > .
>> > .
>> > }
>> >
>> > How do I write the interface .xs routine so that I can call this from
>> > perl using:
>> >
>> > $returnval = &aaa(\@array);
>>
>> What have you tried?
>>
>> Anno
>
>So far nothing much. Just doing
>
>int
>cir_test(yuk)
> char ** yuk
>
> CODE:
> RETVAL = cir_test(yuk);
> OUTPUT:
> RETVAL
>
>fails with an error like 'unable to call XS_unpack_charPtrPtr'
>
>Jim
>
A google usenet archive search
[http://groups.google.com/groups?hl=en&safe=off&ic=1&th=d0804698af56c9c2,2&seekm=742hip%24r79%241%40nnrp1.dejanews.com#p]
reveals this: the function XS_unpack_charPtrPtr is found in 'Dean
Roehrich's CookBookA on CPAN, example 8, Av_CharPtrPtr.[ch].'
Hope this helps.
------------------------------
Date: Thu, 5 Jul 2001 13:38:23 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Correct way to open a .jpg image and save?
Message-Id: <slrn9k99gf.hc2.tadmc@tadmc26.august.net>
Matt L. <mlaw@talk21.comNOSPAM> wrote:
>$file = param('file');
>open (SAVE, ">../images/$file") || die $!;
You had better check the contents of $file before feeding it
to magic open(). There are lots of Bad Guys out there...
perldoc perlsec
What would happen if you ended up with a value like below?
my $file = '../1.jpg';
( you would write to a file in ../ not one in ../images/ )
Use taint checking when processing form input.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 6 Jul 2001 00:02:27 +0100
From: "Stuart Moore" <stumo@bigfoot.com>
Subject: DBI/MySQL: finding ID of an added record
Message-Id: <rl617.6487$Jk6.1409093@news2-win.server.ntlworld.com>
Just starting to use MySQL through the DBI interface (just starting MySQL for
that matter)
I have several tables who's primary key is an unsigned autoincrement integer.
When I add a record to the table, I want to know what value the id field has
been given. What's the best way of doing this?
Apologies if you consider this off topic - I'm undecided as to whether this is
related to Perl or a general MySQL issue.
TIA
Stuart
------------------------------
Date: 05 Jul 2001 23:17:45 GMT
From: ctcgag@hotmail.com
Subject: Re: DBI/MySQL: finding ID of an added record
Message-Id: <20010705191745.759$A3@newsreader.com>
"Stuart Moore" <stumo@bigfoot.com> wrote:
> Just starting to use MySQL through the DBI interface (just starting MySQL
> for that matter)
>
> I have several tables who's primary key is an unsigned autoincrement
> integer. When I add a record to the table, I want to know what value the
> id field has been given. What's the best way of doing this?
>
> Apologies if you consider this off topic - I'm undecided as to whether
> this is related to Perl or a general MySQL issue.
>
> TIA
>
> Stuart
Try running the query "select last_insert_id()"
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service
------------------------------
Date: 5 Jul 2001 14:37:03 -0700
From: lambretta@inet.uni2.dk (allan)
Subject: eval function - performance
Message-Id: <ac2d50d5.0107051337.73774672@posting.google.com>
hello,
i am curious about the eval function. i found and modified a script
from the perl cookbook which should have run faster i guess, using the
/o modifer. but the straightforward solution is still the fastest.
what am i missing here?
script purpose is to extract certain values and a search pattern from
a large file and replace the values when finding the pattern in some
content. both version works, im just interested in best possible
peformance.
cheers
allan
_________
#!perl -w
#sample content
my $content = "<tag id=1> stuff <tag id=1> bla bla ";
#open file with thousands of lines like these:
#<tag id=1>:basic=3.00:private=5.00
#<tag id=178>:basic=13.00:private=15.00
open (FILE, "dbm.txt") or die $!;
my $start = (times)[0]; #start clock
my $switch = 1;
straight_forward_version($content) if $switch == 1;
eval_version($content) if $switch == 2;
my $result = (times)[0] - $start;
print "\nthis took $result";
sub straight_forward_version {
my $output = $_[0];
while (<FILE>) {
chomp;
my ($tag, $val) = /(<tag[^>]+id=\d+>).+basic=([^:]+)/ or next;
$output =~ s/$tag/$val/g
}
print $output;
}
sub eval_version {
my $output = $_[0];
my ($tag, $val);
my $expr = join('||', map {"m/(<tag id=$_>).+basic=([^:]+)/o"} 1..2);
my $match_any = eval "sub { $expr; \$tag=\$1;\$val=\$2;}";
die if $@;
while (<FILE>) {
$output =~ s/$tag/$val/g if &$match_any;
}
print $output;
}
------------------------------
Date: 6 Jul 2001 00:54:35 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: eval function - performance
Message-Id: <9i328b$ba4$2@bob.news.rcn.net>
allan <lambretta@inet.uni2.dk> wrote:
> hello,
> i am curious about the eval function. i found and modified a script
> from the perl cookbook which should have run faster i guess, using the
> /o modifer. but the straightforward solution is still the fastest.
> what am i missing here?
[snip]
> sub straight_forward_version {
> my $output = $_[0];
> while (<FILE>) {
> chomp;
> my ($tag, $val) = /(<tag[^>]+id=\d+>).+basic=([^:]+)/ or next;
There are not variables interpolated into your regular expression, so it's
compiled only once.
> $output =~ s/$tag/$val/g
> }
> print $output;
> }
> sub eval_version {
> my $output = $_[0];
> my ($tag, $val);
> my $expr = join('||', map {"m/(<tag id=$_>).+basic=([^:]+)/o"} 1..2);
> my $match_any = eval "sub { $expr; \$tag=\$1;\$val=\$2;}";
> die if $@;
> while (<FILE>) {
> $output =~ s/$tag/$val/g if &$match_any;
Here you're doing a subroutine call for each line of the file, which is
going to slow you down, and to add insult to injury, it evaluates a more
complex regex than the one in the straightforward version. And to add
even more insult to injury, it passes its results back by modifying
variables in its caller's scope, which is not a Good Thing when it comes
to maintainability.
> }
> print $output;
> }
The moral of the story is that attempts at small-scale optimization often
fail.
------------------------------
Date: Thu, 5 Jul 2001 23:56:56 +0100
From: "Perky Dan" <a@b.c.d>
Subject: Re: Get ownership info in NT OS
Message-Id: <9i2rm5$h35$1@newsg4.svr.pol.co.uk>
Right click the file
Properties>>Security>>Ownership
This shows you the owner, and allows you to take ownership
if you have been granted that permission.
This only applies to files that live on an NTFS partition.
"Гринченко Андрей 378784026" <infokeeper@softpro.kharkov.ua> wrote in
message news:9gnk9t$2tjs$1@bn.utel.com.ua...
> Hi!
>
> How I can get ownership info for file or directory in NT OS?
> Win32::FileSecurity, not help.
>
> Andre.
>
>
------------------------------
Date: Fri, 6 Jul 2001 00:02:19 +0100
From: "Perky Dan" <a@b.c.d>
Subject: Re: Get ownership info in NT OS
Message-Id: <9i2rm7$t26$1@newsg3.svr.pol.co.uk>
Right click the file
Properties>>Security>>Ownership
This shows you the owner, and allows you to take ownership
if you have been granted that permission.
This only applies to files that live on an NTFS partition. The security tab
is not used for FAT16.
"Гринченко Андрей 378784026" <infokeeper@softpro.kharkov.ua> wrote in
message news:9gnk9t$2tjs$1@bn.utel.com.ua...
> Hi!
>
> How I can get ownership info for file or directory in NT OS?
> Win32::FileSecurity, not help.
>
> Andre.
>
>
------------------------------
Date: Thu, 05 Jul 2001 13:27:22 -0500
From: "The Crystal Ball Inc." <shop@wehug.com>
Subject: how do you move a created file
Message-Id: <3B44B18A.F0EED45@wehug.com>
Hello all,
Need some help,
I'm getting 403 errors and must resolve.
I'm using a cgi/perl script that creates a file called
mega.htm and puts that file in my cgi-bin area. When I
try to look at that file by typing the url in my browser,
it gives me a 403 permissions error.
The file is given 666 level permissions by the script,
which seems adequate but still returns a 403 error.
My problem is that the file called mega.htm must be accessed
and read by a spider from an outside website.
There is a peculiar thing , I do not see the directory named
megalist but I do see the file mega.htm in my cgi-bin
area.
I can physically download and then upload this file to my
public html area and then can look at it with my browser.
So what is the best way to fix this, create another few lines
of perl code that can move this file to my public html area ?
Apparently there is a block in the cgi-bin area that wont
allow a browser see files located there by a browser.
here is the sub that creates the file:
###################################
### Sub: BidFind List
### Prints out a very "basic" HTML page for BidFind to use to
### index your web site auction contents.
sub megalist {
umask(000); # UNIX file permission junk
mkdir("$config{'megalist'}", 0777) unless (-d "$config{'megalist'}");
open (MEGAFILE, ">$config{'megalist'}/mega.htm");
print MEGAFILE
"<HTML>\n<HEAD>\n<TITLE>BidFind MegaList at
$config{'sitename'}</TITLE>\n</HEAD>\n<BODY>\n";
close (MEGAFILE);
my $key;
foreach $key (sort keys %category) {
opendir (THEDIR, "$config{'basepath'}$key") || &oops("Category directory
$key could not be opened.");
readdir THEDIR;
readdir THEDIR;
my @allfiles = sort { $a <=> $b } readdir THEDIR;
closedir THEDIR;
my $file;
foreach $file (sort { int($a) <=> int($b) } @allfiles) {
if (-T "$config{'basepath'}$key/$file") {
$file =~ s/^$config{'basepath'}$key\///;
$file =~ s/\.dat$//;
open THEFILE, "$config{'basepath'}$key/$file";
my ($title, $reserve, $inc, $desc, $image, @bids) =
&read_item_file($key,$file);
close THEFILE;
chomp($title, $reserve, $inc, $desc, $image, @bids);
my ($alias, $email, $bid, $time, $add1, $add2, $add3) =
&read_bid($bids[$#bids]);
my ($selleralias, $selleremail, $sellerbid, $sellertime, $selleradd1,
$selleradd2, $selleradd3) = &read_bid($bids[0]);
my @closetime = localtime($file);
$closetime[4]++;
open (MEGAFILE, ">>$config{'megalist'}/mega.htm");
print MEGAFILE
"<A
HREF=$config{'scripturl'}$ENV{'SCRIPT_NAME'}\?category=$key\&item=$file>$title</a>
<PRICE>$bid<CAT>$category{$key}<ENDS>$closetime[4]/$closetime[3]<BR>\n";
close (MEGAFILE);
}
}
}
open (MEGAFILE, ">>$config{'megalist'}/mega.htm");
print MEGAFILE
"</BODY>\n</HTML>\n";
close (MEGAFILE);
}
the sub is called or executed by this
&megalist;
which is placed in another sub that creates a listing for something else.
here is the variable:
$config{'megalist'} = '/usr/www/users/nuspirit/cgi-bin/';
there is an earlier line:
local %config;
also here is some stuff fron the top of the script:
#!/usr/bin/perl
use vars qw(%config %category %form);
require "postal.pl"; #this calls a script that has to do with email and works
fine.
use strict;
#####################
Anyway there it is, would appreciate any suggestions and thanks in advance.
I'm not a cgi or perl programmer, just trying to muddle my way through,
I didn't write this sub or the main script. The script and the addon sub are
for an auction program called everysoft auction. I tried to get some help
from the EA auction forum, but it seems that no one is willing to reply.
Mike
mike@wehug.com
------------------------------
Date: Thu, 5 Jul 2001 16:31:51 -0700
From: "Jim McTiernan" <james.mctiernan@rcn.com>
Subject: How to delete consecutive blank lines
Message-Id: <9i2tha$t63$1@bob.news.rcn.net>
I have a text file with multiple blank lines before and after paragraphs.
How can I get rid of them?
How also to delete paragraphs that contain certain words, or would it be
easier to save the paragraphs that contain only certain words.
Thanks
------------------------------
Date: Fri, 06 Jul 2001 00:32:04 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How to delete consecutive blank lines
Message-Id: <tka1o4gs3bl6e@corp.supernews.com>
Jim McTiernan (james.mctiernan@rcn.com) wrote:
: I have a text file with multiple blank lines before and after paragraphs.
: How can I get rid of them?
If the file is of manageable size, use one of the standard idioms to read
the entire file into a scalar, then translate away multiple adjacent
newlines using 'tr/\n//s'.
: How also to delete paragraphs that contain certain words, or would it be
: easier to save the paragraphs that contain only certain words.
Depends on the application. In either case, reading the file by
paragraphs (perldoc -q paragraphs) will make your life easier.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Magick is the art and science of causing change in conformity
| with Will." - Aleister Crowley
------------------------------
Date: Thu, 5 Jul 2001 17:57:27 -0500
From: "Enrico Ng" <mail@enricong.com>
Subject: how to read multipart/form-data
Message-Id: <9i2re3$sii$1@info1.fnal.gov>
How do I read multipart/form-data?
I am working on making a file upload script but and having trouble getting
the data from a "multipart/form-data" input
--
--
Enrico Ng <mail@enricong.com>
------------------------------
Date: Fri, 6 Jul 2001 00:15:14 +0100
From: "Stuart Moore" <stumo@bigfoot.com>
Subject: Re: how to read multipart/form-data
Message-Id: <px617.6531$Jk6.1419557@news2-win.server.ntlworld.com>
Enrico Ng <mail@enricong.com> wrote in message
news:9i2re3$sii$1@info1.fnal.gov...
> How do I read multipart/form-data?
> I am working on making a file upload script but and having trouble getting
> the data from a "multipart/form-data" input
>
Have you looked at the CGI module? I've used that for several file upload
scripts, had a few teething problems but now works fine. CGI should be a
standard module with Perl.
------------------------------
Date: Thu, 05 Jul 2001 21:39:23 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: I am at a loss as to which database solution to use....
Message-Id: <usm9ktoebie2lue5f9r8lhjtrv4j2col1h@4ax.com>
Hi everyone,
I am at a loss as to which database solution to use for my site. I
have spent hour upon hour looking through a bunch of material on
different database solutions and just don't know which way to go. Any
help would be very appreciated. I have scoured the Internet and there
is very little if anything comparing the relative merits or demerits
of database solutions.
My data file can be stored in any kind of database as long as it can
output the following structure (or store it as this):
KEY VALUE_1 VALUE_2 VALUE_n
<email_address>,<first_name>,<start_date>,etc.
<email_address>,<first_name>,<start_date>,etc.
I believe this structure is called a CSV flat file structure.
I thought of using DB_File (Perl module) but it appears that it cannot
support more than one VALUE associated with the one KEY. I need
multiple VALUES associated with a KEY.
The reason I need to output this structure is that I will be using a
mailing list program called Aureate Group Mail within Windows9x to
send my subscriber list a newsletter. I will download the database
file saved on the hosting server, convert it to the format above (if
not saved that way by the database solution), and import it into
Aureate Group Mail every time I send out my newsletter.
My web site is being hosted on a Unix server.
The only other constraint is that I need a database solution that can
be accessed through ActiveState's Windows Perl. So that I can develop
code for it on Windows Apache and then transfer the code easily to my
Unix web hoster.
Any suggestions?
Carlos
www.internetsuccess.ca
------------------------------
Date: Thu, 05 Jul 2001 22:00:51 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: I am at a loss as to which database solution to use....
Message-Id: <ns517.166529$DG1.27718423@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <usm9ktoebie2lue5f9r8lhjtrv4j2col1h@4ax.com>,
Carlos C. Gonzalez <miscellaneousemail@yahoo.com> writes:
> I thought of using DB_File (Perl module) but it appears that it cannot
> support more than one VALUE associated with the one KEY. I need
> multiple VALUES associated with a KEY.
I'm always at a loss as to why this confuses people.
<geezer>
Back in the day, databases with multiple keys and values were unheard of.
After all, you can only scratch so much information onto one side of a rock.
</geezer>
The two ways to do this are:
1. Create a database with a single key, and a compound value.
Rec1 value,value,value,value
Rec2 value,value,value,value
Rec3 value,value,value,value
Rec4 value,value,value,value
And then just split-and-re-assemble the values each time the record is
read. This ain't so hard. The tough part is finding a delimiter. Use
a multi-character delimiter if needed.
2. The second (and more flexible) way is to create a database with a
compound key, and have many keys represent a complete record. So for a customer
number #00612 and several values:
Key Value
00612_id Bob Smith
00612_addr 1335 Fleet St.
00612_strt Michigan
00612_zip 48034
Then just go looking for the various compound keys every time you need a
record. This also has the advantage of letting you store enormous amounts
of data associated with a single key (use sequence numbers if needed!).
Wrapping either of this in a tidy little API where you pass a structure and
it writes the data, or you pass a key and it retrieves the values makes all of
this transparent.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours *and*
clintp@geeksalad.org Perl Developer's Dictionary
"If you rush a Miracle Man, for details, see http://geeksalad.org
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Fri, 6 Jul 2001 00:14:06 +0100
From: "Stuart Moore" <stumo@bigfoot.com>
Subject: Re: I am at a loss as to which database solution to use....
Message-Id: <mw617.6528$Jk6.1417785@news2-win.server.ntlworld.com>
Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote in message
news:usm9ktoebie2lue5f9r8lhjtrv4j2col1h@4ax.com...
> Hi everyone,
>
> I am at a loss as to which database solution to use for my site. I
> have spent hour upon hour looking through a bunch of material on
> different database solutions and just don't know which way to go. Any
> help would be very appreciated. I have scoured the Internet and there
> is very little if anything comparing the relative merits or demerits
> of database solutions.
>
Have you looked at the Data::Dumper module? With this you can output it to a
text file and read it in again using eval, so it should recreate whatever
structure you had. You can then write a script to output the values in the
desired format.
Probably not the most efficient storage method, but simple to code with.
------------------------------
Date: 5 Jul 2001 17:53:26 -0700
From: leeassoc@hotmail.com (Vlad)
Subject: Re: Need a start or direction for PERL Program (SMS Bulk Message)
Message-Id: <5bd5b7e0.0107051653.4028922c@posting.google.com>
howhow82@hotmail.com (SoftwareSleuth) wrote in message news:<8048c9d1.0107021238.3ee2cf0@posting.google.com>...
> Ever tried Simplewire? I hear they are pretty good for making
> applications to send SMS. http://developers.simplewire.com
>
> leeassoc@hotmail.com (Vlad) wrote in message news:<5bd5b7e0.0106301700.342b4729@posting.google.com>...
> > I have seen, know how it works via sendmail or perl script to send SMS
> > messages to cell phones.
> >
> > There is also clickatel.com to send message for 8.50$ for 250 of them
> > and the more you go the cheaper it is.
> >
> > I would like to read about it or buy a book but I am not sure if the
> > stuff is in there....
> >
> > Anyone tried it might know about, or where to start...
> >
> > Thanks..
> >
Signed up for the Beta, they approved, checked their code and tried
it. They do not support bulk messages yet so... I'll have to wait.. on
that.
------------------------------
Date: 6 Jul 2001 00:12:25 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Newbie Question
Message-Id: <9i2vp9$ba4$1@bob.news.rcn.net>
News <ken@hallitech.com> wrote:
> I am learning Perl for the first time, so be gentle. I successfully wrote
> my first 'hello world' program. Now I am trying to pass a variable from an
> html file (a form) to a perl script and use the perl script to print out the
> variable. I'm doing this to better understand the basics associated with
> variables and the relationship between html and perl.
Your understanding of HTML and Perl is pretty good for a beginner. The
problem you're having is with what goes in between them.
> I have a form in the html file that looks like this:
> <form name="Name" action="cgiscript" method="post">
> Name; <input type="text" name="name" size="20">
> </form>
> I execute the perl like this:
> <h1><a href="cgi/mailer.pl">Run Form</a></h1>
Here's the problem: browsers don't send form values to the server along
with a request unless you make the request by activating an <input
type="submit"...> button. Clicking on a link sends an HTTP GET request to
the server consisting of only the the URL, whereas you want to send an
HTTP POST request which includes your form data. Again, without tricky
client-side scripting (which would be off topic in a Perl group) the only
way to do that is with a submit button.
> The cgi script looks like this:
> #!/usr/local/bin/perl
> #
> # test.pl-- my first mailer program
> #
You should get in the habit of enabling warnings and using strict in all
your code. A lot of people would also strongly recommend enabling taint
checking in all CGI programs; read the perlsec document if you haven't
already done so.
> use CGI;
Using CGI is a Good Thing, especially when you're a beginner.
> my $page = new CGI; my $paramvalue = $page->param('name');
> print "Content-type: text/html\n\n" ;
> # Print the HTML response page to STDOUT
> print <<EOF ;
And using a "here document" rather than a string of print statements is
also a Good Thing.
> <html>
> <head><title>CGI Results</title></head>
> <body>
> <h1>Hello, world.</h1>
> <p>$paramvalue</p>
> </body>
> </html>
> EOF
> exit ;
Ending a program with exit is unnecessary, but harmless.
> $parmvalue doesn't show anything when I execute it. I know I'm missing
> something. Hopefully, I'm not too far out into left field.
You're pretty close to where you want to be, and again, your Perl is
pretty good and isn't the problem.
------------------------------
Date: Thu, 05 Jul 2001 21:22:01 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: OT: The Evils of Posting to comp.lang.perl
Message-Id: <slrn9k9n9n.2vi.tim@vegeta.ath.cx>
Paul Boardman <peb@bms.umist.ac.uk> wrote:
> Tim Hammerquist wrote:
> >
> > Philip Newton <pne-news-20010705@newton.digitalspace.net> wrote:
> > > [Don't followup-to comp.lang.perl; that group doesn't exist.]
> >
> > Don't tell the frequenters of comp.lang.perl that! They post quote
> > frequently as if they exist. When someone tells them they don't exist,
> > they get quite indignant.
[ snippage ]
> I can't see clp in the list of newsgroups from my newsgroup server & I
> can't find it on groups.google.com either. Is it an elusive & secretive
> place? Or, perhaps, does it not exist?
It's in the list of NGs on my NNTP server (slurp), and I browse and post
there week after week. I remember from many previous threads that it's
not widely hosted. If this might help:
$ wc -l .jnewsrc
38495 .jnewsrc
$ grep '^comp.lang.perl' .jnewsrc
comp.lang.perl: 1-24720,24722-24730
comp.lang.perl.announce: 1-1866
comp.lang.perl.modules: 1-49149
comp.lang.perl.misc: 1-412176,412178-412381,412383-412481,412483-412542,
412544-412548
comp.lang.perl.moderated: 1-8489
comp.lang.perl.tk!
And so I repose my question to the groups at large: due to the intended
replacement of clp with clp.*, am I making matters worse by continuing
to post there? Especially since not as many people knowledgable at Perl
can help out there?
--
-Tim Hammerquist <timmy@cpan.org>
People get annoyed when you try to debug them.
-- Larry Wall, 1999
------------------------------
Date: Thu, 5 Jul 2001 17:19:48 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: OT: The Evils of Posting to comp.lang.perl
Message-Id: <slrn9k9mfk.hsi.tadmc@tadmc26.august.net>
Tim Hammerquist <tim@vegeta.ath.cx> wrote:
>Paul Boardman <peb@bms.umist.ac.uk> wrote:
>> Tim Hammerquist wrote:
>> >
>> > Philip Newton <pne-news-20010705@newton.digitalspace.net> wrote:
>> > > [Don't followup-to comp.lang.perl; that group doesn't exist.]
>> >
>> > Don't tell the frequenters of comp.lang.perl that! They post quote
>> > frequently as if they exist. When someone tells them they don't exist,
>> > they get quite indignant.
>
>[ snippage ]
>
>> I can't see clp in the list of newsgroups from my newsgroup server & I
>> can't find it on groups.google.com either. Is it an elusive & secretive
>> place? Or, perhaps, does it not exist?
It does not exist on well-maintained news servers.
It was rmgroup'd years ago.
>It's in the list of NGs on my NNTP server (slurp), and I browse and post
>there week after week.
It appears that there are a lot of poorly-maintained news servers
around then. I do not find that very surprising :-(
>I remember from many previous threads that it's
>not widely hosted.
It is hosted on news servers that to not honor rmgroup's.
>And so I repose my question to the groups at large: due to the intended
>replacement of clp with clp.*, am I making matters worse by continuing
>to post there?
In as much as answering questions there encourages folks to post
there instead of the replacement where their odds are better,
I would say yes, it does make matters worse.
>Especially since not as many people knowledgable at Perl
>can help out there?
Folks should be encouraged to post to comp.lang.perl.misc instead
of comp.lang.misc especially since not as many people knowledgable
at Perl can help out in comp.lang.misc.
:-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 6 Jul 2001 00:54:34 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: OT: The Evils of Posting to comp.lang.perl
Message-Id: <Pine.LNX.4.30.0107060030390.19112-100000@lxplus003.cern.ch>
On Jul 5, Tad McClellan rearranged some electrons to say
> It was rmgroup'd years ago.
AFAIR, it happened during a period of time when there was considerable
upheaval going on in the process for creating and rm'ing groups, and
it seems many admins who would normally have honoured such messages
declined to do so during that interval.
Being one of the major hierarchies, it ought to get ironed out by
periodic checkgroups messages, of course (see "Checkgroups message
(without INET groups)" posted to news.announce.newgroups, in which
the relevant collection of groups was correct as of last Aug.).
This came up in recent discussion on this very group, and the
discussion quotes the actual rmgroup message from 1995. Do a
google-groups search for the phrase "rmgroup comp.lang.perl" and it
pops out.
http://groups.google.com/groups?q=%22rmgroup+comp.lang.perl%22&hl=en&safe=off&rnum=1&ic=1&selm=G7oDr4.55F%40presby.edu
------------------------------
Date: Thu, 05 Jul 2001 12:35:59 -0700
From: Gordon Vrdoljak <vrdoljak@uclink.berkeley.edu>
Subject: Re: passing information between mutiple forms
Message-Id: <3B44C19F.A67F9F9C@uclink.berkeley.edu>
I did something similar when I wanted to save the name information from one cgi
script to another. What I did in the link to the new cgi script, I included the
parameters as (don't know the tech term for it):
--------------------------------------------|-------------|
two variables I want to have for the next script0
print "<a href=unlisted.cgi?last_name=$last_name&first_name=$first_name>";
Umair Tariq Bajwa wrote:
>
> I have a main script called "awards.pl" from where i execute another script
> called "investigator.pl" in a seperate popup window. Once the user enters all
> the information in investigator.pl he/she hits "Done" button. What I would
> like to do is once the user will hit Done,
> I would like to store all information in hash and pass it to "awards.pl" (the
> main script from where its being executed or called) something like that. Any
> suggestions? Does anyone know how can i do that? Any idea is most welcome.
> Thanks in advance.
>
> regards,
>
> Umair
>
> Favorite Quotes:
> ===============
> "The box said 'Windows 95 or better', so I installed Linux"
> -- Unknown
> "A computer without Windows is like a chocolate cake without mustard."
> -- Unknown
>
>
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Gordon Ante Vrdoljak Electron Microscope Lab
ICQ 23243541 http://nature.berkeley.edu/~gvrdolja 26 Giannini Hall
vrdoljak@uclink.berkeley.edu UC Berkeley
phone (510) 642-2085 Berkeley CA 94720-3330
fax (510) 643-6207 cell (510) 290-6793
------------------------------
Date: Thu, 05 Jul 2001 19:32:33 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Perl *is* strongly typed (was Re: Perl description)
Message-Id: <tk9g6hjuncb71f@corp.supernews.com>
In comp.lang.perl.moderated Mark Jason Dominus <mjd@plover.com> wrote:
> In article <m1y9qk9xzu.fsf_-_@halfdome.holdit.com>,
> Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>No, Perl has strong compile-time typing for primitive data types
>>(scalars, arrays, hashes, filehandles),
> I cannot imagine what you might mean by this, since each of these is
> converted to the others automatically upon request, and hardly any
> checking is done. If this qualifies as 'strong typing' then I must
> conclude that 'strong typing' no longer has any meaning at all.
MJD doesn't even mention here that Perl, although it has type checks
for the type of aggregate, has no issue with casting numeric and string
data back and forth -- in fact, it welcomes and fully supports the
conversion. Many would say that 'strongly typed' has something to do
with placing data in a variable which only accepts data of one nature.
In this respect, even C is more strongly typed.
On the other hand, Perl does pretty good type checking on hashes v.
arrays v. scalars at some points. It does treat all of these as
flat lists at other times, though.
My personal opinion is that to call Perl weakly typed or strongly typed,
you must explain your point of view. As in many languages, Perl does
not ride one side of a line or the other. Both Perl and the idea of
type strength are complex topics, and it makes little sense to me to
classify Perl solidly on one side or the other of this classification.
Chris
--
Disclaimer: Actual product may not resemble picture in ad in any way.
------------------------------
Date: Thu, 05 Jul 2001 20:05:33 +0200
From: Buggs <buggs-clpm@splashground.de>
Subject: Re: perl and progress DB
Message-Id: <9i2aa6$9v6$03$1@news.t-online.com>
raj wrote:
> Guys,
>
> is there any perl module to interact with Progress DB?
>
> I gotta write a script (would love to write it in perl) which will
> access a table in progress db, process its records, and then generate
> an output file.
Better of with asking somewhere at
http://www.peg.com/
HQ of the Progress comunity.
Buggs
------------------------------
Date: Fri, 06 Jul 2001 02:43:00 GMT
From: gurm@intrasof.com (Smiley)
Subject: Perl CGI problem with library file
Message-Id: <3b4525a9.210456800@news1.on.sympatico.ca>
Hi,
I've run into a little bit of a baffling problem dealing with library
files. I'm working on an application in which I'm using a library
file to handle my most used procedures and also contain all the
configuration data used throughout the scripts. I hadn't had any
problems until just recently and I'm not sure what I did that changed
everything.
The problem is that the data online isn't being updated when I change
the library file. No matter what I do to it the changes won't take
effect. Even if I delete the library file the program continues to
run as if all the data is there, leaving me to wonder where the heck
the data is coming from. I don't have another copy of the file, to
make sure though I even tried putting the absolute path to it rather
than the relative.
I'd appreciate it if anybody has any ideas on what this might be.
------------------------------
Date: Thu, 05 Jul 2001 19:56:02 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl method for finding current working dir
Message-Id: <hkh9kt8orp9nhl37m49askkcr7buth6sds@4ax.com>
Graham Wood wrote:
>Does nobody know this or are you just choosing not to answer?
>
>How can you determine the directory your script is running in from
>within the script, without calling an external program that differs on
>Windows and Unix?
use FindBin '$Bin';
$Bin is directory your script is in
use Cwd; print cwd;
cwd() is the Current Working Directory.
--
Bart.
------------------------------
Date: Fri, 6 Jul 2001 00:21:35 +0100
From: "Stuart Moore" <stumo@bigfoot.com>
Subject: Re: regular expression ..doh !
Message-Id: <mD617.6548$Jk6.1420941@news2-win.server.ntlworld.com>
<mbower@ibuk.bankgesellschaft.de> wrote in message
news:3b449220.93757859@news...
> I'm trying to parse form input, and would like to remove all entries
> from $ENV{'QUERY_STRING'} which are of type "field"
>
> e.g &field=1&field=2&field=3&other=no
>
>
>
>
>
$var1="/tableview2.pl?editcols=Go&table=atabler&view=yes&canupdate=true&field=eu
rex&field=rtd&field=gl&someother=yes";
> print "$var1\n";
> $var1 =~ s/&field=\w+(&|$)/$1/g;
Haven't tried this, but:
$var1 =~ s/[?&]field=[^&]*//g;
Ought to do it.
(I take it that by remove you mean delete from the string rather than extract
i.e. have the values available for you to use)
Stuart
------------------------------
Date: Thu, 05 Jul 2001 21:11:35 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: Vapo-Rub
Message-Id: <slrn9k9mm6.2vi.tim@vegeta.ath.cx>
Dallas McCarthy <whitetip@iprimus.com.au> wrote:
> Hell no
> "Tim Hammerquist" <tim@vegeta.ath.cx> wrote in message
> news:slrn9k6vqv.1rv.tim@vegeta.ath.cx...
> > Dallas McCarthy <whitetip@iprimus.com.au> wrote:
> > > OK, then, RACK OFF Losers
> >
> > Most people would leave a thread they're not interested in.
> >
> > So I wonder, if we "racked off", would you be left bored?
Glad to hear it!
--
-Tim Hammerquist <timmy@cpan.org>
SURF MUSIC makes EVERYTHING better!
-- Tom Servo
------------------------------
Date: Fri, 6 Jul 2001 01:46:28 +0200
From: "CentaureZ" <julien.carosi@club-internet.fr>
Subject: Wants to use Ftp functions
Message-Id: <9i2ua9$9p0$1@front5.grolier.fr>
Hello,
i'm quite new to perl and i'd like to write a program that could use ftp
functions, so i put
use Net::FTP
at the beggining of my source, but it doesn't work when i try to launch it i
get
centaurez@gateway:~/perl$ ./essai
Can't locate Net/FTP/Common.pm in @INC (@INC contains:
/usr/local/lib/perl/5.6.1 /usr/local/share/perl/5.6.1 /usr/lib/perl5
/usr/share/perl5 /usr/lib/perl/5.6.1 /usr/share/perl/5.6.1
/usr/local/lib/site_perl /usr/local/lib/perl/5.6.0
/usr/local/share/perl/5.6.0 /usr/lib/perl5/5.6
/usr/lib/perl5/5.005/i386-linux /usr/lib/perl5/5.005 .) at ./essai line 3.
BEGIN failed--compilation aborted at ./essai line 3.
I am on a linux debian system.
I thought this module was shipped with perl, but must i download it or is
there something else wrong?
Hope you'll be able to help me :)
Thanks in advance!!
------------------------------
Date: Fri, 06 Jul 2001 02:01:54 +0200
From: Buggs <buggs-clpm@splashground.de>
Subject: Re: web fetching
Message-Id: <9i2v66$29s$02$1@news.t-online.com>
BUCK NAKED1 wrote:
> Interesting that this thread is here today. I was just trying to go into
> the LWP module and write a "get" in plain perl without using socket or
> LWP.
I'd be interested in code
which tries to achieve that
in "plain" Perl without using Socket.
> Problem was that when I went into LWP::Simple, it requires LWP, and
> LWP, in turn needs code from other modules, so it would be a nightmare
> for this rookie to gather all of the proper coding from the modules to
> do a 'get' or 'getstore' in raw perl.
#!/usr/local/bin/perl
use Socket;
$peer_name = 'www.perl.com';
$path = "/";
$port = 80;
socket(Peer, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
$in_addr = inet_aton($peer_name) or die "Bad Hostname\n";
connect(Peer,sockaddr_in($port, $in_addr)) or die "Can't Connect\n";
$msg = "GET $path HTTP/1.0\015\012Host: $peer_name\015\012\015\012";
syswrite(Peer, $msg, length($msg)) || die "Can't write\n";
print while(<Peer>);
END {close(Peer);}
> Why do this? Because not all servers have LWP.pm or Socket.PM, or they
> don't allow you to install them.
It's Socket.pm and you have it.
> I really do think LWP and the other modules it requires to work, SHOULD
> be included in the main distribution.
Notice Bundle::libnet.
Have fun,
Buggs
------------------------------
Date: Thu, 05 Jul 2001 18:32:27 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Will using DB_File work for this??
Message-Id: <f1c9kt4e8a4tp68rakmg5jdunrkhj0pf4p@4ax.com>
Hi everyone,
I would appreciate help from anyone who might have some thoughts about
using DB_File.
Will it allow me to work with records that contain MORE than a single
value associated with my key?
For example my records would look like this.
KEY VALUE_1 VALUE_2 VALUE_n
<email_address>,<first_name>,<date_subscribed>,etc.
<email_address>,<first_name>,<date_subscribed>,etc.
etc..
Can I use DB_File to work with such records and can it save such
records to a comman delimited, text file?
Short of going to a full relational database are there other Perl
database modules that anyone would recommend??
Thanks
Carlos
www.internetsuccess.ca
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 1252
***************************************