[16905] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4317 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 13 21:05:28 2000

Date: Wed, 13 Sep 2000 18:05:14 -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: <968893513-v9-i4317@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 13 Sep 2000     Volume: 9 Number: 4317

Today's topics:
    Re: avoiding do {} while() <lr@hpl.hp.com>
    Re: convert date -> unixtime (Martien Verbruggen)
    Re: cross-platform archive mgt (Martien Verbruggen)
        Determining the length of a string rathmore@tierceron.com
    Re: Determining the length of a string <tony_curtis32@yahoo.com>
    Re: Determining the length of a string rathmore@tierceron.com
    Re: Determining the length of a string <jeffp@crusoe.net>
    Re: E-Commerce scripts <splezunk@usa.net>
    Re: File name with space in Net::FTP put (Charles DeRykus)
    Re: Finding maximum length (Richard J. Rauenzahn)
    Re: Finding maximum length greg_sands@my-deja.com
        Fun with SDL, OpenGl and Perl <thomas2@dalnet.se>
    Re: hash arrays... <lr@hpl.hp.com>
    Re: help in writing a card game <kelley.a.kent@intel.com>
    Re: help in writing a card game <yanick@babyl.sympatico.ca>
    Re: How to get parameters: cgi-bin/login.cgi?username=j xxaxx@my-deja.com
        inserting a long string into access w/perl <gorgano@altavista.com>
    Re: Is there a more elegant way? <rick.delaney@home.com>
    Re: min function (Craig Berry)
    Re: min function (Craig Berry)
        Need help with CGI re: FormMail.pl <hansson@uswest.net>
    Re: open serial port and specify baud rate in linux (David Efflandt)
        OpenGl module for Perl? <Rage@matrix13.freeserve.co.uk>
    Re: Perl script printing to MAIL header (Gwyn Judd)
    Re: Piping output on Win32 system <gondorff@shaws.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 13 Sep 2000 16:30:39 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: avoiding do {} while()
Message-Id: <MPG.1429adfe657d3cf298ad5b@nntp.hpl.hp.com>

