[11365] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4965 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 26 11:20:30 1999

Date: Fri, 26 Feb 99 08:18:45 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 26 Feb 1999     Volume: 8 Number: 4965

Today's topics:
        custom dial script - simple if you know how - I don't <kosta@on-parade.com.au>
    Re: custom dial script - simple if you know how - I don <christoph.wernli@ubs.com>
        Data::MacResFile, cross-platform access to Macintosh re (Andrew M. Langmead)
        Database problem morrowp@mail2.tcd.ie
    Re: Database problem <rick.delaney@home.com>
    Re: Datetime manipulation in perl <dhenders@cpsgroup.com>
    Re: DBD::Oracle, Apache DBI, mod_perl <cunningt@primenet.com>
        deleting files with perl cgi <aaron@tyc.net>
    Re: deleting files with perl cgi (Alastair)
    Re: deleting files with perl cgi <rick.delaney@home.com>
    Re: deleting files with perl cgi (Tad McClellan)
        Determine web directory size <dda@ic.ru>
        determining file name with -n flag mch927@merle.acns.no.sp.am.nwu.edu
    Re: determining file name with -n flag <uri@ibnets.com>
    Re: determining number of returned rows in DBI.pm... jaymecox@my-dejanews.com
        Die function doesn't work. (Mauro Sanna)
    Re: Die function doesn't work. <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: Die function doesn't work. (Larry Rosler)
    Re: Die function doesn't work. <boot@nmt.edu>
    Re: Die function doesn't work. <jdf@pobox.com>
    Re: Die function doesn't work. (Greg Ward)
    Re: Die function doesn't work. <aqumsieh@matrox.com>
    Re: Die function doesn't work. (Ronald J Kimball)
    Re: Die function doesn't work. <dgris@moiraine.dimensional.com>
    Re: Die function doesn't work. <mrsanna@tin.it>
    Re: Die function doesn't work. <tchrist@mox.perl.com>
        Does anyone know where there are PerlTk tutorials? <boot@nmt.edu>
    Re: Does anyone know where there are PerlTk tutorials? <ron.dilley@ada.com>
    Re: Does anyone know where there are PerlTk tutorials? (Greg Ward)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 26 Feb 1999 17:45:20 +1100
From: Kosta <kosta@on-parade.com.au>
Subject: custom dial script - simple if you know how - I don't
Message-Id: <36D64300.B18D6F8@on-parade.com.au>

I need to ring a phone number once every hour to check if a line is
free or not.

If the modem report string is RING the script should  simply hang
up.

But if the report string is BUSY I need the script to  execute a
command
i.e. -> "xanim something.wav"   and to also  continue the same
script cycle.

Please help if you can.

TIA.
Kosta.



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

Date: Fri, 26 Feb 1999 15:43:46 +0100
From: Christoph Wernli <christoph.wernli@ubs.com>
Subject: Re: custom dial script - simple if you know how - I don't
Message-Id: <36D6B322.6BB57667@ubs.com>

Kosta wrote:
> 
> I need to ring a phone number once every hour to check if a line is
> free or not.
> 
> Please help if you can.

The chances that somebody will join in is far greater if you post the -
however tiny - piece of code you've put together already.

-w


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

Date: 23 Feb 1999 17:03:37 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Data::MacResFile, cross-platform access to Macintosh resource data
Message-Id: <7aun19$tim$1@play.inetarena.com>
Keywords: Macintosh Perl resource fork

I have just released the module Data::MacResFile, a module allow Perl
programs to read Macintosh OS resource data on non-macintosh
computers. Most Macintosh software when transmitting files flatten the
resource data for transmission (sometimes combined with the "data
fork" the simple stream of bytes common in files on most other
operating systems). This module should allow cross platform access to
this data.

This version handles the read-only access to the data. I hope to add
resource writing to future versions.

If interested, the module is available at
<URL:http://world.std.com/~aml/perl/macresfile/Data-MacResFile-0.01.tar.gz>
Comments, criticisims, and bug reports are welcome.
-- 
Andrew Langmead




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

Date: Thu, 25 Feb 1999 10:52:01 +0000
From: morrowp@mail2.tcd.ie
Subject: Database problem
Message-Id: <36D52B51.BF7ADBAB@mail2.tcd.ie>

