[12661] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 70 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 7 20:07:20 1999

Date: Wed, 7 Jul 1999 17:01:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 7 Jul 1999     Volume: 9 Number: 70

Today's topics:
        -e fails w/ large files (>2G) (Patrick Tufts)
    Re: Best method to test a sting within an array? (Abigail)
    Re: cgi.pm question (Abigail)
    Re: data structure to emulate pointers (Martien Verbruggen)
    Re: Deleting everything after a pattern? (Larry Rosler)
        fork() in Win32 <iqa@xippix.com>
        Help -- Weird Increments (MacPerl) <john@your.abc.net.au>
    Re: How to read HUGE text file in PERL? (Martien Verbruggen)
    Re: HTTP Proxy programming (Martien Verbruggen)
    Re: I need to hide the source <cmcurtin@interhack.net>
        Is PERL the way to create a pop-up window ? <cd156@att.net>
    Re: Is PERL the way to create a pop-up window ? <hiller@email.com>
    Re: need module to parse html file <cassell@mail.cor.epa.gov>
    Re: need module to parse html file (Martien Verbruggen)
    Re: Newbie Question (Anno Siegel)
    Re: Perl program exist after exec command... (Martien Verbruggen)
    Re: Perl program exist after exec command... (Anno Siegel)
    Re: Problem with a SQL statement in a Perl script <rereidy@uswest.net>
    Re: Problems with derefrencing <mjcarman@zeus.ia.net>
        Tk::BrowseEntry - Return index instead of value? <mjcarman@zeus.ia.net>
    Re: Weird /x regexps <hiller@email.com>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 7 Jul 1999 23:11:31 GMT
From: zippy@cs.brandeis.edu (Patrick Tufts)
Subject: -e fails w/ large files (>2G)
Message-Id: <7m0mr3$fog$1@new-news.cc.brandeis.edu>

The perl file test operators -e (exists), -f (file is a plain file),
-s (file has non-zero size) fail on large files under Solaris 5.6 x86.

Example:


> ls -l
>-rw-r--r--   1 patrick  staff    2150684158 Jun 24 17:42 big-file
>-rw-r--r--   1 patrick  staff    16131861 Jul  7 15:13 small-file

Let's test for the existance of a 2G+ file using the "-e" command:

> perl -e 'if (-e qq#big-file#) {print qq#IT EXISTS\n#} else {print qq#IT DOES NOT EXIST\n#}'
IT DOES NOT EXIST

And now, a 16M file:

> perl -e 'if (-e qq#small-file#) {print qq#IT EXISTS\n#} else {print qq#IT DOES NOT EXIST\n#}'
IT EXISTS

> perl --version
This is perl, version 5.005_02 built for i86pc-solaris

--Pat


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

Date: 7 Jul 1999 18:52:22 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Best method to test a sting within an array?
Message-Id: <slrn7o7q10.ued.abigail@alexandra.delanet.com>

pedro (pedro@nospam.co.uk) wrote on MMCXXXVI September MCMXCIII in
<URL:news:37837901.1426987@news.freeuk.net>:
() Wondered if anyone could suggest
() the best method to test whether
() a string is within an array?

FAQ.

() $m=(grep($match,@array));

You didn't even bother to read the documentation of grep, did you?



Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 7 Jul 1999 18:59:41 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: cgi.pm question
Message-Id: <slrn7o7qen.ued.abigail@alexandra.delanet.com>

John Hurley (jhurleyremove@njsba.org) wrote on MMCXXXVI September
MCMXCIII in <URL:news:378386ff.11237876@news.erols.com>:
\\ 
\\ My site is running on a BSD server and every time i try to run a Perl
\\ program on it with the use CGI line, i get a 500 error.  Can it be
\\ that the Perl interpreter on the server may be an old version that
\\ does not contain cgi.pm on it?  I have been trying to get a hold of my
\\ isp for a while now to find out about this and have not been replied
\\ to yet.  So I just thought I would ask you Perl pros.


