[11505] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5105 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 10 21:07:19 1999

Date: Wed, 10 Mar 99 18:00:22 -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           Wed, 10 Mar 1999     Volume: 8 Number: 5105

Today's topics:
        BigInt: Decimal to Hex <jeromeo@atrieva.com>
    Re: FAQ 3.21: How can I hide the source for my Perl pro (John Moreno)
        FAQ 3.26: Why don't perl one-liners work on my DOS/Mac/ <perlfaq-suggestions@perl.com>
    Re: foreach question (Larry Rosler)
    Re: How best to do multi-file scripts (Ethan H. Poole)
    Re: How best to do multi-file scripts <benbean@yahoo.com>
    Re: I want to know where I can get a sendmail program t ("Adrian Fiorinni")
    Re: I want to know where I can get a sendmail program t ("Adrian Fiorinni")
    Re: I want to know where I can get a sendmail program t <All@n.due.net>
        Memory management & Perl to C extensions (Helena Jeeves)
    Re: Memory management & Perl to C extensions (Ilya Zakharevich)
    Re: MS ACCESS database with perl bcs_webnet@my-dejanews.com
    Re: Net::FTP through squid? <ltl@rgsun5.viasystems.com>
    Re: Newbe Perl question: fs equiv? <rwilliamson@uno.gers.com>
    Re: Newbe Perl question: fs equiv? <msholund@bigfoot.com>
    Re: Newbie question about references/deferencing <andy@andymen.demon.co.uk>
        Perl for antenna positioner article? travis@deskin.com
    Re: Perl interface with yppasswd <ltl@rgsun5.viasystems.com>
    Re: Perl scripts written for UNIX. Will they work on NT (Ethan H. Poole)
    Re: PerlScript locking up MS Access file bcs_webnet@my-dejanews.com
    Re: PerlTk for Win32 ? <aqumsieh@matrox.com>
        please help <koh_cc@pacific.net.sg>
    Re: problems reading HTML file (Clinton Pierce)
    Re: problems with readdir (Clinton Pierce)
        Regex help needed pabs2000@my-dejanews.com
        Script not going well! <roncole@aye.net>
    Re: sigals <aqumsieh@matrox.com>
    Re: split? (Larry Rosler)
    Re: URGENT: Problem with Bitwise AND <aqumsieh@matrox.com>
        Writing to a file olmert@netvision.net.il
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 10 Mar 1999 16:09:33 -0800
From: "Jerome O'Neil" <jeromeo@atrieva.com>
Subject: BigInt: Decimal to Hex
Message-Id: <36E709BD.171E2FDA@atrieva.com>

I have been unsuccessful in attempting to convert large decimal integers
(>20 digits) to their hexadecimal equivalents.

SCO drops core with printf("%x"), and Math::BigInt doesn't support
conversions.  Where else might I look for big_dec2hex conversion code?

Thanks!
 
-- 
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947 
The Atrieva Service: Safe and Easy Online Backup  http://www.atrieva.com


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

Date: Wed, 10 Mar 1999 20:46:38 -0500
From: planb@newsreaders.com (John Moreno)
Subject: Re: FAQ 3.21: How can I hide the source for my Perl program?
Message-Id: <1dogozt.na58a19pdfkqN@roxboro0-0031.dyn.interpath.net>

Tom Christiansen <perlfaq-suggestions@perl.com> wrote:

>     Security through obscurity, the name for hiding your bugs instead of
>     fixing them, is little security indeed.

This isn't true. All security is through obscurity -- it's always about
limiting access to something.

"Trying to hide your bugs instead of fixing them, provides little to no
additional security".

-- 
John Moreno


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

Date: 10 Mar 1999 16:46:47 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 3.26: Why don't perl one-liners work on my DOS/Mac/VMS system?  
Message-Id: <36e70467@csnews>

(This excerpt from perlfaq3 - Programming Tools 
    ($Revision: 1.33 $, $Date: 1998/12/29 20:12:12 $)
part of the standard set of documentation included with every 
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq3.html
if your negligent system adminstrator has been remiss in his duties.)

  Why don't perl one-liners work on my DOS/Mac/VMS system?

    The problem is usually that the command interpreters on those
    systems have rather different ideas about quoting than the Unix
    shells under which the one-liners were created. On some systems,
    you may have to change single-quotes to double ones, which you
    must *NOT* do on Unix or Plan9 systems. You might also have to
    change a single % to a %%.

    For example:

        # Unix
        perl -e 'print "Hello world\n"'

        # DOS, etc.
        perl -e "print \"Hello world\n\""

        # Mac
        print "Hello world\n"
         (then Run "Myscript" or Shift-Command-R)

        # VMS
        perl -e "print ""Hello world\n"""

    The problem is that none of this is reliable: it depends on the
    command interpreter. Under Unix, the first two often work. Under
    DOS, it's entirely possible neither works. If 4DOS was the
    command shell, you'd probably have better luck like this:

      perl -e "print <Ctrl-x>"Hello world\n<Ctrl-x>""

    Under the Mac, it depends which environment you are using. The
    MacPerl shell, or MPW, is much like Unix shells in its support
    for several quoting variants, except that it makes free use of
    the Mac's non-ASCII characters as control characters.

    Using qq(), q(), and qx(), instead of "double quotes", 'single
    quotes', and `backticks`, may make one-liners easier to write.

    There is no general solution to all of this. It is a mess, pure
    and simple. Sucks to be away from Unix, huh? :-)

    [Some of this answer was contributed by Kenneth Albanowski.]