I'm unsure how to take from an excel file/ access database and read it
in, in a fixed format using say 'unpack' and then 'read'.

Is there a way to do it if its saved as tab delimited text?
Should I save it in another format?
Couldnt find and answer to this in FAQ or in the book I've been using?
Unsure as to what approach to take with this?

When specifying structure  a30a30etc. the options given a, A, .... dont
give a whole lot of sway. The stuff I'm trying to read in is about 10
columns wide and contains details of postgraduate courses in Ireland
that I would like to be able to search. I'm rambling so I'll stop.   -
Excel File to fixed format is the problem.


Once I can read in the data my problems should be solved as searching
etc. is fine.

Thanks for your help.
Peter Morrow,




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

Date: Fri, 26 Feb 1999 03:28:43 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Database problem
Message-Id: <36D616D3.57274A80@home.com>

[posted & mailed]

morrowp@mail2.tcd.ie wrote:
> 
> I'm unsure how to take from an excel file/ access database and read it
> in, in a fixed format using say 'unpack' and then 'read'.
> 
> Is there a way to do it if its saved as tab delimited text?

Yes, but not with unpack.  perldoc -f split.

    while(<>){
        @fields = split /\t/;
    }

> Should I save it in another format?

No, but you could use the Win32::OLE module to access it directly.  If
you don't really need to automate this process, a tab separated file is
easiest to work with.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 23 Feb 1999 15:02:24 -0600
From: Dale Henderson <dhenders@cpsgroup.com>
Subject: Re: Datetime manipulation in perl
Message-Id: <87yaloal5r.fsf@camel.cpsgroup.com>


On Wed, 17 Feb 1999 20:33:05 GMT, Charles_Long@Dell.com
<Charles_Long@Dell.com> wrote:

> hi, the 2nd ed blue camel lists Time::Local as containing timelocal() to
> go from textual string to a time() format i.e. mmddyy to ssssssssss UNIX-like
> stamp. i have searched Activestate and CPAN for this module to no avail.
> did they depreciate this? does anyone have such a module. again, to do the
> opposite of localtime().

    I. R. A.> Have you tried compiling just the 'use Time::Local;'
    I. R. A.> statement? Hint: Time::Local is part of the standard
    I. R. A.> distribution, and you *should* already have it.

    I. R. A.> James

     Actually I believe all the modules listed in the back of the 2nd
     ed. camel book are part of the standard distribution.

-- 
Dale Henderson <mailto:dhenders@cpsgroup.com> 

"Imaginary universes are so much more beautiful than this stupidly-
constructed 'real' one..."  -- G. H. Hardy


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

Date: 25 Feb 1999 21:56:49 GMT
From: Thomas Cunningham <cunningt@primenet.com>
Subject: Re: DBD::Oracle, Apache DBI, mod_perl
Message-Id: <7b4gv1$18p$1@nnrp02.primenet.com>

I'm having the same original problem that Al was having .... this pops up
in my error log when I try to make a connection to Oracle.

httpd: [Thu Feb 25 16:37:33 1999] [error] install_driver(Oracle) failed:
Can't load '/usr/lib/perl5/site_perl/i386-linux/auto/DBD/Oracle/Oracle.so'
for module DBD::Oracle: libclntsh.so.1.0: cannot open shared object file:
No such file or directory at
/usr/lib/perl5/i386-linux/5.00404/DynaLoader.pm line 168.

So I went back through DejaNews and tried using Matt Sergeant's advice to
edit /etc/lib.so.conf and run /sbin/ldconfig. Though ldconfig didn't
return anythin, ldconfig -D brought up something that worried me :

<LOTS CUT>
/home/oracle/product/8.0.5.0.0/lib:
/sbin/ldconfig: warning: /home/oracle/product/8.0.5.0.0/lib/libclntsh.so
has inconsistent soname (libclntsh.so.1.0)
        liboci805jdbc.so => liboci805jdbc.so
        libclntsh.so.1.0 => libclntsh.so.1.0
/home/oracle/product/8.0.5.0.0/was302/lib:
        libclntsh.so.1.0 => libclntsh.so.1.0
<LOTS CUT>

Still the same error. I have noticed though, that if I shutdown my browser
and run the script a second time, ORACLE_HOME and LD_LIBRARY_PATH don't
have anything in them, even though I explicitly define them in my mod_perl
script. If I use apachectl to shut down and httpd and restart, ORACLE_HOME
and LD_LIBRARY_PATH are defined correctly during the first run.

