[16936] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4348 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 17 11:05:22 2000

Date: Sun, 17 Sep 2000 08:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <969203107-v9-i4348@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 17 Sep 2000     Volume: 9 Number: 4348

Today's topics:
        Annoying quotation marks! <tigz@ntlworld.com>
    Re: Controlling another program zolakk@geocities.com
        Graphical Perl?? <kyle@iol.ie>
    Re: Graphical Perl?? <bowman@montana.com>
    Re: help please - error: Can't locate loadable object f <gellyfish@gellyfish.com>
    Re: how to insert an HTML page into another perl genera <gellyfish@gellyfish.com>
    Re: Is this terribly inefficient? <gellyfish@gellyfish.com>
    Re: Just curious.. <ren.maddox@tivoli.com>
    Re: Just curious.. <gellyfish@gellyfish.com>
    Re: Just curious.. (Mike Stok)
        Life of a perl script mufy@my-deja.com
    Re: Load graphic from form data <gellyfish@gellyfish.com>
    Re: Mail::Mailer the Only Way? <gellyfish@gellyfish.com>
    Re: open(FNAME...) versus FileHandle <gellyfish@gellyfish.com>
        Page faults on Win98 when using Glob, backticks <marlowe@labyrinth.net.au>
        Parse::RecDescent: Problem with a Grammar <stephen@twocats.dont-spam.demon.co.uk>
    Re: perl and mysql <gellyfish@gellyfish.com>
        Possible to generate html frames from perl ??? (Alone)
    Re: syslog in perl <gellyfish@gellyfish.com>
    Re: Variable Substitution (Keith Calvert Ivey)
    Re: which the best scripting language? (Jon Bell)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 17 Sep 2000 14:17:28 +0100
From: "Tigz" <tigz@ntlworld.com>
Subject: Annoying quotation marks!
Message-Id: <_v3x5.3438$ap5.58124@news6-win.server.ntlworld.com>

In my chat room i have just setup at (http://www.tiger.ltpage.net) when a
message has been submited it adds quotation marks round the message like so:
Tigz:"what u was doing to the cgi"

Could somebody please tell me how to remove them, and also tell me how to
change the font and size.

Thanks,
Mick

This is the output for the new message file:

 open (NEW, ">$filepath$formdata{'room'}$filext");
 print NEW '<HTML><HEAD><META HTTP-EQUIV="Refresh" CONTENT="4"></HEAD><BODY
BGCOLOR="#FFFFFF">';
 print NEW "\n";
 if ($iecompatible) {
  print NEW "\<BR\>\<B\>$formdata{'username'}\</B\>";
  print NEW "<b\>:</b\>\"";
  print NEW "$formdata{'message'}";
  print NEW "\"\n";
  for ($i = 1; $i < 30; $i++)
  {
      print NEW "$lines[$i]";}}
 print NEW "\n";
 close(NEW);




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

Date: Sun, 17 Sep 2000 14:09:53 GMT
From: zolakk@geocities.com
Subject: Re: Controlling another program
Message-Id: <jsj9ss4c8qvh7ddeh5v6abeqg50ofncm0h@4ax.com>

On Sun, 17 Sep 2000 06:17:38 GMT, "Philip Garrett"
<philipg@atl.mediaone.net> wrote:

><zolakk@geocities.com> wrote in message
>news:hak8ss42jh2i2285h5j9lerh0rk2d5tqdq@4ax.com...
>> As a part of learning how to program in Perl, I have decided to write
>> a front end program for the program mpg123 (someday I will have an MP3
>> box on my stereo system). I got nearly everything working just fine,
>> with a bit of research. My only question is how would I go about
>> passing commands to it (for pause, stop, etc) I can play files just
>> fine, but have to wait for the program to finish, (and end) before
>> continuing with anything else. I am guessing that I would need to use
>> fork() or something simillar (anyone have a good explanation of that
>> anyway? everything I read on that seemed a bit confusing) or maybe
>> even pipe()? From what I understand, with a fork, the parent program
>> (mine, I assume) recieves signals from the child (mpg123 in my case),
>> so what I need to do is just the opposite? or, does anyone know of a
>> console mp3 player that would lend itself to this kind of thing
>> easier?
>
>I know absolutely nothing about mpg123, but it it's normally driven by
>keystroke commands from a terminal, you can use the Expect module.  Look it
>up on CPAN.  Last time I tried it, it wasn't as fully-implemented as the
>Expect extension to Tcl, but it can probably do the job.
>
>hth,
>p
>

According to some documentation I found on mpg123, I guess it can be
controlled remotely by <STDIN>, <STDOUT>, and <STDERR>. Would I still
use this module to do this? I read the documentation on Expect, and it
looks like a cool module to play with, but if the program responds to
the STD's, isn't that what fork() or something equivalent is for?
Also, is there a way to pipe (for a lack of words) the text generated
by the program, to a different location, or is that dependant on the
program, not mine?


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

Date: Sun, 17 Sep 2000 13:43:33 GMT
From: Kyle Parfrey <kyle@iol.ie>
Subject: Graphical Perl??
Message-Id: <39C4C9F4.A137BDBA@iol.ie>

Hi all Perl people:
I am a programming beginner just coming over to perl from a bit of java,
liking perls control of the system a lot.  Two questions though:

1) Is there a graphical toolkit for perl? I have heard something about
Tk, but don't know what it is. Is it as easy to use as java's integrated
gui widgets?

