[16566] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3978 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 10 18:05:45 2000

Date: Thu, 10 Aug 2000 15:05:25 -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: <965945125-v9-i3978@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 10 Aug 2000     Volume: 9 Number: 3978

Today's topics:
        'require'd functions access main variables <ab@cd.com>
    Re: 'require'd functions access main variables <tim@ipac.caltech.edu>
    Re: 'require'd functions access main variables <ab@cd.com>
    Re: 'require'd functions access main variables (Robert Hallgren)
    Re: [Q]s: sizeof in perl, ioctl.ph... (Decklin Foster)
        Active Perl for Linux...   <lmoran@wtsg.com>
    Re: Active Perl for Linux... <kperrier@blkbox.com>
    Re: Active Perl for Linux... <lmoran@wtsg.com>
        ANNOUNCE: Quantum::Superpositions 1.03 (Damian Conway)
        ANNOUNCE:Astro::Sunrise 0.02 initial release <hillr@ugsolutions.com>
        Apache/EmbPerl on Win32 Platform <par@bahnhof.removethis.se>
    Re: Best way to copy Dirs containing both binary and te linga@my-deja.com
        calculating with getting a formula out of a $string <domi@boulevards.de>
    Re: calculating with getting a formula out of a $string (Logan Shaw)
    Re: Cant figure this out. <lr@hpl.hp.com>
    Re: Check existence of a remote file!!! (Logan Shaw)
    Re: Check existence of a remote file!!! (Logan Shaw)
    Re: Date convert <lr@hpl.hp.com>
        DBD oracle install HELP! - LD [lnetv2] ?? btaneja@my-deja.com
    Re: DBI question from a Newbie - handling Nulls (Jon Drukman)
    Re: DBI question from a Newbie - handling Nulls <jeff@vpservices.com>
        Encryption <webmaster@jewelion.com>
    Re: Encryption <care227@attglobal.net>
    Re: Encryption (Logan Shaw)
    Re: form replies in HTML <drawbridge@home.com>
        Get the Time <as@if.com>
    Re: Get the Time <tom.kralidis@ccrs.nrcan.gcDOTca>
    Re: Get the Time <mjcarman@home.com>
    Re: GREP - type of script... <lr@hpl.hp.com>
    Re: LWP::UserAgent & login (brian d foy)
        Mail::Header nancy@bigfishmail.com
    Re: Mail::Header (Logan Shaw)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 10 Aug 2000 20:59:23 GMT
From: "Blair Heuer" <ab@cd.com>
Subject: 'require'd functions access main variables
Message-Id: <LIEk5.2377$3M.66400@newsread1.prod.itd.earthlink.net>

I split my script up into a couple different files according to their
functions (database, parsing, etc.) to make them easier to update and view.
I include the functions with 'require.' None of the function are able to
access any variables declared in the main script. At first it just gave me
undeclared errors, so I tried changing the names to: $main::variable
(actually more along the lines of $main::hash{ key }), which did not give an
error, but was empty.

So, my question is, how do I get the variables from the main script? Do I
have to pass every variable I wish to use as a parameter?

Thanks,
-Blair




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

Date: Thu, 10 Aug 2000 14:27:25 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: 'require'd functions access main variables
Message-Id: <39931E3D.FD5C8D5D@ipac.caltech.edu>

Blair Heuer wrote:
> 
> I split my script up into a couple different files according to their
> functions (database, parsing, etc.) to make them easier to update and view.
> I include the functions with 'require.' None of the function are able to
> access any variables declared in the main script. At first it just gave me
> undeclared errors, so I tried changing the names to: $main::variable
> (actually more along the lines of $main::hash{ key }), which did not give an
> error, but was empty.
> 
> So, my question is, how do I get the variables from the main script? Do I
> have to pass every variable I wish to use as a parameter?

Well it's certainly going to be easier if you pass parameters around as sub args
rather than globals. It might be a little fussier to write, but everything is
easier afterwards.

Can't tell why what you're doing doesn't work without a short, on point test
case. Throw us a bone here ...

--

-- Tim Conrow         tim@ipac.caltech.edu       626-395-8435


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