Oh yes. That might be it. But there are a billion other reasons with
about equal probability. Solar flares. Aliens. Packages getting lost
in the Bermuda triangle. Web server being used to play Quake on. 500
is just a cool number according to your webmaster. Breadcrums in the
keyboard. The box acts as a pokertable as well. Your ISP is just one
of the covers for an NSA division. Tidal waves. Hurricanes. Windows.

But it is very unlikely it's a bug in your script. After all you did
carefully read the CGI faqs and studied the pitfalls, or didn't you?



Abigail
-- 
[Bricktext is free today]


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 07 Jul 1999 23:07:21 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: data structure to emulate pointers
Message-Id: <J4Rg3.43$RX3.2848@nsw.nnrp.telstra.net>

In article <3783CD4E.36A1D1A@zdnetmail.com>,
	* Tong * <sun_tong_nospam@zdnetmail.com> writes:
> I searched in CPAN for codes in perl for tree handling. there are

What sort of tree?

> something there, but none of them provide the abstract tree function
> (not for special purpose like directory or C codes).

Have you looked on CPAN?

# perl -MCPAN -e shell
cpan> i /tree/

This returns a very long list

http://www.perl.com/CPAN/modules/00modlist.long.html Also mentions
many modules with Tree in the name. Possibly one of them does what you
want (Class::Tree maybe?).

> So I think I should write it myself. Before I move on, I'd like to ask
> your advise on how to set the data structure for nodes. Perl doesn't
> have pointers as C does, so what if I really need the pointer. 

Sure, if none of the modules on CPAN are what you want, you can write
one yourself. Pointers in perl are called references. They are
explained in the following documentation:

# perldoc perlvar
# perldoc perlref
# perldoc perldsc
# perldoc perllol

You might also want to read

# perldoc perloo

> Is this a question that is too difficult so that no one ever write
> abstract tree module?

I doubt it.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | Freudian slip: when you say one thing
Commercial Dynamics Pty. Ltd.       | but mean your mother.
NSW, Australia                      | 


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

Date: Wed, 7 Jul 1999 16:53:32 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Deleting everything after a pattern?
Message-Id: <MPG.11ed8851566456c0989c70@nntp.hpl.hp.com>

In article <931373154.10465@www2.remarq.com> on Wed, 07 Jul 1999 
10:45:52 -0800, Ashish Kadakia <anonymous@web.remarq.com> says...
> $_ = "hello newsgroup user, this is your string";
> $pattern = "user";
> s/$pattern.*?$//;

The following seems more natural.  I added '/s' because of possible 
newlines in the string; the original poster said 'everything':

> > What would be the most efficient way to remove everything after
> > a pattern. 

  s/$pattern.*//s;

If the pattern is a literal string, and you're *certain* it's in there, 
another way that might be faster is this:

  $_ = substr $_, 0, index $_, $pattern;

Do some benchmarks to find out which is more efficient.

> ( Note, the above removes everything after finding the
> first occurence of pattern)

For the last occurrence of $pattern:

  /$pattern(?!.*$pattern).*//s;

  $_ = substr $_, 0, rindex $_, $pattern;

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


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

Date: Wed, 07 Jul 1999 16:52:20 -0700
From: iqa <iqa@xippix.com>
Subject: fork() in Win32
Message-Id: <3783E834.DD8A9274@xippix.com>

Is there any way I can do like:
	exec @command_list if (!fork());

under Win32 environment where fork() is not suppported.

system("@command_list") almost does it, but the problem is it waits the
command to complete its execution.

Thanks.


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

Date: Wed, 07 Jul 1999 15:30:48 -0800
From: johnny99 <john@your.abc.net.au>
Subject: Help -- Weird Increments (MacPerl)
Message-Id: <931390249.12510@www.remarq.com>

I'm using someone else's script, which uses an external data
file to record an incremented number.

The incremented number is incrementing very strangely.

