[21883] in Perl-Users-Digest
Perl-Users Digest, Issue: 4087 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 8 18:06:48 2002
Date: Fri, 8 Nov 2002 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 8 Nov 2002 Volume: 10 Number: 4087
Today's topics:
Re: A vision for Parrot <goldbb2@earthlink.net>
Re: A vision for Parrot <usenet@dwall.fastmail.fm>
Re: GUI with Perl ?? <ronwolf@screwthebots.com>
Re: GUI with Perl ?? <jds@trumpetweb.co.uk>
Re: GUI with Perl ?? <tk@WINDOZEdigiserv.net>
Re: GUI with Perl ?? <lusol@Pandora.cc.lehigh.edu>
Re: GUI with Perl ?? <ronwolf@screwthebots.com>
Re: Image::Magick (Bill Wheaton)
Re: listing values <goldbb2@earthlink.net>
Re: Memory Usage When Reading Large (non crlf) Files <nobull@mail.com>
Name, value <todd@mrnoitall.com>
Re: Name, value <pinyaj@rpi.edu>
Re: Name, value <kurzhalsflasche@netscape.net>
Re: Name, value (Walter Roberson)
Pause in perl ??? <mail@eircom.net>
Re: perl array into sql database (Adam Hapworth)
Re: perl array into sql database <goldbb2@earthlink.net>
Re: perl ldap and MS-Active Directory or Netmeeting <Rainer.Scherg@t-online.de>
problems with DB_File password database (Ron)
using perl package mananger on win2000 (eddie wang)
Re: using perl package mananger on win2000 <usenet@dwall.fastmail.fm>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 08 Nov 2002 16:13:14 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: A vision for Parrot
Message-Id: <3DCC28EA.24547F4E@earthlink.net>
David K. Wall wrote:
>
> Benjamin Goldberg <goldbb2@earthlink.net> wrote on 08 Nov 2002:
>
> [lots of technical stuff]
>
> Ack. My brain hurts. Make it stop....
Erm, sorry... which particular part hurt? :)
Or was it Walter Robinson's stuff that I quoted that hurt?
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Fri, 08 Nov 2002 22:09:08 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: A vision for Parrot
Message-Id: <Xns92C0AE7B3387Ddkwwashere@216.168.3.30>
Benjamin Goldberg <goldbb2@earthlink.net> wrote on 08 Nov 2002:
> David K. Wall wrote:
>>
>> Benjamin Goldberg <goldbb2@earthlink.net> wrote on 08 Nov 2002:
>>
>> [lots of technical stuff]
>>
>> Ack. My brain hurts. Make it stop....
>
> Erm, sorry... which particular part hurt? :)
>
> Or was it Walter Robinson's stuff that I quoted that hurt?
Just an attempt at humor. Since I was never a CS major, I lack the background
for much of this (still interesting) thread.
There's one segment of the Quake2 game where there are some prisoners being
tortured in gore-encrusted cells. The sound effects for that area include
them saying such things as "It hurts" and "Make it stop" in pain-wracked
voices. For some reason that popped into my head....
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: Fri, 08 Nov 2002 20:16:44 GMT
From: ronwolf <ronwolf@screwthebots.com>
Subject: Re: GUI with Perl ??
Message-Id: <3u6osuc76eoitc3doe0p6f0679n061nb87@4ax.com>
On Fri, 08 Nov 2002 18:57:22 GMT, tk <tk@WINDOZEdigiserv.net> wrote:
>In a fit of excitement on Fri, 8 Nov 2002 18:47:41 -0800, "Linux.ie"
><mail@eircom.net> managed to scribble:
>
>| Is it possilbe to make GUI with perl on win98 ??
>|
>
>If you've installed ActiveState Perl then it should already come with Tk
>installed as a module.
>
>Google'll help ya find out the syntax for Perl->Tk.
>
>
>Regards,
>
> tk
Is there alot of difference in coding with perl/tk and using win32:gui
(I realize that tk is platform independent.) I was wondering if I
could learn tk for use on linux, and then easily switch to win32:gui
module if I wanted to code for windows machines, or if that's a whole
difference system.
I'm just a beginner, if you couldn't already tell :)
Thanks,
ronwolf
------------------------------
Date: Fri, 8 Nov 2002 20:36:22 -0000
From: "Julia deSilva" <jds@trumpetweb.co.uk>
Subject: Re: GUI with Perl ??
Message-Id: <ndVy9.8741$8P5.8443@news-binary.blueyonder.co.uk>
> Is there alot of difference in coding with perl/tk and using win32:gui
> (I realize that tk is platform independent.) I was wondering if I
> could learn tk for use on linux, and then easily switch to win32:gui
> module if I wanted to code for windows machines, or if that's a whole
> difference system.
>
> I'm just a beginner, if you couldn't already tell :)
>
> Thanks,
>
> ronwolf
stick with something like Delphi. I think it's even open source now.
You won't regret it ! Rapid Application Development !!
------------------------------
Date: Fri, 08 Nov 2002 20:51:16 GMT
From: tk <tk@WINDOZEdigiserv.net>
Subject: Re: GUI with Perl ??
Message-Id: <6o8osu0s6hc51v415a4eg14t7vg6d78jqj@4ax.com>
In a fit of excitement on Fri, 08 Nov 2002 20:16:44 GMT, ronwolf
<ronwolf@screwthebots.com> managed to scribble:
[snip]
| Is there alot of difference in coding with perl/tk and using win32:gui
| (I realize that tk is platform independent.) I was wondering if I
| could learn tk for use on linux, and then easily switch to win32:gui
| module if I wanted to code for windows machines, or if that's a whole
| difference system.
Tbh, I've never looked at win32::gui.
I messed with some Perl->Gtk on FreeBSD a while back, but didn't do a
great deal, and within the last 2 weeks tried Perl-Tk under NT5. As far
as I'm aware, as Tk is non platform specific as you state, is there any
reason why you'd need to use win32::gui for windoze development?
Couldn't you possibly use Tk on windoze too? making your development a
lot easier for cross-platform scripts.
I don't know as to what you're doing, so excuse the questioning if
there's obvious answers.
|
| I'm just a beginner, if you couldn't already tell :)
Join the club.. I'm far from a pro meself.. more of a hobby and ya gotta
love its flexability =)
Regards,
tk
--
+--------------------------+
| digiServ Network |
| Web solutions |
| http://www.digiserv.net/ |
+--------------------------+
Remove WINDOZE to reply
------------------------------
Date: 8 Nov 2002 20:48:20 GMT
From: "Stephen O. Lidie" <lusol@Pandora.cc.lehigh.edu>
Subject: Re: GUI with Perl ??
Message-Id: <aqh7uk$i62@fidoii.CC.Lehigh.EDU>
ronwolf <ronwolf@screwthebots.com> wrote:
> On Fri, 08 Nov 2002 18:57:22 GMT, tk <tk@WINDOZEdigiserv.net> wrote:
>>In a fit of excitement on Fri, 8 Nov 2002 18:47:41 -0800, "Linux.ie"
>><mail@eircom.net> managed to scribble:
>>
>>| Is it possilbe to make GUI with perl on win98 ??
>>|
>>
>>If you've installed ActiveState Perl then it should already come with Tk
>>installed as a module.
>>
>>Google'll help ya find out the syntax for Perl->Tk.
>>
>>
>>Regards,
>>
>> tk
> Is there alot of difference in coding with perl/tk and using win32:gui
> (I realize that tk is platform independent.) I was wondering if I
> could learn tk for use on linux, and then easily switch to win32:gui
> module if I wanted to code for windows machines, or if that's a whole
> difference system.
> I'm just a beginner, if you couldn't already tell :)
Try Perl/Tk on Linux. Take the same code and try it under Win32.
You'll note that it looks more like a Windows application. Then see
if you want to try another toolkit ...
Steve
--
@_=map{eval"100${_}"}split/!/,'/5!*2!+$]!/10+$]';use Tk;$m=tkinit;$t='just an'.
'other perl hacker';$z='createText';$c=$m->Canvas(-wi,$_[1],-he,25)->grid;$c->$
z(@_[2,3],-te,$t,-fi,'gray50');$c->$z($_[2]-$],$_[3]-$],-te,$t);$m->bind('<En'.
'ter>',sub{$y=int(rand($m->screenheight));$m->geometry("+$y+$y")});MainLoop;
------------------------------
Date: Fri, 08 Nov 2002 22:32:37 GMT
From: ronwolf <ronwolf@screwthebots.com>
Subject: Re: GUI with Perl ??
Message-Id: <ioeosusmr5p07fvlkldmkaverbhpjsou66@4ax.com>
On Fri, 08 Nov 2002 20:51:16 GMT, tk <tk@WINDOZEdigiserv.net> wrote:
>In a fit of excitement on Fri, 08 Nov 2002 20:16:44 GMT, ronwolf
><ronwolf@screwthebots.com> managed to scribble:
>
>[snip]
>
>| Is there alot of difference in coding with perl/tk and using win32:gui
>| (I realize that tk is platform independent.) I was wondering if I
>| could learn tk for use on linux, and then easily switch to win32:gui
>| module if I wanted to code for windows machines, or if that's a whole
>| difference system.
>
>Tbh, I've never looked at win32::gui.
>
>I messed with some Perl->Gtk on FreeBSD a while back, but didn't do a
>great deal, and within the last 2 weeks tried Perl-Tk under NT5. As far
>as I'm aware, as Tk is non platform specific as you state, is there any
>reason why you'd need to use win32::gui for windoze development?
>Couldn't you possibly use Tk on windoze too? making your development a
>lot easier for cross-platform scripts.
>
>I don't know as to what you're doing, so excuse the questioning if
>there's obvious answers.
>
>
>|
>| I'm just a beginner, if you couldn't already tell :)
>
>Join the club.. I'm far from a pro meself.. more of a hobby and ya gotta
>love its flexability =)
>
>
>Regards,
>
> tk
Appreciate all your comments. I guess I was wondering (i'll try and
explain this without knowing exactly what I'm talking about, btw) if
the calls to the tk module would work with the win32:gui module, or if
the syntax and usage was totally different.
And the reason I ask was because it's my understanding that the
perl/tk scripts look like x-windows, while the win32:gui scripts look
like any other windows app.
Also, if you have any comments on how to compile gui scripts for
stand-alone execution (so no perl installation required) on linux and
windows I'd appreciate it. perlcc, perl2exe, perlapp... lots of
opinions, most contradictory :)
thanks for all the help,
ronwolf
------------------------------
Date: 8 Nov 2002 14:27:54 -0800
From: billwheaton@mindspring.com (Bill Wheaton)
Subject: Re: Image::Magick
Message-Id: <b8871133.0211081427.13aa5397@posting.google.com>
w i l l <willis3140@_no_YAHOO_spam.com> wrote in message news:<r5gnsu4v1lual8r7jh3frudqvobha2hmp6@4ax.com>...
> Could some one show me an example of how to retreive and uploaded
> image via CGI and then resize it so that the width is always 94px with
> Image::Magick?
>
> Thanks,
> W i l l
Bear in mind, that I use Apache/mod_perl, but the idea is here, and
I've anotated the important parts further down.
Here's a little mod_perl module and how I do it.
I've got similar ones for css and js files that need to be
modified on the fly.
If anyone thinks I should release this on CPAN, let me know. NNW:: is
just my name for it, 'NeasesNeedlework' my wife's shop.
package NNW::Image_server;
use strict;
use Apache;
use Apache::Constants qw(:common BAD_REQUEST);
use File::Path;
use File::Basename;
use IO::File;
use DBI;
use Image::Magick;
#use Data::Dumper;
# I begin by declaring a db handle and a statement handle
# that are global and created when the module loads and stay
# resident until the Apache server dies. I can't use Apache::DBI
# because I'm on NT, not unix, so there are better ways.
#
use vars qw( $dbh $sth );
BEGIN{
$dbh = DBI->connect("DBI:mysql:database=thedatabase:thehost","theuser","thepassword")
|| die "can't connect";
$sth = $dbh->prepare("select image from ? where product_id = ?");
}
# Here is the handler that gets executed any time some <img> tags
source points
# to the dimage directory (d for dynamic. its a database of products
# with one image blob field. Aside from the product in the src
attribute
# the tag, there is also the size. Its part of the pathinfo after
p_image
# for example, a src of:
# /dimages/cs/80/sene_2a98.gif
# would mean 'show me the image as a gif from the cross_stitch table,
# record sene_2a98, but resize it to 80px wide first'.
#
# Also, there is a caching mechanizm here that after imagemagick
creates it, and stuffs
# it into a cache directory, the subsequent requests for it use
# the cached image instead of going to the hassle of doing a db query
# and resizing it all over again.... I've got lots of space, ymmv.
#
sub handler{
my $r = shift;
my $uri = $r->uri;
my ($category, $width, $product_id, $ext, $table_name);
# get rid of the leading /
#$r->log_error("uri: $uri");
# these are a couple of mod_perl things.
# mod_perl is fantastic, I'll never go back to CGI.pm
return BAD_REQUEST if($uri !~ m:^/: or index($uri, '*')>-1);
return DECLINED unless ($uri =~ m:^/dimages/(.*)$:);
# now, parse the pathinfo part after /dimages/
$uri = $1;
if ($uri =~ m:^(.*)/(.*)/(.*)\.(.*)$:){
$category = $1;
$width = $2;
$product_id = $3;
$ext = $4;
}elsif ($uri =~ m:^(.*)/(.*)\.(.*)$:){
$category = $1;
$product_id = $2;
$ext = $3;
}
#$r->log_error( "category: $category, width: $width product_id:
$product_id, ext: $ext");
# check to see if it already exists in cache
$uri = "/images/cache/$product_id" . ($width ? ".$width":'' ) .
".$ext";
my $subr = $r->lookup_uri($uri); # that's $subr as in
subrequest, not subroutine...
my $filename = $subr->filename;
unless(-s $filename) {
# nope, not in cache.
if ($width && $width =~ /^(\d{1,3})$/){
if($width<=1000){
$width = $1;
}else{
$width = '';
}
}elsif($width){
#$r->log_error( 'wrong width' );
return _sorry(80); #_sorry is a routine which returns the
'sorry, image not found' png
}
if ($category =~ /cs/){
$table_name = 'cross_stitch_products';
} # elsif ( some other one later on){ make up a table_name}
else{
# hacker attempt to access non-existant table
#$r->log_error( 'wrong category' );
return _sorry($width);
}
# do some checking on the product id. I goofed and have
several valid ways
# oh well.
if ($product_id =~ /^(\w{1,4}\-[\w|\d]+)$/){
$product_id = $1;
}elsif ($product_id =~ /^(\d{4,10})$/){
$product_id = $1;
}else{
#$r->log_error( 'wrong product_id' );
return _sorry($width);
}
# check the extention. I allow gif, jpg, and png files
if ($ext =~ /^(gif|jpg|png)$/i){
$ext = $1;
}else{
#$r->log_error( 'wrong ext' );
return _sorry($width);
}
# get ready, this is simply an SQL select statement that gets
the image
my $st = "select image from $table_name where product_id =
'$product_id'";
#$r->log_error($st);
# get set,
$sth = $dbh->prepare($st);
# go! fetch that sucker
$sth->execute();
# more error checking should be done, but at this point i'm
too tired
my $image_data = $sth->fetchrow_arrayref();
# done with mysql
$sth->finish();
# so, the question is, did we get an image?
unless ( defined $image_data->[0] ){
# nope, return the sorry image, of the width asked for
return _sorry($width);
}else{
# yup, we got an image.
# and this is probably the the part that will be most important
# to you.
#$r->log_error("new image cached");
$r->uri("/images/cache/$product_id" . ($width ?
".$width":'' ) . ".$ext");
mkpath dirname($r->filename); # create the intermediate
directory if it doesn't exist
# make the image magic object
# call the BlobToImage method (because a blob is what I get from my
db. You however
# will probably just want to load the image from disc as it has been
uploaded
# or some such.) Either way, the $image object now has an image in
it.
# Next, resize it to the desired width. I pass my desired width in on
the uri,
# you may have a fixed width constant or somesuch.
# Next, I write it out to the cache directory for next time.
# Finally, I return DECLINED, another mod_perl trick.
# Notice that you never see me print any image headers, or any of that
other crap
# you see people do. That is because, Apache does images all by its
little lonesome.
# you tell it where the image is (and we know now, because we just
cashed it),
# and the server serves it up fresh, with no more smell than
# a bisquit fresh out of the oven.
# Check my final note at the end of this module
my $image = Image::Magick->new();
$image->BlobToImage(@$image_data);
$image->Resize(geometry=>"$width") if ($width);
#$r->log_error("going to write image: " .
$r->document_root . "/images/cache/$product_id" . ($width ?
".$width":'' ) . ".$ext");
my $x = $image->Write($r->document_root .
"/images/cache/$product_id" . ($width ? ".$width":'' ) . ".$ext");
#$r->log_error($x) if $x;
return DECLINED;
}
}
#$r->log_error("using cached image");
$r->uri($uri);
return DECLINED;
}
# This is what you get when the server doesn't have the requested
image
#
sub _sorry{
my $width = shift;
my $r = Apache->request;
my $subr = $r->lookup_uri("/images/cache/sorry$width.png");
my $filename = $subr->filename;
unless (-s $filename){
my $sorryout = Image::Magick->new();
#$r->log_error("reading " . $r->document_root .
"/images/sorry.png");
my $x = $sorryout->Read($r->document_root .
"/images/sorry.png");
#$r->log_error($x) if $x;
$sorryout->Resize(geometry=>"$width");
my $sorrywords = Image::Magick->new();
$sorrywords->Read($r->document_root .
"/images/sorrywords.png");
$sorryout->Composite(image=>$sorrywords,gravity=>"Center");
#$r->log_error("writing " . $r->document_root .
"/images/cache/sorry$width.png");
$x = $sorryout->Write($r->document_root .
"/images/cache/sorry$width.png");
#$r->log_error($x) if $x;
}
$r->uri("/images/cache/sorry$width.png");
return DECLINED;
}
1;
And the above line is the end of the module.
Now here is what you need in
httpd.conf:
PerlTransHandler NNW::Image_server
That's it.
Now, everytime any request comes in, it is checked to see if it begins
with
/dimages/xxxxxsomething
If not, then nothing is done.
But if it is, then we do the above junk to create an newly cached
image of the right size,
and Translate the requested url to the cached one under /images/cache,
and return DECLINED.
Right after the mod_perl Translation phase is done, the regular phase
is run, and since there is
no PerlHandler for anything in the images dir, it just tries to
handle it normally. Since the file ends in '.gif' and it really is a
gif, then Apache handles it like it would any .gif, which by default
in Apache is what you would expect, a pretty picture in a web browser.
Done,
Hope this helps.
As I said at the top, the database handle and statement handle are
created only once. Next time
a request comes in for something that hasn't been cached yet, it will
be quicker, because
there won't be any overhead in creating them, they will just be
re-used. You really should use Apache::DBI, but that is totally
screwed because it uses PerlChildInitHandlers which are not supported
in WinNT, which is yet another reason I can't wait for Perl 5.8.1
multithreading, and mod_perl 2 and Apache support of it. Then I could
actually (gods forbid) serve more than one customer at a time.
-Bill Wheaton
------------------------------
Date: Fri, 08 Nov 2002 16:21:41 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: listing values
Message-Id: <3DCC2AE5.BFC2389@earthlink.net>
Jerry Preston wrote:
>
> Hi!,
>
> I am trying to look at all of the variables by name with their value.
> I can list the value, but not the name.
>
> foreach $is ($query->param) {
The $is variable get aliased to each name in turn.
> print "* value is *$is* $%query->param( $key )*<BR>";
This gets compiled to something like:
print '* value is *' .
$is .
'* $%query->param( ' .
$key .
' )*<BR>";
What is $key, and where do you fetch the values of the params?
> }
>
> How do I list the names?
print "The names of the data fields are: <br>\n";
print "<TT>", join(" ", $query->param), "</TT>\n"
To get the values, too, write:
print "The names and values of the data fields are: <br>\n";
print "<TABLE COLS=2>\n";
print "<TR><TD>$_</TD><TD>", $query->param($_), "</TD></TR>\n"
foreach $query->param;
print "</TABLE>\n";
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: 08 Nov 2002 19:30:45 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Memory Usage When Reading Large (non crlf) Files
Message-Id: <u93cqb5062.fsf@wcl-l.bham.ac.uk>
fw58959@hotmail.com (CK) writes:
> for (1..$count) { # decode each subrecord and print it to another
How big is $count? It it is big then consider: Does the version of
Perl you are using postdate the version where that is optomized? ( I
can't recall when that was).
Try :
perl -e 'for ( 1 .. 100000000 ) { print; last; }'
If it prints "1" immediately the you are OK.
If it prints "Out of memory!" then try changing your program to use a
C-style for() or get a recent version of Perl.
If $count is not big then you have a memory leak. Memory leaks are
not uncommon in Perl.
> A snippet of the code follows:
In situations like this a snippet is not helpfull. It is quite likely
the problem is not in what you chose show us.
Always produce a _minimal_ but _complete_ (strict, warning free)
script that you have _actually_run_ and found to reproduce the
problem. Post it in its entirity unaltered. Include mention of what
version of Perl you are using.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 08 Nov 2002 13:09:19 -0700
From: Todd Anderson <todd@mrnoitall.com>
Subject: Name, value
Message-Id: <3DCC19C4.D04E87B4@mrnoitall.com>
Dear Sirs,
I need to take a list of items (@items) and then identify the name and
the value for each. Is it possible?
@items = ("item1", "item2");
$item1 = "qwef";
$item2 = "sgfbq34t";
foreach $item (@items){
$item = "$name, $value";
}
Thanks in advance for your help
------------------------------
Date: Fri, 8 Nov 2002 15:20:45 -0500
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Todd Anderson <todd@mrnoitall.com>
Subject: Re: Name, value
Message-Id: <Pine.A41.3.96.1021108151933.48666A-100000@cortez.sss.rpi.edu>
[posted & mailed(?)]
On Fri, 8 Nov 2002, Todd Anderson wrote:
>I need to take a list of items (@items) and then identify the name and
>the value for each. Is it possible?
>
>@items = ("item1", "item2");
>$item1 = "qwef";
>$item2 = "sgfbq34t";
>
>foreach $item (@items){
>$item = "$name, $value";
>}
You don't want a bunch of scalars, you want a hash:
my %stuff = (
item1 => "qwef",
item2 => "sgfbq34t",
# ...
);
for (keys %stuff) {
print "name=$_; value=$stuff{$_}\n";
}
Read 'perldoc perldata'.
--
Jeff "japhy" Pinyan RPI Acacia Brother #734 2002 Acacia Senior Dean
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: Fri, 08 Nov 2002 21:24:33 +0100
From: Dominik Seelow <kurzhalsflasche@netscape.net>
Subject: Re: Name, value
Message-Id: <3DCC1D81.4010205@netscape.net>
Todd Anderson announced:
> Dear Sirs,
> I need to take a list of items (@items) and then identify the name and
> the value for each. Is it possible?
>
> @items = ("item1", "item2");
> $item1 = "qwef";
> $item2 = "sgfbq34t";
>
> foreach $item (@items){
> $item = "$name, $value";
> }
> Thanks in advance for your help
>
sounds like you want to use a hash...
use strict;
my %HASH;
$HASH{item1} = "qwef";
$HASH{item2} = "sgfbq34t";
foreach (keys %HASH){
print "$_ = $HASH{$_}\n";
}
HTH,
Dominik
------------------------------
Date: 8 Nov 2002 20:29:20 GMT
From: roberson@ibd.nrc.ca (Walter Roberson)
Subject: Re: Name, value
Message-Id: <aqh6r0$3ic$1@canopus.cc.umanitoba.ca>
In article <3DCC19C4.D04E87B4@mrnoitall.com>,
Todd Anderson <todd@mrnoitall.com> wrote:
:I need to take a list of items (@items) and then identify the name and
:the value for each. Is it possible?
:@items = ("item1", "item2");
:$item1 = "qwef";
:$item2 = "sgfbq34t";
:foreach $item (@items){
:$item = "$name, $value";
:}
Well, it's -possible- using
"$item, $$item"
but why not just use a hash?
%items = ( item1 => "qwef", item2 => "sgfbq34t" );
while( ($item, $value) = each %items) {
print "$item $value\n";
}
Unless, that is, the order is important, but that's a relatively
simple modification.
--
"The human genome is powerless in the face of chocolate."
-- Dr. Adam Drewnowski
------------------------------
Date: Fri, 8 Nov 2002 21:37:17 -0800
From: "Linux.ie" <mail@eircom.net>
Subject: Pause in perl ???
Message-Id: <aqh749$sbl$1@dorito.esatclear.ie>
How do i make my script do :
a) pause for 5 seconds and then continue on
b)stop after it says e.g "Welcome to your ping program" and then i hit enter
and it continues ?
------------------------------
Date: 8 Nov 2002 11:59:16 -0800
From: hap@mikomi.org (Adam Hapworth)
Subject: Re: perl array into sql database
Message-Id: <a6cb04db.0211081159.6eb73156@posting.google.com>
"Rodney Hunter" <rwh2100@hotmail.com> wrote in message news:<BQQy9.25839$Sr6.748171@ozemail.com.au>...
> newbie using perl CGI script - i have data in an array (passed by POST) and
> need to get it into sql database(Oracle) - here's my attempt that's not
> working - where's the perl code errors?
>
> thanks
> Rodney Hunter
>
> do 'dbi-lib.pl';
> use CGI ':standard';
> use DBI;
> use strict;
> my $q = new CGI;
>
> # get value passed from form
> my $thisjobno = $q->param('job_no');
> my @veg_type = $q->param('veg_type');
> # SQL insert statement
I would do this in a different manor then you have here using DBI,
which would make $query1 go away
> my $query1 = "insert into ea_veg (job_no, veg_type, veg_status) values
> ('$thisjobno', '@veg_type', 1)";
>
> # Database DBI driver name
> my $dbname = "DBI:Oracle:";
>
> # Create database handle
> my $dbh = DBI->connect($dbname, $user, $passwd);
> if (!$dbh) {
> showSQLerror("Connecting to the database");
> return;
> } else {
> # set AutoCommit 1 = ON, 0 = OFF (1 is default)
> # transaction control *required* here - set OFF
> $dbh->{AutoCommit} = 0;
> }
>
try something like this.
my $sth = $dbh->prepare(q{insert into ea_veg (job_no, veg_type,
veg_status); values(:job, :type, 1)})||fail "prepare failed";
foreach (@veg_type) {
$sth->bind_param(":job",$thisjobno);
$sth->bind_param(":type",$_);
$sth->execute() || die "insert failed";
}
$dbh->commit;
$dbh->disconnect;
That should be all you would need. Unless I am missing something in
this logic.
This was written on the fly so there may be a couple of typos I am
missing.
Adam
> # Insert the data fetched
> while ((@veg_type) = $sth->fetchrow_array) {
> my ($veg_insert);
> $veg_insert = run_statement($dbh,$query1,"N");
> if ($veg_insert == 1) {
> $dbh->rollback;
> $dbh->disconnect;
> return;
> }
> else {
> # Commit transaction and disconnect from database
> $dbh->commit;
> $dbh->disconnect;
> }
> } # end of fetch while
------------------------------
Date: Fri, 08 Nov 2002 16:23:41 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: perl array into sql database
Message-Id: <3DCC2B5D.7F461241@earthlink.net>
Rodney Hunter wrote:
>
> newbie using perl CGI script - i have data in an array (passed by
> POST) and need to get it into sql database(Oracle) - here's my
> attempt that's not working - where's the perl code errors?
The perl code errors were written to your web server's log file.
Read the web server's documentation to find out where that log file is.
In addition, read perldoc -q 500
> thanks
You're welcome :)
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Fri, 08 Nov 2002 22:39:41 +0100
From: Rainer Scherg <Rainer.Scherg@t-online.de>
Subject: Re: perl ldap and MS-Active Directory or Netmeeting
Message-Id: <3DCC2F1D.88EC5CCD@t-online.de>
Hi!
Tnx, Accessing Exchange is working (NT4, Exc.5.5 with ADSI) at our
site, too. We are using perl/ldap from unix, to update our Exchange
directory data (phone-nr, department, etc. == sync data with
online telefonbook running an unix/apache)
This is working fine.
But for some reason, we did not manage to access Win2K
ils-server (netmeeting). For some reason bind returns error
code 48.
It would be interesting, if the guy at your site managed to access
EXC2K. So any information is welcome...
Rainer
pkent schrieb:
>
> In article <3DCAB74E.A15C6BD7@t-online.de>,
> Rainer Scherg <Rainer.Scherg@t-online.de> wrote:
>
> > has anyone experience in accessing Microsofts
> > Actiev Directory or Netmeeting (ils-Server) from perl
> > with perl-ldap (from unix)?
>
> I don't know if this is any use but soeone at work has managed to
> interface very successfully with the LDAP server that's part of our
> Exchange system (I'm hazy on the details but given a Windows login
> username you can get all the data about the user from Exchange et al)
> and they used the PHP LDAP stuff (some problems there) and teh perl LDAP
> stuff (much better).
>
> If you want I can find out a bit more
>
> P
>
> --
> pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
> Remove the tea to reply
------------------------------
Date: Fri, 08 Nov 2002 21:30:57 GMT
From: nor@htmlcompendium.org (Ron)
Subject: problems with DB_File password database
Message-Id: <3dcc2b8e.1285603@news.synapse.net>
Hi All:
I'm trying to validate readers to sections of my site with
mod_auth_db. Here's the syntax that I'm using:
=-================
tie %database, 'DB_File', "$pwddbfile" or die "Can't initialize
database: $!\n";
foreach (keys %database) {
print "key: $_\t\t";
}
untie %database;
=================
What I'm trying to do here is to print out the contents of the
database so I can check my programming. I don't want to clobber the
wrong stuff. What's happening here is that the database prints out
records alright, and in chronological order which is fine except that
it skips records. i.e. 22 then skips to 24, 25 ...
I've logged in as user number 23 and it validates me but
everytime I try to print out the database is skips this _or_ other
records.
I then tried this syntax:
===============
dbmopen(%DBM, "$pwddbfile", 0644) || die "Cannot open file: $!\n";
while (($key, $value) = each %DBM) {
print "key=$key, value=$value\n";
}
dbmclose(%DBM);
===============
Exactly the same thing happened. It skipped records. What am I
doing wrong?
Thanks for the help.
Ron Woodall
Ron Woodall
nor@synapse.net
responsible for the Compendium of HTML Elements - available at:
http://htmlcompendium.org
------------------------------
Date: 8 Nov 2002 12:24:44 -0800
From: eddiekwang@hotmail.com (eddie wang)
Subject: using perl package mananger on win2000
Message-Id: <879e0e64.0211081224.683f1a46@posting.google.com>
Hello. I am trying to use the perl package manager came with active
perl. when I tried to install a module, I got the following message.
Error: can't create temporary directory 'C:\TEMP/XML-Excel-992': No
such
file or directory
Does any one know how to fix it? it looks like the "/" and "\" are
mixed up here.
Thank you in advance!
eddy
------------------------------
Date: Fri, 08 Nov 2002 21:05:31 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: using perl package mananger on win2000
Message-Id: <Xns92C0A3B24C1C5dkwwashere@216.168.3.30>
eddie wang <eddiekwang@hotmail.com> wrote on 08 Nov 2002:
> Hello. I am trying to use the perl package manager came with active
> perl. when I tried to install a module, I got the following message.
>
> Error: can't create temporary directory 'C:\TEMP/XML-Excel-992': No
> such
> file or directory
Does C:\TEMP exist?
> Does any one know how to fix it? it looks like the "/" and "\" are
> mixed up here.
It's never caused a problem for me when using ppm on win2k. YMMV, though.
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
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 4087
***************************************