-- 
Von Neumann: "Anyone attempting to generate random numbers by
deterministic means is, of course, living in a state of sin."


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

Date: Mon, 8 Mar 1999 18:50:17 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: foreach question
Message-Id: <MPG.114e2c3fcb5f1479989712@nntp.hpl.hp.com>

In article <36e46d0a.1314847931@news.ionet.net> on Tue, 09 Mar 1999 
00:45:54 GMT, Mark P. <mag@imchat.com> says...
> 	Try something like this. 
> 
> $datadir = "./";

Single-quotes are preferable, because no interpolation.
 
>   opendir(COP, "$datadir") || die $!;

The quotes around the scalar are superfluous and misleading.

> @filenames = grep (/\.*$/i,readdir(COP));

Did you really mean that?  *Every* filename ends with 0 or more dots 
(case-insensitive, yet :-).  Perhaps you were thinking of this:

  @filenames = grep !/^\.\.?$/, readdir COP;

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


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

Date: Wed, 10 Mar 1999 18:06:56 -0500
From: ehpoole@ingress.com (Ethan H. Poole)
Subject: Re: How best to do multi-file scripts
Message-Id: <2Lxjxq0a#GA.128@rejz.ij.net>

[Posted and Emailed]  In article <36E6E543.794BFCAA@yahoo.com>, 
benbean@yahoo.com says...
>
>What is the best strategy for working on a large script that would be
>better suited to breaking up into separate files. Go to all the trouble
>of defining each section as a module, or is there some easier C-style
>#include equivalent. The Camel's references on use and require seem a
>little vague about this from a non-modular viewpoint. All I want to do
>is to be able to break a bunch of functions out into separate files and
>call them as though they were one. Unless anybody can give me a
>compelling reason why not in Perl.

Perl's use() and require() are very similar to #include statements in C.  You 
may wish to familiarize yourself with the differences between use() and 
require() although that shouldn't prevent you from experimenting with them.

-- 
Ethan H. Poole              | Website Design and Hosting,
                            | CGI Programming (Perl & C)..
========Personal=========== | ============================
* ehpoole @ ingress . com * | --Interact2Day, Inc.--
                            | http://www.interact2day.com/



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

Date: Thu, 11 Mar 1999 00:42:53 GMT
From: Benjamin Smith <benbean@yahoo.com>
Subject: Re: How best to do multi-file scripts
Message-Id: <36E7118D.42434323@yahoo.com>

Thanks Peter,

The Camel mentions this on p.107 (2nd edition), but it says there are
two caveats... the subroutines from the "require"d file aren't
guaranteed to be in the current namespace, and the require happens at
run-time and consequently too late to serve as a declaration in the file
invoking the require. What's your experience of this? 

I guess this is just something I'll have to experiment with.



Peter Smith wrote:
> 
> think you're looking for 'require' as in the following statment:
> require 'my_subroutines.pl';
> 
> Just make sure you have the statement:
> 1;
> 
> at the end of each subroutine file you wish to include...


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

Date: Wed, 10 Mar 1999 15:55:58 -0800
From: grumetedapanair@hotmail.com ("Adrian Fiorinni")
Subject: Re: I want to know where I can get a sendmail program that will work  with NT.
Message-Id: <eEDF2.209$EF1.1815497@WReNphoon1>

get away M$ stuff, that's only source for
more and more trouble !

if u just can't delete the NT, and install Linux,
check for sendmail.exe in www.demobuilder.com
works on NT, and even on Win9x ( any win32, indeed ).

hope it helps.




*** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ***


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

Date: Wed, 10 Mar 1999 15:56:49 -0800
From: grumetedapanair@hotmail.com ("Adrian Fiorinni")
Subject: Re: I want to know where I can get a sendmail program that will work  with NT.
Message-Id: <1FDF2.214$EF1.1821446@WReNphoon1>

passme

get away M$ stuff, that's only source for
more and more trouble !

if u just can't delete the NT, and install Linux,
check for sendmail.exe in www.demobuilder.com
works on NT, and even on Win9x ( any win32, indeed ).

hope it helps.



*** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ***


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

Date: Wed, 10 Mar 1999 18:57:55 -0500
From: "Allan M. Due" <All@n.due.net>
Subject: Re: I want to know where I can get a sendmail program that will work with NT.
Message-Id: <zFDF2.20$946.3491@nntp1.nac.net>

