[17729] in Perl-Users-Digest
Perl-Users Digest, Issue: 5149 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 19 11:05:37 2000
Date: Tue, 19 Dec 2000 08:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <977241913-v9-i5149@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 19 Dec 2000 Volume: 9 Number: 5149
Today's topics:
#!/usr/bin/perl alternative? (Mike Eggleston)
(Beginner) Simple stuff not working <garry@heaton6.freeserve.co.uk>
Re: (Beginner) Simple stuff not working <uackermann@orga.com>
Re: (Beginner) Simple stuff not working <garry@heaton6.freeserve.co.uk>
Re: (Beginner) Simple stuff not working <garry@heaton6.freeserve.co.uk>
Re: .pl or .plx? <bcaligari@my-deja.com>
beginner question <mcs2@pitt.edu>
Re: beginner question (Abigail)
Re: beginner question <josef.moellers@fujitsu-siemens.com>
Re: beginner question (Tad McClellan)
cant work how to get regex to do something like (patter <tamm@scotlegal.com>
Re: cant work how to get regex to do something like (pa (Abigail)
Re: cant work how to get regex to do something like (pa <josef.moellers@fujitsu-siemens.com>
Re: cant work how to get regex to do something like (pa (Tad McClellan)
CGI name=value with spaces in it, Sendmail/NT invinfo@my-deja.com
Re: crypt <dbohl@sgi.com>
Re: crypt <Per-fredrik.Pollnow@epk.ericsson.se>
Re: deskcode.com hot new perl resource read more <jenny-h@algonet.se>
Emacs modules for Perl programming (Jari Aalto+mail.perl)
Re: execute a Perl Programm with DBD:DBI - SQL-Statemen <fty@mediapulse.com>
Free servers with Perl support? <qbertREMOVE@THISusuarios.retecal.es>
Re: Free servers with Perl support? (Abigail)
help requested with Appache::Session and DBI <dgason@my-deja.com>
Re: Help with Multi-dimensional array <thomas@geffert.com>
Re: Help with Multi-dimensional array (Tad McClellan)
how to invalidate a hash value during a foreach loop? <info@jjmackay.ca>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Dec 2000 14:39:10 GMT
From: mikee@kensho.eggtech.com (Mike Eggleston)
Subject: #!/usr/bin/perl alternative?
Message-Id: <slrn93usoe.p7l.mikee@kensho.eggtech.com>
Seems I remember someone had once proposed an alternative to
#!/usr/bin/perl a shell script line that would search for
the perl binary and re-exec the script with the proper magic.
Does anyone remember what that line was?
TIA
Mike
------------------------------
Date: Tue, 19 Dec 2000 14:46:02 -0000
From: "Garry Heaton" <garry@heaton6.freeserve.co.uk>
Subject: (Beginner) Simple stuff not working
Message-Id: <91nsb3$i87$1@newsg2.svr.pol.co.uk>
This is probably really stupid but I was practcing some short 2 or 3-liners
with the split function to get used to using it but every time I hit perl -w
ex.pl in MS-DOS I received a "Can't modify not in scalar assignment at line
.... " error. At first I thought I'd used split wrongly but I eventually
whittled the script down to 2 simple lines:
!#c:/perl/bin/perl.exe
$phrase = "Its about time";
print phrase;
Still the same error message.
------------------------------
Date: Tue, 19 Dec 2000 16:48:48 +0000
From: Ulrich Ackermann <uackermann@orga.com>
Subject: Re: (Beginner) Simple stuff not working
Message-Id: <3A3F9170.64826618@orga.com>
Garry Heaton wrote:
>
> This is probably really stupid but I was practcing some short 2 or 3-liners
> with the split function to get used to using it but every time I hit perl -w
> ex.pl in MS-DOS I received a "Can't modify not in scalar assignment at line
> .... " error. At first I thought I'd used split wrongly but I eventually
> whittled the script down to 2 simple lines:
>
> !#c:/perl/bin/perl.exe
^^^
Change the first two signs: #!c:/perl/bin/perl.exe
HTH (at least under Linux it does),
Ulrich
--
Ulrich Ackermann
ORGA Kartensysteme GmbH (SY-PEAT-STA)
Tel.:+49.5254.991-925
mailto:uackermann@orga.com
------------------------------
Date: Tue, 19 Dec 2000 14:50:42 -0000
From: "Garry Heaton" <garry@heaton6.freeserve.co.uk>
Subject: Re: (Beginner) Simple stuff not working
Message-Id: <91nsjh$9d2$1@newsg3.svr.pol.co.uk>
Sorry, it was REALLY stupid after all. !# should be #! of course
"Garry Heaton" <garry@heaton6.freeserve.co.uk> wrote in message
news:91nsb3$i87$1@newsg2.svr.pol.co.uk...
> This is probably really stupid but I was practcing some short 2 or
3-liners
> with the split function to get used to using it but every time I hit
perl -w
> ex.pl in MS-DOS I received a "Can't modify not in scalar assignment at
line
> .... " error. At first I thought I'd used split wrongly but I eventually
> whittled the script down to 2 simple lines:
>
> !#c:/perl/bin/perl.exe
>
> $phrase = "Its about time";
> print phrase;
>
> Still the same error message.
>
>
>
------------------------------
Date: Tue, 19 Dec 2000 14:53:12 -0000
From: "Garry Heaton" <garry@heaton6.freeserve.co.uk>
Subject: Re: (Beginner) Simple stuff not working
Message-Id: <91nso6$ttd$1@newsg4.svr.pol.co.uk>
Thanks Ulrich. Just realised before your post. Stupid thing is I've entered
it correctly many times before. Live & learn.
Merry Xmas (if that doesn't offend!)
"Ulrich Ackermann" <uackermann@orga.com> wrote in message
news:3A3F9170.64826618@orga.com...
> Garry Heaton wrote:
> >
> > This is probably really stupid but I was practcing some short 2 or
3-liners
> > with the split function to get used to using it but every time I hit
perl -w
> > ex.pl in MS-DOS I received a "Can't modify not in scalar assignment at
line
> > .... " error. At first I thought I'd used split wrongly but I eventually
> > whittled the script down to 2 simple lines:
> >
> > !#c:/perl/bin/perl.exe
> ^^^
> Change the first two signs: #!c:/perl/bin/perl.exe
>
> HTH (at least under Linux it does),
>
> Ulrich
> --
> Ulrich Ackermann
> ORGA Kartensysteme GmbH (SY-PEAT-STA)
> Tel.:+49.5254.991-925
> mailto:uackermann@orga.com
------------------------------
Date: Tue, 19 Dec 2000 15:32:04 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Re: .pl or .plx?
Message-Id: <91nv1m$up9$1@nnrp1.deja.com>
In article <91lvr7$5fp$1@autumn.news.rcn.net>,
"Chris Godaire" <chris.nospam.godaire@rcn.com> wrote:
>
> > Should standalone scripts be extensioned as .pl or as .plx?
>
> It truly doesn't matter. I use .pl for everything, but can fully
understand
> why someone would use .plx. It's a matter of knowing what a file is
at a
> glance; something that's typically a bit easier in Windows than in a
Unix
yeah...that's the reason why really. My awk scripts are .awk and sed
ones .sed leaving un extensioned executable scripts to be shell ones.
But it's really convenient to exensionify files....especially when
others have to follow up on what you've been doing.
> system.
>
> > I know that at the end of the day it doesn't make a difference, but
> > somewhere I must have read that *.plx is good practice for scripts
> > while *.pl should be left for perl libraries (what on earth is a
perl
> > library??)
> >
>
> Perl libraries are like modules, but are loaded at run-time instead of
> compile time. The line:
>
> require 'file.pl';
>
> would load the code inside of "file.pl", and you'd be able to call
any of
> the functions inside of it (provided it doesn't switch packages on
you).
>
> > Anyways....vim doesn't automatically syntax highlight for .plx
> > (althouth easy to remedy) but I've downloaded ActiveState Komodo,
which
> > (whilst lacking vi keystrokes) is quite nice. However I could not
> > figure out how to associate .plx with perl.
>
> I'm assuming this is Windows of some sort... Open Windows Explorer,
Click
> View | Options | File Types.. You can add the .plx extension here
from there or using 'assoc' from command line.
ActiveState's Komodo provides syntax highliting and an integrated
debugger for perl, python, html and javascript (i think) however it
ties the source code to the language upon the extension. I couldn't
find a way to tell komodo that .plx files were perl and should be
treated as such :~(
Brendon
++++
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 19 Dec 2000 09:57:49 -0500
From: Martin Schmidt <mcs2@pitt.edu>
Subject: beginner question
Message-Id: <3A3F776D.1F271D37@pitt.edu>
Hi,
I'm writing a perl program that uses a few array variables named
something like
@array1, @array2, @array3
I want to access them using a variable to represent the number.
$num = 1;
@array$num These don't work.
@array{$num}
@array${num}
Any idea how to access an array using a scalar as part of the name?
Thanks
Martin
mcs2@pitt.edu
------------------------------
Date: 19 Dec 2000 15:31:43 GMT
From: abigail@foad.org (Abigail)
Subject: Re: beginner question
Message-Id: <slrn93uvqv.p3p.abigail@tsathoggua.rlyeh.net>
Martin Schmidt (mcs2@pitt.edu) wrote on MMDCLXVII September MCMXCIII in
<URL:news:3A3F776D.1F271D37@pitt.edu>:
**
** Any idea how to access an array using a scalar as part of the name?
Did you read the FAQ?
Abigail
--
tie $" => A; $, = " "; $\ = "\n"; @a = ("") x 2; print map {"@a"} 1 .. 4;
sub A::TIESCALAR {bless \my $A => A} # Yet Another silly JAPH by Abigail
sub A::FETCH {@q = qw /Just Another Perl Hacker/ unless @q; shift @q}
------------------------------
Date: Tue, 19 Dec 2000 16:36:33 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: beginner question
Message-Id: <3A3F8081.C2FF8F09@fujitsu-siemens.com>
Martin Schmidt wrote:
> =
> Hi,
> I'm writing a perl program that uses a few array variables named
> something like
> @array1, @array2, @array3
> =
> I want to access them using a variable to represent the number.
> $num =3D 1;
> =
> @array$num These don't work.
> @array{$num}
> @array${num}
> =
> Any idea how to access an array using a scalar as part of the name?
$num =3D 1;
$array1[0] =3D 123;
$var =3D "array$num";
print "${$var}[0]\n";
Josef
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
------------------------------
Date: Tue, 19 Dec 2000 10:01:00 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: beginner question
Message-Id: <slrn93uu1c.9nv.tadmc@magna.metronet.com>
Josef Moellers <josef.moellers@fujitsu-siemens.com> wrote:
>Martin Schmidt wrote:
>>
>> I'm writing a perl program that uses a few array variables named
>> something like
>> @array1, @array2, @array3
>>
>> I want to access them using a variable to represent the number.
>> $num = 1;
>>
>> Any idea how to access an array using a scalar as part of the name?
>
>$num = 1;
>$array1[0] = 123;
>$var = "array$num";
>print "${$var}[0]\n";
Symbolic references are Very Bad. You should not help people be
Very Bad. You should instead help them do it without being bad.
http://www.plover.com/~mjd/perl/varvarname.html
http://www.plover.com/~mjd/perl/varvarname2.html
http://www.plover.com/~mjd/perl/varvarname3.html
Make a 2-D array (perldoc perllol):
$array[1][0] = 123;
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 19 Dec 2000 14:58:33 -0000
From: "Tam McLaughlin" <tamm@scotlegal.com>
Subject: cant work how to get regex to do something like (pattern)\1{14}
Message-Id: <a4tn19.sar.ln@mail.scotlegal.com>
I have a pipe dellimeted fle where i need to replace the 17th (last) feild
which
does not end with a pipe.
I want to be able to say "look for fist 16 occurances of xxx| and then
then look for the
next field (last one - the one to be replaced) and then replace with the
first 16th occurances
matched and then the modified data but just cannot get it to work. I was
trying
I have tried
s/([^\|]*\|)
([^\|]*\|)
([^\|]*\|)
([^\|]*\|)
([^\|]*\|)
([^\|]*\|)
([^\|]*\|)
([^\|]*\|)
([^\|]*\|)
([^\|]*\|)
([^\|]*\|)
([^\|]*\|)
([^\|]*\|)
([^\|]*\|)
([^\|]*\|)
([^\|]*\|)
(.*$)/\1\2\3\4\5\6\7\8\9\10\11\12\13\14\15\16 new-string /xg;
but this does not work because it does not like the \10 \11 etc and I cannot
find how to
use a back reference greater than \9. Also I am sure there must be a way to
say smthg
like
s/([^\|]*\|){16}(.*$)/\1{16} new-string/g;
any pointers would be helpful
thanks.
------------------------------
Date: 19 Dec 2000 15:41:02 GMT
From: abigail@foad.org (Abigail)
Subject: Re: cant work how to get regex to do something like (pattern)\1{14}
Message-Id: <slrn93v0ce.p3p.abigail@tsathoggua.rlyeh.net>
Tam McLaughlin (tamm@scotlegal.com) wrote on MMDCLXVII September MCMXCIII
in <URL:news:a4tn19.sar.ln@mail.scotlegal.com>:
== I have a pipe dellimeted fle where i need to replace the 17th (last) feild
== which
== does not end with a pipe.
== I want to be able to say "look for fist 16 occurances of xxx| and then
== then look for the
== next field (last one - the one to be replaced) and then replace with the
== first 16th occurances
== matched and then the modified data but just cannot get it to work. I was
== trying
==
==
== I have tried
== s/([^\|]*\|)
== ([^\|]*\|)
== ([^\|]*\|)
== ([^\|]*\|)
== ([^\|]*\|)
== ([^\|]*\|)
== ([^\|]*\|)
== ([^\|]*\|)
== ([^\|]*\|)
== ([^\|]*\|)
== ([^\|]*\|)
== ([^\|]*\|)
== ([^\|]*\|)
== ([^\|]*\|)
== ([^\|]*\|)
== ([^\|]*\|)
== (.*$)/\1\2\3\4\5\6\7\8\9\10\11\12\13\14\15\16 new-string /xg;
==
==
==
== but this does not work because it does not like the \10 \11 etc and I cannot
That's because you should be using $1 .. $16.
But there's a much simpler method. Don't count from the beginning, but
use the fact this is the end.
s/[^|]*$/new-string/;
No need for /x or /g.
And if you need to replace something in the middle, use of split and join
will give much more maintainable code.
my @parts = split /\|/ => $str;
$part [11] = new_string;
$str = join '|' => @parts;
Abigail
--
perl -Mstrict -we '$_ = "goto _.print chop;\n=rekcaH lreP rehtona tsuJ";_1:eval'
------------------------------
Date: Tue, 19 Dec 2000 16:44:15 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: cant work how to get regex to do something like (pattern)\1{14}
Message-Id: <3A3F824F.420AD4A5@fujitsu-siemens.com>
Tam McLaughlin wrote:
> =
> I have a pipe dellimeted fle where i need to replace the 17th (last) f=
eild
> which
> does not end with a pipe.
> I want to be able to say "look for fist 16 occurances of xxx| and t=
hen
> then look for the
> next field (last one - the one to be replaced) and then replace with th=
e
> first 16th occurances
> matched and then the modified data but just cannot get it to work. I wa=
s
> trying
How about using split to separate the record in fields, the modfiy the
17th field in the resulting array, then combine the stuff back:
@tmp =3D split /\|/;
$tmp[16] =3D "new-string";
$_ =3D join('|', @tmp);
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
------------------------------
Date: Tue, 19 Dec 2000 09:48:12 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: cant work how to get regex to do something like (pattern)\1{14}
Message-Id: <slrn93ut9c.9m8.tadmc@magna.metronet.com>
Tam McLaughlin <tamm@scotlegal.com> wrote:
>I have a pipe dellimeted fle where i need to replace the 17th (last) feild
>which
>does not end with a pipe.
Then it is not "delimited".
You must have meant "separated" instead?
>I want to be able to say "look for fist 16 occurances of xxx|
Why not say "look for the last field" instead?
>any pointers would be helpful
s/(.*\|).*/$1$newvalue/;
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 19 Dec 2000 15:24:31 GMT
From: invinfo@my-deja.com
Subject: CGI name=value with spaces in it, Sendmail/NT
Message-Id: <91nuj6$u9r$1@nnrp1.deja.com>
I'm designing a form based email system and I'm looking for suggestions.
I'm using NT and ActiveState v5.6.0
Currently, I am just using perl to call java ( and use javamail ).
Testing in command mode, however, my script does not work properly when
the values are multiple words with spaces in between.
( I am enclosing them in double-quotes when entering on the command
line. )
Is sendmail available for NT ?
TIA - Robert
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 19 Dec 2000 08:14:36 -0600
From: Dale Bohl <dbohl@sgi.com>
Subject: Re: crypt
Message-Id: <3A3F6D4C.E866564F@sgi.com>
Per- Fredrik Pollnow wrote:
>
> Hello,
>
> Can someone please help me, I don't know how to crypt. Can someone give me
> an example? I have tried this:
>
> print "Enter password: "chomp($passwd = <STDIN>);
> $x = crypt::DES $passwd
This help?
#!/usr/bin/perl -w
#
# This script verifies a user's password.
$pwd = (getpwuid($<))[1];
$salt = substr($pwd, 0, 2);
system "/usr/bin/stty", "-echo"; # turn off echoing
print "Enter Your Password: ";
chop($word = <STDIN>);
print "\n";
system "/usr/bin/stty", "echo"; # turn on echoing
if (crypt($word, $salt) ne $pwd) {
die "Sorry...That is NOT your Password\n";
} else {
print "That IS your correct Password.\n";
}
--
Thanks,
Dale
Dale Bohl
SGI Information Services
dbohl@sgi.com
(715)-726-8406
http://wwwcf.americas.sgi.com/~dbohl/
JAPH
------------------------------
Date: Tue, 19 Dec 2000 15:39:38 +0100
From: "Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se>
Subject: Re: crypt
Message-Id: <91nrcp$556$1@newstoo.ericsson.se>
Thanx, I hadn't installed the crypt, and the script help me to so thanks :=)
"Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se> wrote in
message news:91nkq2$271$1@newstoo.ericsson.se...
> Hello,
>
> Can someone please help me, I don't know how to crypt. Can someone give me
> an example? I have tried this:
>
> print "Enter password: "chomp($passwd = <STDIN>);
> $x = crypt::DES $passwd
>
>
------------------------------
Date: 19 Dec 2000 15:38:52 +0100
From: Jenny Holmberg <jenny-h@algonet.se>
Subject: Re: deskcode.com hot new perl resource read more
Message-Id: <xrzzitoglblv.fsf@gruk.algonet.se>
tadmc@metronet.com (Tad McClellan) writes:
> But even mail to postmaster@deskcode.com bounces:
>
> <postmaster@deskcode.com>:
> 216.234.161.182 does not like recipient.
> Remote host said: 553 sorry, that domain isn't in my list of
> allowed rcpthosts (#5.7.1)
>
> postmaster will not accept email!
>
> A sure sign of a professional spammer.
In this case, it's a sign of a misconfigured qmail box. A professional
spammer would rather have accepted the mail and devnulled it.
--
Jenny With the Axe, and the Temper http://www.algonet.se/~jenny-h/
#include <std_disclaimer.h>
"You are in front of me. If you value your lives, be somewhere else."
--Ambassador Delenn, B5
------------------------------
Date: 19 Dec 2000 14:55:03 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_977237370@rtfm.mit.edu>
Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://tiny-tools.sourceforge.net/
Maintainer: Jari Aalto <jari.aalto@poboxes.com>
Announcement: "What Emacs lisp modules can help with programming Perl"
Preface
Emacs is your friend if you have to do anything comcerning software
development: It offers plug-in modules, written in Emacs lisp
(elisp) language, that makes all your programmings wishes come
true. Please introduce yourself to Emacs and your programming era
will get a new light.
Where to find Emacs
XEmacs/Emacs, is available to various platforms:
o Unix:
If you don't have one, bust your sysadm.
http://www.gnu.org/software/emacs/emacs.html
http://www.xemacs.org/
Emacs resources at http://home.eu.org/~jari/emacs-elisp.html
o W9x/NT:
http://www.gnu.org/software/emacs/windows/ntemacs.html
Emacs Perl Modules
Cperl -- Perl programming mode
.ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
.<olson@mcs.anl.gov> Bob Olson (started 1991)
.<ilya@math.ohio-state.edu> Ilya Zakharevich
Major mode for editing perl files. Forget the default
`perl-mode' that comes with Emacs, this is much better. Comes
starndard in newest Emacs.
TinyPerl -- Perl related utilities
.http://home.eu.org/~jari/tiny-tools-beta.zip
.http://home.eu.org/~jari/emacs-tiny-tools.html
If you ever wonder how to deal with Perl POD pages or how to find
documentation from all perl manpages, this package is for you.
Couple of keystrokes and all the documentaion is in your hands.
o Instant function help: See documentation of `shift', `pop'...
o Show Perl manual pages in *pod* buffer
o Load source code into Emacs, like Devel::DProf.pm
o Grep through all Perl manpages (.pod)
o Follow POD manpage references to next pod page with TinyUrl
o Coloured pod pages with `font-lock'
o Separate `tiperl-pod-view-mode' for jumping topics and pages
forward and backward in *pod* buffer.
o TinyUrl is used to jump to URLs (other pod pages, man pages etc)
mentioned in POD pages. (It's a general URL minor mode)
TinyIgrep -- Perl Code browsing and easy grepping
[TinyIgrep is included in the tgz mentioned above]
To grep from all installed Perl modules, define database to
TinyIgrep. There is example in the tgz (ema-tigr.ini) that shows
how to set up datatbases for Perl5, Perl4 whatever you have
installed
TinyIgrep calls Igrep.el to run the find for you, You can adjust
recursive grep options, ignored case, add user grep options.
You can get `igrep.el' module from <kevinr@ihs.com>. Ask for copy.
Check also ftp://ftp.ihs.com/pub/kevinr/
TinyCompile -- Browsing grep results in Emacs *compile* buffer
TinyCompile is minor mode for *compile* buffer from where
you can collapse unwanted lines, shorten the file URLs
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT
-->
cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
file1:NNN: MATCHED TEXT
file1:NNN: MATCHED TEXT
End
------------------------------
Date: Tue, 19 Dec 2000 14:47:15 GMT
From: "Jay Flaherty" <fty@mediapulse.com>
Subject: Re: execute a Perl Programm with DBD:DBI - SQL-Statements in a file
Message-Id: <TxK%5.107821$IP1.3630772@news1.giganews.com>
<gerhard.hann@generali.at> wrote in message
news:y3H%5.45$dg5.2325@nreader1.kpnqwest.net...
>***************************************************************************
******
>HERE is my PROBLEM - I WANT TO CALL A FILE, WHERE THE SQL-STATEMENTS ARE
>INSIDE
>HOW DOES THIS WORK ???????????????????
>$dbh->do( <<END_EINGABE2 );
>@c:\\home\\oracle\\script\\utlbstat.cmd <=== this is the file with
sql-statements
>END_EINGABE2
>***************************************************************************
*****
If you have one SQL statement per line just open it and read it:
open(SQL, "file.sql") or die "Unable to open file: $!\n";
my @statements = <SQL>;
close(SQL);
for(@statements) {
chomp;
$dbh->do($_); # I'm assuming INSERT/UPDATE statements
}
--
###############################
Take care of your shoes...jay
Jay Flaherty fty@mediapulse.com
Mediapulse, Inc. -The pulse of your eBusiness
------------------------------
Date: Tue, 19 Dec 2000 15:09:57 +0100
From: "Navcomp" <qbertREMOVE@THISusuarios.retecal.es>
Subject: Free servers with Perl support?
Message-Id: <91nq2k$lm3$1@titan.bt.es>
Hello. I'm looking for a free UNIX-Linux server where I can put my CGIs
written in Perl while I learn the language (just for learning purposes). I
would need Telnet access and FTP too. Is there any server offering this?
Thank you.
Navcomp.
------------------------------
Date: 19 Dec 2000 15:42:46 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Free servers with Perl support?
Message-Id: <slrn93v0fm.p3p.abigail@tsathoggua.rlyeh.net>
Navcomp (qbertREMOVE@THISusuarios.retecal.es) wrote on MMDCLXVII
September MCMXCIII in <URL:news:91nq2k$lm3$1@titan.bt.es>:
** Hello. I'm looking for a free UNIX-Linux server where I can put my CGIs
** written in Perl while I learn the language (just for learning purposes). I
** would need Telnet access and FTP too. Is there any server offering this?
All you need is some Intel hardware. An old 386 will do.
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s};;;
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)}; # Perl 5.6.0 broke this...
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: Tue, 19 Dec 2000 14:06:47 GMT
From: Dave <dgason@my-deja.com>
Subject: help requested with Appache::Session and DBI
Message-Id: <91nq1j$q5v$1@nnrp1.deja.com>
I would like to get Apache::Session to work with a MySQL database. I have
created a very simple Perl script to test it, but unfortunately, it is not
working.
Note that MySQL is working fine, and I can access it with other Perl DBI
programs with no difficulty.
While I am close, I am getting the following error:
[dgason@emerald sessiontest]$ ./simple.pl
Can't connect( HASH(0x81f5904)), no database driver specified and DBI_DSN
env var not set at
/usr/lib/perl5/site_perl/5.6.0/Apache/Session/Lock/MySQL.pm line 36
Here is the program I have created (mostly from copying the
Apache::Session documentation for version 1.53)
#!/usr/bin/perl
use strict;
use Apache::Session::MySQL;
my $user = "auser";
my $password = "apassword";
my $dsn = "dbi:mysql:sessions";
my %session;
#make a fresh session for a first-time visitor
tie %session, 'Apache::Session::MySQL', undef,
{ DataSource => $dsn,
UserName => $user,
Password => $password,
};
#stick some stuff in it
$session{visa_number} = "1234 5678 9876 5432";
#get the session id for later use
my $id = $session{_session_id};
#...time passes... #get the session data back out again during some other
request my %session; tie %session, 'Apache::Session::MySQL', $id;
&validate($session{visa_number});
#delete a session from the object store permanently
tied(%session)->delete;
One more quick question: I have been able to do some guessing, but what
should the sessions table look like? I have tried to create one with the
following fields: id varchar(30) data blob a_session varchar(30)
Thanks in advance for the help!
Dave
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 19 Dec 2000 16:07:39 +0100
From: Thomas Geffert <thomas@geffert.com>
Subject: Re: Help with Multi-dimensional array
Message-Id: <87n1ds30w4.fsf@cal056202.student.utwente.nl>
Raymond WAN <rwan@cs.mu.OZ.AU> writes:
> Hi all,
>
> There's something I would like to do, but I don't know how to do
> it. Basically, I'm creating a two dimensional array and would like to put
> it into a one dimensional array (therefore creating a three dimensional
> array). In pseudocode, what I'm doing looks like this:
>
> for ( ... ) {
> for ( ... ) {
> $_ = <INPUT_FILE>;
> @tmp = split;
> push @grid, [ @tmp ];
> }
>
> $biggrid[$i] = \@grid;
> $i++;
> }
>
> My problem is that grid is always the same thing so biggrid ends
> up being an array of grid's...all of which have the same rows in them. In
> C-speak (sorry, but I'm a C programmer ;) ), I need to re-malloc the grid
> array so that biggrid stores a new memory address each time -- how do I do
> it?
for ( ... ) {
my @grid;
for ( ... ) {
push @grid, [ split /\s+/, <INPUT_FILE> ];
}
push @biggrid, \@grid;
}
> Alternatively, if I could, on line 5 "push" directly into
> $biggrid[$i], that would be great...I could remove the grid variable.
for ( ... ) {
for ( ... ) {
push @{$biggrid[$i]}, [ split /\s+/, <INPUT_FILE> ];
}
$i++;
}
Thomas
------------------------------
Date: Tue, 19 Dec 2000 09:16:04 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help with Multi-dimensional array
Message-Id: <slrn93urd4.9hk.tadmc@magna.metronet.com>
Raymond WAN <rwan@cs.mu.OZ.AU> wrote:
>
>Hi all,
>
> There's something I would like to do, but I don't know how to do
>it. Basically, I'm creating a two dimensional array and would like to put
>it into a one dimensional array (therefore creating a three dimensional
>array). In pseudocode, what I'm doing looks like this:
>
>for ( ... ) {
my @grid; # each iteration of the above loop gets its "own" @grid
> for ( ... ) {
> $_ = <INPUT_FILE>;
> @tmp = split;
> push @grid, [ @tmp ];
You do not need the temp variable:
push @grid, [ split ];
> }
>
> $biggrid[$i] = \@grid;
> $i++;
>}
>
> My problem is that grid is always the same thing so biggrid ends
>up being an array of grid's...all of which have the same rows in them.
> Alternatively, if I could, on line 5 "push" directly into
>$biggrid[$i], that would be great...I could remove the grid variable.
push @{$biggrid[$i]}, [ split ];
> Also, as you can tell, I'm still new to Perl.
The minimum required knowledge can be obtained thus:
perldoc perlreftut
>I know pattern
>matching, but don't know things like this or Packages, Objects, etc. I
>have the "Camel book" by O'Reilly, but truthfully, I find it hard to
>understand. Is there an O'Reilly book that one would suggest as a good
>beginner book that's well written, well organized, and contains good
^^^^^^^^^^^^^
Beginner at what?
Beginner at programming in general, or beginner with Perl?
>examples? [BTW: I said "O'Reilly" because I've read enough of them to
>believe they're pretty good overall.]
Beginner at programming in general:
"Elements of Programming with Perl", Andrew Johnson (Manning Publications)
beginner with Perl:
"Learning Perl", Randal Schwartz (O'Reilly)
disclaimer: I work for Manning, but I recommended Andrew's book even
before that happened. I work for Randal, but I
recommended his book before that happened too :-)
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 19 Dec 2000 15:18:45 GMT
From: "Olwynn" <info@jjmackay.ca>
Subject: how to invalidate a hash value during a foreach loop?
Message-Id: <p%K%5.36$Rb3.15295@sapphire.mtt.net>
I am looping through my hash table ( %form_data) and trying to not execute a
block of code when the user (of the form) has not entered any data. The
idea is that our distributors will be able to send an electronic christmas
card from a page but be able to include several "To" addresses. I have
commented out the sendmail stuff because it fills my log and I can't sort
out the problem. I am sure that the problem lies in the line
if(values(%form_results)!='')
because regardless, the loop executes, so... is there some default data that
comes in an empty form that I will have to remove to parse the keys
properly? or am I just no good at negation? TIA for any help or daylight.
Richard
What I have is this:
#!/usr/bin/perl -w
# Mailing script to get these damn christmas cards out
# Richard Owen 18/12/00
print "Content-type: text/html\n\n";
print "<HTML>";
print "<HEAD><TITLE>TEST FOR CARDS</TITLE></HEAD>";
print "<BODY>";
print "<H2>Emails sent to:</H2>";
$text = $ENV{'QUERY_STRING'};
my @value_pairs = split (/&/,$text);
my %form_results = ();
foreach $pair (@value_pairs)
($key, $value) = split (/=/,$pair);
$value =~ tr/+/ /;
$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
$form_results{$key} = $value;
}
foreach $key (sort keys(%form_results)) {
if (values(%form_results)!=''){
print "$key has a value of $form_results{$key}<BR>\n";
# open (SENDMAIL, "/usr/bin/sendmail") or die "cannot open sendmail:
$!";
# print SENDMAIL "To: $form_results{$key}\n";
# print SENDMAIL "From: customer.service\@jjmackay.ca\n";
# print SENDMAIL "Subject: Holiday Greeting\n\n";
# print SENDMAIL "Message Body";
# close (SENDMAIL);
}
else {}
}
--
GIT/FA d-@ s+:- a-- C++++$ U P+>++ L+()>+++ !E--- W+++$ N+++ K- w+>++ O-
M- V PS+ PE Y PGP t+ 5+ X++ R++ tv- b+++ DI+++ D+ G e*>+++++ h r* y+@
------------------------------
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 5149
**************************************