Anyone have any ideas?

Thanks,

Tom



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

Date: Wed, 24 Feb 1999 15:02:50 -0800
From: "aaron" <aaron@tyc.net>
Subject: deleting files with perl cgi
Message-Id: <36d4f9f7.0@news1.jps.net>

Looked for this at perl.com and didn't find anything...I must not know how
to look for things because I'm sure it's there.  Now if someone searches
dejanews for deleting files with perl, they'll find this message and know
that I once felt their pain =]

I have this sub that is designed to delete a file.  It won't though.  Any
clue as to why?  It also won't trigger the &errors or set variables.

sub delete_count {

$del_file  = "$data_dir/$del_account";
$del_file .= ".count";

my $fs_item  = "$data_dir/$del_file";

   if (-d $fs_item)

      if (unlink $fs_item)

      $fs_item = "$deleted1";
      }
    else {
    &error("File Deletion Error. $fs_item")
    }
  }
}

Am I going about this totally wrong?

Thank you for reading...

Aaron




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

Date: Thu, 25 Feb 1999 00:47:17 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: deleting files with perl cgi
Message-Id: <slrn7d97fh.5o.alastair@calliope.demon.co.uk>

aaron <aaron@tyc.net> wrote:
>
>my $fs_item  = "$data_dir/$del_file";
>
>   if (-d $fs_item)

That tests if the 'file' is a directory I think.

>      if (unlink $fs_item)

The docs say ;

Note: unlink will not delete directories unless you are superuser and
the B<-U> flag is supplied to Perl.  Even if these conditions are
met, be warned that unlinking a directory can inflict damage on your
filesystem.  Use rmdir instead.

(perldoc -f unlink)

Could this be the problem?

HTH.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Thu, 25 Feb 1999 03:47:01 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: deleting files with perl cgi
Message-Id: <36D4C990.50F7C854@home.com>

[posted & mailed]

aaron wrote:
> 
> I have this sub that is designed to delete a file.  It won't though.  
> Any clue as to why?  It also won't trigger the &errors or set 
> variables.
> 
> sub delete_count {
> 
> $del_file  = "$data_dir/$del_account";
> $del_file .= ".count";
> 
> my $fs_item  = "$data_dir/$del_file";

So $fs_item eq "$data_dir/$data_dir/$del_account.count".  Do you really
want $data_dir in there twice?

> 
>    if (-d $fs_item)

"$data_dir/$data_dir/$del_account.count" should be a directory?

> 
>       if (unlink $fs_item)

Please cut and paste your code.  You're missing a '{' here.  Alastair
has already pointed out that you shouldn't try to unlink directories. 
Use rmdir instead.

> 
>       $fs_item = "$deleted1";
>       }
>     else {
>     &error("File Deletion Error. $fs_item")

I'm not sure what &error does but you might want to check why it doesn't
delete.  

    &error("File Deletion Error. $fs_item:  $!");

>     }
>   }

    else { die "$fs_item is not a directory\n" }

> }


-- 
Rick Delaney
rick.delaney@home.com


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

Date: Wed, 24 Feb 1999 18:51:19 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: deleting files with perl cgi
Message-Id: <n932b7.nmc.ln@magna.metronet.com>

aaron (aaron@tyc.net) wrote:

: I have this sub 


   You may have _a_ sub somewhere that is giving you problems,
   but it isn't the sub you included below.

   It won't even compile.

   Don't try and type in the code again, use cut/paste, else
   you'll just get a bunch of comments about your typos instead
   of about your real problem.


: that is designed to delete a file.  It won't though.  Any
: clue as to why?  It also won't trigger the &errors or set variables.

: sub delete_count {

: $del_file  = "$data_dir/$del_account";
                ^^^^^^^^^

   $data_dir is now part of $del_file


: $del_file .= ".count";

: my $fs_item  = "$data_dir/$del_file";
                  ^^^^^^^^^


   Now there are *two* $data_dir at the beginning of $fs_item...

   Is that what you wanted to do?


:    if (-d $fs_item)

   you are missing a curly to open the block


:       if (unlink $fs_item)

   you are missing a curly to open the block


:       $fs_item = "$deleted1";

   the quotes serve no purpose and are not needed


:       }

   that ends the subroutine definition...