In article <Pine.OSF.4.21.0009131116550.9558-100000@pearl.cs.sc.edu> on 
Wed, 13 Sep 2000 11:26:22 -0400, Gopi Sundaram <gopalan@cs.sc.edu> 
says...
> On Mon, 11 Sep 2000, Larry Rosler wrote:
> 
> >   my @try = my @sigs = </path/to/files/*>;
> >   my $found;
> >   1 while @try && ! -T ($found = splice @try, rand @try, 1);
> >   @try or die "All files tried!\n";
> >   ^^^^^^^^^^^
> > The name of the desired file is in $found.
> 
> Unfortunately, the last test you do is not correct. If $found was the
> last element of the array, @try would be empty, and the test would
> fail, whereas $found does indeed contain a correct value.

Alas.

> I changed it to
> 
> die "No valid files found!\n" unless defined $found && -T $found;
> 
> I added the defined so that even if the /path/to/files is empty, I
> won't get a warning about uninitialized values. I could of course
> remove it, and run without the -w flag.

Yuck.

Here's another approach, which relies on all entries in @try being TRUE 
because of the glob:

     1 while $found = splice @try, rand @try, 1 and ! -T $found;
     $found or die "All files tried!\n";

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 13 Sep 2000 22:23:04 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: convert date -> unixtime
Message-Id: <slrn8rvvhl.2cp.mgjv@verbruggen.comdyn.com.au>

On Wed, 13 Sep 2000 10:48:42 GMT,
	gumbygumbygumby@my-deja.com <gumbygumbygumby@my-deja.com> wrote:
> Hi, how do i do this conversion, is there some function i can use or do
> i have to code it myself?

When you put a question in the Subject: line of your post, you should
repeat it in the body as well. Make sure the body of your post is a
standalone piece of text.

What do you mean by date? A string? An array of values? a Julian day
(for various values of Julian)?

Learn about CPAN. Start at http://www.cpan.org/. Try
http://search.cpan.org/. If you're on Win, use ppm to install the
modules you find. If you're on Unix, use the CPAN module.

# perl -MCPAN -e shell
cpan> i /date/
[this gives a list that is too long to display here]

I suspect that you want to parse a string, and create something
numerical out of it (unixtime or whatever):

Two modules that I know of that do this:

Date::Parse
ParseDate

There are others, probably.

But you'll have to do some work yourself.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Failure is not an option. It comes
Commercial Dynamics Pty. Ltd.   | bundled with your Microsoft product.
NSW, Australia                  | 


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

Date: Wed, 13 Sep 2000 22:34:29 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: cross-platform archive mgt
Message-Id: <slrn8s0072.2cp.mgjv@verbruggen.comdyn.com.au>

[please, in the future, post your reply _after_ the suitably trimmed
text you reply to.]

On Tue, 12 Sep 2000 22:57:06 -0700,
	David P. Schwartz <davids@YYYYdesertigloo.com> wrote:

[reformatted]

> ps: as far as being an SAQ goes, consider this: most of the searches
> I've done for this using as many as eight keywords have been turning
> up over 10,000 hits.

Use a decent search engine. It really would help a lot if everyone
would stay away from altavista and such, or would only use it after
having read the help pages.

http://www.google.com/

'zip archive perl'

The first page of results contains many references to the module you
are looking for. Google always is this successful.

>                       I'm surprized to get zero hits with only two
> keywords on cpan, especially when both of them should score 100% on
> substring matches.  Here I posted one query, and I got one direct

That is surprising, but probably just because search.cpan isn't a free
text keywording thing. I am not sure how it's set up. I'm sure they'll
welcome volunteers that are willing to put some effort into making it
a better service.

>                     Here I posted one query, and I got one direct
> hit.

Maybe, but it's an expensive hit. Human interaction is always
expensive. That's why search engines exist. It really is important
that you learn to use them correctly. Not all search engines are
equal. Some work better with as few keywords as possible (especially
the very specialised ones), and some need loads of keywords, and they
still give lots of garbage.

The time of the people here would be much more sensibly spent on
discussing Perl issues, and maybe helping some people out with Perl
issues. A search engine that consists of linked human minds is just
too expensive. 

Another illustration:

# perl -MCPAN -e shell
cpan> i /zip/
[snip of very long list that _does_ contain what you want]
cpan i /archive/
Distribution    J/JP/JPETERSON/Apache-Archive-0.1.tar.gz
Distribution    N/NE/NEDKONZ/Archive-Zip-0.06.zip
Distribution    N/NE/NEDKONZ/Archive-Zip-0.10.tar.gz
Distribution    R/RB/RBOW/File-Archive-0.53.tar.gz
Distribution    S/SR/SRZ/Archive-Tar-0.22.tar.gz
Module          Apache::Archive
	(J/JP/JPETERSON/Apache-Archive-0.1.tar.gz)
Module          Archive::Tar    (S/SR/SRZ/Archive-Tar-0.22.tar.gz)
Module          Archive::Zip    (N/NE/NEDKONZ/Archive-Zip-0.10.tar.gz)
Module          Archive::Zip::BufferedFileHandle
	(N/NE/NEDKONZ/Archive-Zip-0.10.tar.gz)
Module          Archive::Zip::MockFileHandle
	(N/NE/NEDKONZ/Archive-Zip-0.10.tar.gz)
Module          BufferedFileHandle (N/NE/NEDKONZ/Archive-Zip-0.06.zip)
Module          File::Archive   (R/RB/RBOW/File-Archive-0.53.tar.gz)
Module          MockFileHandle  (N/NE/NEDKONZ/Archive-Zip-0.06.zip)
Module          VCS::PVCS::Archive (B/BM/BMIDD/VCS_PVCS-0.02.tar.gz)

[reformatted to fit line length]

[Snip of jeopardy quote]

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | That's funny, that plane's dustin'
Commercial Dynamics Pty. Ltd.   | crops where there ain't no crops.
NSW, Australia                  | 


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

Date: Wed, 13 Sep 2000 22:22:21 GMT
From: rathmore@tierceron.com
Subject: Determining the length of a string
Message-Id: <8poum6$p7c$1@nnrp1.deja.com>

$data = "This is my data";
$_ = $data;
$length = tr/a-zA-Z0-9 //;
print "The string $data has $count characters.";

Is there a better way to find the length of a string in Perl than the
above code? The above doesn't consider every possible character that
could be found so it isn't reliable.

Thanks!

*I hope this wasn't posted twice, I got an error the first time I tried
to post.
**I'm learning tin so I can stop using deja BTW...


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


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

Date: 13 Sep 2000 17:34:27 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Determining the length of a string
Message-Id: <87og1r7wgc.fsf@limey.hpcc.uh.edu>

>> On Wed, 13 Sep 2000 22:22:21 GMT,
>> rathmore@tierceron.com said:

> Is there a better way to find the length of a string in
                                    ^^^^^^
                                    The answer is rather
                                    obvious, isn't it? :-)

    perldoc -f length

hth
t
-- 
WWNKD?


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

Date: Wed, 13 Sep 2000 22:42:25 GMT
From: rathmore@tierceron.com
Subject: Re: Determining the length of a string
Message-Id: <8povsd$qkv$1@nnrp1.deja.com>

Where is the delete key?!....

Sorry folks, I found the answer and it was right under my nose. I'm
just stressing a bit because I'm coming up on my deadline and this is
my first ever programming project for work. I want to do a good job so
bad!

For those who don't know (like anyone doesn't!) here is the way to do
it:

$data = "This is my data";
$count = length($data);
print "The string $data has $count characters.";

Ignoramusly yours,
Rathmore


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


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

Date: Wed, 13 Sep 2000 19:33:41 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Determining the length of a string
Message-Id: <Pine.GSO.4.21.0009131933020.3023-100000@crusoe.crusoe.net>

On Sep 13, rathmore@tierceron.com said:

>$data = "This is my data";
>$_ = $data;
>$length = tr/a-zA-Z0-9 //;
>print "The string $data has $count characters.";

Obfuscation alert.

  y ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc;

-- 
Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/



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

Date: Thu, 14 Sep 2000 09:23:20 +1100
From: "Splezunk" <splezunk@usa.net>
Subject: Re: E-Commerce scripts
Message-Id: <39bffe4c@isupx1.isd.tafensw.edu.au>

I know that :)

I am a Data Warehouse Technician.  But in this particular instance, I am
only interested in a flat file solution.  It would be nice to set up an
Oracle Database that it connects to, but I am trying to get this thing set
up with as little cost as possible...  Once the Money starts pouring in, I
can look at more robust solutions that use Databases.

Cheers
Zunk

"Jevon MacDonald" <jevon@islandtelecom.com> wrote in message
news:bIKv5.8$JP6.7771@sapphire.mtt.net...
> > PS.  Flat file access is preferable over database access.
>
> No it's not.
>
>      :)
>
>         -Jevon
>
>




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

Date: Wed, 13 Sep 2000 23:09:53 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: File name with space in Net::FTP put
Message-Id: <G0uLoH.8J3@news.boeing.com>

In article <8podbk$33j$1@nnrp1.deja.com>,  <scarlzong@my-deja.com> wrote:
>Hi,
>
>a quick question concerning Nert::FTP.
>
>I have a script using ftp to transfer files but put("$file") does not
>work if the file name contains space. The remote computer is a RH6.2 so
>it does  support for example touch "qa dd", but $ftp->put("qa dd") does
>not work. Any ideas anyone ?
>

Did you add debug, i.e. Net::FTP->new("somehost...", Debug=>1)

hth,
--
Charles DeRykus


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

Date: 13 Sep 2000 22:23:53 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: Finding maximum length
Message-Id: <968883832.387329@hpvablab.cup.hp.com>


Ren Maddox <ren.maddox@tivoli.com> writes:
>Not surprisingly, the straight-forward for loop is the fastest and the
>sort is the slowest.  That the XOR is faster than the MAP is a bit
>surprising.

I becoming fond of List::Util:

$maxlen = length List::Util::reduce { length $a > length $b ? $a : $b} @array

44:7:$maxlen=(sort{$a<=>$b}map length,@array)[-1]
43:7:map{length>$maxlen and$maxlen=length}@array
42:7:length>$maxlen and$maxlen=length for@array
39:7:y///c>$maxlen and$maxlen=y///cfor@array
34:7:$m^="$_"for@array;$maxlen=length$m
33:7:$m^=$_ for@array;$maxlen=length$m
77:7:$maxlen = length List::Util::reduce { length $a > length $b ? $a : $b} @array
Benchmark:
timing 100000 iterations of
 $m^="$_"for@array;$maxlen=length$m, $m^=$_ for@array;$maxlen=length$m, $maxlen = length List::U
til::reduce { length $a > length $b ? $a : $b} @array, $maxlen=(sort{$a<=>$b}map length,@array)[
-1], length>$maxlen and$maxlen=length for@array, map{length>$maxlen and$maxlen=length}@array, y/
//c>$maxlen and$maxlen=y///cfor@array
 ...

$m^="$_"for@array;$maxlen=length$m:  
	2 wallclock secs ( 1.86 usr +  0.00 sys =  1.86 CPU)

$m^=$_ for@array;$maxlen=length$m:  
	2 wallclock secs ( 1.74 usr +  0.00 sys =  1.74 CPU)

$maxlen = length List::Util::reduce { length $a > length $b ? $a : $b} @array:  
	1 wallclock secs ( 1.28 usr +  0.00 sys =  1.28 CPU)

$maxlen=(sort{$a<=>$b}map length,@array)[-1]:  
	3 wallclock secs ( 2.72 usr +  0.00 sys =  2.72 C PU)

length>$maxlen and$maxlen=length for@array:  
	2 wallclock secs ( 1.26 usr +  0.00 sys =  1.26 CPU)

map{length>$maxlen and$maxlen=length}@array:  	
	3 wallclock secs ( 2.68 usr +  0.00 sys =  2.68 CPU)

y///c>$maxlen and$maxlen=y///cfor@array:  
	2 wallclock secs ( 2.35 usr +  0.00 sys =  2.35 CPU)



I suspect reduce is more efficient with larger sets of data.  I'll
change @array to be 1 ..  100.



Benchmark:
timing 100000 iterations of
 $m^="$_"for@array;$maxlen=length$m, $m^=$_ for@array;$maxlen=length$m, $maxlen = length List::U
til::reduce { length $a > length $b ? $a : $b} @array, $maxlen=(sort{$a<=>$b}map length,@array)[
-1], length>$maxlen and$maxlen=length for@array, map{length>$maxlen and$maxlen=length}@array, y/
//c>$maxlen and$maxlen=y///cfor@array
 ...

$m^="$_"for@array;$maxlen=length$m: 
	19 wallclock secs (18.58 usr +  0.00 sys = 18.58 CPU)

$m^=$_ for@array;$maxlen=length$m: 	
	17 wallclock secs (15.55 usr +  0.01 sys = 15.56 CPU)

$maxlen = length List::Util::reduce { length $a > length $b ? $a : $b} @array: 
	11 wallclock secs (11.29 usr +  0.01 sys = 11.30 CPU)

$maxlen=(sort{$a<=>$b}map length,@array)[-1]: 
	38 wallclock secs (36.98 usr +  0.00 sys = 36.98 CPU)

length>$maxlen and$maxlen=length for@array: 
	13 wallclock secs (12.66 usr +  0.00 sys = 12.66 CPU)

map{length>$maxlen and$maxlen=length}@array: 	
	46 wallclock secs (44.65 usr +  0.00 sys = 44.65 CPU)

y///c>$maxlen and$maxlen=y///cfor@array: 
	30 wallclock secs (29.67 usr +  0.00 sys = 29.67 CPU)



Reduce only *barely* squeaks by "length>$maxlen and$maxlen=length for@array"


[Ren's Benchmark Code:]

#!/usr/bin/perl -l
use Benchmark;
use List::Util;
@array=qw/one two 3 four fifteen 2000/;
for my $code (<DATA>) {
   my $maxlen;
   chomp $code;
   eval $code;
   print length $code, ":$maxlen:$code";
   $code{$code}=$code;
}
timethese 100_000, \%code;
__DATA__
$maxlen=(sort{$a<=>$b}map length,@array)[-1]
map{length>$maxlen and$maxlen=length}@array
length>$maxlen and$maxlen=length for@array
y///c>$maxlen and$maxlen=y///cfor@array
$m^="$_"for@array;$maxlen=length$m
$m^=$_ for@array;$maxlen=length$m
$maxlen = length List::Util::reduce { length $a > length $b ? $a : $b} @array
-- 
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant     | I speak for me,     |   19055 Pruneridge Ave. 
Development Alliances Lab|            *not* HP |                MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014


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

Date: Thu, 14 Sep 2000 00:30:32 GMT
From: greg_sands@my-deja.com
Subject: Re: Finding maximum length
Message-Id: <8pp679$1sq$1@nnrp1.deja.com>

In article <5TEv5.3168$O5.63702@news.itd.umich.edu>,
  mcafee@waits.facilities.med.umich.edu (Sean McAfee) wrote:
> In article <8pmkss$1it$1@nnrp1.deja.com>,  <greg_sands@my-deja.com>
wrote:
> >I'm trying to find the maximum length of the elements of an array.
>
> Here's an idiom I like:
>
> sub maximum (&@) {
>     my $sub = shift;
>     my ($max, $value);
>     foreach (@_) {
>         $value = $sub->();
>         !defined $max || $max < $value and $max = $value;
>     }
>     $max;
> }
>
> my $maxlen = maximum { length } @array;

Thanks Sean, this looks exactly like what I was looking for.

Greg


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


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

Date: Wed, 13 Sep 2000 23:29:25 GMT
From: "Thomas Åhlen" <thomas2@dalnet.se>
Subject: Fun with SDL, OpenGl and Perl
Message-Id: <p5Uv5.371$pz5.235498@news.bahnhof.se>

You should check this page out!
There are both screenshots and source.

You can do much fun with perl..:)

http://www.metaverse.fsnet.co.uk/sdlpl/

Thomas Åhlen


Rage Matrix <Rage@matrix13.freeserve.co.uk> skrev i
diskussionsgruppsmeddelandet:8pp0mu$os1$1@newsg4.svr.pol.co.uk...
> Hi all,
>
> I recently downloaded and installed an OpenGL module for Perl. Has anyone
> used this module in Perl and what did you think? What is performance and
> functionality like? I don't intend to use this module for anything in
> particular, but I have a working knowledge of Perl and I am interested in
> OpenGL as a possible game development option. As I was searching the net
for
> information on OpenGL, I found this module so I downloaded and installed
it
> just for kicks.
>
> Any experiences?
>
> Jon.
>
> --
> Jonathan M Baker
> Software Engineer, Semantico Ltd.
> Tron Software: http://www.tronsoftware.freewire.co.uk
> -=The views expressed by me are not necessarily those of Semantico=-
>
>




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

Date: Wed, 13 Sep 2000 16:50:27 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: hash arrays...
Message-Id: <MPG.1429b2a2a09e74bb98ad5c@nntp.hpl.hp.com>

[Removed alt.perl.]

In article <slrn8rthn0.id4.tjla@thislove.dyndns.org> on Wed, 13 Sep 2000 
00:14:27 GMT, Gwyn Judd <tjla@guvfybir.qlaqaf.bet> says...
> I was shocked! How could Alvaro Bahamondes V. <alvaro@arbol-logika.com>
> say such a terrible thing:
> >Sorry I think I din't explain my problem well.
> >I will receive as a parameter a string containing pairs (key, data). I can
> >define
> >the format of the string so the format is not a problem. I would like
> >to put this string in a hash so I can access it easly. I did it with a split
> >and works, but, because this string can be large I'm worried about
> >the performance of the split function. My question if there are any
> 
> use Data::Dumper;
> $r="1, a,  2, b, 3, c";
> %t = eval $r;
> 
> print Dumper \%t;
> 
> Works for me
> 
> :)

I guess the smiley should be warning enough to the original poster (in 
addition to the other warnings caused by the barewords).  But as 
performance was specifically the issue, a benchmark would also help.

Benchmark: timing 16384 iterations of Eval, Split...
      Eval:  6 wallclock secs ( 5.72 usr +  0.00 sys =  5.72 CPU) @ 
2864.84/s (n=16384)
     Split:  1 wallclock secs ( 1.48 usr +  0.00 sys =  1.48 CPU) @ 
11040.43/s (n=16384)

#!/usr/local/bin/perl
use strict;
use Benchmark;

our $r = '1, a,  2, b, 3, c';

timethese( 1 << (shift || 0), {
    Eval  => 'my %t = eval $r',
    Split => 'my %t = split /\s*,\s*/ => $r',
} );

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 13 Sep 2000 14:59:52 -0700
From: "Kelley Kent" <kelley.a.kent@intel.com>
Subject: Re: help in writing a card game
Message-Id: <8potaf$i4n@news.or.intel.com>