2) I think this is partially covered by another post: I want to let my
perl program control another command line application. Is it possible
for perl to open another program , and then enter things in the other
programs command prompt? Also would it be possible for my script to open
a new terminal window , and have the second application running there?
I'm using linux.

Thanks,
Kyle


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

Date: Sun, 17 Sep 2000 08:04:09 -0600
From: "bowman" <bowman@montana.com>
Subject: Re: Graphical Perl??
Message-Id: <v44x5.1903$JV3.6183@newsfeed.slurp.net>


Kyle Parfrey <kyle@iol.ie> wrote in message news:39C4C9F4.A137BDBA@iol.ie...
> 1) Is there a graphical toolkit for perl? I have heard something about
> Tk, but don't know what it is. Is it as easy to use as java's integrated
> gui widgets?

comp.lang.perl.tk

It isn't as rich a widget set as Swing, but is easier to use and runs
faster. Conceptually, it is similar to Java.

> 2) I think this is partially covered by another post: I want to let my
> perl program control another command line application. Is it possible
> for perl to open another program , and then enter things in the other
> programs command prompt?

Yes. Depending on the complexity of your app, you might want to look
at one of the Expect bindings, or at least the Expect source if you need
the whole pty thing. Otherwise, just an open with the pipe option or
one of the IPC::popens might do the trick.





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

Date: 17 Sep 2000 15:28:54 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: help please - error: Can't locate loadable object for module.
Message-Id: <8q2kf6$e4p$1@orpheus.gellyfish.com>

In comp.lang.perl.misc Nico F Zigouras <zigouras@mail.med.upenn.edu> wrote:
> I am wondering if some one can help.  I just installed DBD::DB2 and got
> this error:
> 
> Can't locate loadable object for module DBD::DB2::Constants in @INC (@INC
> contains: /usr/local/lib/perl5/5.00503/sun4-solaris /usr/local/lib/perl5/5.00503
> /usr/local/lib/perl5/site_perl/5.005/sun4-solaris
> /usr/local/lib/perl5/site_perl/5.00
> 5 .) at /usr/local/lib/perl5/site_perl/5.005/sun4-solaris/DBD/DB2.pm line
> 25
> BEGIN failed--compilation aborted at
> /usr/local/lib/perl5/site_perl/5.005/sun4-s
> olaris/DBD/DB2.pm line 25.
> BEGIN failed--compilation aborted at -e line 1.
> 