:     else {
:     &error("File Deletion Error. $fs_item")
:     }
:   }
: }

   ... so what is that code there supposed to be?


: Am I going about this totally wrong?


   Asking us to troubleshoot fantasy code instead of the same
   code you have is totally wrong.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sun, 21 Feb 1999 23:24:48 +0300
From: Dmitry Diskin <dda@ic.ru>
Subject: Determine web directory size
Message-Id: <36D06B8F.9C45F948@ic.ru>

Hi,

Is there any simple solution for count the total size of files in
particular directory of web server? 

Dmitry.


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

Date: 23 Feb 1999 16:36:42 -0600
From: mch927@merle.acns.no.sp.am.nwu.edu
Subject: determining file name with -n flag
Message-Id: <uuxsobwg32d.fsf@brahms.polisci.nwu.edu>


If I have a script that executes with a -n (or -p) loop called with

	./script.pl < infile > outfile

is there anyway for script.pl to know the name of the file (here,
infile) being sent into it?

Thanks,

michael



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

Date: 23 Feb 1999 18:42:12 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: determining file name with -n flag
Message-Id: <39vhgspu0b.fsf@ibnets.com>

>>>>> "m" == mch927  <mch927@merle.acns.no.sp.am.nwu.edu> writes:

  m> If I have a script that executes with a -n (or -p) loop called with

  m> 	./script.pl < infile > outfile

  m> is there anyway for script.pl to know the name of the file (here,
  m> infile) being sent into it?

think about this a little. what does < mean and who interprets it? the
shell!! it opens the file and connects it to the stdin of the
program which is perl. so how can perl find out the name of the file? no 
normal way is possible.

why not have the script take the file names as arguments and open them
inside perl? or at least the input one and you can still use the -n/-p
loop but get the name of the file with $ARGV.

hth,

uri

-- 
Uri Guttman                             Hacking Perl for Ironbridge Networks
uri@sysarch.com				uri@ironbridgenetworks.com	


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

Date: Tue, 23 Feb 1999 23:20:25 GMT
From: jaymecox@my-dejanews.com
Subject: Re: determining number of returned rows in DBI.pm...
Message-Id: <7avd3g$8t8$1@nnrp1.dejanews.com>

I know this is a kludge, but if you replace $sth->rows with $DBI::rows
everything will work as expected.


In article <Pine.SOL.4.05.9902091509420.2090-100000@galaga.rs.itd.umich.edu>,
  Matthew Whitworth <mgwhit@ibm.net> wrote:
>
> I'm having trouble determing the number of rows returned by a SELECT
> statement using DBI and DBD::Oracle before I actually start calling
> $sth->fetchrow().
>
> I've looked at example code where the author checks $sth->rows immediately
> after calling $sth->execute, but when I do that the value of $sth->rows eq
> "DBI::st=HASH(0xb68b0)->rows" -- not really what I had in mind!
>
> Here's some sample code and output:
>
> #! /usr/local/bin/perl -w
>
> use diagnostics;
> use DBI;
>
> my $dbh = DBI->connect( "dbi:Oracle:satest",
>                      "system",
>                      $ARGV[0],          # send on the command line...
>                      {
>                          RaiseError => 1,
>                          AutoCommit => 0
>                      }
>                    ) || die $DBI::errstr;
>
> my $sql = "SELECT name FROM customers WHERE pexec = 'mgwhitw'";
> my $sth = $dbh->prepare($sql);
> die "$DBI::errstr\n" unless $sth;
> $sth->execute();
>
> if ( $sth->rows ) {
>
>     while ( my @row = $sth->fetchrow() ) {
>         print @row, "\n";
>     }
>
> } else {
>     print "no rows returned.", "\n";
>     print '$sth->rows =', "$sth->rows", "\n";
> }
>
> $sth->finish;
> $dbh->disconnect;
>
> -----
>
> nobhill:/usr/local/apache/htdocs/satest$ ./rowtest.pl mypassword
> no rows returned.
> $sth->rows =DBI::st=HASH(0xb68b0)->rows
>
> -----
>
> If I remove the "if ( $sth->rows )" bit, it actually prints out the values
> of several rows.
>
> -----
>
> nobhill:/usr/local/apache/htdocs/satest$ ./rowtest.pl mypassword
> Bobs Ribs
> City of Bakersfield Trash Management
> Scribble.com
>
> -----
>
> Any ideas?
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> matthew whitworth
> mgwhit@ibm.net
>
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 23 Feb 1999 22:05:05 GMT
From: mauro@msan. (Mauro Sanna)
Subject: Die function doesn't work.
Message-Id: <7av8mh$kpd$1@nslave1.tin.it>