Yanick Champoux wrote:

>> I just wanted to point out that there is a nifty module
>> called Games::Cards available on CPAN that does all the
>> boring stuff like shuffling cards, giving hands, shooting
>> the pesky cheaters with three aces in their sleeves.

Hmmm .... when I started off planning this out (if spur of
the moment can be considered planning!) I didn't even
consider that there was a Perl module available for such
a task. So I checked it out and looked over it and yeah, it
does look like it takes a lot of the "boring stuff" outta the
programmer's hand. And the TK module that comes with
it was a very nice surprise. But I'll tell you why I won't be
using them, even now (minus an occaisional glance for
those obligatory "So THAT'S how they did it" moments).

Here's my story (cue the violins). I've been programming
in Perl for about 4 years now. And the only thing I seem to
know about the language is the basic syntax. For all my work-
related projects, that was sufficient. And I never really took the
time to expand my Perl skills and knowledge beyond that. I
mean, I still need to reference the camel book when parsing
through multidimensional hashes:

     foreach $level1 ( keys %hash ) {
          # It's the next line that gets me all the time
          foreach $level2 ( keys %{ $hash{$level1}} )  {
          ...

And I find that kinda sad really (I even had to look it up in order
to include it here in the email!).

So I was looking at this Spades game that I'm trying to
develop as a chance to start actually learning all those little
Perl nuances and work through some tougher issues than
my usual CGI scripting and database management give me.

And in just writing the "boring stuff" (or at least what I have
so far) I've learned some things. Mainly about references,
again something I've never programmed with in Perl.

In closing this somewhat off-topic pointless post, let me just
say thanx for the response Yanick and for the point to the
information. It's always nice when newsgroup subscribers can
provide answers rather than attitude. :-) But this newsgroup is
usually excellent about that, so that's not a slam on anyone,
especially not anyone in this thread.

--Kelley




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

Date: Wed, 13 Sep 2000 23:32:46 GMT
From: Yanick Champoux <yanick@babyl.sympatico.ca>
Subject: Re: help in writing a card game
Message-Id: <y8Uv5.12376$Kp4.438318@news20.bellglobal.com>

Kelley Kent <kelley.a.kent@intel.com> wrote:

<snip>

: Here's my story (cue the violins). 

	*grab popcorn and snuggle in warm blanket, all ears*

<snip story of courage, betrayals, love, hate, redemption 
and the bond between a man and his code>

: And in just writing the "boring stuff" (or at least what I have
: so far) I've learned some things. Mainly about references,
: again something I've never programmed with in Perl.

	*wipe tears away from eyes* 

	That was beautiful. 8)