Rollo Lawson wrote in message <36e6f07a.0@news3.enter.net>...
>Iam a new programmer to perl, and I was wondering where I can get a simple
>program that sends mail
>in an NT web environment.  Does anybody have a Url or ftp that has one that
>will work please help
>
>rollo lawson
>rollo@enter.net
>
>

Blat is popular and free:

http://gepasi.dbs.aber.ac.uk/softw/Blat.html

and hey, there is a sendmail for windows, but they charge for it which seems
odd given the name.

http://www.demobuilder.com/sendmail.htm

HTH

AmD





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

Date: 11 Mar 1999 00:19:54 GMT
From: hjeeves@us.ibm.com (Helena Jeeves)
Subject: Memory management & Perl to C extensions
Message-Id: <7c727a$pv6$1@poknews.pok.ibm.com>

Who out there has experience in either one of these 
(preferrably combined.)

I have a situation where my program runs differently
under the debugger than on the command line, and if
I use different debugger options (ie PERLDB_OPTS=f=5
vs PERLDB_OPTS=f=6) the program will either run
or crash while trying to access the extension file.

I have been trying to model C structures using Perl
Classes in the extensions. The memory management
has been heinous so far, is there anyone who could
give me tips as to how to better see what Perl
is doing to manage memory, and perhaps get more
control over it?

If someone says "just use C", I'll scream. Luckily,
you folks won't hear it!

Thanks in advance

Helena J.



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

Date: 11 Mar 1999 01:24:57 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Memory management & Perl to C extensions
Message-Id: <7c7619$g9q$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Helena Jeeves
<hjeeves@us.ibm.com>],
who wrote in article <7c727a$pv6$1@poknews.pok.ibm.com>:
> Who out there has experience in either one of these 
> (preferrably combined.)
> 
> I have a situation where my program runs differently
> under the debugger than on the command line, and if
> I use different debugger options (ie PERLDB_OPTS=f=5
> vs PERLDB_OPTS=f=6) the program will either run
> or crash while trying to access the extension file.

Most probably, you stomp over memory.

> I have been trying to model C structures using Perl
> Classes in the extensions. The memory management
> has been heinous so far, is there anyone who could
> give me tips as to how to better see what Perl
> is doing to manage memory, and perhaps get more
> control over it?

Perl is not going to manage memory for you.  You need to keep REFCNT
and count-of-mortality correct at all times you create or destroy
things.  Devel::Peek is you friend too.

Ilya


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

Date: Wed, 10 Mar 1999 22:49:09 GMT
From: bcs_webnet@my-dejanews.com
Subject: Re: MS ACCESS database with perl
Message-Id: <7c6st0$imm$1@nnrp1.dejanews.com>

Leon, can you help me.	I have ActivePerl 509, DBI-ODBC, and Access working
together for SELECT statements only, I cannot get an EXECUTE or UPDATE
statement to work without getting some type of "invalid statement" error, I
have check and recheck syntax, and it is correct (ODBC sql, not Access sql).

Please help.
Brian Smith
bsmith@webnetint.com

In article <7c4ld4$j6p$1@nnrp1.dejanews.com>,
  leonandrews@my-dejanews.com wrote:
> It's easy, so long as you are reasonably proficient with Perl and can get to
> grips with some documentation.
>
> You need ActivePerl 509 from http://www.activestate.com
>
> install DBD-ODBC and DBI using the ppm installer supplied with ActivePerl,
> set up an ODBC system DSN in control panel, and away you go.
>
> In fact, that's exactly what I did this morning, and it works very well. Give
> me a shout if you want more help,
>
> Leon.
>
> In article <7c0k8o$rjc$1@xenon.inbe.net>,
>   "Nicolas Malfeyt" <nicolasm@luon.be> wrote:
> > Is it possible and how hard would it be to send some kind of SQL query to an
> > MS ACCESS database residing on your webserver with Perl, and then using the
> > results in your web application?
> >
> > Thanks,
> >
> > Nicolas Malfeyt
> > nicolasm@luon.com
> >
> >
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own
>

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


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

Date: 10 Mar 1999 23:42:40 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: Re: Net::FTP through squid?
Message-Id: <7c701g$9gg$2@rguxd.viasystems.com>

Neil Salter <neil@mve.com> wrote:

:>Hello,

:>Is it possible to get Net::FTP working through squid?

I went down this same road last week but had to leave for vacation
before resolving it.  Maybe somebody will take pity on us soon.

I was trying to get the CPAN module to work on a machine without 
name resolution or even a route to the internet (though it does 
have a route to the squid proxy server).  My next step was going
to be to install lynx which would at least give me a way to get
CPAN to work through squid.  I seem to remember getting that to work
once before in a similar situation.

Please post if you figure out how to get Net::FTP working.

-- 
// Lee.Lindley   | There was a time when I thought that "being right"
// @bigfoot.com  | was everything.  Then I realized that getting along
//    | was more important.  Still, being right is more fun!
//    | And if I'm wrong, somebody will get some joy out of telling me!


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