This looks like the module hasnt been installed properly - I would reinstall
in the first place.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: 17 Sep 2000 12:25:11 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: how to insert an HTML page into another perl generated HTML page
Message-Id: <8q29mn$dou$1@orpheus.gellyfish.com>

On Sat, 16 Sep 2000 14:26:59 +0700 Dimitri wrote:
> How to insert an HTML page into another perl generated HTML page ?
> I think I need to remove what is not in the <body> of the page first?
> How to do?  (Beginner) Thank you.  Dimitri.

You probably want to use HTML::Parser to do this .  In the first instance
you might want to search Deja news for examples in this group.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: 17 Sep 2000 12:16:29 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Is this terribly inefficient?
Message-Id: <8q296d$do4$1@orpheus.gellyfish.com>

On Sun, 17 Sep 2000 11:09:53 +1000 Stephan Carydakis wrote:
> Hello All,
> 
> I have written a sort subroutine which I think maybe a little inefficient.
> Why do I think it's inefficient? Well, $a/$b are entire records from a flat
> file db(1 line per record) and I use re's to extract the dates from the
> record which I then split up into day/month/year using re's again. Is this
> inefficient? Could someone suggest a better way?
> 
> My code:
> 
> sub byDate {
> 
>     my ($dateA, $dateB, $yearA, $yearB, $monthA, $monthB, $dayA, $dayB);
> 
>     $a =~ m/.*?\|.*?\|.*?\|(.*?)\|.*/;
>     $dateA=$1;
> 
>     $b =~ m/.*?\|.*?\|.*?\|(.*?)\|.*/;
>     $dateB=$1;
> 
>     $dateA =~ m|(.*?)/(.*?)/(.*)|;
>     ($dayA,$monthA,$yearA)=($1,$2,$3);
> 
>     $dateB =~ m|(.*?)/(.*?)/(.*)|;
>     ($dayB,$monthB,$yearB)=($1,$2,$3);
> 
>     $yearB <=> $yearA
>                 ||
>     $monthB <=> $monthA
>                 ||
>     $dayB <=> $dayA;
> 
> }

For even a moderately sized data set you should probably consider doing
the key extraction prior to doing the sort and simplifying the sort sub
considerably - a quick example might be :


#!/usr/bin/perl -w

use strict;

my @sorted = map  { $_->[3] }
             sort {
                    $b->[2] <=> $a->[2]
                    ||
                    $b->[1] <=> $a->[1]
                    ||
                    $b->[0] <=> $a->[0]
                 }
             map { [ split( '/',(split /\|/,$_)[3]), $_ ] }
             <DATA>;
print @sorted;
__END__
blah|woof|zub|21/04/1993|cow
blah|woof|zub|09/03/1993|cow
blah|woof|zub|09/03/1993|cow
blah|woof|zub|06/06/1993|cow
blah|woof|zub|20/02/1993|cow
blah|woof|zub|18/01/1993|cow
blah|woof|zub|18/01/1993|cow
blah|woof|zub|17/01/1993|cow
blah|woof|zub|01/12/1992|cow
blah|woof|zub|09/08/1993|cow
blah|woof|zub|09/06/1993|cow
blah|woof|zub|09/06/1993|cow
blah|woof|zub|15/11/1992|cow
blah|woof|zub|15/11/1992|cow

Of course it might even further simplify the sort sub if one was to
decompose the sort keys to the epoch time using Time::Local .  The type
of technique I have presented here (known as a Schwartzian Transform) is
only one way  - there is also the Guttman-Rosler transform which uses
packed sortkeys with the aim of doing away with the sort sub altogether 
among other things.  You will want to read the section in perlfaq4 about
sorting and also Larry & Uri's award winning paper on the matter of sorting,
I can't remember the URL of the latter but I am sure someone will post it.

/J\

   
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: 16 Sep 2000 23:33:11 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Just curious..
Message-Id: <m3r96jbptk.fsf@dhcp11-177.support.tivoli.com>

halofive <halo_five@my-deja.com> writes:

