[12430] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6030 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 17 10:17:36 1999

Date: Thu, 17 Jun 99 07:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 17 Jun 1999     Volume: 8 Number: 6030

Today's topics:
    Re: Afraid to ask about Y2K! (Chris Nandor)
    Re: Clear screen function in Perl? (David Cantrell)
        exporting a hash from a module akluyskens@my-deja.com
    Re: forceing only post methods with perl CGI module <webmaster@chatbase.com>
    Re: Help me I'm a dummy (Kvan)
    Re: How to extract emails from Outlock Express (brian d foy)
    Re: How to extract emails from Outlock Express (Bart Lateur)
        how to get miliseconds ???!!!!???!!! <hgouhier@imaginet.fr>
    Re: how to get miliseconds ???!!!!???!!! (Malcolm Ray)
    Re: how to get miliseconds ???!!!!???!!! (Cameron Laird)
    Re: how to get miliseconds ???!!!!???!!! <gellyfish@gellyfish.com>
    Re: how2 find first occurence of... (Philip 'Yes, that's my address' Newton)
    Re: MIcrosofts Attack on Perl (Chris Nandor)
    Re: newbie questions re conditional operators <webmaster@chatbase.com>
    Re: perl on-line <webmaster@chatbase.com>
    Re: Perl print to stdout not working...causes beeps. <martin@adoma.se>
    Re: Perl Script Question <david.cross@qxl.com>
        Perl training on east coast <jkeys@pobox.upenn.edu>
    Re: Probably simple, but pulling hair out <webmaster@chatbase.com>
        qr// doesn't save my day! (Bart Lateur)
        Request for improvements to my search script lou@visca.com
    Re: s and tr (Philip 'Yes, that's my address' Newton)
    Re: Searching for file types on a web site mmclaug@my-deja.com
    Re: Searching for file types on a web site <gellyfish@gellyfish.com>
    Re: simple math question!  Why doesn't the * multiply t (Philip 'Yes, that's my address' Newton)
    Re: SQL statement in Perl <paul.bunkham@synetica.com>
    Re: SQL statement in Perl paulm@dirigo.com
    Re: SQL statement in Perl paulm@dirigo.com
    Re: SQL statement in Perl paulm@dirigo.com
    Re: Win32 select() donath@my-deja.com
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 17 Jun 1999 13:06:43 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Afraid to ask about Y2K!
Message-Id: <pudge-1706990906470001@192.168.0.77>

In article <7k5njd$nbp$1@nnrp1.deja.com>, finsol@ts.co.nz wrote:

# Thankyou for being one of the contributors to this newsgroup to
# acknowledge that Perl programs do need to be audited for Y2K problems.

Is this something that need to be acknowledged?  It is self-evident,
pretty much.  What people have a problem with is you and other people
blaming the language instead of the programmer, which is nonsense.  Yes,
we should audit for Y2K.  No, we should not blame the language.  Yes, we
should blame the programmer for screwing u, becuase the ubiquitous
documentation is very clear on the subject.


# I have recently developed, and am sucessfully selling, Y2K scan software
# - not for Perl however!

For which language, MVS, CICS, or CGI?

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: Thu, 17 Jun 1999 10:58:43 GMT
From: NukeEmUp@ThePentagon.com (David Cantrell)
Subject: Re: Clear screen function in Perl?
Message-Id: <3768d30b.79493806@news.insnet.net>

On 15 Jun 1999 16:57:40 -0700, Tom Christiansen <tchrist@mox.perl.com>
said:

>In comp.lang.perl.misc, jan@ude.org writes:
>
>:         I use scrolling for updating the screen but that's not
>:the best way to do it. Is there a clear screen funtion ...
>
>            what part of the answer to this question as 
>elaborated in the standard perlfaq8 manpage included with
>every Perl distribution was unclear to you?

Although it should be pointed out that any method involving 'clear'
will only work on a Unix-like system.  Likewise, Term::Cap assumes
various Unix idioms, such as the existence of a termcap file.

On a Windoze system you can do:

  system("command /c cls");

But this WON'T work:

  $clear=`command /c cls`;
  print $clear;

(both tested on NT4)

[Copying newsgroup posts to me by mail is considered rude]

-- 
David Cantrell, part-time Unix/perl/SQL/java techie
                full-time chef/musician/homebrewer
                http://www.ThePentagon.com/NukeEmUp


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

Date: Thu, 17 Jun 1999 10:13:46 GMT
From: akluyskens@my-deja.com
Subject: exporting a hash from a module
Message-Id: <7kahom$f7d$1@nnrp1.deja.com>

I want to create a module that contains some subroutines that will be
used in all our scripts. The first subroutine defines a hash containing
our scripting directory structure. The problem is that untill now I
cannot export this complete hash the the script calling the module.

The module is located in perl library under ibmtools/bootstrap.pm.

This is the module:

#!/usr/bin/perl
########################################################################
#
#
#
#Bootstrap environment file, used by all scripts, has to be initialized
#
#in /etc/environment.
#
#Gives locations of default directories, Tivoli environment files,
#
#of global environment variable, scripts that extract data from
location#
#the global environment file.
#
#
#
#Use: Ex the statement print $std_dir{"TMPDIR"}, "\n";  will output
#
#     the corresponding PATH to TMPDIR as a string.
#
#     This string can then be used to define a Filehandle or perform
#
#     some other perlish things.
#
#
#
#	Changes :	1.) 18/03/1999 V1.0.4 Pieter Dubois
#
#			INI directory status + Y2K status check
#
#			2.) 20/04/1999 V1.05 Pieter Dubois
#
#			SMIT directories added.
#
#			3.) 30/05/99 V2 Anthony Kluyskens
#
#			Ported to PERL
#
#
#
#	Y2K STATUS :	OK
#
#
#
########################################################################
#
#
#Package Declaration
#
package ibmtools::bootstrap;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(def_std_dir);
@EXPORT_OK = qw (%std_dir);
#
#Variable declaration used by this local subroutine
#
sub def_std_dir {

$ROOTDIR = "/home/ibmtools";
$SCRIPTSDIR = "${ROOTDIR}/scripts";
$LOGSDIR = "${ROOTDIR}/logs";
$CHECKSDIR = "${ROOTDIR}/checks";
$TMPDIR = "${ROOTDIR}/tmp";
$OLDDIR = "${ROOTDIR}/old";
$INIDIR = "${ROOTDIR}/ini";
$SMITDIR = "${ROOTDIR}/smit";
#
#Scriptsdir for the different products : accessible
#
%std_dir = (
#
#Standard dirs
#
"ROOTDIR" => "/home/ibmtools",
"SCRIPTSDIR" => "${ROOTDIR}/scripts",
"LOGSDIR" => "${ROOTDIR}/logs",
"CHECKSDIR" => "${ROOTDIR}/checks",
"TMPDIR" => "${ROOTDIR}/tmp",
"OLDDIR" => "${ROOTDIR}/old",
"INIDIR" => "${ROOTDIR}/ini",
"SMITDIR" => "${ROOTDIR}/smit",
#
#Std Productdir
#
"ADSMSCRIPTS" => "${SCRIPTSDIR}/adsm",
"MANUSCRIPTS" => "${SCRIPTSDIR}/manugistics",
"INFORMIXSCRIPTS" => "${SCRIPTSDIR}/informix",
"SYSTEMSCRIPTS" => "${SCRIPTSDIR}/system",
"SAPSCRIPTS" => "${SCRIPTSDIR}/sap",
"ORACLESCRIPTS" => "${SCRIPTSDIR}/oracle",
"TIVOLISCRIPTS" => "${SCRIPTSDIR}/tivoli",
"NETWORKSCRIPTS" => "${SCRIPTSDIR}/network",
"DISKSCRIPTS" => "${SCRIPTSDIR}/disk",
"HACMPSCRIPTS" => "${SCRIPTSDIR}/hacmp",
"HASCRIPTS" => "${SCRIPTSDIR}/ha",
"SECSCRIPTS" => "${SCRIPTSDIR}/security",
#
#Checkscriptsdir for the different products : accessible
#
"ADSMCHECKS" => "${CHECKSDIR}/adsm",
"MANUCHECKS" => "${CHECKSDIR}/manugistics",
"INFORMIXCHECKS" => "${CHECKSDIR}/informix",
"SYSTEMCHECKS" => "${CHECKSDIR}/system",
"SAPCHECKS" => "${CHECKSDIR}/sap",
"ORACLECHECKS" => "${CHECKSDIR}/oracle",
"TIVOLICHECKS" => "${CHECKSDIR}/tivoli",
"NETWORKCHECKS" => "${CHECKSDIR}/network",
"DISKCHECKS" => "${CHECKSDIR}/disk",
"HACHECKS" => "${CHECKSDIR}/ha",
"HACMPCHECKS" => "${CHECKSDIR}/hacmp",
"SECCHECKS" => "${CHECKSDIR}/security",
#
#Logsdir for the different products : accessible
#
"ADSMLOG" => "${LOGSDIR}/adsm",
"MANULOG" => "${LOGSDIR}/manugistics",
"INFORMIXLOG" => "${LOGSDIR}/informix",
"SYSTEMLOG" => "${LOGSDIR}/system",
"SAPLOG" => "${LOGSDIR}/sap",
"ORACLELOG" => "${LOGSDIR}/oracle",
"TIVOLILOG" => "${LOGSDIR}/tivoli",
"NETWORKLOG" => "${LOGSDIR}/network",
"DISKLOG" => "${LOGSDIR}/disk",
"HACMPLOG" => "${LOGSDIR}/hacmp",
"HALOG" => "${LOGSDIR}/ha",
"SECLOG" => "${LOGSDIR}/security",
#
#Tmpdir for the different products : accessible
#
"ADSMTMP" => "${TMPDIR}/adsm",
"MANUTMP" => "${TMPDIR}/manugistics",
"INFORMIXTMP" => "${TMPDIR}/informix",
"SYSTEMTMP" => "${TMPDIR}/system",
"SAPTMP" => "${TMPDIR}/sap",
"ORACLETMP" => "${TMPDIR}/oracle",
"TIVOLITMP" => "${TMPDIR}/tivoli",
"NETWORKTMP" => "${TMPDIR}/network",
"DISKTMP" => "${TMPDIR}/disk",
"HACMPTMP" => "${TMPDIR}/hacmp",
"HATMP" => "${TMPDIR}/ha",
"SECTMP" => "${TMPDIR}/security",
#
#Olddir for the different products : accessible
#
"ADSMOLD" => "${OLDDIR}/adsm",
"MANUOLD" => "${OLDDIR}/manugistics",
"INFORMIXOLD" => "${OLDDIR}/informix",
"SYSTEMOLD" => "${OLDDIR}/system",
"SAPOLD" => "${OLDDIR}/sap",
"ORACLEOLD" => "${OLDDIR}/oracle",
"TIVOLIOLD" => "${OLDDIR}/tivoli",
"NETWORKOLD" => "${OLDDIR}/network",
"DISKOLD" => "${OLDDIR}/disk",
"HACMPOLD" => "${OLDDIR}/hacmp",
"HAOLD" => "${OLDDIR}/ha",
"SECOLD" => "${OLDDIR}/security",
#
#Inidir for the different products : accessible
#
"ADSMINI" => "${INIDIR}/adsm",
"MANUINI" => "${INIDIR}/manugistics",
"INFORMIXINI" => "${INIDIR}/informix",
"SYSTEMINI" => "${INIDIR}/system",
"SAPINI" => "${INIDIR}/sap",
"ORACLEINI" => "${INIDIR}/oracle",
"TIVOLIINI" => "${INIDIR}/tivoli",
"NETWORKINI" => "${INIDIR}/network",
"DISKINI" => "${INIDIR}/disk",
"HACMPINI" => "${INIDIR}/hacmp",
"HAINI" => "${INIDIR}/ha",
"SECINI" => "${INIDIR}/security",
#
#Smit dir for the different products : accessible
#
"ADSMSMIT" => "${SMITDIR}/adsm",
"MANUSMIT" => "${SMITDIR}/manugistics",
"INFORMIXSMIT" => "${SMITDIR}/informix",
"SYSTEMSMIT" => "${SMITDIR}/system",
"SAPSMIT" => "${SMITDIR}/sap",
"ORACLESMIT" => "${SMITDIR}/oracle",
"TIVOLISMIT" => "${SMITDIR}/tivoli",
"NETWORKSMIT" => "${SMITDIR}/network",
"DISKSMIT" => "${SMITDIR}/disk",
"HASMIT" => "${SMITDIR}/ha",
"HACMPSMIT" => "${SMITDIR}/hacmp",
"SECSMIT" => "${SMITDIR}/security",
);
}

_____________

This is a test script calling the module:

#!/usr/bin/perl
require ibmtools::bootstrap;
ibmtools::bootstrap::def_std_dir(%std_dir);
print $std_dir{"LOGSDIR"}, "\n";
______________


What am I doing wrong, or what should I do to be able to use this hash?

Thank you for your help.

Anthony Kluyskens






Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 17 Jun 1999 03:51:35 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: forceing only post methods with perl CGI module
Message-Id: <3768D337.1E4E97C4@chatbase.com>

Andrew S Gianni wrote:
> 
> Is there anyway to do this? I'd like to be able to protect some scripts
> from people passing whatever arguments to them they want. Is there a
> pragma in this module I can use?

<SNIP>

Do you mean something like:

if ($ENV{'REQUEST_METHOD'} ne "POST") {
   error message here;
   exit;
}

Or something else?... I'm assuming that's what you meant, and this
question is better off asked in a CGI NG.
-- 
Regards,
Tim Greer: chatmaster@chatbase.com / software@linkworm.com
Chat Base: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software: http://www.linkworm.com | CGI scripting in Perl/C, & more.
Unix/NT/Novell Administration, Security, Web Design, ASP, SQL, & more.
Freelance Programming & Consulting, Musician, Martial Arts, Sciences.


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

Date: Thu, 17 Jun 1999 09:29:45 GMT
From: kvan@dis.dk (Kvan)
Subject: Re: Help me I'm a dummy
Message-Id: <3768bf4e.585110414@news.newsguy.com>

On Wed, 16 Jun 1999 21:34:15 -0700, Bill & Carrie <woof@thegrid.net>
wrote:

>I would like to know how to search $text until I match a certain string
>then
>only print what comes after that string (or line)

$text ~= s/^.*?certain string(.*)/$1/;

You need to read up on regexen:

perldoc perlre

or the regex chapters of your Perl book, or, even better, Mastering
Regular Expressions by Jeffrey Friedl.

Kvan.

-------Casper Kvan Clausen------ | 'A *person* is smart. People are
---------<kvan@dis.dk>---------- |  dumb, panicky, dangerous animals
                                 |  and you know it.'
                                 |        - "K" in Men in Black.


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

Date: Thu, 17 Jun 1999 06:42:41 -0400
From: brian@pm.org (brian d foy)
Subject: Re: How to extract emails from Outlock Express
Message-Id: <brian-ya02408000R1706990642410001@news.panix.com>

In article <3768b53f@newsread3.dircon.co.uk>, Jonathan Stowe <gellyfish@gellyfish.com> posted:

> Mosl Roland <founder@pege.org> wrote:
> > Tom Phoenix <rootbeer@redcat.com> wrote in message
> > news:Pine.GSO.4.02A.9906161353580.26850-100000@user1.teleport.com...
> > 
> >> If you think there might be a module made for working with these files
> >> from Perl, check the Module List on CPAN.

> > CPAN is so search engine unfriednly designed,
> > that I stoped even to try to find there something

CPAN is not a search engine.  however, it is very clearly laid out.

> Then in you are in big trouble because more often than not people will
> simply refer to CPAN in that way.

well, there is

    http://theory.uwinnipeg.ca/search/cpan-search.html

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>


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

Date: Thu, 17 Jun 1999 10:55:01 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: How to extract emails from Outlock Express
Message-Id: <3769d391.7367255@news.skynet.be>

Mosl Roland wrote:

>I would like to extract all emails from
>Outlock Express 5 and store the
>messages in an own database system.
>
>First step: how to extract from the
>Outlock Express files?

Your mistype of the name is very appropriate. Indeed: Outlook has it's
own propriatary file format, and pretty much locks you out.

You may try poking it using OLE, either in VB or (Activestate) Perl. It
won't be easy, I guess.

	Bart.


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

Date: Thu, 17 Jun 1999 13:41:37 +0200
From: "herve" <hgouhier@imaginet.fr>
Subject: how to get miliseconds ???!!!!???!!!
Message-Id: <7kamra$piu$1@news.imaginet.fr>

Hi everybody!

I spent allmost 1 hour screaming on my computer to find out the way to get
MILISECONDS !
Obviously, that ain't something hard to do in C or pascal...
I searched perldocs on several servers, but no way!
I have to say that perldoc is kinda bullshit... never saw something worst
concerning documentation...
Even Micro$oft makes better ones...

Why the fuck can't I do that in Perl !!!

is there something like

use Time::localtime;
my $tt = localtime;
print "msec=".$tt->msec".\n";


Thanx!




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

Date: 17 Jun 1999 12:09:32 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: how to get miliseconds ???!!!!???!!!
Message-Id: <slrn7mhpbs.879.M.Ray@carlova.ulcc.ac.uk>

On Thu, 17 Jun 1999 13:41:37 +0200, herve <hgouhier@imaginet.fr> wrote:
>Hi everybody!
>
>I spent allmost 1 hour screaming on my computer to find out the way to get
>MILISECONDS !
>Obviously, that ain't something hard to do in C or pascal...
>I searched perldocs on several servers, but no way!
>I have to say that perldoc is kinda bullshit... never saw something worst
>concerning documentation...
>Even Micro$oft makes better ones...

You jest.  Sure, the perldoc utility itself is something of a kludge,
and some people feel the docs could use better indexing, but IMO the
*content* of the documentation is excellent.  But, you know, Perl is
a collaborative effort, and if you feel that strongly that it needs
improvement, step right up and volunteer.

>
>Why the fuck can't I do that in Perl !!!

Do you wear your underpants on your head?  Your use of punctuation
suggests so.

>
>is there something like
>
>use Time::localtime;
>my $tt = localtime;
>print "msec=".$tt->msec".\n";
>
>
>Thanx!

perldoc perlfaq8:

       How can I measure time under a second?

       In general, you may not be able to.  The Time::HiRes
       module (available from CPAN) provides this functionality
       for some systems.

       If your system supports both the syscall() function in
       Perl as well as a system call like gettimeofday(2), then
       you may be able to do something like this:

and so on (you can look up the rest yourself).  Take a look at
Time::HiRes on CPAN.

-- 
Malcolm Ray                           University of London Computer Centre


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

Date: 17 Jun 1999 07:12:29 -0500
From: claird@Starbase.NeoSoft.COM (Cameron Laird)
Subject: Re: how to get miliseconds ???!!!!???!!!
Message-Id: <7kaond$183$1@Starbase.NeoSoft.COM>

In article <7kamra$piu$1@news.imaginet.fr>, herve <hgouhier@imaginet.fr> wrote:
>Hi everybody!
>
>I spent allmost 1 hour screaming on my computer to find out the way to get
>MILISECONDS !
>Obviously, that ain't something hard to do in C or pascal...
>I searched perldocs on several servers, but no way!
>I have to say that perldoc is kinda bullshit... never saw something worst
>concerning documentation...
>Even Micro$oft makes better ones...
			.
			.
			.
Did your search not lead you to <URL:http://language.perl.com/newdocs/pod/perlfaq8.html#How_can_I_measure_time_under_a_s>?

Also, perhaps <URL:http://x30.deja.com/getdoc.xp?AN=484132761>
will interest you.  I believe Tom has the intention of updating
Part 8 with one line which mentions this.

Many people *do* find Perl documentation useful.  Maybe others
will offer tips that can make it more inviting to you.
-- 

Cameron Laird           http://starbase.neosoft.com/~claird/home.html
claird@NeoSoft.com      +1 281 996 8546 FAX


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

Date: 17 Jun 1999 14:11:56 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: how to get miliseconds ???!!!!???!!!
Message-Id: <3768f41c@newsread3.dircon.co.uk>

herve <hgouhier@imaginet.fr> wrote:
> Even Micro$oft makes better ones...
> 
> Why the fuck can't I do that in Perl !!!
> 

Bye Bye

*plonk*

/J\
-- 
"It needs to be said: Tinky Winky is ... an ideal role model for any
child without toes or genitalia" - Paul Rudnick, The Guardian


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

Date: Thu, 17 Jun 1999 13:34:36 GMT
From: nospam.newton@gmx.net (Philip 'Yes, that's my address' Newton)
Subject: Re: how2 find first occurence of...
Message-Id: <3768c40b.436866716@news.nikoma.de>

On Wed, 16 Jun 1999 14:15:56 -0700, Tom Phoenix <rootbeer@redcat.com>
wrote:

>On Wed, 16 Jun 1999, Marshall V Pierce wrote:
>
>> there must be a more efficient way to code this?
>
>I think you wanted 'last'. Cheers!

Yes, and probably also an assignment to (undef, ...) instead of
($junk, ...) -- and just maybe ?^Subject: ? rather than
/^Subject: / ? (Though 'last' is probably better here -- if you're
just grepping for subject headers, no need to read any further.)

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.net>


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

Date: Thu, 17 Jun 1999 13:14:08 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: MIcrosofts Attack on Perl
Message-Id: <pudge-1706990914130001@192.168.0.77>

In article <1dtcf89.aiwhns1bh8xklN@inksplash.demon.co.uk>,
wayne_allison@yahoo.com (Wayne Allison) wrote:

# It would seem that many people would feel that Perl would be hijacked by
# Microsoft in that they would improve it so that it would need to run on
# WinTel platforms to use those new improved features. 

This won't happen in the current arrangement, and yet could happen at any
time, announced or unannounced, but any company anywhere.  But not in this
arrangement as it stands, because Sarathy won't let that happen.

# > # Are people aware of the "negative" consequences of such a move,
# > # especially in relation to one of Perls core ojectives in relation to
# > # maintaining the language as "portable"?
# > 
# > Yes.  Perl will in all liklihood become more portable as a result of this
# > arrangement.
# We'll see what features are added my MSs envolvement that enhance
# "portability". I'd be surprised if it becomes more portable than just
# being able to run on WinTel better, which when splitting hairs may be
# the political point of Microsofts involvement.

No, MS' involvement will likely increase portability, not just on Windows,
but on other platforms.  Part of the funding will go toward certain ways
of getting fork() to work on Windows, which could provide fork() to other
platforms too (like Mac OS and VMS); hence, portability of Perl code
increases.  Yay for Microsoft for funding something Good.

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: Thu, 17 Jun 1999 03:45:36 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
To: Rory C-L <campbell-lange@easynet.co.uk>
Subject: Re: newbie questions re conditional operators
Message-Id: <3768D1D0.76AC8CF@chatbase.com>

Rory C-L wrote:
> 
> Conditional Operators
> 
> Quote from perlop.pod:
> "...It works much like an if-then-else.  If the argument before the ? is
> true, the argument before the : is returned, otherwise the argument after
> the : is returned..."
> 
> $ok = "ok";
> $a = "ok";
> $b = "match";
> $c = "no match";
> 
> ($a eq $ok) ? $a = $b : $a = $c;
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

$a = ($a eq $ok) ? $b : $c;

Does that help you with your problem?

> print "$a\n";

<SNIP>
-- 
Regards,
Tim Greer: chatmaster@chatbase.com / software@linkworm.com
Chat Base: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software: http://www.linkworm.com | CGI scripting in Perl/C, & more.
Unix/NT/Novell Administration, Security, Web Design, ASP, SQL, & more.
Freelance Programming & Consulting, Musician, Martial Arts, Sciences.


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

Date: Thu, 17 Jun 1999 03:10:57 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: perl on-line
Message-Id: <3768C9B1.3510D84D@chatbase.com>

Leonid Goltser wrote:
> 
> I want to try to run perl scripts (with cgi) on-line but I can't find a
> server that supports perl.
> Where can I upload my scripts? (Preferably free).
> 
> Thank you

This isn't the place to ask where to find a web server that offers such
a thing, this NG is geared towards Perl programming and the like.
However, you can do a 'Net search using your favorite search engine and
seek out "free web hosting" and add in the words CGI and Perl possibly.
If nothing else, check out hypermart.net and virtualave.net. You can
also run Perl on your own system just as if it was a real online web
server by using any number of free personal web servers available, also
found by doing a search of doing a little research. Apache works pretty
well on Windows systems, and even better on Unix variants. Perl is free
and downloadable from many places for virtually any OS/platform you are
using.
-- 
Regards,
Tim Greer: chatmaster@chatbase.com / software@linkworm.com
Chat Base: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software: http://www.linkworm.com | CGI scripting in Perl/C, & more.
Unix/NT/Novell Administration, Security, Web Design, ASP, SQL, & more.
Freelance Programming & Consulting, Musician, Martial Arts, Sciences.


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

Date: Thu, 17 Jun 1999 15:12:14 +0100
From: "Martin Quensel" <martin@adoma.se>
Subject: Re: Perl print to stdout not working...causes beeps.
Message-Id: <7katdo$8t2$1@cubacola.tninet.se>


gharris8158@my-deja.com skrev i meddelandet <7k8rhl$sh4$1@nnrp1.deja.com>...
 The code that
>outputs the file to STDOUT is simply:
>
>binmode(Repfile);
>binmode(stdout);
>while (<Repfile>){
>  print ;
>}
>

You have to print out the headers...
try  print "Content-type: text/html\n\n";

Not sure this works for you.. i am a beginner..but since noone else had a
suggestion i figured you couldent die, trying mine,

best regards
Martin Quensel





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

Date: Thu, 17 Jun 1999 13:37:55 +0100
From: Dave Cross <david.cross@qxl.com>
Subject: Re: Perl Script Question
Message-Id: <3768EC23.9E2F635@qxl.com>

John Fung wrote:
> 
> Perl Script Question
> 
> Dear Sir,
> 
>         I'm having problem when writing perl script, I would to have
>         a perl script that when I input my name : JJ and age : 19, then
>         click "Send", it will display in another page :
>         Your Name is JJ
>         Your age is 19
> 
>         Please help me and reply !!
>         Thank you very much for your help !!

Why don't you post a cut down version of the code that you already have
and tell us what problems you're having with it. We'll then be able to
give you more help.

Alternatively, you could try reading the copius documentation that comes
with your copy of Perl.

hth,

Dave...


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

Date: Thu, 17 Jun 1999 09:55:33 -0500
From: jkeys <jkeys@pobox.upenn.edu>
Subject: Perl training on east coast
Message-Id: <37690C5D.600A7AC6@pobox.upenn.edu>

Hello,

I am looking for training for a staff member at the University of
Pennsylvania.
Anyone familiar with traiing offered in the Philadelphia, New Jersey or
New York area?

Thank you.

Joy Keys
ISC Technology Training Group
Administrative Coordinator




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

Date: Thu, 17 Jun 1999 03:29:01 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: Probably simple, but pulling hair out
Message-Id: <3768CDED.EB68E773@chatbase.com>

Michael Hill wrote:
> 
> In my perl script I am trying to pass the value that is being stored to
> my variable.
> 
> $myvalue="fresh";
> print '<input type=hidden name="myfield" value=$myvalue>';
> 
> Of course what I get is $myvalue and not fresh.
> 
> Thanks, Mike

Look at the DOCs to see the difference between a single quote and a
double quote. It won't interpolate in single quotes, you need double
quotes, or it'll just print it as it's typed and will not replace it
with the variable's value.
-- 
Regards,
Tim Greer: chatmaster@chatbase.com / software@linkworm.com
Chat Base: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software: http://www.linkworm.com | CGI scripting in Perl/C, & more.
Unix/NT/Novell Administration, Security, Web Design, ASP, SQL, & more.
Freelance Programming & Consulting, Musician, Martial Arts, Sciences.


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

Date: Thu, 17 Jun 1999 10:49:51 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: qr// doesn't save my day!
Message-Id: <3768d134.6761651@news.skynet.be>

I don't know if I'm doing anything wrong. I'm trying out the new qr//
feature, but it turns out to be SLOWER even than recompiling the regex
every time. Or did I just pick a bad example?

  use Benchmark;
  $regex1 = ' \\w+';
  $regex2 = qr/$regex1/;
  $text = "Hello, world!\n";
  timethese(10000, {
    'string' => sub { $text =~ /$regex1/ },	# compile every time
    'precompiled' => sub { $text =~ $regex2},	# precompiled
    'straightforward' => sub { $text =~ /$regex1/o }, # compile once
  });
__END__
Benchmark: timing 10000 iterations of precompiled, straightforward,
string...
precompiled:  6 wallclock secs ( 5.71 usr +  0.00 sys =  5.71 CPU)
straightforward:  4 wallclock secs ( 5.22 usr +  0.00 sys =  5.22 CPU)
    string:  5 wallclock secs ( 5.60 usr +  0.00 sys =  5.60 CPU)

	Bart.


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

Date: Thu, 17 Jun 1999 12:33:39 GMT
From: lou@visca.com
Subject: Request for improvements to my search script
Message-Id: <7kapv3$hld$1@nnrp1.deja.com>

Greetings:

I've written a Perl script called Site Search whose purpose is to
recursively search a web site for a user-supplied string. The user can
choose Boolean AND, OR or AS A PHRASE; whole-word or not; and
case-sensitive or not. The program returns a list of pages, represented
by their titles and description meta-tags, and sorted by relevance,
which is determined by the file length of the page divided by the number
of matches per page.

I've taken the liberty of posting the script in the hopes that people
here will offer comments and suggestions for improvements. I plan to
offer this script for free.

In the interests of brevity:
1) I haven't included the 'error', 'head', 'foot', and 'goback'
subroutines, since they merely generate HTML code;
2) I haven't included the 'id' sub, which identifies the script if
someone calls it with 'GET'.
3) Finally, I've truncated the 'replace_entities' subroutine; its
purpose should be clear from the few lines I've included.