Date: Wed, 10 Mar 1999 16:01:10 -0800
From: "Rusty Williamson" <rwilliamson@uno.gers.com>
Subject: Re: Newbe Perl question: fs equiv?
Message-Id: <xJDF2.104$UK6.1518@news.connectnet.com>

Peter,
As far as I can see this only seems to give the file size and inode number
of a file.  BTW, fs should have been df -- that's the UNIX command which
provides the output I need.

Rusty





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

Date: Wed, 10 Mar 1999 20:50:07 -0500
From: "Mark D. Sholund" <msholund@bigfoot.com>
Subject: Re: Newbe Perl question: fs equiv?
Message-Id: <36E7214F.D6627A7B@bigfoot.com>

Perhaps I'm mistaken, but I believe 'stat' gives information on files themselves
(what kind it is, whether it's read-only, write-only, etc).  I don't think 'stat'
tell you anything about the filesystem itself.

Peter Smith wrote:

> check out 'stat'
>
> Rusty Williamson wrote:
> >
> > Hi!
> >
> > I need to get filesystem stats (total Mb, free, inodes, unused) -- I'm on a
> > UNIX box.  Short of back quoting the fs command does Perl have a function
> > (it has PS)?  I searching the doc -- so far zip.  Hopefully I'm just missing
> > it.
> >
> > Thanks,
> > Rusty Williamson
>
> --
> --Peter--
> psmith01@mindspring.com

--
in accordance with prophecy.

        "Computer, install a recursive algorithm."
                                        - Ensign Harry Kim




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

Date: Thu, 11 Mar 1999 00:23:34 +0000
From: Andy Mendelsohn <andy@andymen.demon.co.uk>
To: Scott Stark <sstark@informix.com>
Subject: Re: Newbie question about references/deferencing
Message-Id: <36E70D06.FB21B17F@andymen.demon.co.uk>

Scott Stark wrote:
> 
> I'm a newbie learning about references, and I'm having trouble passing a value
> from a subroutine using references. I'm not sure what I've done wrong here.
> 
> Here's a code snippet:
> 
>         &check_flags2(\$preserve);
>         print "The value of preserve is " . ${$preserve} . ".\n";
> 
>         sub check_flags2 {
>          my($preserveP)=@_;
>          $$preserveP=1;
>         }
> 
> When I run it I get the following message (line 20 is the print line):
> 
>         Can't use string ("1") as a SCALAR ref while
>         "strict refs" in use at getargsP.pl line 20.
> 
> Can someone tell me what I'm doing wrong? If I don't "use strict" all I get is:
> 
>         The value of preserve is .
> 

Yes, Perl can tell you, and it did. 

>         Can't use string ("1") as a SCALAR ref while
>         "strict refs" in use at getargsP.pl line 20.

Line 20 is the print line so look at the print line.

>         print "The value of preserve is " . ${$preserve} . ".\n";

It's telling you, because you wisely used 'strict refs', that there's a
string("1") that's being used as a SCALAR ref(erence). It's obvious to
you (because you wrote it) that you are trying to dereference $preserve.
${$preserve} de-references $preserve, therefore $preserve must equal "1"
not the reference you seem to think it holds. read perlref, understand
what references are and how to use them, and pay attention to the bit on
'symbolic references'. To cap it off, perldoc strict to get an
understanding of what you're actually doing when you're using the strict
pragmas. 

It might be wise to keep using 'strict refs', in this case it did
exactly what it's supposed to do : stop you from dereferencing a
variable that isn't a reference.

> thanks, and apologies for the simple-minded nature of this post.
> 
> Scott Stark

hth 
andy

Andy Mendelsohn
andy@focus-consulting.co.uk


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

Date: Thu, 11 Mar 1999 00:20:00 GMT
From: travis@deskin.com
Subject: Perl for antenna positioner article?
Message-Id: <7c7276$nim$1@nnrp1.dejanews.com>

Hi Perl-ites-

I'm trying to locate an article I remember seeing about an antenna
positioner that was written in Perl. I'm pretty sure it was published
in late '96 or early '97, in either Linux Journal or Perl Journal.
I've checked both LJ's and TPJ's back issue listing to no avail.

Does this ring any bells with anyone?

Thanks in advance!

Travis
travis@deskin.com

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


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

Date: 10 Mar 1999 23:10:23 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: Re: Perl interface with yppasswd
Message-Id: <7c6u4v$9gg$1@rguxd.viasystems.com>

Brett Johnson <brett@amcu-tx.sps.mot.com> wrote:
:>I am trying to do something somebody probably has already done, but
:>I can't find. I am taking a modified version on Larry's passwd
:>program and trying to interface it with 'yppasswd' instead of the
:>local /etc/passwd file. I've done similar shell scripts before
:>and interfacing using sub-shells and Here Documents. That does not
:>seem to work with Perl. My questions are,
:>1. Has somebody already does this?
:>2. If not is the use of the open2() the best way to setup interactive
:>communication with a yppasswd process?

Why not just use the getpw* functions that are built into perl?

Try "perldoc -f getpwnam".

This assumes that your perl is installed correctly and that you system
is configure to use NIS.  If you can login using an NIS account,
then these functions should return information from the NIS maps.

Assuming that you have an NIS account for a user "xxx", the following
test should prove it for you:

perl -e 'my @pwentry = getpwnam("xxx"); print "@pwentry\n"'

-- 
// Lee.Lindley   | There was a time when I thought that "being right"
// @bigfoot.com  | was everything.  Then I realized that getting along
//    | was more important.  Still, being right is more fun!
//    | And if I'm wrong, somebody will get some joy out of telling me!


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

Date: Wed, 10 Mar 1999 18:03:42 -0500
From: ehpoole@ingress.com (Ethan H. Poole)
Subject: Re: Perl scripts written for UNIX. Will they work on NT?
Message-Id: <VgTR#o0a#GA.74@rejz.ij.net>

[Posted and Emailed]  In article <36E68C16.7D786A6A@ford.com>, 
cpierce1@ford.com says...
>
>If the perl scripts are well written, only very small changes might be
>needed.  Such as, anywhere you do pathname manipulation (because your
>separator changes from "/" to "\").  There's even portable ways of doing
>this, because you can query Perl for the OS's pathname separator (use Config
>I think).   ...and you did put all of your hard-coded
>pathnames-to-useful-things in one place, right?  :-)