So, basically, you are not travelling to point B for the sake
of arriving to point B, but for the mountains, valleys and
other lanscapities you will find on your way, thus making my
observation that there is a airplane company selling dirt cheap
tickets for said point B rather pointless. Well, I can live 
with that. :) 

: In closing this somewhat off-topic pointless post, let me just
: say thanx for the response Yanick and for the point to the
: information. 

	My pleasure. 

Joy,
Yanick (who will stop before someone notice that
        this is offtopic, and smell of warmth and
		fuzziness..)

-- 
eval $problem."
require 'yet another Perl hacker' " unless $trivial;
callsys; # surely the sys-admin knows Perl
wait; wait; wait; # why doesn't he answer?
listen PHONE, 0;$@=~s/^.*?(y.*?)in.*$/\u$1/; # argh! line noise!
warn $whine and $curse => "$@$;@_"; # All right! Plan B, then! 
use CPAN;


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

Date: Wed, 13 Sep 2000 22:05:46 GMT
From: xxaxx@my-deja.com
Subject: Re: How to get parameters: cgi-bin/login.cgi?username=john&password=doe
Message-Id: <8potna$o4u$1@nnrp1.deja.com>

In article <39BFF0EA.F3A8AC5F@acsoft.dk>,
  Steen Angelo <angelo@acsoft.dk> wrote:
