[22396] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4617 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 24 18:10:45 2003

Date: Mon, 24 Feb 2003 15:10:12 -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           Mon, 24 Feb 2003     Volume: 10 Number: 4617

Today's topics:
        Long strings're causing problems (aybikem)
    Re: Long strings're causing problems <mfowle@ATnavicominc.dropme.com>
    Re: LWP Requests <bart.lateur@pandora.be>
        Parsing line into hash... <hamish@travellingkiwi.com>
    Re: Parsing line into hash... <nobull@mail.com>
    Re: Parsing Unix mbox in MS Environment <vampire@tiamat.obscure.org>
    Re: Parsing Unix mbox in MS Environment <vampire@tiamat.obscure.org>
    Re: Parsing Unix mbox in MS Environment <tassilo.parseval@post.rwth-aachen.de>
        Perl -- CGI and background process <mlm@nospam.com>
        perlcc error with DBI on Linux <minter@lunenburg.org>
    Re: Pushing onto hash of hash of array <daveh@ci.com.au>
    Re: Q: about opening many processes in parallel as file <goldbb2@earthlink.net>
    Re: setting permissions on my server for cgi (conclusio <cpb6043@osfmail.rit.edu>
    Re: setting permissions on my server for cgi (conclusio <cpb6043@osfmail.rit.edu>
        Splice problem <jon@rogers.tv>
    Re: Splice problem <uri@stemsystems.com>
    Re: Switch order of sprintf conversions <noreply@gunnar.cc>
        Using DBI::mysql <geoff.news6@alphaworks.co.uk>
    Re: Using DBI::mysql <rik.gordon@acm.org>
        Using Perl to parse C buffers under Linux (need help) <topper@virginia.edu>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 24 Feb 2003 12:32:13 -0800
From: aybike2@hotmail.com (aybikem)
Subject: Long strings're causing problems
Message-Id: <a92d90.0302241232.9409a62@posting.google.com>

Hi,

I am quite new to Perl and trying to dig up following issue. Any
insight would be greatly appreciated.

We have been experiencing very strange behaviour in our Perl Scripts. 

There are text fields and text areas that user fill out on the web
using the page written with perl. The values of text fields and text
areas are than written to the Oracle database. Corresponding field's
names and sizes are equal in database with those in the perl code...

The problem comes alive when user enters a long strings into these
fields, this induces cgi-bin database errors. I am trying to figure
out the reason.

My initial thought was the column name in database for the given text
field (or area) might be smaller than the actual value that is
assigned in the Perl code. But the sizes are the same.

Would it be a problem while transfering big chunks of data (long
strings) the system can not handle the job? and than give cgi-bin
database errors?


Thank you in advance.

J.


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

Date: Mon, 24 Feb 2003 21:37:22 GMT
From: Mark <mfowle@ATnavicominc.dropme.com>
Subject: Re: Long strings're causing problems
Message-Id: <194l5vkqa1kv5aaeniiof1tpcof900bvt3@4ax.com>

On 24 Feb 2003 12:32:13 -0800, aybike2@hotmail.com (aybikem) wrote:

>Hi,
>
>I am quite new to Perl and trying to dig up following issue. Any
>insight would be greatly appreciated.
 ....
>Would it be a problem while transfering big chunks of data (long
>strings) the system can not handle the job? and than give cgi-bin
>database errors?
>
>
>Thank you in advance.
>
>J.

there is an extream lack of error messages etal in the request but.

if you say that the lenths are matched, i'll assume you mean that
leterally.
So if the feild name_first is ten characters and I enter a ten
character name. and it is being stuffed into a CHAR(10) data base
field. it might blopw up if you are not removing carage returns.

to remove charage returns:
 $in{'name_first'} = get post data some how;
chomp($in{'name_first'});


Also do not trust html enforsed variable lengths, always test in perl.

Mark



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

Date: Mon, 24 Feb 2003 18:12:40 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: LWP Requests
Message-Id: <03ok5v87ohtao5nhgmghnpqhcpo3o0an58@4ax.com>

Smiley wrote:

>This is the page to search for information:
>
>
>my $req = POST 'http://www.cpso.on.ca/Doctor_Search/ez_srch.asp',

The main text in what I get is:

	 Session has expired.  Please start again.

	20 minutes have elapsed since you last used the system. Your
	 session has been expired, please try again.

You need cookie support.

-- 
	Bart.


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

Date: Mon, 24 Feb 2003 16:30:01 +0000
From: Hamish Marson <hamish@travellingkiwi.com>
Subject: Parsing line into hash...
Message-Id: <3E5A4889.6010105@travellingkiwi.com>


I have a datafile that contains lines in the following format

<IDENT> key value

e.g.

USER HITS fred 22 john 36 joe 33

where key value is repeated many times. I want to read the key value 
pairs into a hash... But am having problems. I'm trying

if ((%userhits) = (/^USER HITS(\s(\w+)\s(\d+))+/)) {

which matches, but doesn't get the desired result of a hash with the 
expected numbers in the expected keys...

How exactly should I do this? I've also tried a while loop inside the if 
using /g but that appears to go into an infinite loop...

eg.

if (/^USER HITS/g) {
   while ((%userhits) = /\s(\w+)\s(\d+)/g) {
     #  printf "Got userhits\n";
   }
   # Never reaches here...


}



TIA

Hamish

-- 

I don't suffer from Insanity... 	| Linux User #16396
	I enjoy every minute of it...	|
					|
http://www.travellingkiwi.com/ 
	|



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

Date: 24 Feb 2003 17:43:31 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Parsing line into hash...
Message-Id: <u9r89xbmm4.fsf@wcl-l.bham.ac.uk>

Hamish Marson <hamish@travellingkiwi.com> writes:

> I have a datafile that contains lines in the following format
> 
> <IDENT> key value
> 
> e.g.
> 
> USER HITS fred 22 john 36 joe 33
> 
> where key value is repeated many times. I want to read the key value
> pairs into a hash... But am having problems. I'm trying
> 
> if ((%userhits) = (/^USER HITS(\s(\w+)\s(\d+))+/)) {
> 
> which matches, but doesn't get the desired result of a hash with the
> expected numbers in the expected keys...
> 
> How exactly should I do this?

In two steps!

TMTOWTDI but IMHO one of the most idomatic is (TMTOWTDIBIMHOOOTMII?)

  # First find the string to the right of 'USER HITS'
  if ( my ($userhits_string) = /^USER HITS\s+(.*)/ ) {
    # Then split that string
    %userhits = split /s+/, $userhits_string;
  }

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 24 Feb 2003 21:14:27 GMT
From: vampire <vampire@tiamat.obscure.org>
Subject: Re: Parsing Unix mbox in MS Environment
Message-Id: <b3e1vj$an9@dispatch.concentric.net>

>> David wrote:
> Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote:

[info on Mail::MboxParser module for reading Unix mail folders]

>> Thanks for the info.  Am I correct in saying that Mail::MboxParser does not
>> return a MIME entity that I could then send to the other code that we have
>> written for dealing with single mails + attachments.  

> No, you are not. It does return MIME::Entity objects if you ask it to
> (get_entities() method on mail objects).

Thanks for the information.  I don't see any information on get_entities in either
in the readme, or in the perldoc but I am working with it now and hopefully won't
have too many issues.  Thanks for your help.

David
 


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

Date: 24 Feb 2003 21:22:58 GMT
From: vampire <vampire@tiamat.obscure.org>
Subject: Re: Parsing Unix mbox in MS Environment
Message-Id: <b3e2fi$an5@dispatch.concentric.net>


[Correction to last post on Mail::MboxParser - news server isn't carrying it yet]

The readme for Mail::MboxParser does in fact have a metion of get_entities

::get_entities (array or scalar if called with a number) 

Thanks
DAvid


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

Date: 24 Feb 2003 22:02:58 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Parsing Unix mbox in MS Environment
Message-Id: <b3e4qi$1i6$1@nets3.rz.RWTH-Aachen.DE>

Also sprach vampire:

> [Correction to last post on Mail::MboxParser - news server isn't
> carrying it yet]
> 
> The readme for Mail::MboxParser does in fact have a metion of get_entities
> 
>::get_entities (array or scalar if called with a number) 

The README is not a replacement for the real documentation. Did you look
in the right class? Try 'perldoc Mail::MboxParser::Mail'. You'll find it
there (among others).

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Mon, 24 Feb 2003 10:32:02 -0600
From: mlm <mlm@nospam.com>
Subject: Perl -- CGI and background process
Message-Id: <ZdOdnQkcbrKf1MejXTWcrg@giganews.com>

I would like to have two perl programs, one to manage a connection to a 
news server, and the other to look after the CGI part.  I want to avoid 
CGI for the news server part to avoid continually opening and closing the 
connection to the news server.

I envisage a program called on first access to the web page which will 
open a connection to the NNTP server and keep it open waiting for 
requests to retrieve particular articles.  A CGI program would take HTTP 
requests and hand them off to the NNTP manager to be serviced and 
returned to the client browser.  Perhaps after 3-400 seconds of no 
activity, the NNTP management program would close the NNTP connection and 
shut itself down.

I am looking for suggestions as to where to start looking to create this 
type of setup.  My real lack of knowledge is in how to kickstart the NNTP 
manager and keep it running on my (remote) unix web server until it 
decides to stop or is told by the CGI program to stop.

Any suggestions or advice would be welcome.

Mark


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

Date: Mon, 24 Feb 2003 21:04:07 GMT
From: "H. Wade Minter" <minter@lunenburg.org>
Subject: perlcc error with DBI on Linux
Message-Id: <bNv6a.41232$Se4.5465738@twister.southeast.rr.com>

I'm playing around with perlcc on the latest Red Hat beta.  It has perl
5.8.0.

I have a simple testcase script here:

#####
#!/usr/bin/perl -w

use DBI;
use DBD::mysql;

print "Connecting...";
$dbh = DBI->connect("DBI:mysql:dbname","dbuser","dbpass");
$dbh->disconnect;
print "Disconnected\n";
#####

Run from the command line via ./dbi.pl, it runs fine, printing the output
with no warnings.

I compile the script by running:

[minter@localhost minter]$ perlcc -o dbi dbi.pl

Then I run the resulting binary, and get:
[minter@localhost minter]$ ./dbi
Undefined subroutine &DBI::dr::connect called at /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/DBI.pm line 513.
Undefined subroutine &DBI::dr::disconnect_all called at /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/DBI.pm line 575.
END failed--call queue aborted.
Connecting...   (in cleanup) Undefined subroutine &DBI::dr::DESTROY called during global destruction.

Does anyone have any suggestions on what's going wrong?

Thanks,
Wade


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

Date: Tue, 25 Feb 2003 09:53:11 +1100
From: Dave Horsfall <daveh@ci.com.au>
Subject: Re: Pushing onto hash of hash of array
Message-Id: <20030225094617.L34195@mippet.ci.com.au>

Many thanks to Tore Aursand and Peter Cooper; I've now got the hang of it!

The "trick" was using @{$...} (in its incarnations).

And apologies to Peter Cooper for the mail blacklisting; I can't control
that.  Seems I can't win; I never saw the responses until I went to Google
Groups, and I never saw your mail :-(

Thanks again.

-- Dave


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

Date: Mon, 24 Feb 2003 16:21:51 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Q: about opening many processes in parallel as filehandles and  win*    OSes
Message-Id: <3E5A8CEF.1CE1BB0D@earthlink.net>

Michele Dondi wrote:
> 
> On Sat, 22 Feb 2003 18:45:45 -0500, Benjamin Goldberg
> <goldbb2@earthlink.net> wrote:
> 
> >   my @p;
> >   local $/;
> >   for( 1 .. 255 ) {
> >      print readline shift @p if @p == 64;
> >      open $p[@p], "-|", "ping $net$_ -c 10"
> >         or die "Couldn't start ping for $net$_: $!\n"
> >   }
> >   print readline $_ for @p;
> >   __END__
> >[untested]
> 
> Fine!! What surprises me more is that the code is not substantially
> more complex than the original one...
> 
> The code works, modulo calling ping as "ping -n 10..." - I tried it on
> Win98.
> 
> As a side note, first I thought of a typo because of the "$p[@p]"
> construct, but then... I learnt something new! And, as usual, when you
> discover this kind of things you say "why didn't I think of it
> myself?"
>
> OTOH, don't you loose, so to say, (approximately) 3/4 of
> parallelization this way? That is 64 pings are started first, but from
> then on a new one is started only as the "first in" terminates - or is
> this utter nonsense?

Yes, you do lose some of the parallelization.  You may be able to
improve the speed slightly by doing this:

   my %p;
   local $/;
   for( 1 .. 255 ) {
      print readline delete $p{wait()} if keys(%p) == 64;
      my $pid = open my($f), "-|", "ping -n 10 $net$_"
         or die "Couldn't start ping for $net$_: $!\n" 
      $p{$pid} = $f;
   }
   print readline $_ for values %p;

This assumes (requires!) that the total amount of data output by each
ping process be small -- not more than the amount that can be written
(without blocking) to a pipe that isn't being actively read from.  On
Windows95, this size is 512 bytes, so with 10 pings per ip, it had
better not print out more than 51 letters per line.

This code change has the effect of printing the results of the first
ping which exits, rather than the first ping which was started.


Although it won't speed up the *total* running time of the process, you
can speed up the apparent rate of output of your program by changing
that last line to:

   print readline delete $p{wait()} while %p;

-- 
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print


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

Date: Mon, 24 Feb 2003 13:02:40 -0500
From: "chris" <cpb6043@osfmail.rit.edu>
Subject: Re: setting permissions on my server for cgi (conclusion)
Message-Id: <3e5a5dbc@news.isc.rit.edu>

i have finally discovered the sources of all my problems! it turns out that
it wasn't my script, or the permissions, at all!

no, in fact, it was the encoding. i had the idea to try loading up my script
through pico after i uploaded it to the server, and it looked like this:

#-

just that! everything else somehow got erased! so i retyped it in pico,
saved it, and lo and behold! bingo! i'm so happy!

so, any ideas as to what format i should save my scripts? that's what i'm
testing now.




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

Date: Mon, 24 Feb 2003 13:15:31 -0500
From: "chris" <cpb6043@osfmail.rit.edu>
Subject: Re: setting permissions on my server for cgi (conclusion)
Message-Id: <3e5a60cf@news.isc.rit.edu>

ok, sorry for double post, but i know what i'm doing now. the ascii data
mode supported by ftp uploads it fine, it's when i try to upload it through
windows' ftp explorer interface it doesn't upload it in the correct data
mode (probably unicode or something else). so i tried uploading it using dos
ftp and it worked fine, i checked it afterwards in pico.

curse you windows!




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

Date: Mon, 24 Feb 2003 18:09:55 +0100
From: Jon Rogers <jon@rogers.tv>
Subject: Splice problem
Message-Id: <3E5A51E2.1B1608BE@rogers.tv>

Hi

I can't seem to get splice to work:

my @array=('aaaaa','bbbbb','ccccc','dd','eeeee','fffff','ggggg');

my $length = scalar @array -1;
my $i;

for ($i=0 ; $i<=$length; $i++) {

  if (length $array[$i] <5) {
      @array = splice (@array, $i+1,$i+2); } }


Having read the docs, I'd say this should take away the element
containing 'dd' and leave the rest. But this is what i get when i ask it
to print @array:

eeeee fffff ggggg
 
What should I do to get it to remove only the 'dd' element?

/ Jon


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

Date: Mon, 24 Feb 2003 17:11:00 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Splice problem
Message-Id: <x78yw5mwnw.fsf@mail.sysarch.com>

>>>>> "JR" == Jon Rogers <jon@rogers.tv> writes:

  JR> I can't seem to get splice to work:

  JR> my @array=('aaaaa','bbbbb','ccccc','dd','eeeee','fffff','ggggg');


	my @array= qw( aaaaa bbbbb ccccc dd eeeee fffff ggggg );

  JR> my $length = scalar @array -1;

bah. that is not the length of the array. that is the index of the last
element. the scalar is not needed as the + (or just the =) provides
scalar context.

  JR> my $i;

  JR> for ($i=0 ; $i<=$length; $i++) {

why this loop? you claim you only want to remove 'dd'. 

  JR>   if (length $array[$i] <5) {

now you seem to want to remove any short elements. you didn't state
that. in any case, think about the $i value. it will range from 0 to
4. but if you shrink the array it will index past the end of it. so this
logic is broken.


  JR>       @array = splice (@array, $i+1,$i+2); } }

rtfm more carefully. the second arg to split is the index. if $i is 0
then why do you add 1 to it for the index? the third arg to splice is a
length, not an ending index. so your length will be based on where you
are in the loop. the length here should be just 1.

  JR> Having read the docs, I'd say this should take away the element
  JR> containing 'dd' and leave the rest. But this is what i get when i ask it
  JR> to print @array:

  JR> eeeee fffff ggggg
 
  JR> What should I do to get it to remove only the 'dd' element?


don't use splice. looping in perl for this is slow and clumsy. grep is
what you want.

	@array = grep length < 5, @array ;

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class


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

Date: Mon, 24 Feb 2003 22:07:44 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Switch order of sprintf conversions
Message-Id: <b3e2bu$1kmjp8$1@ID-184292.news.dfncis.de>

Benjamin Goldberg wrote:
>    http://www.perldoc.com/perl5.8.0/pod/func/sprintf.html

Thanks. I think www.perldoc.com was temporarily down yesterday.

> Taking into account the use of the *other* places where \d+\$ can occur
> would make the function more complicated, but it's still doable:
> 
> sub sprintfmt {
>    my $fmt = shift;
>    my ($i, @p) = 0;
>    $fmt =~ s[(
>       %
>       (?:(\d+)\$)?
>       [-+ 0#]*
>       (?:(?:\*(?:\d+\$)?)?v)?
>       0?
>       (?:\d+|\*(?:\d+\$)?)?
>       (?:\.(?:\d*|\*(?:\d+\$)?))?
>       [hlqLV]?
>       [%bcdefginopsux_DFOUX]
>    )]{
>       my $use_i = !$2;
>       my $pat = $1;
>       push @p, $1-1 while $pat =~ s/(\d+)\$//;
>       push @p, $i++ if $use_i;
>       $pat;
>    }xge;
>    sprintf $fmt, @_[@p];
> }
> __END__
> [untested]
> 
> How's that for complicated? :)

Yeah, now I don't fully understand, so I feel as usual, sort of. :(

The v5.8 sprintf docs includes a few more examples in the section "order 
of arguments", and the above code failed the last of them when I tested.

However, right now I'm only using the %s and %d conversions in the 
strings that will be passed to the 'sprintfmt' function, and I can't 
think of any need to include other attributes but the format parameter 
index, so I think that a slightly modified version of your "simple" 
function is all that's needed:

     sub sprintfmt {
       my $fmt = shift;
       return sprintf $fmt, @_ if $] >= 5.008;
       my ($i, @p) = 0;
       $fmt =~ s{((?:^|[^%])%)(?:(\d+)\$)?([sd])}
                { push @p, $2 ? $2-1 : $i++; $1.$3 }ge;
       sprintf $fmt, @_[@p];
     }

>>I can't help wondering if the behaviour is intended, or if it is a
>>bug. Do you know how to find somebody who would be able to tell?
> 
> I suppose that the person who put it in... I've been trying to look
> through the Changes5.8 file, but it's a gargantuan file.  I suppose that
> if you really want to know, I could go ask on the perl5porters mailing
> list, to find out how put it in.

No need to; the v5.8 sprintf docs is clear about the intended behaviour, 
and after having studied it, I'm convinced that it's not a bug.

One conclusion is that I'd better instruct the translators to add format 
parameter indices to *all* the conversions in a string when reordering.

Thanks, Benjamin, for all your valuable help!

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Mon, 24 Feb 2003 21:55:33 -0000
From: "Geoff Soper" <geoff.news6@alphaworks.co.uk>
Subject: Using DBI::mysql
Message-Id: <3e5a94d4$0$6303$cc9e4d1f@news.dial.pipex.com>

I'm making a first attempt at using DBI:mysql. Given a table with two text
columns, one called username and one called user_cookie where the entries in
each column are unique what is the best way to extract the value of
first_name for a given username? The code asI think it should be is below
with a comment showing where I am stuck!

Many thanks
Geoff

**********************************

#!/usr/bin/perl -Tw
use strict;
use CGI qw(:all);
use DBI();

my $dbh = DBI->connect("DBI:mysql:database=xxxx;host=xxxx",
     "xxxx", "xxxx",
     {'RaiseError' => 1});
my $first_name = $dbh->prepare ( "SELECT first_name FROM users WHERE
username = \'geoff\'");

#What do I need here??

print +(header),
  start_html("Database test"),
  h1("Database test"),
  p("First name = $name_value"),
  end_html;

$dbh->disconnect();





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

Date: Mon, 24 Feb 2003 22:54:45 +0000 (UTC)
From: "Rik Gordon" <rik.gordon@acm.org>
Subject: Re: Using DBI::mysql
Message-Id: <b3e7rk$cic$1@venus.btinternet.com>

Hi Geoff,

Firstly you have only *prepared* your SQL statement you need to execute
with:

$first_name->execute();

You then need to decide how you want the data returned.  Personally I find
it easiest to return the records using a hashref, as in the following
example:

while($data=$first_name->fetchrow_hashref())
{
  print "$data->{datafieldname}\n";
}

In the above datafieldname is the name of a field in your database, the
while loops around all the records returned in your select printing only
this one field.

If this makes no sense, email me and I'll send you a complete working
example.

Regards,
Rik Gordon

Geoff Soper <geoff.news6@alphaworks.co.uk> wrote in message
news:3e5a94d4$0$6303$cc9e4d1f@news.dial.pipex.com...
> I'm making a first attempt at using DBI:mysql. Given a table with two text
> columns, one called username and one called user_cookie where the entries
in
> each column are unique what is the best way to extract the value of
> first_name for a given username? The code asI think it should be is below
> with a comment showing where I am stuck!
>
> Many thanks
> Geoff
>
> **********************************
>
> #!/usr/bin/perl -Tw
> use strict;
> use CGI qw(:all);
> use DBI();
>
> my $dbh = DBI->connect("DBI:mysql:database=xxxx;host=xxxx",
>      "xxxx", "xxxx",
>      {'RaiseError' => 1});
> my $first_name = $dbh->prepare ( "SELECT first_name FROM users WHERE
> username = \'geoff\'");
>
> #What do I need here??
>
> print +(header),
>   start_html("Database test"),
>   h1("Database test"),
>   p("First name = $name_value"),
>   end_html;
>
> $dbh->disconnect();
>
>
>




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

Date: Mon, 24 Feb 2003 15:55:27 -0500
From: "David J. Topper" <topper@virginia.edu>
Subject: Using Perl to parse C buffers under Linux (need help)
Message-Id: <3E5A86BF.8060300@virginia.edu>

Hi folks,

I've been looking at "man perl_embed" and having some luck.  IE., I can 
get things to compile.  But I am at a loss to really make things work. 
Here's the background:

1.  I have an old C program which uses its own parser.  I've managed to 
change it so that I can:

	P_PROG < text.pl

and it now uses perl to parse the file and trigger PROG's functions. 
Woohoo!

But what I'd like even more now is to be able to have a function whereby 
I can say:


	parse_buf(*inbuf);

where inbuf is a string buffer containing a valid perl script.  I'm 
trying stuff like the following:

int perl_parse_buf (char *inBuf) {
	dSP;
	STRLEN n_a;
	SV *command = NEWSV(1099, 0);

	char *embedding[] = { "", "-e", "0" };
	
	perl_interp = perl_alloc();
	perl_construct( perl_interp );
	
	perl_parse(perl_interp, NULL, 3, embedding, NULL);
	PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
	perl_run(perl_interp);

	sv_setpv(command, inBuf);
	eval_sv(command, TRUE);

	
	return 0;
}

but it doesn't seem to be working.  I'd love to hear from people with 
some input on teh subject.

Thanks,

DT
--
Technical Director, Virginia Center for Computer Music



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

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


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