>  Hello, I've been bugged to death by something in perl, dealing with
> Hashes.  It's pretty irrelavent, I suppose but I'm curious all the same.
> 
> Summary of problem:
> %hash = ("one", "two", "three")
> # Notice that there's an odd number, Key "three" returns Unef
> 
> With that, here's the problem... If I wanted $hash{} to return "three",
> how would I go about doing so?  Would $hash{""} do the trick, or is it
> not that simple?

Given that you already stated that "three" is a key of the hash, why
would you expect $hash{blah} to return three (for any "blah")?  Using
"keys %hash" will certainly include "three" in the output.  Is that
what you want?  If not, then give an example of a "blah" such that
$hash{blah} returns "one" so that I can better understand what you are
trying to get.

-- 
Ren Maddox
ren@tivoli.com


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

Date: 17 Sep 2000 10:57:26 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Just curious..
Message-Id: <8q24i6$dh9$1@orpheus.gellyfish.com>

On Sat, 16 Sep 2000 23:35:56 GMT halofive wrote:
>  Hello, I've been bugged to death by something in perl, dealing with
> Hashes.  It's pretty irrelavent, I suppose but I'm curious all the same.
> 
> Summary of problem:
> %hash = ("one", "two", "three")
> # Notice that there's an odd number, Key "three" returns Unef
> 

If you had used the '-w' switch then you would have been warned about
having an odd number of elements.

> With that, here's the problem... If I wanted $hash{} to return "three",
> how would I go about doing so?  Would $hash{""} do the trick, or is it
> not that simple?
> 

If you must do this and want to retrieve the key then you should use the
keys() operator.  If you want to hold more than one value for a given
key then you should use an array reference :

  %hash = ('one' => ['two','three']);

You will probably benefit from reading the perldata and perldsc manpages.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Sun, 17 Sep 2000 14:41:35 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Just curious..
Message-Id: <zK4x5.5510$3y3.142875@typhoon.austin.rr.com>

In article <8q104r$sa2$1@nnrp1.deja.com>,
halofive  <halo_five@my-deja.com> wrote:
> Hello, I've been bugged to death by something in perl, dealing with
>Hashes.  It's pretty irrelavent, I suppose but I'm curious all the same.
>
>Summary of problem:
>%hash = ("one", "two", "three")
># Notice that there's an odd number, Key "three" returns Unef
>
>With that, here's the problem... If I wanted $hash{} to return "three",
>how would I go about doing so?  Would $hash{""} do the trick, or is it
>not that simple?

When you initialise a hash from a list then the list is interpreted as key
/ value pairs, so when you say

  %hash = ('one', 'two', 'three');

the 'three' is a key, not a value.  If you use the debugger (use perldoc
perldebug to get instructions on whatyou can do with the debugger supplied
with perl) then you can try things out and see what's happening:

  DB<1> %hash = ('one', 'two', 'three')

  DB<2> X hash
%hash = (
   'one' => 'two'
   'three' => undef
)
  DB<3> 

If you *really* want the final element in a list with an odd number of
elements to be a hash value then you will have to do some work
yourself.  The perldata manual page might be a good place to start.

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |
GPG PGP Key 1024D/059913DA         | Fingerprint      0570 71CD 6790 7C28 3D60
stok@colltech.com (CT - work)      |                  75D2 9EC4 C1C0 0599 13DA


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

Date: Sun, 17 Sep 2000 13:53:30 GMT
From: mufy@my-deja.com
Subject: Life of a perl script
Message-Id: <8q2ick$gi6$1@nnrp1.deja.com>

I want to run a perl script once every day.
Presently I have to make my browser point to the
location of the script every day in order to run
it.
Is there a way to automate this ?
I do not have cron access to the server where the
script is hosted, so I was thinking of using
something like a sleep or suspend in my script,
but I do not know the right function to call.
This means that I need to extend the life of the
script. I need a method to suspend execution of
the script for 24 hours and resume it the next
day but I dont know how to do it.