> 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
>

To grab incoming data use:
$forminfo = $ENV{'QUERY_STRING'};

If you want to test for GET method vs. POST method you can use:
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
	$forminfo = $ENV{'QUERY_STRING'};
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
	$forminfo = <STDIN>;
}

Any info coming in this way will be encoded.
But you'll see that when you try to work with it.

Claude
p.s. Or use the CGI module.



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


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

Date: Wed, 13 Sep 2000 23:28:19 GMT
From: Jason Hurst <gorgano@altavista.com>
Subject: inserting a long string into access w/perl
Message-Id: <8pp2ht$tpu$1@nnrp1.deja.com>

I'm trying to input a large amount of data from a cgi program into a
memo field in an access database.  But when i try to do it i get the
following error:

Error occured: [Microsoft][ODBC Microsoft Access Driver]Invalid
precision value (SQL-S1104)(DBD: _rebind_ph/SQLBindParameter err=-1)

Now, when i take some of the info out (making the data amount smaller)
it inserts just fine.  So i'm guessing that i'm trying to insert just a
little to much.  I know you can do  $dbh->{LongReadLen}=19999; when
your reading a large amount of data, but is there something you need to
do for INSERTING a large amount of data?  I looked in the manuals but i
couldn't find anything.  If someone could point me in the right
direction it would be greatly appreciated.  Thanks for the help in
advance.