If you'd like to see the script in action, a provisional version can be
run from http://www.visca.com/search.html

Thank-you very much for your help.

#!/usr/local/bin/perl -Tw
# site_search.plx

## CAPTURE WARNINGS AND FATALS ##
BEGIN {
open (STDERR, ">/path/error.log");
}

use strict;
use File::Find;
use CGI;
my $q = new CGI;

## PATHS ##
my $basedir = '/path';
my $baseurl = 'http://www.foo.com';
my $cgidir = "$basedir/cgi-bin";
my $body = qq~<body background="$baseurl/media/blue-g.jpg"
bgcolor="#f8f8f8" text="black" link="blue" vlink="purple" alink="red">~;
my $skipfile = "$cgidir/skips.txt";
my $searchpage = "$baseurl/search.html";
my $search_help = "$baseurl/search_help.html";

## IDENTIFY THE SCRIPT IF NOT POST METHOD ##
id('Site Search ver. 1.0') unless ($ENV{'REQUEST_METHOD'} =~ /post/i);

## DEFINE NON-ASCII CHARACTERS, ETC. WE WILL ACCEPT ##
my $w = 'abf`ecdgijhkmnloqstrxuv~z{y|}ABF@ECDGIJHKMNLOQSTRXUV^Z[Y\]7@\'
-';