Date: Thu, 10 Aug 2000 21:48:21 GMT
From: "Blair Heuer" <ab@cd.com>
Subject: Re: 'require'd functions access main variables
Message-Id: <FqFk5.2448$3M.68847@newsread1.prod.itd.earthlink.net>

> Can't tell why what you're doing doesn't work without a short, on point
test
> case. Throw us a bone here ...

Ok, here is one sample of what I need this for:

In the main script:

    &load( 'standard' );

In a required 'parse.pl' file:

    sub load() {
     open ( TEMPLATE, "$s{'board_data'}/$i{'cid'}/templates/$_[0].pbml" )
      or open ( TEMPLATE, "$s{'sys_data'}/templates/$_[0].pbml" )
      or die "Template file could not be found or opened.";
      my $template = join( '', <TEMPLATE> );
     close ( TEMPLATE );
     ...
    }

So, instead of the simple passing of the template name, I would need to pass
the system (%s) and input (%i) hashes.

It gets even more complicated when parsing a template which would need more
hashes passed through multiple functions (I have a s// which passes found
data to a function to be parsed, and that would need to keep passing the
variables on as well).

So, it would be easiest to figure out how to get the functions to use code
from the main file. If I can't find an easy way to accomplish this, I will
just put the code back into the main file and all problems will be solved,
but I'd like to figure a way to do it like this.

Thanks,
-Blair




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

Date: Thu, 10 Aug 2000 21:56:48 GMT
From: sandhall@swipnet.se (Robert Hallgren)
Subject: Re: 'require'd functions access main variables
Message-Id: <slrn8p68i9.239.sandhall@poetry.lipogram>

On Thu, 10 Aug 2000 20:59:23 GMT,
 Blair Heuer <ab@cd.com> wrote:

> I include the functions with 'require.' None of the function are
> able to access any variables declared in the main script.

Some examples would help in understanding what you're trying to do.

[...]
> So, my question is, how do I get the variables from the main script?
> Do I have to pass every variable I wish to use as a parameter?

Would recommend that, yes, instead of using global variables where not
needed. If you're splitting up the code for easy maintainment, I don't
understand why you would want to mess it up with global variables.

<URL: http://www.plover.com/~mjd/perl/FAQs/Namespaces.html >

But it's not impossible to do what you ask for. This would work:

file2.pl
----------
  sub testsub { print $testvar }
  1;

file1.pl
----------
  #!/usr/bin/perl -w
  use strict;
  use vars '$testvar';
  use subs 'testsub';
  require "file2.pl";
  $testvar = "Foobar";
  testsub;



Robert
-- 
Robert Hallgren <sandhall@swipnet.se>

PGP: http://www.lipogram.com/pgpkey.asc
5F1E 95C2 F0D8 25A3 D1BE 0F16 D426 34BD 166A 566C


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

Date: Thu, 10 Aug 2000 20:53:07 GMT
From: decklin+usenet@red-bean.com (Decklin Foster)
Subject: Re: [Q]s: sizeof in perl, ioctl.ph...
Message-Id: <TCEk5.15488$f_5.77253@news1.rdc1.ct.home.com>

kj0 <kj0@mailcity.com> writes:

>   syswrite OUT, $x, $sizeof_x;

Why? Do you *need* $sizeof_x? Maybe you should read the documentation
for syswrite first.

-- 
There is no TRUTH. There is no REALITY. There is no CONSISTENCY. There
are no ABSOLUTE STATEMENTS. I'm very probably wrong. -- BSD fortune(6)


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

Date: Thu, 10 Aug 2000 14:27:35 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Active Perl for Linux...  
Message-Id: <8vOSOQ4MBGAr6pkczJUWnGYu0xM0@4ax.com>

--Any advantages, dis-advantages?



 ...no Y2K was fine, it was W2K we had the problems with..
lmoran@wtsg.com


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

Date: 10 Aug 2000 16:18:10 -0500
From: Kent Perrier <kperrier@blkbox.com>
Subject: Re: Active Perl for Linux...
Message-Id: <075F57644B9A41EC.68BB89F329C97CCE.F02C278F600C52E5@lp.airnews.net>

Lou Moran <lmoran@wtsg.com> writes:

> --Any advantages, dis-advantages?