Any help to show how this could be programmed in
the script or other ideas would be very helpful.

Please mail responces to mufy@techie.com

Thanks in advance,
Mufy.




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


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

Date: 17 Sep 2000 15:15:09 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Load graphic from form data
Message-Id: <8q2jld$e41$1@orpheus.gellyfish.com>

On Sat, 16 Sep 2000 20:38:09 GMT tayloremail@netscapeonline.co.uk wrote:
> Hi all.
> I have a form that allows the user to select different options for a
> product.
> When all the selections are complete, and the user clicks the
> appropriate button, I want to load a flash movie to show what they have
> selected graphically.
> I will have a few different movies, each showing the selected product
> with different options.
> 
> I need a script to proces the form data, deceide which movie should be
> displayed, then upload it and display it.
> 
> Does anyone know of an example script that does this, or can anyone help
> me write one from scratch?

Its just a matter of outputting the appropriate HTML using print() - if
you need to find what the appropriate HTML would be you will want to ask
in comp.infosystems.www.authoring.html .

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: 17 Sep 2000 10:28:44 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Mail::Mailer the Only Way?
Message-Id: <8q22sc$df7$1@orpheus.gellyfish.com>

On Fri, 15 Sep 2000 21:09:35 GMT rathmore@tierceron.com wrote:
> 
> I'm getting the following error when I run a test script that I got
> from the Cookbook:
> 
> C:\Projects\Test Programs>perl -w mail_test.pl
> 
> Odd number of elements in hash assignment at
> C:/Perl/lib/Mail/Mailer/smtp.pm line 13.
> 
> Invalid argument at C:/Perl/lib/Mail/Mailer.pm line 270.
> 
> Here is the script I'm using:
> 
> use Mail::Mailer;
> 
> $from_address = "rathmore\@tierceron.com";
> $to_address = "wrathmolten\@hotmail.com";
> $subject = "Mail Test";
> $body = "This is the body. It's pretty nice, eh?\n";
> 
> $mailer = Mail::Mailer->new("smtp", "mail.tierceron.com");

That should be :

  $mailer = Mail::Mailer->new('smtp', Server => 'mail.tierceron.com');

The @args to new() are in key => value pairs.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: 17 Sep 2000 15:09:13 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: open(FNAME...) versus FileHandle
Message-Id: <8q2ja9$e3c$1@orpheus.gellyfish.com>

On Sat, 16 Sep 2000 11:25:15 GMT Brendon Caligari wrote:
> 
> 
> so far, for source code manageability, I've been localising file
> handles in subroutines.
> 
> what is the recommended practice?  To keep on doing so, or
> "use FileHandle"?
> 

With 5.6.0 you get get autovivification of file handles so you can use
a lexical variable as a filehandle :

{
  my $handle;
  open($handle,">blah") || die "Can't open file - $!\n";
  print $handle "Blah blah";
}

That might help.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Mon, 18 Sep 2000 00:33:04 +1100
From: Rohan Parkes <marlowe@labyrinth.net.au>
Subject: Page faults on Win98 when using Glob, backticks
Message-Id: <MPG.142f731fd8e2c5c19897ef@news.labyrinth.net.au>

I'm learning Perl on a Win98 machine.  However, when I try to use any 
function that accesses the file system, I always get a page fault.  The 
code involved is fairly uncontroversial code taken from the Randal 
Schwartz book (the one about Perl on Win 32) and a few others, eg

sub init_words {
	while (defined($filename = glob("*.sec"))){
		open (WORDSLIST, "wordslist.txt") || die "Can't open 
$filename: $!";
		if (-M WORDSLIST <= 7.0) {
		   while (defined ($name = <WORDSLIST>)) 
{		#check that a value is returned
		   		 chomp ($name);
		   		 $word = <WORDSLIST>;
		   		 chomp($word);
		   		 $words{$name} = $word;
		   		 }
		}
		close (WORDSLIST) || die "Couldn't close wordslist.txt: 
$!";
	}
}