Hi.
I use Linux Debian 2.0 with Perl 5.004.
I use a perl cgi to connect to a Mysql database.
In this example code:
$dbh = DBI->connect('DBI:mysql:Timbrature','mauro','')
|| die "can't connect";
the "die" function doesn't work.
Why?
Anyone can help me?
Thanks.


-- 
per rispondere togli <toglimi> dall'indirizzo di posta. 


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

Date: 24 Feb 1999 12:33:28 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Die function doesn't work.
Message-Id: <83btik9gtz.fsf@vcpc.univie.ac.at>

Re: Die function doesn't work., Mauro <mauro@msan.>
said:

Mauro> Hi.  I use Linux Debian 2.0 with Perl 5.004.
Mauro> I use a perl cgi to connect to a Mysql
Mauro> database.  In this example code: $dbh =
Mauro> DBI->connect('DBI:mysql:Timbrature','mauro','')
Mauro> || die "can't connect"; the "die" function
Mauro> doesn't work.  Why?  Anyone can help me?
Mauro> Thanks.

What do you mean by "doesn't work"?  Maybe the
connect is successful?

If it's a CGI program, where is die outputting to?
Have you told the program how to get error output
back to the browser (perldoc CGI --> fatalsToBrowser).

Mauro> -- per rispondere togli <toglimi>
Mauro> dall'indirizzo di posta.

Non, invia qui, leggi qui!    (rusty Italian :-)

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien.  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Wed, 24 Feb 1999 07:23:14 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Die function doesn't work.
Message-Id: <MPG.113db93a1c8fdfcc989681@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7av8mh$kpd$1@nslave1.tin.it>, on 23 Feb 1999 22:05:05 GMT 
mauro@msan. says...
 ...
> $dbh = DBI->connect('DBI:mysql:Timbrature','mauro','')
> || die "can't connect";
> the "die" function doesn't work.
> Why?

The precedences in your statement are wrong.  It is equivalent to:

  $dbh = (DBI->connect('DBI:mysql:Timbrature', 'mauro', '')
      || die "can't connect");

Try either this:

  ($dbh = DBI->connect('DBI:mysql:Timbrature', 'mauro', ''))
      || die "can't connect";

or (better style, in my opinion):

  $dbh = DBI->connect('DBI:mysql:Timbrature', 'mauro', '')
      or die "can't connect";

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 24 Feb 1999 09:46:02 -0700
From: James Garvin <boot@nmt.edu>
Subject: Re: Die function doesn't work.
Message-Id: <36D42CC9.4418CCF8@nmt.edu>

Mauro> Hi.  I use Linux Debian 2.0 with Perl 5.004.
Mauro> I use a perl cgi to connect to a Mysql
Mauro> database.  In this example code: $dbh =
Mauro> DBI->connect('DBI:mysql:Timbrature','mauro','')
Mauro> || die "can't connect"; the "die" function
Mauro> doesn't work.  Why?  Anyone can help me?
Mauro> Thanks.

I would have to see the rest of the code, but you should never use || die...always use or die...

the || die can sometimes cause your program to die for no reason other than || has more priorty

than some other things...

/* James M. Garvin */
/* CS 222 */
/* NOTE: Feed program on a regular basis */





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

Date: 24 Feb 1999 12:17:02 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: James Garvin <boot@nmt.edu>
Subject: Re: Die function doesn't work.
Message-Id: <m3g17vn2lt.fsf@joshua.panix.com>

James Garvin <boot@nmt.edu> writes:

>  you should never use || die...always use or die...
> 
> the || die can sometimes cause your program to die for no reason
> other than || has more priorty

Why do you want to take away a powerful and expressive piece of the
language?