Active perl?  whats that?  Are you talking about Activestate perl?  That
is for Win32.  If you want perl for your linux box, grab the source, compile
and install it.

Kent
-- 
You think your Commodore 64 is really neato
What kinda chip you got in there, a Dorito?
Weird Al -- All about the Pentiums


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

Date: Thu, 10 Aug 2000 17:35:12 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: Active Perl for Linux...
Message-Id: <GB6TOXV9wtr8uMv86FRiU8ur=cyN@4ax.com>

Kent,
 ActiveState calls their product ActivePerl...  They have Linux
distros available (RH rpm, Debian, Linux AS...) so I was merely
wondering if there would be any advantage or disadvantage to using it
over the pre-installed Perl from my RH 6.2 distro, or the Perl
available at www.perl.org (et al).

And while pricking my forefinger (index if you like) is probably the
purest way to write I chose this news reader instead.  But thank you
for your thoughtful and insightful response.

On 10 Aug 2000 16:18:10 -0500, Kent Perrier <kperrier@blkbox.com>
wrote:

>Lou Moran <lmoran@wtsg.com> writes:
>
>> --Any advantages, dis-advantages?
>
>Active perl?  whats that?  Are you talking about Activestate perl?  That
>is for Win32.  If you want perl for your linux box, grab the source, compile
>and install it.
>
>Kent


 ...no Y2K was fine, it was W2K we had the problems with...
lmoran@wtsg.com


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

Date: 10 Aug 2000 19:51:01 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: ANNOUNCE: Quantum::Superpositions 1.03
Message-Id: <sp620u3pn4t127@corp.supernews.com>
Keywords: perl, module, release

==============================================================================
              Release of version 1.03 of Quantum::Superpositions
==============================================================================


NAME
    Quantum::Superpositions - QM-like superpositions for Perl