Glob functions and backticks seem to cause it. Everything else seems 
fine. Is there anything I need to configure to make these functions work?
-- 
Rohan Parkes
Melbourne
Australia


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

Date: Sun, 17 Sep 2000 14:56:34 +0100
From: "Stephen Collyer" <stephen@twocats.dont-spam.demon.co.uk>
Subject: Parse::RecDescent: Problem with a Grammar
Message-Id: <969199113.10661.0.nnrp-07.9e98901a@news.demon.co.uk>


I'm trying to write a grammar that parses a subset of C
style function calls and I'm falling over on a fairly basic
problem - the grammar doesn't recognize embedded
function calls like:

abc( def() )

I've tried running the thing with RD_TRACE switched on,
but I can't see where things go wrong from that. Anyone
got any ideas ? My head's spinning from staring at this.
(The grammar is below).

And I've got a couple of questions about the use of rulevars.

1. Parse::RecDescent seems to get shirty about unqualified
rulevars unless they are localized (e.g. <rulevar: local $var>) but
the documentation doesn't seem to mention this AFAIK.
What's going on here ? In fact, the docs say that "all such variables
are "my" variables" which seems to run counter to the requirement
to localize them.

2. Is there any reason to use rulevars rather than variables in main::
or wherever ? It's not clear to me why Parse::RecDescent supports
them. Is it just a question of avoiding the use of a more global
variable, or is there some deeper reason ?

And here's the code that's giving me problems.

===================================================

my $func_grammar = q{

    Function: <rulevar: local @Args>

    Function: Identifier ArgList


                    return { FuncName => $item[1],
                              ArgNames => [ @Args ] };
                  }

    ArgList: '(' Arg(?) (Sep Arg)(s?) ')'

    Arg:  Quote

                        push @Args, $item[1];
                      }
        | Function
        | Identifier

                        push @Args, $item[1];
                      }

    Identifier: /\w+/

    # stolen from demo_decomment.pl

    Quote : m{"             # a leading delimiter
               ((                  # zero or more...
                 \\\\.             # escaped anything (need multiple \ here
?)
                 |                 # or
                 [^"]             # anything but a delimiter
                )*
               )
              "}x

    Sep: ','

};

===================================================

Steve Collyer




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

Date: 17 Sep 2000 11:25:29 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: perl and mysql
Message-Id: <8q266p$dji$1@orpheus.gellyfish.com>

On Sun, 17 Sep 2000 02:52:58 GMT pohanl@my-deja.com wrote:
> 
> 
> In a tied hash to a database, you can check for the existence of
> a key by the following...
> 
> if (defined $database{$key}) { bla bla bla }
> 
> If you have a mysql database instead, how do you check for the
> existence of a field value in a table?  example,
> if i have a table with one field called "name", how do
> I check if there is a value of "name" called "john"?
> 
> (given a $dbh->do or $dbh->prepare/execute statement).
> 

This is really an SQL question - you will probably use a query such as:

  SELECT COUNT(*) FROM table WHERE name = "john"

and you will get a value returned which will be 0 if no such row exists
and more than 0 if one does (possibly 1 if the column is a unique key).
> 
> 
> Also, how do you check if a table actually exists in the database
> schema?  for example, if you do a "show tables" it shows you all
> the tables.  but I would like a statement where I basically check
> for the validity of one table.  like  "does table customers exists?"
> and pass this sql statement to the database.

There may well be some MySQL specific extension that allows you to do
this - you will be able to find this out from the MySQL documentation.
DBI has some methods categorized as Experimental that can return
information about the tables in a database, though being experimental
they may be removed from future releases of DBI - you can read about these
in the DBI manpage.  In the absence of any such facility you might want
to do a query that uses the table and check if any errors returned indicate
that the table doesnt exist - If you have set the RaiseError option on the
database handle you will need to do this is an eval block to prevent it
from terminating your program.  The appropriate errors are discussed in
the MySQL documentation.