Instead of recommending that people not use a language feature, I'd
recommend that people learn operator precedence.  Just print out the
first page of perlop and tape it up near your monitor.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 24 Feb 1999 18:49:23 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: Die function doesn't work.
Message-Id: <7b1hjj$4k7$1@news0-alterdial.uu.net>

Mauro Sanna <mauro@msan.> wrote:
> I use Linux Debian 2.0 with Perl 5.004.
> I use a perl cgi to connect to a Mysql database.
> In this example code:
> $dbh = DBI->connect('DBI:mysql:Timbrature','mauro','')
> || die "can't connect";
> the "die" function doesn't work.

Please define "doesn't work".  First, under what circumstances do you
expect DBI->connect to return false?  *Is* it returning false in your
application when you expect it to?

Also, where did you look for the "die" message?  In most CGI setups,
it'll be in the server's error log, but missing useful information such
as the date, time, and script name.  (See the CGI::Carp module for
information on adding that stuff.)

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: Wed, 24 Feb 1999 09:51:08 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Die function doesn't work.
Message-Id: <x3y1zjfetyb.fsf@tigre.matrox.com>


mauro@msan. (Mauro Sanna) writes:

> In this example code:
> $dbh = DBI->connect('DBI:mysql:Timbrature','mauro','')
> || die "can't connect";
> the "die" function doesn't work.

die() will only "work" if the DBI->connect() failed. Did it fail? are
you sure it did?



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

Date: Thu, 25 Feb 1999 00:23:18 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Die function doesn't work.
Message-Id: <1dnr85s.srguzsdfbmdcN@bay1-206.quincy.ziplink.net>

Larry Rosler <lr@hpl.hp.com> wrote:

> The precedences in your statement are wrong.  It is equivalent to:
> 
>   $dbh = (DBI->connect('DBI:mysql:Timbrature', 'mauro', '')
>       || die "can't connect");

What's wrong with that?

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
          perl -le 'print "Just another \u$^X hacker"'


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

Date: 25 Feb 1999 00:51:06 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Die function doesn't work.
Message-Id: <m34soa53bp.fsf@moiraine.dimensional.com>

rjk@linguist.dartmouth.edu (Ronald J Kimball) writes:

> Larry Rosler <lr@hpl.hp.com> wrote:
> 
> > The precedences in your statement are wrong.  It is equivalent to:
> > 
> >   $dbh = (DBI->connect('DBI:mysql:Timbrature', 'mauro', '')
> >       || die "can't connect");
> 
> What's wrong with that?

Nothing at all.  Especially since the alternative isn't saying
the same thing.  Consider-

  $tied_var = $some_var  || die 'oops!';
 ($tied_var = $some_var) || die 'oops!';

These two lines of code look amazingly similar considering just how
different they are.  First, a simple tie class.

    package Tie::AssignTest;
    
    sub TIESCALAR {
        my $class = shift;
        my $tie = 'bar';
        print "in TIESCALAR";
        return bless \$tie, $class;
    }
    
    sub FETCH {
        my $self = shift;
        print "in FETCH";
        return $$self;
    }
    
    sub STORE {
        my ($self, $value) = @_;
        print "in STORE";
        $$self = $value;
    }
    
    1;

And a little program to exercise it.
 
    #!/home/dgris/bin/perl5.00555 -l
    #
    # tieassign- playing with tie
    
    use strict;
    use Tie::AssignTest;
    
    my ($a, $tied_var);
    
    tie $tied_var, 'Tie::AssignTest';
    
    # $a = 1;                            
    # $tied_var  = $a  || die "oops";    # 1
    # ($tied_var = $a) || die "oops";    # 2

First we'll take a look at the normal case where $a is
defined and true (corresponding to $a being initialized).
With the assignment in 1 we get-

    $ ./tieassign 
    in TIESCALAR
    in STORE
    $ 

Just what we expected.  We assigned something to our variable
and STORE() was called.  That's not what happens when we use
the second assignment form, though.

    $ ./tieassign 
    in TIESCALAR
    in STORE
    in FETCH
    $ 

Hmmmm... why is our _assignment_ calling FETCH()?  Oh, it's because
we asked for the value back so that we could test it for truth.  You'd
better hope that FETCH() doesn't have any side effects (like advancing
a pointer into a deeper data structure hidden behind the tie()).

The difference between the two is even more pronounced when
$a isn't initialized.