Note that I am not trying to insert more data than the database can
handle because I can insert the data manually into access with no
problems.

-jason


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


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

Date: Thu, 14 Sep 2000 00:16:05 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Is there a more elegant way?
Message-Id: <39C01B52.47C1BB5@home.com>

[posted & mailed]

Sean McAfee wrote:
> 
> sub myfunc {
>     my ($arg1, $arg2) = @_;
>         my ($usetarget, $target) = (@_ >= 3, \$_[2]);
>     local *_;
>     *_ = $target if $usetarget;
>     $_ = get_data($arg1, $arg2);

Not a huge improvement, but it seems a little cleaner to me:

        my $usetarget = @_ >= 3;
        local $_;
        *_ = \($_[2] = get_data($arg1, $arg2) );

>     otherfunc();
>     return if $usetarget;
>     return $_;
> }


-- 
Rick Delaney
rick.delaney@home.com


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

Date: Wed, 13 Sep 2000 22:44:35 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: min function
Message-Id: <ss00qjikct6139@corp.supernews.com>

brian d foy (brian@smithrenaud.com) wrote:
: > 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.

Of course; it's just that doing that takes an O(N) task and turns it into
O(N log N) or worse.  And again, parsimony arguments about Perl almost
make me laugh.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Every force evolves a form."
   |              - Shriekback


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