Unfortunately the above is a common misconception.  Perl for Win32 (and NT 
itself for that matter) will quite happily accept '/' as the path seperator, 
which saves the need for a lot of unecessary escaping of '\'s.

The only time you need to be careful with this is if you supply the path as a 
parameter in a system call because the '/' (unescaped by quotes) is 
considered an argument seperator. (e.g. dir "/users" will work from the 
command line)

>Some changes are going to be needed if you relied on server-specific aspects
>of CGI.  I've found that things like $ENV{DOCUMENT_ROOT} don't appear under
>IIS and do under Apache, and have to be calculated differently.  Your
>Mileage Will Vary.

In the case of IIS, you can generally obtain DOCUMENT_ROOT by subracting 
PATH_INFO from PATH_TRANSLATED.


-- 
Ethan H. Poole              | Website Design and Hosting,
                            | CGI Programming (Perl & C)..
========Personal=========== | ============================
* ehpoole @ ingress . com * | --Interact2Day, Inc.--
                            | http://www.interact2day.com/



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

Date: Wed, 10 Mar 1999 22:46:00 GMT
From: bcs_webnet@my-dejanews.com
Subject: Re: PerlScript locking up MS Access file
Message-Id: <7c6sn4$ido$1@nnrp1.dejanews.com>

I would love to have one of those products but don't have the money for even a
single license right now, I may try the NT version of MySql, as it is fairly
inexpensive, or scavenge and set up a Linux box.
Brian

In article <36DE18F8.C1D09059@his.com>,
  Chris Morrow <morrowc@his.com> wrote:
> Can I suggest you get a real database?
>
> Access is NOT the right solution for a Web database, it's not really
> good at multiple simultaneous access.
>
> Try SQL Server? or Oracle?
>
> (The behaviour you are describing is quite common on Windows
> systems...as a whole, unfortunately)
>
> -Chris
>
> brian_smith@sonat.com wrote:
> >
> > My PerlScript/ASP pages seem to lock onto my MS Access file with the very
> > first page access, and I cannot replace/edit the file without killing the
> > process where the PerlScript dll has a lock on it, sometime even have to
> > restart web service.
> >
> > I make sure to destroy my connection and resultset objects.
> >
> > Please help.
> > brian
> >
> > -----------== Posted via Deja News, The Discussion Network ==----------
> > http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own
>

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


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

Date: Wed, 10 Mar 1999 17:57:08 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: PerlTk for Win32 ?
Message-Id: <x3yzp5ldkcb.fsf@tigre.matrox.com>


"Patrick Fichou" <fichou@club-internet.fr> writes:

> Does Tk module for Win32 Perl (Activestate) exists ?

Yes ... you can either download it from activestate, or use ppm (which
comes bundled with activestate Perl) to automatically fetch it,
install it, install the docs and do everything for you.

HTH,
Ala



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

Date: Thu, 11 Mar 1999 09:40:06 -0800
From: Steven <koh_cc@pacific.net.sg>
Subject: please help
Message-Id: <36E7FFF6.B93D3A46@pacific.net.sg>

hi,

   Catrtidge Error : ORA-1223 : TNS : unable to connect to destination


   Database and WAS in different machine.


   Script :

   use Oraperl;
   use CGI;
   $query = new CGI;
   print "content-type:text/plain\n\n";
   #print $query->param('event_id');
   #print $query->param('img_align');

   &ora_version;
   print "Image Sucessfully inserted !!";
   $lda=&ora_login('mworks','happen','happen') || die $ora_errstr;
   #$lda=&ora_login('mworks','scott','tiger') || die $ora_errstr;
   #$csr=&ora_open($lda,'select * from event_img ') || die $ora_errstr;
   #$csr=&ora_open($lda,'insert into event_img values(:1,:2,:3)') || die