The first assignment-

    $ ./tieassign 
    in TIESCALAR
    oops at ./tieassign line 13.
    $ 

The second-

    $ ./tieassign 
    in TIESCALAR
    in STORE
    in FETCH
    oops at ./tieassign line 14.
    $ 

I'm sure there are cases where the second behavior is what is desired,
but generally speaking the first is more likely to DWIM.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Thu, 25 Feb 1999 22:36:15 +0100
From: msan <mrsanna@tin.it>
Subject: Re: Die function doesn't work.
Message-Id: <36D5C24F.D79EF491@tin.it>

> The precedences in your statement are wrong.  It is equivalent to:
> 
>   $dbh = (DBI->connect('DBI:mysql:Timbrature', 'mauro', '')
>       || die "can't connect");
> 
> Try either this:
> 
>   ($dbh = DBI->connect('DBI:mysql:Timbrature', 'mauro', ''))
>       || die "can't connect";
> 
> or (better style, in my opinion):
> 
>   $dbh = DBI->connect('DBI:mysql:Timbrature', 'mauro', '')
>       or die "can't connect";
> 
Ok. I've tried this, but it still doesn't work.
I have no error messages in my html page when I can't connect to my
database.
It seems that die function is ignored.
Thanks.


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

Date: 25 Feb 1999 16:46:53 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Die function doesn't work.
Message-Id: <36d5e0ed@csnews>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, msan <mrsanna@tin.it> writes:
:Ok. I've tried this, but it still doesn't work.
:I have no error messages in my html page when I can't connect to my
:database.
:It seems that die function is ignored.

You're wrong.  die does not output things to the web page!

    use CGI::Carp qw(fatalsToBrowser);

might help.  Please try the CGI group.

--tom
-- 
The software required `Windows 95 or better', so I installed Linux.


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

Date: Tue, 23 Feb 1999 19:20:41 -0700
From: James Garvin <boot@nmt.edu>
Subject: Does anyone know where there are PerlTk tutorials?
Message-Id: <36D361F9.59757C9C@nmt.edu>


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

I need a PerlTk Tutorial, I don't know how to use PerlTk (I know TCL/TK,
but those commands don't seem to work)  Could anyone help me in this
endevor?

--

/* James M. Garvin */
/* CS 324 */
/* NOTE: Feed program on a regular basis */



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

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
I need a PerlTk Tutorial, I don't know how to use PerlTk (I know TCL/TK,
but those commands don't seem to work)&nbsp; Could anyone help me in this
endevor?
<pre>--&nbsp;

/* James M. Garvin */
/* CS 324 */
/* NOTE: Feed program on a regular basis */</pre>
&nbsp;</html>

--------------5C6966A35F2CD1CDA4697232--



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

Date: Tue, 23 Feb 1999 20:55:40 -0800
From: Ron Dilley <ron.dilley@ada.com>
Subject: Re: Does anyone know where there are PerlTk tutorials?
Message-Id: <36D3864C.FCC7AE23@ada.com>

James,

O'Reilly has a Perl/tk book out.

-----
http://www.amazon.com/exec/obidos/ASIN/1565923146/qid=919832191/sr=1-1/002-6846038-8754005
-----

Ron

James Garvin wrote:
> 
>    Part 1.1    Type: Plain Text (text/plain)
>            Encoding: 7bit

-- 
+--------------------------------------------------------+
|   Ron Dilley          Sr. UNIX Network Administrator   |
|   ron.dilley@ada.com          Applied Digital Access   |
+--------------------------------------------------------+


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

Date: 24 Feb 1999 18:51:29 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: Does anyone know where there are PerlTk tutorials?
Message-Id: <7b1hnh$4k7$2@news0-alterdial.uu.net>

James Garvin <boot@nmt.edu> wrote:
> --------------5C6966A35F2CD1CDA4697232
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit

Arg!  Please don't post HTML to USENET -- it's annoying and wasteful of
bandwidth.

> I need a PerlTk Tutorial, I don't know how to use PerlTk (I know TCL/TK,
> but those commands don't seem to work)  Could anyone help me in this
> endevor?

Have you seen the new book *Learning Perl/Tk*, written by Nancy Walsh
and published by O'Reilly & Associates?  I thumbed through it in a
bookstore and it looks like it covers the fundamentals -- probably worth
picking up if you need an intro.

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

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

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