Date: Wed, 13 Sep 2000 22:46:46 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: min function
Message-Id: <ss00um1kct6133@corp.supernews.com>

Chris Fedde (chris@fedde.littleton.co.us) wrote:
: 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;
[snip]

That's great!  If this were a democracy, I'd vote for it. :)

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Every force evolves a form."
   |              - Shriekback


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

Date: Wed, 13 Sep 2000 18:06:29 -0700
From: "Theodore Hansson" <hansson@uswest.net>
Subject: Need help with CGI re: FormMail.pl
Message-Id: <TtVv5.98$e96.7418@news.direcpc.com>

Hi you CGI experts,

I just installed Groundbreak.com affiliate tracker. But here's a
problem we are not able to solve, so far, even with Groundbreak's
help.

Here's the problem:

My order form: https://id56.securedata.net/thansson/ordersecure.htm as
well as my Thank You page:
https://id56.securedata.net/thansson/thanksorder.htm and my Error
page: https://id56.securedata.net/thansson/error.htm all reside on the
secure server with the same host.

The tracking files all reside in the cgi-bin folder (not on the
https - secure site).

However, in order for the sale to be recorded by the affiliate
tracking program that resides in the cgi-bin it needs to go to the
cgi-bin (non-secure) right after the purchaser hits the "order" button
and immediately after that it will be re-directed to the "thank you"
(secure) page.