DESCRIPTION

    The Quantum::Superpositions module provides a new scalar data
    structure: the superposition. In a metaphor drawn from quantum
    mechanics, superpositions store a collection of values by overlaying
    them in parallel superimposed states within a single scalar
    variable. Which allows for cool stuff like:

        use Quantum::Superpositions;

        if ($x == any($a, $b, $c) { ...  }

        while ($nextval < all(@thresholds) { ... }

        $max = any(@value) < all(@values);

AUTHOR
    Damian Conway (damian@conway.org)

COPYRIGHT
    Copyright (c) 1997-2000, Damian Conway. All Rights Reserved. This module
    is free software. It may be used, redistributed and/or modified under
    the terms of the Perl Artistic License (see
    http://www.perl.com/perl/misc/Artistic.html)


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

CHANGES IN VERSION 1.03


	- Fixed argument passing to superimposed subroutines.
	  [should now test cleanly under 5.6.0]


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

AVAILABILITY

Quantum::Superpositions has been uploaded to the CPAN
and is also available from:

	http://www.csse.monash.edu.au/~damian/CPAN/Quantum-Superpositions.tar.gz

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




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

Date: Thu, 10 Aug 2000 11:16:52 -0700
From: Ron Hill <hillr@ugsolutions.com>
Subject: ANNOUNCE:Astro::Sunrise 0.02 initial release
Message-Id: <sp60ocb5n4t78@corp.supernews.com>

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

              Release of version 0.02 of Astro::Sunrise
==============================================================================

 NAME

Astro::Sunrise - Perl extension for computing the sunrise/sunset on a
given day

 SYNOPSIS

  use Astro::Sunrise;

 @array = sunrise(YYYY,MM,DD,longitude,latitude,Time Zone,DST);

  this will return an array, containing rise time/set time in local
time!!
  (Note: Time Zone is the offset from GMT and DST is daylight
  savings time, 1 means DST is in effect and 0 is not.

 DESCRIPTION


   This module will return the sunrise/sunset for a given day.
   Many thanks go to Paul Schlyer, Stockholm, Sweeden for his excellent
   web page on the subject.


AUTHOR
Ron Hill
rkhill@pacbell.net




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

Date: Thu, 10 Aug 2000 21:37:29 GMT
From: Par Svensson <par@bahnhof.removethis.se>
Subject: Apache/EmbPerl on Win32 Platform
Message-Id: <tgFk5.26$7P4.33783@news.bahnhof.se>

Hi,

I have downloaded the binary distribution of Apache/EmbPerl (perl-win32-bin-0.6.exe)
and installed it, following the instructions. However, after starting the Apache web
server and loading a file containing embedded Perl, the Perl code just shows up,
without being executed. I have tried both using the httpd.conf-dist-win and
httpd.conf-perl configuration files, both including the line 
LoadModule perl_module modules/ApacheModulePerl. 
I am running Windows 98 and my test file was:

<HTML>
<BODY>
[- $a=5 -]
[+ $a +]
</BODY>
</HTML>


The documentation doesn't say much about Win32-installation at all. Hope
someone can help me, or give me a pointer in the right direction.

Thanks,

/Par



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

Date: Thu, 10 Aug 2000 21:35:37 GMT
From: linga@my-deja.com
Subject: Re: Best way to copy Dirs containing both binary and text data
Message-Id: <8mv779$9sa$1@nnrp1.deja.com>

Thanks Brendon, it worked perfectly.  I had a regex that changed all
the forward slashes to back slashes:
$source =~ s/\//\\/g;
and then I called xcopy with the s, e, and i flags.
thanks again,
sanjay

In article <8muomp$hdt$1@news.news-service.com>,
  "Brendon Caligari" <bcaligari@shipreg.com> wrote:
>
> <linga@my-deja.com> wrote in message news:8muh13
$nhi$1@nnrp1.deja.com...
> > Hi, my script needs to copy directories from a network share onto my
> > box.  The contents of the directories are a mix of both binary and
text
> > data.  I was thinking about using File::Recurse as such:
> > recurse {copy($_, dir2)} dir1
> > but the File::Copy command doesn't check for the format of the
data.  I
> > was considering modifying the File::Copy module so that it would
test
> > the filehandle which would switch the filehandle to binary if
> > necessary, but I was concerned about portability.  How should I
> > approach this?  Is the use of File::Copy::copydir preferable?  This
is
> > my modification to the File::Copy module...any suggestions regarding
> > these?  Thanks for your help,
> > Sanjay
> >
>
> system("xcopy $source $dest /e /s");
>
> should do the trick........dirty....lazy...but works.
>
> Brendon
> ++++
>
>


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


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

Date: Thu, 10 Aug 2000 19:09:10 +0200
From: Dominik Leinfelder <domi@boulevards.de>
Subject: calculating with getting a formula out of a $string
Message-Id: <3992E1B6.9F2B7188@boulevards.de>

Hi,

I've got this problem:
I want to calkulate from an $int with a $formula (like "*1.16").
I'm getting the values out of a DBMS.
Now I'm wondering how I could get the Result into a new $var.
(29 * 1.16 for example)
Is this possible at all? If so, how to catch the result?
(Maybe I can't get the $formula to be executet in my code?..)

I don't know where to look - maybe someone has a hint for me?
(some perldoc or somewhere in one of the Oreilly's)

tia
Dominik Leinfelder


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

Date: 10 Aug 2000 13:49:03 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: calculating with getting a formula out of a $string
Message-Id: <8mutev$grq$1@provolone.cs.utexas.edu>

In article <3992E1B6.9F2B7188@boulevards.de>,
Dominik Leinfelder  <domi@boulevards.de> wrote:
>I've got this problem:
>I want to calkulate from an $int with a $formula (like "*1.16").
>I'm getting the values out of a DBMS.
>Now I'm wondering how I could get the Result into a new $var.
>(29 * 1.16 for example)
>Is this possible at all? If so, how to catch the result?
>(Maybe I can't get the $formula to be executet in my code?..)

Do you mean you have a string like "1 + 1" and you want to convert
it into a string like "2"?  If so, that's easy:

	$expr = "1 + 1";
	$result = eval $expr;
	# $result is now the number 2.

Be careful, though.  eval will execute *any* perl code, so this could
be a security risk is someone puts "system ('rm -rf /'), 1 + 1" in the
database instead of "1 + 1".  If you have total control over the
contents of the database, then that's great.  Otherwise, you need to
either look at some alternate method or _very_ carefully clean up the
expression before trying to execute it.

  - Logan


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

Date: Thu, 10 Aug 2000 11:48:07 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Cant figure this out.
Message-Id: <MPG.13fc98c01742aec798ac60@nntp.hpl.hp.com>

In article <x71yzx15z7.fsf@home.sysarch.com> on Thu, 10 Aug 2000 
15:38:36 GMT, Uri Guttman <uri@sysarch.com> says...
> >>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
> 
>   BL> Uri Guttman wrote:
>   >> why the assigment? just use s///
>   >> 
>   >> $var =~ s/(.*)#/$1/ ;
> 
>   BL> 	^var =~ s/(.*)#.*/$1/;
> 
>   BL> You don't want to delete just that character.
> 
> yep. 3am coding is not smart. but still the assignment was not the best way.

Neither is the regex and substitution.  Though it is wordier, *this* is 
the best (fastest) way:

    substr($var, rindex $var, '#') = "";

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


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

Date: 10 Aug 2000 13:40:13 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Check existence of a remote file!!!
Message-Id: <8musud$gph$1@provolone.cs.utexas.edu>

In article <GSAk5.18$3T6.1780@monolith.news.easynet.net>,
JohnnyP <JohnP@townpages.co.uk> wrote:
>Hi, I am trying to figure out how to check the existence of a remote file in
>my perl program on a Solaris 7 system running perl 5.003.  The remote host
>is not sharing filesystems, but does allow rsh, rlogin etc.
>
>The purpose of this is to perform an error check after rcp'ing a number of
>files to the remote host from the master server.
>
>I just can't figure out how to connect to the remote host, check for the
>file and return a value back into the perl script to flag it's existence or
>not.

I believe this should do it:

	open(FOO, "rsh -n '$hostname' "
			. "test -e '$filename' && echo exists || echo dne\" |")
		or die "Can't run command because '$!'\n";
	$answer = undef;
	while (<FOO>)
		{
		/^exists/ && $answer = 1;
		/^dne/ && $answer = 0;
		}
	close FOO;

Hope that helps.

  - Logan


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

Date: 10 Aug 2000 13:41:57 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Check existence of a remote file!!!
Message-Id: <8mut1l$gqh$1@provolone.cs.utexas.edu>

In article <8musud$gph$1@provolone.cs.utexas.edu>,
Logan Shaw <logan@cs.utexas.edu> wrote:
>	open(FOO, "rsh -n '$hostname' "
>			. "test -e '$filename' && echo exists || echo dne\" |")

Grrr...  What I meant to type was this:

	open(FOO, "rsh -n '$hostname' "
		. "\"test -e '$filename' && echo exists || echo dne\"|")

  - Logan


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

Date: Thu, 10 Aug 2000 11:56:08 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Date convert
Message-Id: <MPG.13fc9aa58e83091d98ac61@nntp.hpl.hp.com>

In article <8muc79$jha$1@nnrp1.deja.com> on Thu, 10 Aug 2000 13:54:52 
GMT, bakhshek@essilor.fr <bakhshek@essilor.fr> says...
> Est-ce que quelqu'un sait si il y a un module en perl(V 5.6) qui permet
> de savoir le temps écoule entre deux date.
> 
> Mon Jul 24 20:12:28 METDST 2000
> Mon Jul 24 23:51:53 METDST 2000
> ---------------------------------------------
> 	     3:39:25

perlfaq4: "How can I compare two dates and find the difference?"

> Si non comment faire pour enlever la partie fractionnaire de mon $tt:
> 
> sub foo
> {
> 	(local $h, $m, $s, $tt) = 0;

That is not valid Perl.  You should use 'my', not 'local', and the 
parentheses are wrong.

perlfaq7: "What's the difference between dynamic and lexical (static) 
scoping? Between local() and my()?"

> 	$tt = 13165;
> 	$tt %= 3600;
> 	$tt ==> 3.65694444444444;   # comment faire pour n'avoir que 3
> }

perldoc -f int

> Merci

Il n'y a pas de quois.

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


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

Date: Thu, 10 Aug 2000 20:29:11 GMT
From: btaneja@my-deja.com
Subject: DBD oracle install HELP! - LD [lnetv2] ??
Message-Id: <8mv3ag$6oi$1@nnrp1.deja.com>



I am trying to "make" DBD.. however it keeps bailing out
as below...

I do not have any LD_LIBRARY_PATH setup.. could this be the problem..
If so what should it be... ?? the LD_LIB_PATH is not mentioned in the
install manual .. HELP??

thanks,
Bruce, Chicago


Running Mkbootstrap for DBD::Oracle ()
        chmod 644 Oracle.bs
        LD_RUN_PATH="" ld -o blib/arch/auto/DBD/Oracle/Oracle.sl  -b -
s -a shared Oracle.o  dbdimp.o  oci7.o  oci8.o -
L/u01/oracle/product/8.0.6/lib/ -
L/u01/oracle/product/8.0.6/rdbms/lib   -
clntsh /u01/oracle/product/8.0.6/lib/nautab.o /u
01/oracle/product/8.0.6/lib/naeet.o /u01/oracle/product/8.0.6/lib/naect.
o /u01/oracle/product/8.0.6/lib/naedhs.o
`cat /u01/oracle/product/8.0.6/lib/naldflgs`  -lnetv2 -lnttcp -
lnetwork -lncr  -lnetv2 -lnttcp -lnetwork -lclient -lvsn -lcommon -
lgeneric -lmm -lnlsrtl3  -lcore4 -lnlsrtl3 -lcore4 -lnlsrtl3 -lnetv2 -
lnttcp-lnetwork -lncr  -lnetv2 -lnttcp -lnetwork -lclient -lvsn -
lcommon -lgeneric  -lepc -lnlsrtl3  -lcore4 -lnlsrtl3 -lcore4 -
lnlsrtl3 -lclient -lvsn -lcommon -lgeneric -lnlsrtl3  -lcore4 -
lnlsrtl3 -lcore4 -lnlsrtl3
`cat /u01/oracle/product/8.0.6/lib/sysliblist`  -lm
ld: Can't find library for -lnetv2
*** Error exit code 1

Stop.


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


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

Date: Thu, 10 Aug 2000 21:59:35 GMT
From: jsd@cluttered.com (Jon Drukman)
Subject: Re: DBI question from a Newbie - handling Nulls
Message-Id: <slrn8p69ea.vg0.jsd@cluttered.com>

On Thu, 10 Aug 2000 13:09:02 GMT,
 gavin_gibson@my-deja.com <gavin_gibson@my-deja.com> wrote:
>objecting to. It seems that Perl is holding the 'null' values in a
>'format' my sql doesn't like. I'm wondering if anyone can give me some
>advice on how to get my null values into an acceptable format for my
>sql? Many thanks in advance.

DBI returns undef for NULL, so you'll have to chase down and destroy
all undefs in the data you try to insert.  Here's a good way of 
doing that...

>foreach $line(@$BILL_DETAILS){
>        $DBSd->execute(@$line);
>}

change the middle line to:

$DBSd->execute(map { defined $_ ? $_ : '' } @$line);

this will replace all occurences of undef from @$line with
empty strings.

-jsd-




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

Date: Thu, 10 Aug 2000 14:59:50 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: DBI question from a Newbie - handling Nulls
Message-Id: <399325D6.E5EC88C8@vpservices.com>

gavin_gibson@my-deja.com wrote:
> 
> I'm fairly new to Perl and very new to DBI (I'm running on Ingres) 
> ...
> some of the fields in each table are NULL values, which the DBI is
> objecting to.

I don't know specifically about Ingres, but most DBI databases treat
perl undef as NULL so a statement like this works:

my $sth = $dbh->prepare(qq/
    INSERT INTO foo (col1,col2,col3) VALUES (?,?,?)
/);
$sth->execute('bar',undef,3);

That should end up with col1='bar' and col3=3 and IS NULL true for
col2.  

If your data uses an empty string or the string 'NULL' for NULLS (bad
data, bad data), then you should clean it up before the execute,
something like this which replaces all columns that have empty strings
or the string 'NULL' with undef:

@data = map { /^$/ || /^NULL$/ ? undef : $_ } @data;
# ...
$sth->execute(@data);

Modify the cleanup process if your data uses something else for NULL or
if for some reason Ingres needs the NULLs as something other than undef.


Jeff
-- 
perl -MDBI -e "$d=DBI->connect('dbi:RAM:');
$d->func(['Just,Another,Perl,Hacker'],'import');
print join ' ', $d->selectrow_array('SELECT * FROM table1')"


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

Date: Thu, 10 Aug 2000 20:01:55 +0100
From: "Julian Stokes" <webmaster@jewelion.com>
Subject: Encryption
Message-Id: <8muu32$ru8$1@phys-ma.sol.co.uk>

Does anyone out there know of a good perl encryption routine suitable, say,
for storing info gathered from a web page form in a file on a web server.
Or where would be a good place to look...

Regards,

Julian






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

Date: Thu, 10 Aug 2000 15:34:58 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Encryption
Message-Id: <399303E2.3BFBCACE@attglobal.net>

Julian Stokes wrote:
> 
> Does anyone out there know of a good perl encryption routine suitable, say,
> for storing info gathered from a web page form in a file on a web server.
> Or where would be a good place to look...

http://search.cpan.org


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

Date: 10 Aug 2000 14:46:52 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Encryption
Message-Id: <8mv0rc$h7t$1@provolone.cs.utexas.edu>

In article <8muu32$ru8$1@phys-ma.sol.co.uk>,
Julian Stokes <webmaster@jewelion.com> wrote:
>Does anyone out there know of a good perl encryption routine suitable, say,
>for storing info gathered from a web page form in a file on a web server.
>Or where would be a good place to look...

CPAN would be a good place to look.  There's a document called
"The Perl 5 Module List" that has a section on encryption.

I'm not sure of specifics of what you're trying to accomplish, but if
you only want to gather the information on the web server and later do
something else with it somewhere else, then public/private key
cryptography would be nearly ideal.  Keep a private key somewhere
that's not on the web server but keep the public key on the web
server.  Then, you can encrypt the information on the web server using
the public key and the web server will have no way to get it back
again.  Thus, if someone breaks in to the web server, your information
will still be secure.

  - Logan


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

Date: Thu, 10 Aug 2000 18:25:40 GMT
From: DM <drawbridge@home.com>
Subject: Re: form replies in HTML
Message-Id: <3992F400.2FA4906F@home.com>


As long as the email program recieving the e-mail can accept HTML.  For
example when i get ads and e-mails from Amazon and stuff, that is HTML. 
The HTML tags should be used in the body of the message.  The Perl and
all variables can be placed into a single variable  for holding your
message body like so:

$MessageBody = <<"HOLDHTML";

<HTML>
<HEAD> 
  <meta http-equiv="Content-Type" content="text/HTML;
charset=iso-8859-1">
  <TITLE>Testpage</TITLE>
<BODY>
<!--    ================ Message here ================    -->

<TABLE>
Name:  $Name
</TABLE>


<!--    ================ Message here ================    -->
</BODY>
</HTML>

HOLDHTML

print "Content-type: text/html\n\n";
print $MessageBody;


==== Good luck.
____James

Kimochi3D wrote:
> 
> Hi!
> Is it possible to receive html emails from a self made script? Is it as
> simple as placing the <HTML> tags into the output meant for the targeted
> user? I have a client who wants her reply forms looking exactly as what her
> customers fill in on her website, which means the emails she receives from
> them must look like the website....
> 
> Do post here I lurk.... and miss.... replies to email are of course best!
> Thanks!
> 
> --
> *remove nospam from email address before reply!*
> 
> Regards,
> Alvin Yap
> http://www.kimochi3d.com


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

Date: Thu, 10 Aug 2000 18:25:53 GMT
From: "Kermit" <as@if.com>
Subject: Get the Time
Message-Id: <RsCk5.138709$Gh.1990722@news20.bellglobal.com>

Just discovered how to get the time, hope this helps someone somewhere.

$watch = time;
$clock = localtime $watch;

print $clock;







Cheers.




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

Date: Thu, 10 Aug 2000 14:38:16 -0400
From: "Tom Kralidis" <tom.kralidis@ccrs.nrcan.gcDOTca>
Subject: Re: Get the Time
Message-Id: <8musqo$qh13@nrn2.NRCan.gc.ca>

Kermit <as@if.com> wrote in message
news:RsCk5.138709$Gh.1990722@news20.bellglobal.com...
> Just discovered how to get the time, hope this helps someone somewhere.
>
> $watch = time;
> $clock = localtime $watch;
>
> print $clock;
>
>
> Cheers.
>
When my watch breaks, I use:

perl -e 'print localtime(time) . "\n";'

FYI, I'm sure the newsgroup would appreciate question-type postings, rather than
(simple) arbitrary code snippets.

 ..Tom




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

Date: Thu, 10 Aug 2000 14:29:06 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Get the Time
Message-Id: <39930282.91A72BBB@home.com>

Tom Kralidis wrote:
> 
> FYI, I'm sure the newsgroup would appreciate question-type 
> postings, rather than (simple) arbitrary code snippets.

It could be worse -- he could have rewritten the builtins. ;-)

-mjc


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

Date: Thu, 10 Aug 2000 11:16:45 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: GREP - type of script...
Message-Id: <MPG.13fc9166e20c4f9498ac5d@nntp.hpl.hp.com>

In article <8m05ps0entbl9skkba1frpdoppiu5ghhj4@4ax.com> on Thu, 10 Aug 
2000 10:30:17 GMT, Bart Lateur <bart.lateur@skynet.be> says...

 ...

> Like I said. The command line:
> 
> 	perl -pi.bak -e "s/^test(?=,)/whatever/" foo.txt
> 
> will rename foo.txt to foo.bak, and make a new, modified version for
> foo.txt. (On Unix, replace the quotes with single quotes.)
> 
> The backup is a side effect. I'm not sure about newer evolutions, but
> last time I looked, you couldn't use the -i (modify file itself) option
> without making a backup.

It is time that you took another look.  Here is an excerpt from perlrun:

-i[extension]

 ...

If no extension is supplied, no backup is made and the current file is 
overwritten.

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


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

Date: Thu, 10 Aug 2000 14:17:22 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: LWP::UserAgent & login
Message-Id: <brian-ya02408000R1008001417220001@news.panix.com>

In article <8muls4$rhn$1@nnrp1.deja.com>, beginner <lliu00@my-deja.com> posted:

>    I am using LWP::UserAgent to access web page at
> http://www.xxx.com/login.dll, there is login dialog in the first place,
> asking for login and password information. How do I pass login and
> password to the server and pass througth login screen?

the LWP docs has an example of what you need to do.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Thu, 10 Aug 2000 18:41:59 GMT
From: nancy@bigfishmail.com
Subject: Mail::Header
Message-Id: <8mut1m$1gu$1@nnrp1.deja.com>

I need to extract the header of a mail message from a message contained
in a file.  I believe I can use the Mail::Header module to do this.
At this point, I merely want to grab serveral of the headers and
examine their values (Precedence and Sender).

I've looked at the man pages for Mail::Header, but I'm having trouble
finding samples that do this.  I think I need to use the read method to
grab the header out of the file, but after that I'm not sure how to get
into the values.

Does anyone have some tips on this?


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


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

Date: 10 Aug 2000 14:00:14 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Mail::Header
Message-Id: <8muu3u$gvn$1@provolone.cs.utexas.edu>

In article <8mut1m$1gu$1@nnrp1.deja.com>,  <nancy@bigfishmail.com> wrote:
>I need to extract the header of a mail message from a message contained
>in a file.  I believe I can use the Mail::Header module to do this.
>At this point, I merely want to grab serveral of the headers and
>examine their values (Precedence and Sender).
>
>I've looked at the man pages for Mail::Header, but I'm having trouble
>finding samples that do this.  I think I need to use the read method to
>grab the header out of the file, but after that I'm not sure how to get
>into the values.

Like this:

	use Mail::Internet;

	# read in the file
	@lines = <>;

	# build a Mail::Internet object, which includes a Mail::Header
	$mail_object = new Mail::Internet (\@lines);

	# get the Mail::Header object
	$header = $mail_object->head;

	# get the two headers we want
	$Precedence = $header->get ('Precedence');
	$Sender = $header->get ('Sender');

Hope that helps.

  - Logan


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

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


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