[16903] in Perl-Users-Digest
Perl-Users Digest, Issue: 4315 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 13 18:10:38 2000
Date: Wed, 13 Sep 2000 15:10:24 -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: <968883024-v9-i4315@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 13 Sep 2000 Volume: 9 Number: 4315
Today's topics:
How to get parameters: cgi-bin/login.cgi?username=john& <angelo@acsoft.dk>
Re: How to get parameters: cgi-bin/login.cgi?username=j (Jerome O'Neil)
Re: How to read/decode UDP packets <bkennedy@hmsonline.com>
Re: I really need help !!!! <notkmetcalf@notlighthousemarketingnot.com>
insert a string to a file nodo70@my-deja.com
Re: insert a string to a file <aqumsieh@hyperchip.com>
Re: insert a string to a file nodo70@my-deja.com
Re: insert a string to a file <lauren_smith13@hotmail.com>
Re: Inserting into arrays (Andrew J. Perrin)
Re: Is there a more elegant way? <tim@ipac.caltech.edu>
Re: killfiles? scores? I wish I had these luxuries (Colin Watson)
Re: logparser for fps's <iltzu@sci.invalid>
LWP::UserAgent and EBay using Post xxaxx@my-deja.com
Re: min function (brian d foy)
Re: min function <chris@fedde.littleton.co.us>
Re: min function (Randal L. Schwartz)
NDBM_File.pm question <louis@lilith1.demon.co.uk>
Need Help in preparing Textarea for POST method using L xxaxx@my-deja.com
Re: Need Help in preparing Textarea for POST method usi (Jerome O'Neil)
Re: Need Help in preparing Textarea for POST method usi xxaxx@my-deja.com
Re: Need Help in preparing Textarea for POST method usi (Jerome O'Neil)
Re: OFF TOPIC IGNORE Re: killfiles? scores? I wish I <godzilla@stomp.stomp.tokyo>
open serial port and specify baud rate in linux <aschlies@citynet.net>
Re: Passing hashes to a function <tim@ipac.caltech.edu>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 13 Sep 2000 21:26:53 GMT
From: Steen Angelo <angelo@acsoft.dk>
Subject: How to get parameters: cgi-bin/login.cgi?username=john&password=doe
Message-Id: <39BFF0EA.F3A8AC5F@acsoft.dk>
Hi there.
How do I within the CGI-script get access to parameters given at the
URL-line in the browser:
www.acsoft.dk/cgi-bin/login.cgi?username=john&password=doe
I want to test for the parameters:
username=john
and
password=doe
and put them into $username and $password within my CGI-script
I've tried to use @ARGV, but that's appearently not for this use
thanx
--
Cheers
Steen Angelo
angelo@_nospam_acsoft.dk
(delete _nospam_)
------------------------------
Date: Wed, 13 Sep 2000 21:29:17 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: How to get parameters: cgi-bin/login.cgi?username=john&password=doe
Message-Id: <NkSv5.252$L46.265010@news.uswest.net>
Steen Angelo <angelo@acsoft.dk> elucidates:
> How do I within the CGI-script get access to parameters given at the
> URL-line in the browser:
>
> www.acsoft.dk/cgi-bin/login.cgi?username=john&password=doe
> I've tried to use @ARGV, but that's appearently not for this use
What you want is to use CGI. It is thouroughly documented.
HTH!
------------------------------
Date: Wed, 13 Sep 2000 18:17:38 GMT
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: How to read/decode UDP packets
Message-Id: <6xPv5.23883$AW2.306658@news1.rdc2.pa.home.com>
"Robert Jones" <robert@purdy.com> wrote in message
news:8pmod3$tnv$1@news.chatlink.com...
> while(1)
> {
> $message = '';
> undef $paddr;
> $paddr = recv(Server, $message, $MAXSIZE, 0);
> if(!defined $paddr) {next;}
> ($port,$iaddr) = sockaddr_in($paddr) or die "Ciel mes socketes ! $!";
> &print_info($message,$port,$iaddr);
> }
>
> contents of $message contains lots of special characters like spades,
> hearts, arrows, etc along with some clear text that can be read as is. I
> assume unpack is needed to convert it into a readable form. I have tried
> every thing using unpack without success.
It looks like your print_info() sub is also printing out the packed address
in $iaddr, which would account for the hearts and spades. You want
something like:
my $message;
while(my $paddr = recv(SOCK,$message,1500,0)) { # 1500 is big enough
$paddr or die "Recv error: $!";
my($port,$addr) = unpack_sockaddr_in($paddr); # unpack the port
number and packed IP address
my $dot_ip = inet_ntoa($addr); # convert the packed IP address to
human readable form
print "$dot_ip:$port - $message\n";
}
-- Ben Kennedy
------------------------------
Date: 13 Sep 2000 18:19:35 GMT
From: Kevin Metcalf <notkmetcalf@notlighthousemarketingnot.com>
Subject: Re: I really need help !!!!
Message-Id: <39BFC5A6.BE113B9@notlighthousemarketingnot.com>
First off, this is a great place for certain people here to exercise that
fun thing called self control. RIGHT?
OK, any book that claims to be about CGI and doesn't bother to explain
anything about web servers needs to be calmly set back on the shelf and
covered in dust for eternity. You should look for the solution to your
problem not in the HTML or perl code, but rather in the configuration of
you server. The first question you asked ([first, what is this...]) has
an easy answer. That was the program that was a few pages back that
contained the code that does the dirty work. Let me guess, you never read
the other chapters, right? You just jumped into this chapter, started
typing the programs in and expected them to work without doing any
research even in the book you were reading? Like I said, SELF CONTROL
PEOPLE!!! Anyway, here are some answers:
1) Read a few chapters until you find the program "html.pl" that contains
a few functions such as HTML_Header.
2) If your cgi-bin directory is protected-cgi-bin, you might want to
append that to the path of any cgi-programs you are calling from your HTML
files.
That's about all I'm going to say. You REALLY should read the who book
before declairing it hogwash, though. Just a thought.
-- Carbon Ocelot --
If tin whistles are made out of tin, what do they make fog horns out of?
peter wrote:
> I'm having a hell of a time trying to get my perl cgi scripts to work.
>
> I'm using Mandrake 7.1, and I'm working out of a book called: Perl,
> CGI, and JavaScript, by Sybex.
>
> Right now I'm working in chapter 12: Creating Real-World HTML Forms
> with Perl and CGI.
>
> I've got a few question about HTML and Perl code, what is happening
> here is that a user will enter his data and then push the submit
> button and then the data will be displayed in a new page.
>
> THIS IS THE PERL [file name: geturl.pl]:
>
> #!/usr/bin/perl
>
> require "/pub/scripts/perl-cgi/html.pl";
> [first, what is this?, the book doesn't say, and no such file or dir
> exists on my system]
>
> $Title = "Get Information From A URL";
>
> $QueryString = $ENV{ 'QUERY_STRINGS'} ;
>
> @NameValuePairs = split (/&/, $QueryString);
>
> &HTML_Header ($Title);
> print "\n";
> print "<H1>$Title</H1>\n";
> print "<HR>\n";
>
> foreach $NameValue (@NameValuePairs)
> {
> ($Name, $Value) = split (/=/, $NameValue);
> print "Name = $Name, value = $Value<BR>\n";
> }
>
> $HTML_Ender;
>
> AND HERE IS THE HTML:
>
> <html>
> <head>
> <title>Visitor Information Form</title>
> </head>
> <body>
> <h1 align="left">Visitor Information Form</h1>
> <hr>
> <form action="geturl.pl" METHOD="GET">
>
> [I'm not sure which dir the form action should point to, in my config
> files, apache says: protected-cgi-bin/ /home/httpd/protected-cgi-bin/]
>
> <b>
> Last name: <INPUT TYPE="text" NAME="LastName" SIZE=16>
>
> First name: <INPUT TYPE="text" NAME="FirstName" SIZE=16>
> <br><br>
>
> Address: <INPUT TYPE="text" Name="Address" SIZE=32>
>
> City: <INPUT TYPE="text" NAME="City" SIZE=32>
> <br><br>
>
> State: <INPUT TYPE="text" NAME="State" SIZE=2>
> <br><br>
> </b><center><b>
> <INPUT TYPE="submit" VALUE="Send Information">
> <INPUT TYPE="reset" VALUE="Clear Form Fields">
> </b>
>
> </center></form>
> </body>
> </html>
>
> [Unfortunately this book does a poor job, I'll probably return it, can
> anyone tell me a good book about cgi (perl-cgi) that's worth the paper
> it's printed on ?]
------------------------------
Date: Wed, 13 Sep 2000 19:27:46 GMT
From: nodo70@my-deja.com
Subject: insert a string to a file
Message-Id: <8poken$c7t$1@nnrp1.deja.com>
Is there any way that insert a line of string to a file without
renaming the file?
Here is my code to write:
sub insertString2File {
my ($file, $string) = @_;
my ($tempFile) = $file . ".temp";
rename ($file, $tempFile);
open (TEMP, "$tempFile") || die ("Cannot open $tempFile: $!\n");
open (FILE, ">$file") || die ("Cannot open $file: $!\n");
$line = <TEMP>;
if (grep (/#!/,$line)) { #if it is a perl script then insert
print FILE $line; #a string right after a first line
print FILE $string;
else {
print FILE $string;
print FILE $line;
}
while (($line = <TEMP>) ne "") { #just copy the rest
print FILE $line;
}
unlink $tempFile;
}
But once it complete the permission of the file is different from
original file which I don't want it. Please advise. Thanks for help.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 13 Sep 2000 19:49:13 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: insert a string to a file
Message-Id: <7ak8cgoyx0.fsf@merlin.hyperchip.com>
nodo70@my-deja.com writes:
> Is there any way that insert a line of string to a file without
> renaming the file?
Yes, and it is in the FAQs. Please check the FAQs next time before you
post. For this question, the specific document you need is perldoc5:
How do I change one line in a file/
delete a line in a file/
insert a line in the middle of a file/
append to the beginning of a file?
--Ala
------------------------------
Date: Wed, 13 Sep 2000 20:21:09 GMT
From: nodo70@my-deja.com
Subject: Re: insert a string to a file
Message-Id: <8ponis$gc2$1@nnrp1.deja.com>
Where is FAQs? Sorry being dum here.
In article <7ak8cgoyx0.fsf@merlin.hyperchip.com>,
Ala Qumsieh <aqumsieh@hyperchip.com> wrote:
>
> nodo70@my-deja.com writes:
>
> > Is there any way that insert a line of string to a file without
> > renaming the file?
>
> Yes, and it is in the FAQs. Please check the FAQs next time before you
> post. For this question, the specific document you need is perldoc5:
>
> How do I change one line in a file/
> delete a line in a file/
> insert a line in the middle of a file/
> append to the beginning of a file?
>
> --Ala
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 13 Sep 2000 13:25:49 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: insert a string to a file
Message-Id: <8ponnj$l5e$1@brokaw.wa.com>
<nodo70@my-deja.com> wrote in message news:8poken$c7t$1@nnrp1.deja.com...
> Is there any way that insert a line of string to a file without
> renaming the file?
That's answered in the FAQ. perlfaq5: How do I change one line in a
file/delete a line in a file/insert a line in the middle of a file/append to
the beginning of a file?
> Here is my code to write:
> sub insertString2File {
> my ($file, $string) = @_;
> my ($tempFile) = $file . ".temp";
>
> rename ($file, $tempFile);
> open (TEMP, "$tempFile") || die ("Cannot open $tempFile: $!\n");
> open (FILE, ">$file") || die ("Cannot open $file: $!\n");
> $line = <TEMP>;
> if (grep (/#!/,$line)) { #if it is a perl script then insert
Why don't you just do a
if ($line =~ /#!/)
and skip the grep?
> print FILE $line; #a string right after a first line
> print FILE $string;
> else {
> print FILE $string;
> print FILE $line;
> }
>
> while (($line = <TEMP>) ne "") { #just copy the rest
> print FILE $line;
> }
> unlink $tempFile;
> }
> But once it complete the permission of the file is different from
> original file which I don't want it. Please advise. Thanks for help.
perldoc -f chmod ?
Lauren
--
$JAPH='!rekcaH lreP rehtonA tsuJ';%JAPH=map{$_=>chop
$JAPH} (b..z); print map $JAPH{$_}, sort keys %JAPH;
------------------------------
Date: 13 Sep 2000 15:19:03 -0400
From: aperrin@demog.berkeley.edu (Andrew J. Perrin)
Subject: Re: Inserting into arrays
Message-Id: <uits0nlqw.fsf@demog.berkeley.edu>
tasher1234@my-deja.com writes:
> In article <uog1sny5p.fsf@demog.berkeley.edu>,
> aperrin@demog.berkeley.edu (Andrew J. Perrin) wrote:
> > tasher1234@my-deja.com writes:
> >
> > > Okay, I'm a newbie to Perlscript. What I need to do
> > > is to insert an array element into any position in an array.
> > > For example the array @items has this in it:
> > > Bob Ted Alice
> > > Between Bob and Ted I want to insert Uri.
> > > So now the array should look like this:
> > > Bob Uri Ted Alice
> > > So would a splice command do it?
> > > $i is the element counter
> > > splice @items,$i,0
> >
> > What happened when you tried it?
> >
> > Check out perldoc -f splice for more.
> >
> That was just a guess. I tried it (splice) but it wrote over Ted
> and left the array count to be the same when it should have got
> incremented.
> I do have the Programming Perl manual and have read the small part
> about splice - no help.
> Is your perldoc -f splice command given from the Dos command line?
> If so, then I guess I have to be on the Server's directory where
> Perl was installed. I'm on a NT workstation now.
perldoc is on any machine with a correctly installed perl. If you're
developing on NT it would behoove you to make your NT machine one of
the above, which you can do with relatively little trouble at
www.activestate.com. If for some reason you can't or don't want to do
that, try www.perl.com, which contains in its innards the entire perl
documentation tree including the FAQ's. Therein lie the answers to
your question(s), including the documentation for splice:
splice ARRAY,OFFSET,LENGTH,LIST
splice ARRAY,OFFSET,LENGTH
splice ARRAY,OFFSET
Removes the elements designated by OFFSET and LENGTH
from an array, and replaces them with the elements of
LIST, if any. In list context, returns the elements
removed from the array. In scalar context, returns the
last element removed, or `undef' if no elements are
removed. The array grows or shrinks as necessary. If
OFFSET is negative then it start that far from the end
of the array. If LENGTH is omitted, removes everything
from OFFSET onward. If LENGTH is negative, leave that
many elements off the end of the array. The following
equivalences hold (assuming `$[ == 0'):
push(@a,$x,$y) splice(@a,@a,0,$x,$y)
pop(@a) splice(@a,-1)
shift(@a) splice(@a,0,1)
unshift(@a,$x,$y) splice(@a,0,0,$x,$y)
$a[$x] = $y splice(@a,$x,1,$y)
Example, assuming array lengths are passed before
arrays:
sub aeq { # compare two list values
my(@a) = splice(@_,0,shift);
my(@b) = splice(@_,0,shift);
return 0 unless @a == @b; # same len?
while (@a) {
return 0 if pop(@a) ne pop(@b);
}
return 1;
}
if (&aeq($len,@foo[1..$len],0+@bar,@bar)) { ... }
Given your description of the problem and the documentation above, you
should be able to find your answer.
--
----------------------------------------------------------------------
Andrew Perrin - Solaris-Linux-NT-Samba-Perl-Access-Postgres Consulting
aperrin@igc.apc.org - http://demog.berkeley.edu/~aperrin
----------------------------------------------------------------------
------------------------------
Date: Wed, 13 Sep 2000 14:15:52 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Is there a more elegant way?
Message-Id: <39BFEE88.E408AF8E@ipac.caltech.edu>
Sean McAfee wrote:
>
> I wrote a function that essentially looks like this:
>
> sub myfunc {
> my ($arg1, $arg2) = @_;
> local $_ = get_data($arg1, $arg2); # This function may return
> # a very large scalar.
> otherfunc(); # This function modifies $_.
> return $_;
> }
>
> I'll generally know before calling myfunc whether the scalar that will be
> returned will be very large or not. I want to reduce unnecessary copying of
> large blocks of memory, ...
Why not just have get_data() always return a reference to the data, which you
can pass to otherfunc, which also returns that ref?
sub myfunc { return otherfunc( get_data(@_) ); }
sub get_data {
my ($arg1,$arg2) = @_;
my $data;
... load data into $data ...
return \$data;
}
sub otherfunc {
my $dataref = shift;
$$dataref .= " added data";
return $dataref;
}
--
-- Tim Conrow tim@ipac.caltech.edu |
------------------------------
Date: 13 Sep 2000 07:45:27 GMT
From: cjw44@flatline.org.uk (Colin Watson)
Subject: Re: killfiles? scores? I wish I had these luxuries
Message-Id: <8pnban$nn3$1@riva.ucam.org>
jason <elephant@squirrelgroup.com> wrote:
>Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote ..
>>Get thineself to www.mutt.org and sin no more :)
>
>read *before* you post oh-shocked-one .. Jeff is using pine as a *news*
>reader
There are NNTP patches for mutt. One of my friends uses mutt-nntp as a
news reader (I still think she should just give in and use trn, but
hey).
--
Colin Watson [cjw44@flatline.org.uk]
"Ah, young webmaster ... Java leads to Shockwave. Shockwave leads to
RealAudio, and RealAudio leads to suffering." - Peter da Silva, ASR
------------------------------
Date: 13 Sep 2000 21:27:13 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: logparser for fps's
Message-Id: <968879830.13501@itz.pp.sci.fi>
In article <eQ2r5.2592$Av5.72045@news.kpnqwest.fi>, John Tackman wrote:
>basically, open all files in specified directory, scan them for data that is
>wanted (maybe defined in separate
>config file) and store the data in an internal DB, postgres or MySQL.
>
>No other functionality needed, and if you live in Finland and want to do
>this for me, I'll buy you a beer =)
That sound like a lot of work for a beer. If you told us more about
the format of the data files, maybe someone could help, but as it is
all I can say is that you probably want to use readdir() and DBI.
Oh, and where does the data come form? Is this a one time job where
some throwaway hack would suffice, or do you need a reusable utility
with a clean user interface? Or something in between?
If the latter, you'll likely need to pay at least a case of beer. If
a one-liner will do, however, and the specs are simple enough, maybe
one of the regulars will take it as a challenge. But don't count on
being able to understand the answer..
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla | "By promoting postconditions to
and its pseudonyms - | preconditions, algorithms become
do not feed the troll. | remarkably simple." -- Abigail
------------------------------
Date: Wed, 13 Sep 2000 21:05:01 GMT
From: xxaxx@my-deja.com
Subject: LWP::UserAgent and EBay using Post
Message-Id: <8poq5d$jm4$1@nnrp1.deja.com>
I'm using the following code to attempt posting a form to Ebay:
sub post2ebay {
my(%data) = @_;
require LWP::UserAgent;
my($ua) = LWP::UserAgent->new;
$ua->agent('Mozilla/4.61 [en] (Win95; I)');
my($url) = 'http://cgi2.ebay.com/aw-cgi/eBayISAPI.dll';
my ($req) = HTTP::Request->new(POST => "$url");
$req->content_type('application/x-www-form-urlencoded');
$req->header('Accept' => 'text/html', Referer => "$url");
my($stufftosend);
foreach $key (keys %data) {
$data{$key} =~ s/([!@#$%^&()_+\n])/sprintf("%%%02x",ord($1))/eg;
$data{$key} =~ s/\s/+/g;
$stufftosend .= "$key=$data{$key}&";
}
$stufftosend =~ s/&$//;
$req->content($stufftosend);
my ($res) = $ua->request($req);
return($res->as_string);
}
This is called by:
$SEND_DATA{'MfcISAPICommand'} = 'LeaveFeedback';
$SEND_DATA{'userid'} = 'usernamehere';
$SEND_DATA{'pass'} = 'passwordhere';
$SEND_DATA{'otheruserid'} = 'persontoleavefeedbackfor';
$SEND_DATA{'itemno'} = 'relateditemnumber';
$SEND_DATA{'which'} = 'positive';
$SEND_DATA{'comment'} = 'Great Ebay buyer. etc.';
$SEND_DATA{'submit'} = 'leave feedback';
$response = post2ebay(%SEND_DATA);
The result of this is:
HTTP/1.0 302 (Found) Object Moved
Date: Wed, 13 Sep 2000 21:01:11 GMT
Date: Wed, 13 Sep 2000 21:01:11 GMT
Location:
http://cgi3.ebay.com/aw-cgi/eBayISAPI.dll?userid=usernamehere&itemno=rel
ateditemnumber&submit=leave+feedback&pass=passwordhere&comment=Great+Eba
y+buyer.+etc.&which=positive&otheruserid=persontoleavefeedbackfor&MfcISA
PICommand=LeaveFeedback
Server: Microsoft-IIS/4.0
Server: Microsoft-IIS/4.0
Client-Bad-Header-Line: HTTP/1.0 501 Not Implemented
Client-Date: Thu, 14 Sep 2000 06:36:32 GMT
Client-Peer: 216.32.120.138:80
I've run this with proper ids and passwords with same result.
Has anyone managed to use the LWP::UserAgent POST method on ebay forms?
Any help would be appreciated.
Claude
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 13 Sep 2000 14:33:42 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: min function
Message-Id: <brian-ya02408000R1309001433420001@news.panix.com>
In article <srvg36ect619@corp.supernews.com>, cberry@cinenet.net (Craig Berry) posted:
> Chris Stith (mischief@motion.net) wrote:
> : We have a modulus operator, so why not a min and a max?
> : Where's that wishlist for Perl6 again?
> I would propose making the syntax for min and max parallel that for sort.
> That way you could specify your own comparison block, or take the default
> cmp as the min/maximization criterion.
of course, you can already do that with sort, although an iterator
version would be really nice.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Wed, 13 Sep 2000 20:51:16 GMT
From: Chris Fedde <chris@fedde.littleton.co.us>
Subject: Re: min function
Message-Id: <8NRv5.135$W3.170584064@news.frii.net>
In article <brian-ya02408000R1309001433420001@news.panix.com>,
brian d foy <brian@smithrenaud.com> wrote:
>In article <srvg36ect619@corp.supernews.com>, cberry@cinenet.net (Craig
>Berry) posted:
>
>> Chris Stith (mischief@motion.net) wrote:
>> : We have a modulus operator, so why not a min and a max?
>> : Where's that wishlist for Perl6 again?
>
>> I would propose making the syntax for min and max parallel that for sort.
>> That way you could specify your own comparison block, or take the default
>> cmp as the min/maximization criterion.
>
>of course, you can already do that with sort, although an iterator
>version would be really nice.
>
This is conceptually similar to map and grep but it returns a scalar.
The operator could be called 'pick' and use a magic $a variable
similar to $a and $b from sort. If $a is undefined or the condition
evaluates to true then perl makes $a = $_.
@list = (34, 22, 56, 12, 56, 3, 66);
$min = pick {$a < $_} @list;
$RGBcolors = [[102,205,170], [46,139,87], [153, 50, 204]];
$redest = pick {$a->[0] > $_->[0]} $RGBcolors;
sub max{ pick {$a > $_} @_ }
What do you think?
chris
--
This space intentionally left blank
------------------------------
Date: 13 Sep 2000 13:55:46 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: min function
Message-Id: <m13dj4ggfh.fsf@halfdome.holdit.com>
>>>>> "Chris" == Chris Fedde <chris@fedde.littleton.co.us> writes:
Chris> This is conceptually similar to map and grep but it returns a scalar.
Chris> The operator could be called 'pick' and use a magic $a variable
Chris> similar to $a and $b from sort. If $a is undefined or the condition
Chris> evaluates to true then perl makes $a = $_.
Chris> @list = (34, 22, 56, 12, 56, 3, 66);
Chris> $min = pick {$a < $_} @list;
Chris> $RGBcolors = [[102,205,170], [46,139,87], [153, 50, 204]];
Chris> $redest = pick {$a->[0] > $_->[0]} $RGBcolors;
Chris> sub max{ pick {$a > $_} @_ }
Chris> What do you think?
use List::Util qw(reduce min); # List::Util is in the CPAN
$result = min(34, 22, 56, 12, 56, 3, 66);
## and if min wasn't defined, it'd be this:
sub min (@) { reduce { $a < $b ? $a : $b } @_ }
Been there. Done that. Your op would be:
$reddest = reduce { $a->[0] > $b->[0] ? $a : $b } @$RGBcolors;
Of course, you forgot to dereference your $RGBcolors.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Wed, 13 Sep 2000 22:03:35 +0100
From: louis <louis@lilith1.demon.co.uk>
Subject: NDBM_File.pm question
Message-Id: <39BFEBA6.45391DC7@lilith1.demon.co.uk>
Hi
I am fairly new to Perl so please bear with me if this question seems
stupid.
I am trying to get to grips with interfacing to databases and have been
trying to get a simple test program to work.
Some may know this so I'll include the info :
cgidb.cgi - from Perl Black book - requires NDBM_File.pm and
dynaload.pm apart from others.
Running locally on Sambar server (Win98) - latest Active perl etc.
This example puts up a HTML page with two forms that allow a dbase to be
created by adding elements and a search routine.
I get an error when running this module which all seems to come down to
the following line in NDBM_file.pm :
$Version = "1.01";
bootstrap NDBM_File $Version;
The message I get if run at the dos prompt is "can't locate loadable
object for module NDBM_File in @INC .."
If I comment out the bootstrap line it runs but doesn't write the
database file. I presume that the message is telling me that it can't
find the "bootstrap" routine.
Looking in dynaload.pm there is a bootstrap subroutine.
Can anyone tell me what the problem is (I know this may not be enough
information but I am hoping that someone knows the code I am using from
the Black book or knows about this problem). Perhaps it is something to
do with running this on Windows platform although most things seem to
work ok.
Louis
------------------------------
Date: Wed, 13 Sep 2000 18:25:43 GMT
From: xxaxx@my-deja.com
Subject: Need Help in preparing Textarea for POST method using LWP::UserAgent
Message-Id: <8pogqc$7jv$1@nnrp1.deja.com>
The http://search.cpan.org/doc/GAAS/libwww-perl-5.48/lwpcook.pod was
helpful in getting started with LWP::UserAgent.
But it says nothing (that I've found yet) about preparing textarea type
input. Is there a method which will convert raw textarea data into a
format which will make it through the post process?
Thanks
Claude
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 13 Sep 2000 18:54:54 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: Need Help in preparing Textarea for POST method using LWP::UserAgent
Message-Id: <24Qv5.160$L46.202717@news.uswest.net>
xxaxx@my-deja.com elucidates:
> The http://search.cpan.org/doc/GAAS/libwww-perl-5.48/lwpcook.pod was
> helpful in getting started with LWP::UserAgent.
>
> But it says nothing (that I've found yet) about preparing textarea type
> input. Is there a method which will convert raw textarea data into a
> format which will make it through the post process?
There is no such thing as "textarea" type input outside of your
browser.
Bits is bits.
------------------------------
Date: Wed, 13 Sep 2000 19:24:03 GMT
From: xxaxx@my-deja.com
Subject: Re: Need Help in preparing Textarea for POST method using LWP::UserAgent
Message-Id: <8pok7o$c3f$1@nnrp1.deja.com>
In article <24Qv5.160$L46.202717@news.uswest.net>,
jerome.oneil@360.com wrote:
> xxaxx@my-deja.com elucidates:
>
> There is no such thing as "textarea" type input outside of your
> browser.
>
> Bits is bits.
>
Tis true.
But there is such a thing as preparing a scalar to mimic and/or pass
along textarea input in the
$req->content($stufftosendtoform);
In the examples they have:
$req->content('match=www&errors=0');
I suppose if there is no other problems the question boils down to the
most effective s/// for converting necessary characters to %xx format.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 13 Sep 2000 19:45:40 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: Need Help in preparing Textarea for POST method using LWP::UserAgent
Message-Id: <EPQv5.182$L46.222285@news.uswest.net>
xxaxx@my-deja.com elucidates:
> I suppose if there is no other problems the question boils down to the
> most effective s/// for converting necessary characters to %xx format.
You want to URL encode it. Don't use a regex, as it will cause you grief.
Use URI::Escape, and you will be happy.
>
------------------------------
Date: Wed, 13 Sep 2000 11:06:01 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: OFF TOPIC IGNORE Re: killfiles? scores? I wish I had these luxuries
Message-Id: <39BFC209.D64CE3D2@stomp.stomp.tokyo>
Russ Jones wrote:
> "Godzilla!" wrote:
> plonk and this time it's for good.
Ahhh... you are breaking my wittle heart,
truly you are, Frank.
Godzilla!
--
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class
------------------------------
Date: Wed, 13 Sep 2000 16:15:42 -0400
From: "Tony Schliesser" <aschlies@citynet.net>
Subject: open serial port and specify baud rate in linux
Message-Id: <39bfdfcb$1_1@corp.newsfeeds.com>
Hi There,
I have open serial ports a few times in small projects, however, I am
working on one where I need to set the baud rate prior to the open and I am
not familiar with how to do this in perl, on a linux box.
any suggestions would be helpful.
Thank You
Tony
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Wed, 13 Sep 2000 13:37:49 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Passing hashes to a function
Message-Id: <39BFE59D.5547A537@ipac.caltech.edu>
Geoff Soper wrote:
>
> OK, I've read the relavent chapter in "Programming Perl" (there's little
> in "Learning Perl") but I feel don't really understand the concept of
> references. What do I do in my case to the hashes inside the function i.e.
> in the four different occurances of the %form_data hash as illustrated in
> the four extracts below?
perldsc has many detailed examples. Here's a simple example:
my %a = (x=>1);
sub foo { my $hashref = shift; print $hashref->{x}."\n"; }
foo(\%a);
... prints '1'.
--
-- Tim Conrow tim@ipac.caltech.edu |
------------------------------
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 4315
**************************************