However when the "order" button is pressed, the warning message comes
up "that the visitor is about to leave the secure site". (because the
tracking that resides on the "non-https" cgi-bin site.

How do I get around this problem?

My thinking - "How about if it writes to a file on the secure server,
and then after the customer has gotten the "Thank You" page and leaves
my secure site - then it will update to the sale.cgi."???

Thanks for any help you can give me.

Theodore






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

Date: Thu, 14 Sep 2000 00:11:48 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: open serial port and specify baud rate in linux
Message-Id: <slrn8s05tl.pji.efflandt@efflandt.xnet.com>

On Wed, 13 Sep 2000, Tony Schliesser <aschlies@citynet.net> wrote:
>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.

Device::SerialPort which is a Unix port (developed in Linux) of
Win32::SerialPort

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



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

Date: Thu, 14 Sep 2000 00:01:47 +0100
From: "Rage Matrix" <Rage@matrix13.freeserve.co.uk>
Subject: OpenGl module for Perl?
Message-Id: <8pp0mu$os1$1@newsg4.svr.pol.co.uk>

Hi all,

I recently downloaded and installed an OpenGL module for Perl. Has anyone
used this module in Perl and what did you think? What is performance and
functionality like? I don't intend to use this module for anything in
particular, but I have a working knowledge of Perl and I am interested in
OpenGL as a possible game development option. As I was searching the net for
information on OpenGL, I found this module so I downloaded and installed it
just for kicks.

Any experiences?

Jon.

--
Jonathan M Baker
Software Engineer, Semantico Ltd.
Tron Software: http://www.tronsoftware.freewire.co.uk
-=The views expressed by me are not necessarily those of Semantico=-




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

Date: Thu, 14 Sep 2000 01:00:01 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Perl script printing to MAIL header
Message-Id: <slrn8s08oe.727.tjla@thislove.dyndns.org>

I was shocked! How could Eirik Johansen [netmaking.com] <eirik@netmaking.com>
say such a terrible thing:
>Hi Gwyn,
>
>
>> >I was wondering if it's possible to print to the MAIL header when
>> >sending a MAIL through a Perl script. If it is, how do  I access
>> >the mail header? (I want to append a content-type and
>> >mime-version line).
>>
>> Well there are many ways of sending mail with Perl. How are you doing
>> it?
>
>By using sendmail. Do you need any other information?


slove:~]$ /usr/lib/sendmail -t  
To: gwyn
From: noone
So: why are you reading this

blah
 .

Does that help? If not then maybe you should post some code.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
But we can both blame it all on Henry.
             -- Larry Wall on perl's regex engine


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

Date: Wed, 13 Sep 2000 22:45:25 GMT
From: Henry Gondorff <gondorff@shaws.com>
Subject: Re: Piping output on Win32 system
Message-Id: <nj00ss8udfk0o6r99asg7bqq8rcqacedgb@4ax.com>

Make sure $cmd is writing to STDOUT and not STDERR.  I notice that
your sh command pipes both STDOUT and STDERR to the log
(note the 2>&1 that redirects STDERR to point to STDOUT).

DTD

On Mon, 11 Sep 2000 23:57:38 GMT, eedlin@my-deja.com wrote:

>Hello All,
>
>I'm sure someone has done this before, but I can't seem to find or do
>exactly what I need.
>
>I'm porting some Unix sh scripts to perl on a PC (Oh what FUN!).
>
>I have the following code (sh)
>
>($cmd $args 2>&1) |\
>sh -c "while read line; do echo \"\$line\" >> $log;done" &
>Now $cmd is a binary (daemon) that continues to spew stuff to STDOUT.
>Piping it into the subshell and then into the log file allows users to
>cycle logs and keep the output going to $log instead of the old file
>descriptor which used to be $log, but is now named something different
>(ie $log.Sep2000).
>
>On top of doing this I also need to run it in the background.
>
>I tried using Win32::Process, but I'm guessing that it does not support
>piping.  I tried this :
>
>        my $cmd_object;
>        Win32::Process::Create($cmd_object,
>                "$binDir\\${cmd}.exe",
>                "$cmd $args | cmd_log_router $logFile",
>                0,
>                "NORMAL_PRIORITY_CLASS",
>                ".") or die ErrorReport();
>
>cmd_log_router is a simple perl scripts which takes in STDIN and prints
>it in the passed in file ($logFile in this case).
>
>When I run it this way, the cmd is executed and is running in the
>background, but the output is not being piped to cmd_log_router.  It is
>being spewed to the console and the log is never created.
>
>Anyone have an idea or two?  These types of problems keep making my list
>of reasons to blow up all of our PCs even longer!
>
>Thanks,
>
>Eric
>
>
>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 4317
**************************************


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