$ora_errstr;
   #$csr=&ora_open($lda,'update event_img set img_align=:2 where
event_id=:1') ||  die $ora_errstr;


#&ora_bind($csr,$query->param('event_id'),NULL,$query->param('img_align'));




  Kindly advise on this issue.


Thanks

--
With regards
Steven

Steven Koh, Internet Software Engineer,
Mediaworks, Pacific Internet Pte. Ltd.,
77 Science Park Drive, 04-09/12
Cintech III, Singapore Science Park,
Singapore 118256.

Tel: (65) 7711305;
Fax: (65) 8728523
www.mediaworks.com.sg, www.pacific.net.sg




--
With regards
Steven

Steven Koh, Internet Software Engineer,
Mediaworks, Pacific Internet Pte. Ltd.,
77 Science Park Drive, 04-09/12
Cintech III, Singapore Science Park,
Singapore 118256.

Tel: (65) 7711305;
Fax: (65) 8728523
www.mediaworks.com.sg, www.pacific.net.sg




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

Date: Thu, 11 Mar 1999 00:00:43 GMT
From: clintp@geeksalad.org (Clinton Pierce)
Subject: Re: problems reading HTML file
Message-Id: <36e706a0.4850747@news.roalok1.mi.home.com>

On Wed, 10 Mar 1999 20:21:12 GMT, cybear_x[nospam]@geocities.com
(Cybernetic Bear) wrote:
>open (FILE, $indexfile);

*THUNK*

Always, always check the results of any file open command.  Always.
Go fix your program now.  Go on.  Shoo.

	open(FILE, $indexfile) || die "Cannot open $indexfile: $!\n";