## UNTAINT ##
my @names = $q->param;
my %in = ();
for (@names) {
    $in{$_} = ${ \$q->param($_) };
}
for my $key (keys %in) {
    if ( $in{$key} =~ /^([\.\w$w]+)$/ ) {
        $in{$key} = $1;
    } else {
        error("Sorry, your search string, <code><b>$in{$key}</b></code>,
        contained unsafe characters (e.g., quotes, slashes, parentheses,
        etc.), which, in unscrupulous hands, can represent a security
        risk. Use your browser's back button to return to the previous
        page.");
        exit;
    }
}

## ASSIGN VARIABLES ##
my $value = $in{'value'};
my $whole = $in{'whole'};
my $case = $in{'case'};
my $boolean = $in{'boolean'};

## GET TIME ##
my $time = times();

## REMOVE LEADING AND TRAILING WHITESPACE FROM SEARCH STRING ##
$value =~ s/^\s*//;
$value =~ s/\s*$//;

## DO BOOLEAN STUFF ##
my @terms = ();
if ($boolean eq 'As a phrase') {
    $terms[0] = $value;
}
elsif ($boolean eq 'Or') {
    @terms = split / /, $value;
    my $tmp = join '|', @terms;
    @terms = ();
    $terms[0] = $tmp;
}
else {
    @terms = split / /, $value;
}

## DO WHOLE WORD STUFF ##
my $ww;
$whole eq 'Yes' ? ($ww = 'whole-word only') : ($ww = 'non-whole-word
only');

## READ SKIP DIRECTORIES FILE ##
# This file simply lists the names of directories we don't want
# searched: Example (there is no indentation):
# cgi-bin
# tmp
# oldstuff

open SKIPS, $skipfile or die "$skipfile: $!";
my @skips = ();
while (<SKIPS>) {
    chomp;
    push @skips, "/$_/";
}
close SKIPS or warn $!;
my $skips = join '|', @skips;

## GRAB THE RELEVANT FILES ##
my @found = ();
finddepth sub {push @found, $File::Find::name if /(html?|cgi)$/ && !-d},
$basedir;

## ELIMINATE SKIPPED DIRECTORIES FROM FOUND ARRAY ##
@found = grep !m{$skips}o, @found;

## GET THE NUMBER OF FILES FOUND AND THEIR TOTAL SIZE ##
my $filecount = scalar(@found);
my $size;
for (@found) {
    $size += -s $_;
}
$size = int($size / 1000);

## DO THE SEARCH ##
my @matches = ();
my $total_matchcount = '0';
undef $/;
START:for my $filename (@found) {
    open FILE, $filename or die "$filename: $!";
    my $file = <FILE>;

    # Note: When searching for whole words, we can't use the \b anchor
    # because the search string might start or end with a non-ASCII
    # character. Therefore we'll use \s, but this will fail if the
    # search string contains the first or last character of the file. To
    # get around this, we'll add a space character to the beginning and
    # end of the file.
    $file = " $file ";

    # REMOVE HTML TAGS FROM THE SEARCH (PERLFAQ 4) #
    (my $no_tags = $file) =~ s/<(?:[^>'"]*|(['"]).*?\1)*>//gs;

    # REPLACE HTML ENTITIES WITH NON-ASCII CHARACTERS (e.g., &agrave;
    # with `)
    $no_tags = replace_entities($no_tags);

    my ($matchcount, $relevance);
    my $filelength = length($file);

    ## CHECK FOR MATCHES; GO BACK TO START IF NONE ##
    for (@terms) {
        if ($case eq 'Case sensitive' && $whole eq 'Yes') {
            next START unless ($no_tags =~ /\s+$_\s+/);
            while ( $no_tags =~ /\s$_\s/g ) {$matchcount++};
        }
        elsif ($case eq 'Case sensitive' && $whole eq 'No') {
            next START unless ($no_tags =~ /$_/);
            while ($no_tags =~ /$_/g) {$matchcount++};
        }
        elsif ($case eq 'Not case sensitive' && $whole eq 'Yes') {
            next START unless ($no_tags =~ /\s$_\s/i);
            while ($no_tags =~ /\s$_\s/gi) {$matchcount++};
        }
        else { #($case eq 'Not case sensitive' && $whole eq 'No') {
            next START unless ($no_tags =~ /$_/i);
            while ($no_tags =~ /$_/gi) {$matchcount++};
        }
    }

    ## GRAB THE TITLE AND DESCRIPTION META TAGS ##
    ## (we only get here if we have a match) ##

    my ($title, $meta);
    if ( $file =~ /<title>(.*?)<\/title>/i ) {
        $title = $1;
    }
    else {
        $title = 'No title';
    }
    if ($file =~ /<meta name="description" content="(.*?)">/i) {
        $meta = $1;
    }
    else {
        $meta = 'No description';
    }

    ## DETERMINE RELEVANCE ##
    $relevance = $filelength / $matchcount unless $matchcount == '0';

    ## URL-IZE THE FILE NAME ##
    (my $fileurl = $filename) =~ s/$basedir/$baseurl/;

    ## ADD A LIST OF FILE INFO TO THE MATCHES ARRAY ##
    push @matches, [$fileurl, $title, $meta, $filelength, $matchcount,
    int($relevance)];

    $total_matchcount += $matchcount;
}

## IF NOTHING FOUND... ##
if ($total_matchcount == 0) {
    my $newtime = times();
    head('No Results', $body, '1');
    print qq~<p>Summary: Searching for <b>$value</b>, did a Boolean:
    <i>$boolean</i>, <i>$case</i>, <i>$ww</i> search in $filecount files
    ($size Kb) but could not find any matches. The search took
    ${\($newtime - $time)} seconds on $^O.</p>~;
    if ($search_help) {
        print qq~<p>Perhaps you would like to visit our <a
        href="$search_help">Search Help Page</a>, where we offer advice
        on getting the most out your searches.</p>~;
    }
    goback($searchpage, 'Return to the Search page');
    foot($clue_scripts, $script_name);
    exit;
}

## GET THE TOTAL NUMBER OF PAGES MATCHED ##
my $foundcount = scalar(@matches);

## SORT THE RESULTS BY RELEVANCY ##
@matches = sort { $a->[5] <=> $b->[5] } @matches;

## GET A RELEVANCY PERCENTAGE FOR EACH MATCH (Thanks Russ!) ##
# After the previous sort, $matches[0][5] will have the highest
# relevancy rating.
my $best = $matches[0][5];

# Now we'll divide each relevancy rating by the best one and multiply by
# 100. The highest will of course be 100, and the others diminishing
# percentages of it.
for my $i (0 .. $#matches) {
    my $rel_percent = ($best / $matches[$i][5]) * 100 unless
    $matches[$i][5] == '0';
    # We don't want any 0% relevancies #
    $rel_percent = $rel_percent + 1 if $rel_percent < 1;
    $matches[$i][6] = int($rel_percent);
}

my $totals;

## CREATE OUTPUT ##
head('Search Results', $body, '1');
$totals .= qq~<hr>
<dl>\n~;

## ADD THE RESULTS TO THE $totals VARIABLE ##
# The fileurl is $matches[$i][0], the title is $matches[$i][1], the meta
# description is $matches[$i][2], the filelength is $matches[$i][3], the
# matchcount is $matches[$i][4], and the relevancy percentage is
# $matches[$i][6]
for my $i (0 .. $#matches) {
    $totals .= qq~<dt><a href="$matches[$i][0]">$matches[$i][1]</a>
    <dd><small>( Matches: $matches[$i][4] Filelength: $matches[$i][3] =
    Relevancy: <b>$matches[$i][6]%</b>)</small><br>
    Description: $matches[$i][2]\n~;
}
$totals .= qq~</dl>~;

my $newtime = times();

print qq~<p>Summary: Searching for <b>$value</b>, did a <i>Boolean:
$boolean</i>, <i>$case</i>, <i>$ww</i> search in $filecount files ($size
Kb) and found $total_matchcount matches on $foundcount web pages. The
search took ${\($newtime - $time)} seconds on $^O.</p>
$totals
<hr>
<p>Note: These results are sorted by a 'relevance factor', which is
determined by "length of file" divided by "number of matches". The best
match always equals 100%, and the others are obtained dividing their
'relevance factor' into that of the best match's.</p>
~;
goback("$searchpage", 'Return to the Search page');
foot($clue_scripts, $script_name);


## SUBS ##

sub replace_entities {
    my $string = shift;
    $string =~ s/&aacute;/a/g;
    $string =~ s/&acirc;/b/g;
    $string =~ s/&aelig;/f/g;
    ... etc. ...
    $string =~ s/&Uuml;/\/g;
    $string =~ s/&Yacute;/]/g;
    return $string;
}

--
JAPHW
Lou Hevly
lou@visca.com


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 17 Jun 1999 13:34:36 GMT
From: nospam.newton@gmx.net (Philip 'Yes, that's my address' Newton)
Subject: Re: s and tr
Message-Id: <3768c4de.437077559@news.nikoma.de>

On Wed, 16 Jun 1999 19:37:06 -0400, "Matt" <splinter@monmouth.com>
wrote:

>I was thinking of doing something like
>s/// or tr/// but they can't have variables in them like  s/$id//;

Who said that? What happened when you tried it out?

(Though for your deleting-line needs, heed mjd's advice and head for
the FAQ.)

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.net>


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

Date: Thu, 17 Jun 1999 09:17:20 GMT
From: mmclaug@my-deja.com
Subject: Re: Searching for file types on a web site
Message-Id: <7kaees$eao$1@nnrp1.deja.com>

Thanks, Tom. But I've got the basics sorted out.
I can use LWP to contact web sites and use get(URL) to download stuff.

I was wondering if there were any modules or code out there specifically
to do what I want.

Michael


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 17 Jun 1999 11:23:11 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Searching for file types on a web site
Message-Id: <3768cc8f@newsread3.dircon.co.uk>

mmclaug@my-deja.com wrote:
> Thanks, Tom. But I've got the basics sorted out.
> I can use LWP to contact web sites and use get(URL) to download stuff.
> 
> I was wondering if there were any modules or code out there specifically
> to do what I want.
> 

You can use the HTML::LinkExtor module to extract links from an HTML
page - you may want to use some regular expression to determine if they
are the right kind of file extension - see the perlre manpage.

/J\
-- 
"You're blowing me off for a monkey?" - Joey, Friends


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

Date: Thu, 17 Jun 1999 13:34:33 GMT
From: nospam.newton@gmx.net (Philip 'Yes, that's my address' Newton)
Subject: Re: simple math question!  Why doesn't the * multiply two numbers?
Message-Id: <3768998b.425984691@news.nikoma.de>

Since others have commented on the * being interpreted by the shell
(_myprogram 3 '*' 4_ should work, though), I'll just add a little:

On Sun, 13 Jun 1999 21:43:53 -0400, "Ryan T. Rhea"
<ryan420@earthling.net> wrote:

>I have written the following script in perl.  Everything works except
>the multiplication.  What's going on?
>
>#!/usr/bin/perl

you forgot -w

>#
># simple command line calculator
># Copyright 1999 by Ryan T. Rhea
>$num1 = @ARGV[0];
>$oper = @ARGV[1];
>$num2 = @ARGV[2];

you're confusing @array[n] with $array[n].

> please reply to ryan420@earthling.net

No.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.net>


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

Date: Thu, 17 Jun 1999 12:35:03 +0100
From: Paul Bunkham <paul.bunkham@synetica.com>
Subject: Re: SQL statement in Perl
Message-Id: <3768DD67.701DB060@synetica.com>

paulm@dirigo.com wrote:
> 
> Does anyone have any familiarity with writing SQL statements in Perl?
> 

Some under win32, so I hope I can help...

> I have a script that's using Win32 OLE and calling a System DSN.  The
> call to the system DSN is working, but the script is failing when
> running the SQL statement.  I'm attempting to grab info from an Access
> 97 database.  It looks as follows:
> 
> my $db = new Win32::ODBC( $dsn ) || die "Error: " . Win32::ODBC::Error
> ();
> $stmt = "SELECT ALL * FROM [Forecast]";
> 

Can you give me a little more information, such as the way that you are
executing the SQL, and the errors that you get.   The first thing to do
is to check that Access likes your SQL, because quite often it can be a
bit picky.  If it does then it is almost certainly something to do with
the actual connection to the database, and how the query is getting run,
but without some more info I wouldn't really want to speculate.

Cheers,

Paul.

-- 
*****************************************
Paul Bunkham
Developer
Synetica Knowledge Technologies
*****************************************


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

Date: Thu, 17 Jun 1999 12:44:05 GMT
From: paulm@dirigo.com
Subject: Re: SQL statement in Perl
Message-Id: <7kaqii$hsj$1@nnrp1.deja.com>

?????? What?????

In article <slrn7mgki1.ejb.abigail@alexandra.delanet.com>,
  abigail@delanet.com wrote:
> paulm@dirigo.com (paulm@dirigo.com) wrote on MMCXV September MCMXCIII
in
> <URL:news:7k87td$joa$1@nnrp1.deja.com>:
> .. Not sure what your talking about, but a Perl script will run SQL if
> .. writen correctly!
> ..
> .. I've used 1000 different SQL strings to try and get this working
and
> .. none has worked.  I've tried brackets, quotes, I've even looked at
how
> .. my queries are formatted in Access 97 and used the EXACT same
string,
> .. but it still will not work.
>
> This kind of contradicts your first statement, doesn't it?
>
> Abigail
> --
> perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -
wle'print +(
> HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
> LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
> "http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) ->
content))
> =~ /(.*\))[-\s]+Addition/s) [0]'
>
>   -----------== 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 ==-----
>

--
Paul R. Mesker
System Engineer
Dirigo Inc.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 17 Jun 1999 12:45:58 GMT
From: paulm@dirigo.com
Subject: Re: SQL statement in Perl
Message-Id: <7kaqm3$huh$1@nnrp1.deja.com>

Eric,

This was extremely helpful.  Thank you so much.  DBI is much more
friendly than the method we were using.  I'm going to try to find out
more about it.

Thanks again.

In article <7k7p77$7be@news.vtcom.fr>,
  "Ysteric's" <eyounes@aol.com> wrote:
> why don't you use DBI and DBD::ODBC modules, it's very easy ...
>
> look the folowing example :
>
> use DBI;
>
> print "connexion ...";
> $dbh = DBI->connect('dbi:ODBC:Secu') || die('$DBI::errstr');
> #                                                        ^^^^^ this
is your
> DSN
>
> print "...connexion OK";
>
> $sth = $dbh->prepare(qq{select * from testrg});
> $sth->execute || die('$DBI::errstr');
>
> $cnt = 0;
> print qq{<font face="Arial,Helvetica" width=600><table>
> };
> $no_secu =~ s/ /+/g;
> if( @rows = $sth->fetchrow_array) {
>     foreach $x (@rows) {
>         print "$x<br>"; #for example !!!
>     }
> } else {
>  print qq{
>   <table width="400" border=0 bgcolor="#000000">
>     <th><font face="Arial, Helvetica" color="#FFFFFF"
> size="5"><center><b>Fiche
employ&eatute;<br>&nbsp;</b></center></font></th>
>     <tr>
>       <td><hr><font face="Arial, Helvetica, sans-serif"
> color="#FFFFFF"><b>Sorry, no records found !</b></font><hr></td>
>     </tr>
>   </table>
>  };
> }
>
> $sth->finish;
> $dbh->disconnect;
>
> Hope that it will be useful for you
>
> Eric - FRANCE
>
> paulm@dirigo.com a icrit dans le message <7k669f$ts0
$1@nnrp1.deja.com>...
> >Does anyone have any familiarity with writing SQL statements in Perl?
> >
> >I have a script that's using Win32 OLE and calling a System DSN.  The
> >call to the system DSN is working, but the script is failing when
> >running the SQL statement.  I'm attempting to grab info from an
Access
> >97 database.  It looks as follows:
> >
> >my $db = new Win32::ODBC( $dsn ) || die "Error: " .
Win32::ODBC::Error
> >();
> >$stmt = "SELECT ALL * FROM [Forecast]";
> >
> >I've tried multiple combinations of the SQL.  It's attempting to grab
> >the data from the Forecast table and print it, but it keeps erring
out.
> >
> >Does this have something to do with Access 97?
> >Any help would be largely appreciated.
> >
> >Thanks in advance.
> >
> >--
> >Paul R. Mesker
> >System Engineer
> >Dirigo Inc.
> >
> >
> >Sent via Deja.com http://www.deja.com/
> >Share what you know. Learn what you don't.
>
>

--
Paul R. Mesker
System Engineer
Dirigo Inc.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 17 Jun 1999 12:52:05 GMT
From: paulm@dirigo.com
Subject: Re: SQL statement in Perl
Message-Id: <7kar1h$i25$1@nnrp1.deja.com>

Well, I was able to get the connection to work using DBI.  The SQL
connection was working, but as you mentioned, ACCESS 97 didn't like my
SQL string.  I needed to put brackets around the table name in order
for it to work....go figure.

Anyway, I've got it working now. Thanks for all your help.



> Can you give me a little more information, such as the way that you
are
> executing the SQL, and the errors that you get.   The first thing to
do
> is to check that Access likes your SQL, because quite often it can be
a
> bit picky.  If it does then it is almost certainly something to do
with
> the actual connection to the database, and how the query is getting
run,
> but without some more info I wouldn't really want to speculate.
>
> Cheers,
>
> Paul.
>
> --
> *****************************************
> Paul Bunkham
> Developer
> Synetica Knowledge Technologies
> *****************************************
>

--
Paul R. Mesker
System Engineer
Dirigo Inc.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 17 Jun 1999 12:42:06 GMT
From: donath@my-deja.com
Subject: Re: Win32 select()
Message-Id: <7kaqer$hrt$1@nnrp1.deja.com>

In article <37673d30.464744@news.dial.pipex.com>,
  david.whitmarsh@dial.pipex.com wrote:
> I think I'm right in saying that windows select() works only on
> sockets and not on filehandles.

That's right.  But I'm looking for a way to see if there is data waiting
to be read on a file handle.  Since select() does not work, perhaps
someone has another suggestion?


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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 V8 Issue 6030
**************************************

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