Here's a script I put together to reproduce the effect:

		open (NUMBER,"+<data.txt");
		$num = <NUMBER>;
		print "I got $num from the data.txt file ";
		$num++;
		print "and I incremented it to $num.\n";
		print NUMBER $num;
		close (NUMBER);

which produces these effects, (starting with a zero as the
contents of data.txt):

I got 0 from the data.txt file and I incremented it to 1.
I got 01 from the data.txt file and I incremented it to 02.
I got 0102 from the data.txt file and I incremented it to
0103.
I got 01020103 from the data.txt file and I incremented it
to 01020104.
I got 0102010301020104 from the data.txt file and I
incremented it to 0102010301020105.

Can anyone help me?

This script works just fine on UNIX, by the way, and you end
up with a file consisting of just



**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****


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

Date: Wed, 07 Jul 1999 23:24:29 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How to read HUGE text file in PERL?
Message-Id: <NkRg3.57$RX3.2848@nsw.nnrp.telstra.net>

In article <7m09ks$lv8$1@nnrp1.deja.com>,
	jteens@my-deja.com writes:

> open(FH, "textfile.txt");

my $file = 'textfile.txt';
open(FH, $file) || die "Cannot open $file for reading: $!";

> while ($text = <FH>) {

In some versions of perl this will cause a warning (of course you have
warnings enabled, right? If you're using a perl 5.005 you're fine. On
perl 5.004 you need to put a defined around that.

>   chop($text);

Do you really want to chop off the last character? Or do you just want
to remove $/ (newline in most cases). If the latter:

chomp $text;

>   print "$text\n";

Chop off the last character, and then print it out with a newline,
which in most cases was the last character anyway? Or did you set $/
to something odd?

> }
> 
> close(FH);

> This code work fine on small file but my text file's very big. It around

This code will work equally well on small and large files.

> 500MB, so simple code above didn't work. How can I read huge text file 1

500 MB isn't large.

> line at a time? Any help would be mostly appreciated.

Your problem is not that perl cannot read a large file line by line.
It is something else. Either the OS you're on does something nasty,
or the file you're reading is not correct. Are you maybe on a platfomr
that distinguishes between binary and text files? Like MS? And is the
file you're reading maybe not a text file, but instead a binary one?
Does it maybe contain an end-of-file character?

Again: the perl code is fine, It must be something else. I have no
crystal ball, so I cannot tell you.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd.       | negative.
NSW, Australia                      | 


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

Date: Wed, 07 Jul 1999 23:11:55 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: HTTP Proxy programming
Message-Id: <%8Rg3.49$RX3.2848@nsw.nnrp.telstra.net>

In article <378340C7.E8C8A58A@mediaone.net>,
	"M. Brian Akins" <bakins@mediaone.net> writes:

> I have a problem though.  When connecting to apche servers which use
> name based virtual hosting, since I am only connecting via IP, I get the
> default "host" on that server.  What I need is a way to determin from

Of course you do.

> the HTTP request from a browser what server they are attempting to
> connect to by name and then forward this to the apache server.  Right
> now all I can  see is the generice HTTP request: "GET /  HTTP 1.0".

And your perl question is?

HTTP headers are discussed in the comp.infosystems.www.* hierarchy.
Not in the perl newsgroups. Of course, you are now writing something
much more complex than just an IP level packet router. You might want
to read the relevant RFCs.

> Any help out here??

Not here.

> Please e-mail me directly.

No. Post here, read here, even if it is irrelevant to this group. This
response on this group may encourage other people with similar
questions to think about which group they need to ask these questions
on.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | The gene pool could use a little
Commercial Dynamics Pty. Ltd.       | chlorine.
NSW, Australia                      | 


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

Date: 07 Jul 1999 19:04:11 -0400
From: Matt Curtin <cmcurtin@interhack.net>
Subject: Re: I need to hide the source
Message-Id: <xlxd7y4f4es.fsf@gold.cis.ohio-state.edu>

>>>>> On Wed, 07 Jul 1999 19:26:57 GMT, rdosser@my-deja.com said:

rdosser> I need to hide a decryption algorithm for confidential
rdosser> data.

Absolutely not.  Never should you need to hide 

See the Snake Oil FAQ, available from the master site at
http://www.interhack.net/people/cmcurtin/snake-oil-faq.html and fine
FAQ archives all over the world.

-- 
Matt Curtin cmcurtin@interhack.net http://www.interhack.net/people/cmcurtin/


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

Date: Wed, 7 Jul 1999 18:12:47 -0500
From: "cd156" <cd156@att.net>
Subject: Is PERL the way to create a pop-up window ?
Message-Id: <7m0mse$27o$1@bgtnsc03.worldnet.att.net>

I know that most of us are annoyed by pop-up windows, but I have a situation
where a pop-up window would be an advantage.  Javascript is not the answer
 ..

I'm wondering if there is a way to have a perl script open a small window .
I've tried a couple of methods, but not getting positive results.

A few webhosting servers produce pop-ups, how the heck are they doing it ?

Any ideas, thoughts are appreciated.......

TIA
Clif




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

Date: Wed, 07 Jul 1999 23:57:08 GMT
From: Jordan Hiller <hiller@email.com>
Subject: Re: Is PERL the way to create a pop-up window ?
Message-Id: <3783E954.39C3A01C@email.com>

They are usually doing it with JavaScript. JavaScript pretty well is THE ONLY
answer (although you could investigate VBScript and Java)...Perl is probably 

Jordan

cd156 wrote:
> 
> I know that most of us are annoyed by pop-up windows, but I have a situation
> where a pop-up window would be an advantage.  Javascript is not the answer
> ..
> 
> I'm wondering if there is a way to have a perl script open a small window .
> I've tried a couple of methods, but not getting positive results.
> 
> A few webhosting servers produce pop-ups, how the heck are they doing it ?
> 
> Any ideas, thoughts are appreciated.......
> 
> TIA
> Clif

-- 
Jordan Hiller (hiller@email.com)

JavaScript and Perl programs for
 making online tests and quizzes:
http://web-shack.hypermart.net/quiz.html


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

Date: Wed, 07 Jul 1999 16:05:01 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: need module to parse html file
Message-Id: <3783DD1D.56483D77@mail.cor.epa.gov>

lmoloch@my-deja.com wrote:
> 
> does anyone know of a module/function which parses an html file and
> stores the results as an array of ordinary words and html tags?
> 
> does anyone know if there anything similar to what i have described?

Yes.  There are a bunch.  Check out the HTML::* modules available
on your install of Perl, on CPAN, and via ppm [you did send this
from WinNT via Internet Exploder, so I'm assuming you're using
ActiveState Perl].

HTML::Parser and HTML::TokeParser may do what you want.  If not,
try nsgmls.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 07 Jul 1999 23:14:31 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: need module to parse html file
Message-Id: <rbRg3.50$RX3.2848@nsw.nnrp.telstra.net>

In article <7m0en4$oa3$1@nnrp1.deja.com>,
	lmoloch@my-deja.com writes:
> does anyone know of a module/function which parses an html file and
> stores the results as an array of ordinary words and html tags?

HTML::Parser

It's not the best thing though. Its name is slightly misleading,
because this module doesn't really parse HTML, but SGML.

There are other tools out there that do a good job. I believe Abigail
has posted a few responses in the last few days that mention this. And
of course, you have read these articles before you posted this
question, so you already know this. If not, I suggest you do so now,
and you do so in the future before posting questions.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | Unix is user friendly. It's just
Commercial Dynamics Pty. Ltd.       | selective about its friends.
NSW, Australia                      | 


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

Date: 7 Jul 1999 23:38:19 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Newbie Question
Message-Id: <7m0odb$4nb$1@lublin.zrz.tu-berlin.de>

Adrian Mink <akmink@worldnet.att.net> wrote in comp.lang.perl.misc:
>    Hello,
>
>        I'm running Active Perl Build 517 and have a simple question. I'm
>writing a script to weed bad email addresses out of a list and am looking
>for a way to do a simple comparison against what the basic email address
>should look like. (We have a lot of people who enter their address in
>compleatly wrong, I'd like to weed them out.)

While some of those addresses are probably indeed wrong, there is an
amazing array of strings that *are* valid email addresses.

>        I was thinking of just comparing the address in question against a
>pattern using wildcards ($email == something@something.something) but cannot
>seem to figure out how to do this. Can someone help? Thanks. I am very new
>to Perl and will appreciate any help. Thanks.

This approach (something@something.something) is overly simplistic (or
maybe not, depending on what "something" is supposed to be).

Jeffrey Friedl has constructed a regular expression that parses valid
email addresses (see http://enterprise.ic.gc.ca/~jfriedl/regex/code.html).
It is 28 K long.

Anno


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

Date: Wed, 07 Jul 1999 23:01:32 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl program exist after exec command...
Message-Id: <g%Qg3.42$RX3.2848@nsw.nnrp.telstra.net>

In article <7m0ied$lp1$2@corpnews1.corp.sun.com>,
	saic@shirdi.corp.sun.com (Sai Chimakurty) writes:

>         # Program is aborting after this line..............

It isn't aborting. It is being _replaced_ by the arguments to exec().

>         exec "ps -ef |grep -i $ccmgr_name";

# perldoc -f exec
=item exec LIST

=item exec PROGRAM LIST

The C<exec()> function executes a system command I<AND NEVER RETURNS> -
use C<system()> instead of C<exec()> if you want it to return.
[snip]

Next time, please refer to the documentation first before you post.
The first two lines would have explicitly, in capitals, and empasised
told you that that is the behaviour that exec displays, and what to do
instead.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd.       | enough features yet.
NSW, Australia                      | 


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

Date: 7 Jul 1999 23:03:15 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl program exist after exec command...
Message-Id: <7m0mbj$4l8$1@lublin.zrz.tu-berlin.de>

Sai Chimakurty <saic@shirdi.corp.sun.com> wrote in comp.lang.perl.misc:
>Hi,
>        I am in a process of finding PID through perl program and then
>        issue the PID to the following statements. But the program is
>        exiting after "exec" command in the program.
>
>        I have written the program like this.
>
>        #!/usr/dist/share/perl,v5.003/5bin.sun4/perl -w

Perl sure gets around to see funny places.

>        use strict;
>        use English;
>        use File::Basename;
>        use FileHandle;
>
>        my $basename;
>        $basename = basename("$PROGRAM_NAME", "");
>
>        if (scalar @ARGV != 1)
>         {
>           die "Usage: $basename Concurrent Manager\n";
>         }
>        my $ccmgr_name = shift @ARGV;
>        if (! defined $ccmgr_name)
>         {
>           die "Usage: $basename Concurrent Manager\n";
>         }
>
>        # Program is aborting after this line..............
>
>        exec "ps -ef |grep -i $ccmgr_name";

Well yes.  When you exec a program, the current one is replaced by
the new one.  You want system instead, or probably backticks.

[rest snipped]

Anno


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

Date: Wed, 07 Jul 1999 18:05:39 -0600
From: Ron Reidy <rereidy@uswest.net>
Subject: Re: Problem with a SQL statement in a Perl script
Message-Id: <3783EB53.407139B1@uswest.net>


--------------F1F0C8336711D77996D202AF
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Jeff Pascoe wrote:

> I can't seem to get an embedded SQL statement in my cgi script to work.
> It is written with perl(the script) and is not reporting any errors
> when run. The database is an oracle database and the table is already
> created. If I use a select statement on the same database it works. It
> also works if I run the insert directly from a SQL prompt
> Could someone please tell me what I am doing wrong.
>
> An html form calls the script and passes the $fooval variable
> ******************************************************************
> #!/usr/local/bin/perl -w
>
> use CGI_Lite;
> use DBI;
>
> $ENV{'ORACLE_HOME'} = '/oracle/app/oracle/product/805';
> $ENV{'ORACLE_SID'} = 'wwwdev';
> require ("Library.pl");
>
> 1;
> $|=1;
>
> $dbh = &Connect;
> unless($dbh) {
>    print "Can't connect to database\n";
>    exit 0;
> }
>
> $cgi = new CGI_Lite();
>
> print "Content-type: text/html\n\n";
> $cgi->set_directory ("/www/free/htdocs/db/freeform") || die "Directory
> doesn't exist.\
> n";
> $cgi->add_timestamp (0);
> $cgi->set_platform("UNIX");
> $cgi->set_file_type ("handle");
> %data = $cgi->parse_form_data (); #parses the querystring hash
>
> $cgi->create_variables (\%data); #creates $fooval from the key fooval
>                                  #and assigns it the value of the key
>
> $sql = "INSERT INTO bar (foo) VALUES ('$fooval')";
> $sh = $dbh->prepare($sql);
>  print $dbh->errstr;
> $sh->execute;
>  print $dbh->errstr;
> print "$sql\n";
> print "The fooval is $fooval\n";
> exit (0);
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.

Who are you connecting as in &Connect ?

Does that user have INSERT privileges on the table?

What exactly does your error message say?

BTW - 1.  You really should check the return values of all DBI calls
            2.  Since you are running in CGI, consider using eval { ... }
blocks around your DBI calls to allow you to make use of "die".


--
Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.


--------------F1F0C8336711D77996D202AF
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Jeff Pascoe wrote:
<blockquote TYPE=CITE>I can't seem to get an embedded SQL statement in
my cgi script to work.
<br>It is written with perl(the script) and is not reporting any errors
<br>when run. The database is an oracle database and the table is already
<br>created. If I use a select statement on the same database it works.
It
<br>also works if I run the insert directly from a SQL prompt
<br>Could someone please tell me what I am doing wrong.
<p>An html form calls the script and passes the $fooval variable
<br>******************************************************************
<br>#!/usr/local/bin/perl -w
<p>use CGI_Lite;
<br>use DBI;
<p>$ENV{'ORACLE_HOME'} = '/oracle/app/oracle/product/805';
<br>$ENV{'ORACLE_SID'} = 'wwwdev';
<br>require ("Library.pl");
<p>1;
<br>$|=1;
<p>$dbh = &amp;Connect;
<br>unless($dbh) {
<br>&nbsp;&nbsp; print "Can't connect to database\n";
<br>&nbsp;&nbsp; exit 0;
<br>}
<p>$cgi = new CGI_Lite();
<p>print "Content-type: text/html\n\n";
<br>$cgi->set_directory ("/www/free/htdocs/db/freeform") || die "Directory
<br>doesn't exist.\
<br>n";
<br>$cgi->add_timestamp (0);
<br>$cgi->set_platform("UNIX");
<br>$cgi->set_file_type ("handle");
<br>%data = $cgi->parse_form_data (); #parses the querystring hash
<p>$cgi->create_variables (\%data); #creates $fooval from the key fooval
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
#and assigns it the value of the key
<p>$sql = "INSERT INTO bar (foo) VALUES ('$fooval')";
<br>$sh = $dbh->prepare($sql);
<br>&nbsp;print $dbh->errstr;
<br>$sh->execute;
<br>&nbsp;print $dbh->errstr;
<br>print "$sql\n";
<br>print "The fooval is $fooval\n";
<br>exit (0);
<p>Sent via Deja.com <a href="http://www.deja.com/">http://www.deja.com/</a>
<br>Share what you know. Learn what you don't.</blockquote>

<p><br>Who are you connecting as in &amp;Connect ?
<p>Does that user have INSERT privileges on the table?
<p>What exactly does your error message say?
<p>BTW - 1.&nbsp; You <b>really</b> should check the return values of all
DBI calls
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
2.&nbsp; Since you are running in CGI, consider using eval { ... } blocks
around your DBI calls to allow you to make use of "die".
<br>&nbsp;
<p>--
<br>Ron Reidy
<br>Oracle DBA
<br>Reidy Consulting, L.L.C.
<br>&nbsp;</html>

--------------F1F0C8336711D77996D202AF--



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

Date: Wed, 07 Jul 1999 18:09:28 -0500
From: Michael Carman <mjcarman@zeus.ia.net>
Subject: Re: Problems with derefrencing
Message-Id: <3783DE28.EE410565@zeus.ia.net>

> my $warning = "WARNING LOW DISK SPACE!";
> open (DFOUTPUT, "df -I \| grep dev|") or die "cannot access df!";
> while(<DFOUTPUT>){
>    ($filesystem, $total_kb, $used, $free, $percent_used, $mount_point)
> = split;
>    push( @{$df_output{$mount_point}}, $percent_used);
> }
>
> basically when i try to do a
>
> print $df_output{$mount_point};
>
> it returns a value like ARRAY(hex_code).  I need it to return
> the actual value sourced in there.

It would. Try
    print @{df_output{$mount_point}};
which will print the array elements seperated by spaces.

> when i try to do something like
>
> print $df_output{$mount_point}->[1];
> I get the following error:
> Use of uninitialized value at ./space_check.pl line 36, <DFOUTPUT>
> chunk 12.

Remember that array indices start at 0. Maybe the while() loop only
executed one time and there's nothing at index 1.

It looks like you're dereferencing things correctly. The problem could be
in the while() loop. I'd throw some print statements in there and see what
you're getting in the results of your split. Also run it with -w if you
haven't already.



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

Date: Wed, 07 Jul 1999 18:15:15 -0500
From: Michael Carman <mjcarman@zeus.ia.net>
Subject: Tk::BrowseEntry - Return index instead of value?
Message-Id: <3783DF83.5B342B31@zeus.ia.net>

Okay, I've tried posting this to a couple of other Perl ng's thinking
that it would be more appropriate there but have received no response so
I'm going where there's more traffic and (hopefully) knowledge.
Apologies to anyone who's already seen this elsewhere.

I am just starting to work with Tk. For my first little toy application
I'm using BrowseEntry to make a selection box. This widget normally sets
the associated variable to the value of whichever option is chosen. Can
it return the index instead? Or better yet, an arbitrary value? I've
found nothing in the docs to suggest that
I can do so, but I wouldn't think that it's uncommon to desire this
behavior. What I'm really trying to do is to use a hash to populate the
box, displaying the values to choose from but returning the keys. The
hash is 1:1 so I could make a copy using reverse() and then look up the
key there, but that feels too much like a kludge. Has anyone wrestled
with this before?





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

Date: Wed, 07 Jul 1999 23:45:47 GMT
From: Jordan Hiller <hiller@email.com>
Subject: Re: Weird /x regexps
Message-Id: <3783E6AC.3FC8620B@email.com>

Well, I found the problem, but it sure is strange. Apparently Perl didn't like
me using brackets in my comments. But why would that be a problem? They're
COMMENTS, to be IGNORED, aren't they?

Jordan

Martien Verbruggen wrote:
> 
> In article <3783D4B1.EA3B5006@email.com>,
>         Jordan Hiller <hiller@email.com> writes:
> > Can someone explain why this works:
> >
> > m/^([A-Z]{3,5})([+-]?\d{1,2}\:?\d{0,2})([a-z]{0,5})\s+(.*)$/i;
> >
> > But not this:
> >
> > m/^([A-Z]{3,5})               # comment
> > ([+-]?\d{1,2}\:?\d{0,2})      # comment
> > ([a-z]{0,5})  # comment
> > \s+   # comment
> > (.*)$/ix;     #comment
> 
> Both work fine for me on perl 5.004_04 and 5.005_02. Which version are
> you trying this on? Is this the exact code you are trying to compile?
> 
> Martien

-- 
Jordan Hiller (hiller@email.com)

JavaScript and Perl programs for
 making online tests and quizzes:
http://web-shack.hypermart.net/quiz.html


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 70
************************************


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