Among other problems:

	while (<FILE>){
	    my $line = <FILE>;

You're reading a line from FILE into $_, and another line into $line.
Read up on the <> operator and why it's doing this.



-- 
"If you rush a Miracle Man, you get rotten miracles"
                     --Miracle Max, The Princess Bride
http://www.geeksalad.org


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

Date: Thu, 11 Mar 1999 00:17:24 GMT
From: clintp@geeksalad.org (Clinton Pierce)
Subject: Re: problems with readdir
Message-Id: <36e80877.5321301@news.roalok1.mi.home.com>

[poster CC'd in E-Mail]

On Wed, 10 Mar 1999 20:16:12 GMT, jstrike@execpc.com wrote:
>$profiledir = "e:/inetpub/wwwroot/or/";
>$filetype = ".pdf";
>$opcount = 0;
>$workcount = 0;
>$numtoshow = 4;  ## Number of items to display
>
>##Get the listing of all the files
>opendir(DIR, $profiledir) || die 'Cannot open';
>local (@catagories) = grep(/$filetype$/, readdir(DIR));
>closedir(DIR);

Down to here looks fine.  The local() is probably unnecessary.  I
don't think it's doing what you think it's doing here.  As a matter of
fact, most of the time when you use local, it's not what you want.

Silly question, have you checked your server logfiles to see if the
opendir failed?  Otherwise this should work.  (Assuming of course, 
there are ".pdf" files in that directory.)

>sub sortlist {

Ye GODS!  Is that a bubble-sort?  I haven't seen one of those in
years.  Why not use Perl's built-in sort?

>      ($dev1, $ino1, $mode1, $nlink1, $uid1, $gid1, $rdev1, $size1,
>$atime1, $mtime1) = stat @list[$x];
>      ($dev2, $ino2, $mode2, $nlink2, $uid2, $gid2, $rdev2, $size2,
>$atime2, $mtime2) = stat @list[$y];

Ok, stat() is expensive.  Bubble sorting makes this even more
expensive.  Since you're a beginner, this whole thing could probably
have been recoded:

	@worklist = sort { (stat($a))[9]<=>(stat($a))[9] } @workload;

Even that's a bit expensive, but for a beginner it should be an
easy-to-understand solution.  When you get comfortable with this, read
in "The Perl Cookbook" (or search the Web) about the Schwartzian
Transform.  It will help (a lot).

Also, are you sure this ever worked?  The stat's are always failing.
How do I know?  readdir() returns just the filename.  stat() requires
the whole pathname, unless you're in the directory along with the file
you're stat'ing.  

Maybe that's why it fails on the webserver and not when you test.  :-)

-- 
"If you rush a Miracle Man, you get rotten miracles"
                     --Miracle Max, The Princess Bride
http://www.geeksalad.org


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

Date: Thu, 11 Mar 1999 01:09:27 GMT
From: pabs2000@my-dejanews.com
Subject: Regex help needed
Message-Id: <7c753v$q6h$1@nnrp1.dejanews.com>

I have created a form that users fill out; it contains various controls,
including textareas.  After clicking the submit button, the contents are
written to a log file (which is a text file).  Users are able to type in
carriage return s - which is not a good thing for me, because I want to
display each user's entry on a single line, not multiple lines.

I want to create a regular expression that reads the log file and, just prior
to displaying the file's contents, replaces all occurrences of the newline
character, except the final one in the record.	I end each record with "!!!".
Is it possible to do what I'm asking?  Is there a better way to do so?

Thanks in advance,

Pablo

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


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

Date: Wed, 10 Mar 1999 20:56:37 -0500
From: "Ron Cole" <roncole@aye.net>
Subject: Script not going well!
Message-Id: <7c77t8$spi$1@remarQ.com>

Hello all,

Let me start by stating that I am a complete Perl Newbie! I managed to
convince my boss that Perl was the best way to implement what they wanted,
and I was given the go-ahead to start. Now I have hit a brick wall, and I
cannot get certain parts of this script to work as they should. Where I am
having problems is the add and delete subroutines. Data is not being passed
to them properly from other parts of the script. I'm sure it's a simple
problem, but I cannot figure it out! The data is read in from a
pipe-delimited flat text file. The search, ping, and output subroutines all
work properly. If anyone could take a look at this and tell me what's wrong,
I would really appreciate it! Deadlines are approaching fast. The script is
below my sig.

TIA,

Ron Cole

--
roncole@aye.net
Webmaster/Technical Documentation Manager, IED, Inc.


**********Script Begins**********

#!d:\sambar42\perl\perl.exe


use CGI qw (:standard);

@fields = ("name","address","status");
$database = "complist.txt";

$q = new CGI;
print $q->header;

$field_count = @fields;
$colspan = $field_count+1;

$search_for   = $q->param(search_for);
$search_field = $q->param(search_field);
$action       = $q->param(action);
@keys         = $q->param(key);
$key_matches  = @keys;

$search_field = "all" if($search_field eq "");
$search_for   = '.'   if ($search_for eq "");

&search_database($search_for);
&output;
&ping;

#print "<FONT SIZE=2 FACE=ARIAL>$name</FONT><BR>";
#print "<FONT SIZE=2 FACE=ARIAL>$address</FONT><BR>";
#print "<FONT SIZE=2 FACE=ARIAL>$status</FONT><BR>";
#print "<FONT SIZE=2 FACE=ARIAL>$record</FONT><BR>";
print "<FONT SIZE=2 FACE=ARIAL>Done!</FONT><BR>";

### Subroutines go below here.

sub add_record {
  $key   = time();
  $record=$key;
  foreach $field (@fields){
    ${$field}  = $q->param($field);
#    ${$field}  = filter(${$field});
    $record   .= "\|${$field}";
  }

  unless (-e $database){
    open (DB, ">$database") || die "Error creating database.  $!\n";
  } else {
    open (DB, ">>$database") || die "Error opening database.  $!\n";
  }
#   flock DB, $EXCLUSIVE;
   seek DB, 0, 2;
   print DB "$record\n";
#   flock DB, $UNLOCK;
  close(DB);
} # End of add_record subroutine.

###############################################################

sub delete_record{
  $tempfile="$database.tmp";

  open (DB,   $database)    or die "Error opening file: $!\n";
  open (TEMP, ">$tempfile") or die "Error opening file: $!\n";
#  flock TEMP, $EXCLUSIVE;

  while(<DB>){
    $match="";
    ($key,$name,$address,$status)=split(/\|/);
    foreach $current (@keys){
      if($current == $key){$match=1;}
    } # End of foreach loop.
   print TEMP $_ unless ($match == 1);
  } # End of while loop.

# NT Changes.  (Had to close file before rename and unlink on NT)
#  flock TEMP, $UNLOCK;
  close(DB);
  close(TEMP);
  unlink($database)           || die "Could not delete file! $!";
  rename($tempfile,$database) || die "Could not rename file! $!";

} # End of subroutine.

###############################################################

sub search_database{
  my $search_for = $_[0];
  open(DB, $database) or die "Error opening file: $!\n";
    while(<DB>){
      if($search_field =~ /all/i){
        if(/$search_for/oi){push @results, $_};
      } else {
        ($key,$name,$address,$status) = split(/\|/, $_);
        if(${$search_field} =~ /$search_for/oi){push @results, $_};
      } # End of else.
    } # End of while.
  close (DB);
} # End of search_database subroutine.

###############################################################

sub output{
#foreach $field (@fields){
#    print "<FONT SIZE=2 FACE=ARIAL><B>\u$field</B></FONT><BR>";
#  } # End of foreach
#foreach(@results){ print; }

foreach $record (@results){
    ($key,$name,$address,$status) = split(/\|/,$record);
      print "<FONT SIZE=2 FACE=ARIAL>$name</FONT><BR>";
      print "<FONT SIZE=2 FACE=ARIAL>$address</FONT><BR>";
      print "<FONT SIZE=2 FACE=ARIAL>$status</FONT><BR>";
      print "<FONT SIZE=2 FACE=ARIAL>$record</FONT><BR>";
#		$checkvar = $record;
       if ($status == 2) {
          $COMPSTATUS = "/compyel.jpg";
#          &delete_record;
#          &add_record;
    }
       if ($status == 3) {
          $COMPSTATUS = "/compred.jpg";
#          &delete_record;
#          &add_record;
    }
#      print "<FONT SIZE=2 FACE=ARIAL>$COMPSTATUS</FONT><BR>";
     } # End of foreach loop.

}

###############################################################

sub ping{
   @checkit = `c:/winnt/system32/ping -n 5 $address`;
   $miss = -2;
   open (IX,"c:/winnt/system32/ping -n 5 $address |");
   while (<IX>)
    {
       open (OUT, ">>pingtest.txt");
       print OUT "$_";
       $count = tr/a-z//;
       if ($count <= 14) {
          $miss = ($miss + 1);
    }
       print OUT "$count\n";
       print OUT "$miss\n";
       close (OUT);
    }
   close (IX);
	if ($miss == 5)	{
		$status = 3;
		&delete_record;
	        print $miss;
	        print $status;
		&add_record;
} elsif ($miss != 0)	{
		$status = 2;
		&delete_record;
		&add_record;
}


#&update_page;
}

###############################################################





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

Date: Wed, 10 Mar 1999 16:57:28 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: sigals
Message-Id: <x3y1zixf1o8.fsf@tigre.matrox.com>


Ed Prochak <prochak@my-dejanews.com> writes:

> Another way is to catch the SIGCLD (18) signal using the %SIG array.

1) I think you mean SIGCHLD .. not SIGCLD
2) %SIG is more appropriately (and unambigiously) termed as a hash. 
PS. I hate the terms associative arrays and dictionaries.

> sub child_died {
>    print "the child process died, clean up!";
>    close(SOMETHING);
> }
> ...
> 
> $SIG{'CLD'} = 'child_died'; # set up signal handler forchild exit

This should be $SIG{CHLD} .. but from perlipc, using

$SIG{CHLD} = 'sub_name'; 

could fail in some modules. The best strategy is to use:

$SIG{CHLD} = \&sub_name;

HTH,
Ala



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

Date: Mon, 8 Mar 1999 15:06:08 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: split?
Message-Id: <MPG.114df7bc42de960b989711@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7c1fnh$qbg$1@nnrp1.dejanews.com> on Mon, 08 Mar 1999 
21:33:36 GMT, bing-du@tamu.edu <bing-du@tamu.edu> says...
> There is a string  $test = "3:http://www.test.edu/building.html".
> 
> How to split this string to get two parts.  One is "3" and the other is
> "http://www.test.edu/building.html"?
> 
> I tried the command:
> 
>  ($first, $second) = split(/:/,$test);
> 
> Then $first is "3".  However $second is just "http" instead of
> "http://www.test.edu/building.html" which is what I want.

   ($first, $second) = split /:/, $test, 2;
                                         ^
This specifies the maximum number of fields to split into.

perldoc -f split

Or you could use a regex:

   ($first, $second) = $test =~ s/^([^:]+):(.+)/;

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


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

Date: Wed, 10 Mar 1999 14:22:19 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: URGENT: Problem with Bitwise AND
Message-Id: <x3y3e3df8ut.fsf@tigre.matrox.com>

slamda@hotmail.com writes:

[snip]

>     $r=($clubdata{'Fencing Club'} & $mask{'activity'});
> 
> which equates to 2368 & 2048 ....which should yield 2048 not 0 - my results
> are the same whatever field/mask combinations are used.

[snip]

> print("Content-type: text/html\n\n"); print"<html><body>"; foreach $clubname
> (keys(%clubdata)) {  ##iterate through clubnames  foreach $fieldname
> (keys(%mask)) {  ##iterate through fields to mask 
> $result=($clubdata{$clubname} & $mask{fieldname});  print("CLUB: $clubname
					^^^^^^^^^

Had you used the '-w' switch, which you should have, Perl would've
generated a warning. You have a typo. 'fieldname' should be
'$fieldname'. It's always better to check your code before posting.

And, please make sure your code is properly formatted when you paste
it into the newsreader. Many people will just ignore your question
because of that (I almost did).



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

Date: Thu, 11 Mar 1999 01:30:15 GMT
From: olmert@netvision.net.il
Subject: Writing to a file
Message-Id: <7c76b8$r9k$1@nnrp1.dejanews.com>

Hello,
I tried to open a file for writing. The unfortunate result is always that the
entire file is erased, while wwhat i am trying to do is to insert the line
"This line contains the blues!<P>\n" every time the file contains the string
"begin". This is my code:
if (open (BOOK, "+> $bookLocation"))   {
@LINES=<BOOK>;
$SIZE=@LINES;
for ($i=0;$i<=$SIZE;$i++) {
   $_=$LINES[$i];
      if (/begin/) {
      print BOOK "This line contains the blues!<P>\n";
             }
      print $_;
               }
close (BOOK);
      }
else  {
print "error";
     }

Any ideas?
please reply to both author and group.
Thanks.

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


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

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

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