> 
> lastly, given a execute, and you followup with a fetch, how
> do you convert the results into an array?  like..
> select phone from customer table where customertype is adult.
> (only one phone returned per row, but there could be multiple customers
> that are adult).
> 

push() the appropriate values onto the array - or use the fetchall_arrayref
method as described in the DBI manpage.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Sun, 17 Sep 2000 14:20:49 GMT
From: Alone@Work.com (Alone)
Subject: Possible to generate html frames from perl ???
Message-Id: <39c4cb8e.51769585@news.reliable-net.net>


Is it possible to generate an html frameset without writing to a file?



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

Date: 17 Sep 2000 10:24:23 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: syslog in perl
Message-Id: <8q22k7$de0$1@orpheus.gellyfish.com>

On Sun, 17 Sep 2000 03:06:04 GMT Dave Sherohman wrote:
> On 16 Sep 2000 12:56:28 GMT, Robert Jan Schaper <r.schaper@chello.nl> wrote:
>> Try to set the to unix instead of the default inet:
>> 
>> 	Sys::Syslog::setlogsock('unix'); 
> 
> Yep, that did it - thanks!
> 
> Now the inevitable followup questions:
> 
> 1)  If the machine is using a remote log host, will this still work?  I would
> assume so, since the perl script would (presumably) use a unix socket to
> connect to the local syslogd, which would then use an inet socket to connect
> to the log host's syslogd, but I'm not certain that it works that way.
> 
> 2)  Why would I not be able to log using an inet socket, particularly when
> the script is running as root?
> 

The syslogd needs to be started to receive log messages from the network -
on my system this means supplying the '-r' switch to syslogd on startup -
you will probably want to check then syslogd manpage on your system - you
will probably find that this also describes how you would configure syslog
to log to a remote host.

> 3)  If inet is more likely to have problems, why is it the default?  Is it
> just because unix domain sockets don't exist under Win32 or is there some
> other reason?

I am not absolutely sure but I think that it probably is because that on
certain systems the internet domain socket connection is the default - it
seems that it is largely on Linux that the unix domain socket is the default.

/J\

-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Sun, 17 Sep 2000 14:14:26 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Variable Substitution
Message-Id: <39c5cf15.83928331@news.newsguy.com>

Stephen Daniel Wells <wells@cedarnet.org> wrote:

>I'm sure that Tom, Randal or someone has covered this extensively
>and try as I might I can't find it.  It would be more helpful if
>you could point me in the direction of the documentation than to
>just solve this problem though the latter is fine.  

No, no, you're never going to find your way into everyone's kill
files properly with that attitude.  You're supposed to demand an
answer (preferably ASAP, with some sob story about how you have
a deadline tonight) and then attack anyone who points you in the
direction of documentation or suggests that you should solve
your problem in a different way.  Oh, and post numerous "Thank
you" messages for the people who gave you cut-and-paste
solutions that don't really work.

You're looking for "How can I expand variables in text strings?"
in perlfaq4, which is on your system if you've installed Perl
(type "perldoc perlfaq4") as well as at
http://www.perldoc.com/perlfaq4.html.

You might also want to look at Mark-Jason Dominus's three-part
article (it's not as long as it sounds) on why what you're doing
is probably a bad idea:

    http://www.plover.com/~mjd/perl/varvarname.html

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Sun, 17 Sep 2000 14:40:44 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: which the best scripting language?
Message-Id: <G11Crw.F4C@presby.edu>

In article <39c4847e.0@news.cbn.net.id>,
Lucisferre <lucisferre@email.com> wrote:
>You think which is the best scripting language?

Best for what?

-- 
Jon Bell <jtbell@presby.edu>                        Presbyterian College
Dept. of Physics and Computer Science        Clinton, South Carolina USA
[ Questions about newsgroups?  Visit http://www.geocities.com/nnqweb/  ]
[                or ask in news:news.newusers.questions                ]


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

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


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