[6540] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 165 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 23 18:07:24 1997

Date: Sun, 23 Mar 97 15:00:23 -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           Sun, 23 Mar 1997     Volume: 8 Number: 165

Today's topics:
     Re: "Shared Hash" (Simon Hyde (aka Jeckyll))
     Re: "Shared Hash" <rootbeer@teleport.com>
     :  Q: cgi --directly execute program with added-informa <mxu@eecs.ukans.edu>
     : Q: cgi --directly execute program with added-informat <mxu@eecs.ukans.edu>
     Re: A Call for Clarity (Schwartzian Transform Considere aaron_watters@msn.com
     AS400 PERL 5.003 Port Problem (David A. Pota)
     Beginner needs help <bruceb@cfw.com>
     Re: binhex support (John D Groenveld)
     Can't read from spawned process <badsmrfs@stratos.net>
     Counter Help <amerar@unsu.com>
     Re: File upload (Raul Almquist)
     Re: Getting the time for a date (Simon Hyde (aka Jeckyll))
     Re: Getting the time for a date <rootbeer@teleport.com>
     Help!: database data replacement with perl <webdesign@abacom.com>
     Re: How can I find the current working directory? (Simon Hyde (aka Jeckyll))
     NTserver/perl problem <ster@stargazer.net>
     Perl 5.003 on HPUX10.10 with gcc2.5.8 (Bryan Greenberg)
     Re: perl scripts (Simon Hyde (aka Jeckyll))
     sample odbc perl script <niamh.walsh@gwa.ie>
     Re: sample odbc perl script <niamhw@indigo.ie>
     Re: What's a good Perl book? (InfoFreako)
     Re: Wildcards in a system (mv, fn, fn) call won't work (Christian Murphy)
     WWW::Search - for 2 engines only?? <mschilli@blacksun.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sun, 23 Mar 1997 17:31:08 GMT
From: shyde@poboxes.com (Simon Hyde (aka Jeckyll))
Subject: Re: "Shared Hash"
Message-Id: <33366000.3191755@news.uni-stuttgart.de>

On Sat, 22 Mar 1997 16:06:51 -0300, "Paulo C. Marques F."
<paul@u-netsys.com.br> wrote:

>Hi all,
>
>Is there any way to have a hash shared by two or more scripts? Let me 
>explain that. We have a CGI-Script which does some text processing
>using a hash %dictionary. The hash has 10.000 entries, and is loaded
>to the memory as the script starts.
>
>It should be great if several different scripts started by different
>users could use the same hash, so minimizing the amount of RAM 
>memory used by set of scripts.
>
As far as I know there is no easy way (if any way at all) to do this.
So i'd recommend that instead of loading the whole hash into memory
you stick it in a db file and use dbmopen() and dbmclose() or tie()
and untie() to use it just like a hash, your program won't know the
difference and it will  save you a lot of memory unless you look at
every entry.
---
Yours Sincerely,
                                      ,                     
   () o                              /|   |          |      
   /\     _  _  _    __   _  _        |___|        __|   _  
  /  \|  / |/ |/ |  /  \_/ |/ |       |   |\|   | /  |  |/  
 /(__/|_/  |  |  |_/\__/   |  |_/     |   |/ \_/|/\_/|_/|__/
                                               /|           
                                               \|           
(Simon Hyde)
/****************How To Contact Me******************\
|         Internet Email: shyde@POBoxes.com         |
\***************************************************/


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

Date: Sun, 23 Mar 1997 14:26:28 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "Paulo C. Marques F." <paul@u-netsys.com.br>
Subject: Re: "Shared Hash"
Message-Id: <Pine.GSO.3.96.970323141938.18695C-100000@kelly.teleport.com>

On Sat, 22 Mar 1997, Paulo C. Marques F. wrote:

> Is there any way to have a hash shared by two or more scripts? 

No, but you can fake it so well that nobody knows. :-)

> We have a CGI-Script which does some text processing using a hash
> %dictionary. The hash has 10.000 entries, and is loaded to the memory as
> the script starts. 
> 
> It should be great if several different scripts started by different
> users could use the same hash, so minimizing the amount of RAM memory
> used by set of scripts. 
> 
> The hash is only read, and never updated, by the scripts.

This sounds like a job for a tied hash. You can make a hash which isn't
really in your process's memory space, but instead is accessed by a
daemon. Or maybe it would be tied to a database, or maybe it would be
somewhere else. Which method you choose depends upon the details of your
application, of course. There's an example of making a read-only hash in
Config.pm, which is built when you make Perl. Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Sun, 23 Mar 1997 16:06:30 -0600
From: Mousheng Xu <mxu@eecs.ukans.edu>
Subject: :  Q: cgi --directly execute program with added-information
Message-Id: <3335A966.167E@eecs.ukans.edu>

Dear Perl/CGI experts:
        In a perl cgi program, if one wants to go to another program
after some
work, he can use require("anotherprogram.cgi") to do it. But How if I
have to give my "anotherprogram.cgi" some extra information 
which is normally passed through $ENV variable? Suppose I want to pass
STUDENT-ID=12345 to "anotherprogram.cgi", is there a nice way to do it?
I know you can use <form action="anotherprogram.cgi?STUDENT-ID=12345">
 ... to achieve this with one mouse click. Suppose I don't want even a
signle mouse click -- I want it directly go to "anotherprogram.cgi" with
"STUDENT-ID=12345" as the environment information.
        Thanks in advance. Any help is highly appreciated.

M. Xu


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

Date: Sun, 23 Mar 1997 16:08:28 -0600
From: Mousheng Xu <mxu@eecs.ukans.edu>
Subject: : Q: cgi --directly execute program with added-information
Message-Id: <3335A9DC.2781@eecs.ukans.edu>

Dear Perl/CGI experts:
        In a perl cgi program, if one wants to go to another program
after some
work, he can use require("anotherprogram.cgi") to do it. But How if I
have to give my "anotherprogram.cgi" some extra information 
which is normally passed through $ENV variable? Suppose I want to pass
STUDENT-ID=12345 to "anotherprogram.cgi", is there a nice way to do it?
I know you can use <form action="anotherprogram.cgi?STUDENT-ID=12345">
 ... to achieve this with one mouse click. Suppose I don't want even a
signle mouse click -- I want it directly go to "anotherprogram.cgi" with
"STUDENT-ID=12345" as the environment information.
        Thanks in advance. Any help is highly appreciated.

M. Xu


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

Date: Sun, 23 Mar 1997 13:21:29 -0600
From: aaron_watters@msn.com
Subject: Re: A Call for Clarity (Schwartzian Transform Considered Scary)
Message-Id: <859132639.9436@dejanews.com>

In article ,
  buhr@stat.wisc.edu (Kevin Buhr) wrote:
> Your points are well-taken, but I can't help but think "unhighly" of
> people who feel fear, shock, pain, anger, and resentment whenever
> they're faced with something they don't immediately understand.  (How
> do people with so little self-esteem survive in day-to-day life?

It's tough, let me tell you.

> Are
> they merely careful to limit their activities to such a degree that
> they avoid experiencing anything the pushes the limits of their
> knowledge?)

No, I mainly don't like confusing cryptic magic when it's not needed.
I don't like overloading my brain with too much magical context
when trying to understand someone else's code.

> That being said, I've found myself "de-clevering" answers I give on
> c.l.p.m, simply because, looking back at my "first draft", I discover
> how very much obscure Perl idiom is required to understand something
> even only marginally clever.  I refuse to *totally* de-clever my
> answers, however, because Perl's defining feature is the "clever
> answer to a difficult problem".  If you instead want laborious answers
> to trivial problems, you should pick a more suitable programming tool.

There is a difference between "clever" and "cryptic and magical".
When Tom started this thread he omitted my Python translation to
the Schwartzian transform.  Without understanding Python, you
may find it cryptic too, but I claim it uses less magic (only the magical
list.sort method, everything else is fundamental Python).  It's a bit
longer, but worth it.

In pseudocode,  Assume you have a function F which produces a metric
by which you wish to sort a list, as in, for example
   F("Feb94") = (94, 2)
the following outlines how to sort the list by the metric:

def Schwartzian_Transform(List, F):
      def pairing(element, Metric=F):
            return (Metric(element), element) # pair metric with elt
      PairedList = map(pairing, List)
      PairedList.sort() # sort by the metric
      return map(Project, PairedList)

def Project(pair):
      return pair[1] # throw away the metric from the pair

Oops.  Sorry, this isn't psuedocode, it's working Python.
[Damn, I hate it when I do that!]  Also, now that it's
implemented once you'll never have to write it again.
What a shame!  It was so much fun the first time!

Actually, this was the wrong way to do it. It should be

def Schwartzian_Transform(List, F):
      def my_cmp(e1, e2, metric=F):
            return cmp(metric(e1), metric(e2))
      List1 = List[:]
      List1.sort(my_cmp) # sort, comparing F values
      return List1

But that's a bit more magical, and also slower, oh well.
I wouldn't be surprised if one or both of these translate
directly to Perl, in which case, maybe newbies would
find this approach less confusing.  But, the $a $b $1 $2 $_ thing
does have a mystic appeal, I must admit.
    -- Aaron Watters
===
Do you really thing I pushed him out the window on
  purpose, Potatohead?
That's Mr. Potatohead to you.

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 23 Mar 1997 22:35:59 GMT
From: dpota@ix.netcom.com(David A. Pota)
Subject: AS400 PERL 5.003 Port Problem
Message-Id: <5h4b8f$ohf@dfw-ixnews7.ix.netcom.com>

Has anyone had a problem getting the perlpgm.savf to ftp to an AS400?
The AS400 ftp error log reports corrupt data. I have downloaded
the file twice and still can't get the file to ftp to the AS400.
This is the site I downloaded from.
http://web.rge.com/pub/languages/perl/ports/as400/

Any assistance would be greatly appreciated.
Thank You
Dave


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

Date: Sat, 22 Mar 1997 20:59:02 -0500
From: Bruce Brownfield <bruceb@cfw.com>
Subject: Beginner needs help
Message-Id: <33348E66.18B0@cfw.com>

How do I write a program with perl. Do I just use notepad and type in
the program? I have a cgi script but it does not work.
http://www.fw.com/~bruceb/hello.htm	This is supposed to be a simple
program, the page links to ../cgi-bin/hello.cgi    When I try to execute
the script I get an error, malformed header from script. Can anyone help
me?


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

Date: 23 Mar 1997 14:26:45 -0500
From: groenvel@tholian.cse.psu.edu (John D Groenveld)
Subject: Re: binhex support
Message-Id: <5h405l$836@tholian.cse.psu.edu>

In article <3333160D.24F97761@enteract.com>, Eryq  <eryq@enteract.com> wrote:
>I think can have this ready in a trice, if no-one else is working 
>on it.

You might want to look at the uudeview code--I think its in C.
http://www.uni-frankfurt.de/~fp/uudeview/
John
groenvel@cse.psu.edu


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

Date: Sun, 23 Mar 1997 15:34:26 -0600
From: "Aaron, Penny, Jaymee Minner" <badsmrfs@stratos.net>
Subject: Can't read from spawned process
Message-Id: <3335A1E2.5066ECB8@stratos.net>

After spending all weekend on this, I'm throwing myself to
the mercy of anyone who can tell me what's wrong with this.
It's supposed to spawn a child process, and if the "popen"
flag is given, set the child's STDOUT to a file handle that
the parent can read (sort-of like popen(3?)).

In the parent process though, it doesn't read from the child
filehandle, and in fact complains of "no child process" when
I go to read from the handle.

Here's the code I use to call it and read from the handle:

use strict;
use FileHandle;

$::EMODEL = "dud2.pl" if $::TESTING;

Spawn( $::EMODEL, 'popen' ) || Crash( "Spawn failed: $!" );
print "$::EMODEL running (pid: $::ChildByName{$::EMODEL})\n";

my( $gbg );
( $gbg = <$::ParReadHandle{$::EMODEL}> ) || print "Error - $!\n";
print "gbg is <$gbg>";



Here's the Spawn subroutine:


#############################################################
# Subroutine: Spawn
# Purpose:  This routine forks/execs a process and adds it to the hashes
#   we use to monitor child processes.  These global hashes are
#   %ChildByName and %ChildByPid which store the process id of the child
#   by either name (eg. "fvwm") or process id (as returned from fork).
#
#   The flag 'popen' says to send the output of the child back to stdin
#   of the parent.
#############################################################

sub Spawn
{
  my( $prog, $flags ) = @_;
  my( $pid, $Read, $Write );
  my( $popen ) = 0;

  if ( defined( $flags ) && $flags eq 'popen' ) {
    $popen = 1;
    ( $::ParReadHandle{$prog}, $::ChildWriteHandle{$prog} ) =
FileHandle::pipe;
    unless ( defined( $::ParReadHandle{$prog} ) &&
             defined( $::ChildWriteHandle{$prog} ) ) {
      print "pipe failed: $!";
      return( 0 );
    }
  }

FORK: {
  if ( $pid = fork ) {
    # parent
    $::ChildByName{$prog} = $pid;
    $::ChildByPid{$pid} = $prog;
    if ( $popen ) {
      $::ChildWriteHandle{$prog}->close;
    }
    return( 1 );

  } elsif ( defined $pid ) {
    # child
    # the SIG{__WARN__} blocks warnings in the child, such as "can't
exec"
   
    if ( $popen ) {
      $::ParReadHandle{$prog}->close;
      open( STDOUT, ">&$::ChildWriteHandle{$prog}" );
      $::ChildWriteHandle{$prog}->autoflush;
    }
    local $SIG{__WARN__} = sub { ; };
    exec "$prog" or die( "Error: exec $prog failed - $!\n" );

  } elsif ( $! =~ /No more process/ ) {
    # EAGAIN, supposedly recoverable fork error
    sleep 5;
    redo FORK;

  } else {
    # wierd fork error
    return 0;
  }
}  # end of FORK: block

}  # end of Spawn subroutine




Thanks for any help given.  If there's a better way to do
this, while being able to keep track of the children created
by name and pid, by all means, let me know that too.

Thanks,

Aaron

(PS. Don't feel slighted if I don't respond right away; I'll
out of town for the week.)


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

Date: Sun, 23 Mar 1997 10:32:43 -0600
From: Arthur Merar <amerar@unsu.com>
Subject: Counter Help
Message-Id: <33355B2B.420F@unsu.com>

Hello,

I am fairly new to Perl and I am hoping that someone can help me out.

I am trying to write a homepage counter that will display .GIF images. 
I know there are a lot of ready-made counters out there, but this one
will be different.  The .GIF files will not be regular numbers.  They
will be the numbers in Korean.  Therefore, some special coding is
necessary for some extra characters.

Writing the code should not be to hard.  What I am having trouble doing
is displaying the .GIf in the HTML document.  How do I display the .GIF
in an HTML document from within a Perl script?

Also, if I have a Perl script that does not give any output, how do I
call it from an HTML document?

Thank you,

Arthur
amerar@unsu.com
http://www.unsu.com


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

Date: Sun, 23 Mar 1997 12:29:50 -0600
From: imrs@winternet.com (Raul Almquist)
Subject: Re: File upload
Message-Id: <imrs-2303971229500001@ppp-67-219.dialup.winternet.com>

In article <5guea5$jld@capella.hkstar.com>, yinglee@hkstar.com (Yinglee) wrote:

> I am using WinNT4.0 + Perl 5 + Netscape 3 to upload file(binary) from client 
> to server. The size of uploaded file usually > 1Mb. So I can't use cgi-lib.pl
> I use the follow code to read from STDIN and write to a file.

  You can try using CGI.pm but I would not recommend using it as it has
too many lacks (esp. a functional upload example), however you could get
CGI_Lite.pm which is currently in v1.7 from any CPAN site, it does work
pretty good.


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

Date: Sun, 23 Mar 1997 16:46:14 GMT
From: shyde@poboxes.com (Simon Hyde (aka Jeckyll))
Subject: Re: Getting the time for a date
Message-Id: <33355960.1494600@news.uni-stuttgart.de>

On Sun, 23 Mar 1997 09:48:03 GMT, brian@brie.com (Brian Lavender)
wrote:

>I am trying to get the time for a date in seconds. As far as I can
>see, the function time returns the current time in seconds since the
>date January 1, 1970. I want to get the time for another date. How do
>I do that?
>
I think what your looking for is functions that do the opposite of
gmtime and localtime, convert a date and time into time since Jan 1,
1970, these can be used as follows:

use Time::Local;
$sec = 0;
$min = 30;
$hours = 10;
$mday = 23;
$mon = 3;
$year = 96;
$time = timelocal($sec,$min,$hours,$mday,$mon,$year);
print scalar(localtime($time)), "\n";
$time = timegm($sec,$min,$hours,$mday,$mon,$year);
print scalar(gmtime($time)), "\n";

#or if your still stuck with perl 4 replace the use Time::Local with:
require('timelocal.pl');
#And add an & before the function calls, like so:
$time = &timelocal($sec,$min,$hours,$mday,$mon,$year);
print scalar(localtime($time)), "\n";
$time = &timegm($sec,$min,$hours,$mday,$mon,$year);
print scalar(gmtime($time)), "\n";

---
Yours Sincerely,
                                      ,                     
   () o                              /|   |          |      
   /\     _  _  _    __   _  _        |___|        __|   _  
  /  \|  / |/ |/ |  /  \_/ |/ |       |   |\|   | /  |  |/  
 /(__/|_/  |  |  |_/\__/   |  |_/     |   |/ \_/|/\_/|_/|__/
                                               /|           
                                               \|           
(Simon Hyde)
/****************How To Contact Me******************\
|         Internet Email: shyde@POBoxes.com         |
\***************************************************/


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

Date: Sun, 23 Mar 1997 14:19:26 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Brian Lavender <brian@brie.com>
Subject: Re: Getting the time for a date
Message-Id: <Pine.GSO.3.96.970323141813.18695B-100000@kelly.teleport.com>

On Sun, 23 Mar 1997, Brian Lavender wrote:

> I am trying to get the time for a date in seconds. As far as I can see,
> the function time returns the current time in seconds since the date
> January 1, 1970. I want to get the time for another date. How do I do
> that? 

You convert that date string using one of the functions available in a
module from CPAN, of course. :-)

    http://www.perl.org/CPAN/
    http://www.perl.com/CPAN/

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Sun, 23 Mar 1997 12:19:36 -0500
From: Bergy <webdesign@abacom.com>
Subject: Help!: database data replacement with perl
Message-Id: <33356628.1C15@abacom.com>

I'm an intermidiate user of perl... What is the best way to replace a
data field in a separate text file with perl? e.g:

data.txt opened:
John;Smith;3;65;(819)555-5555;

and I want to replace 65 by 75...
Further more, I would like to erase this line from my database.

What is the simpliest way?

Thanx

Bergy from Quebec


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

Date: Sun, 23 Mar 1997 17:31:10 GMT
From: shyde@poboxes.com (Simon Hyde (aka Jeckyll))
Subject: Re: How can I find the current working directory?
Message-Id: <33376245.3771991@news.uni-stuttgart.de>

On Sun, 23 Mar 1997 11:19:50 -0500, Chris <webmaster@surewould.com>
wrote:

>How in Perl can I determine the name of the current working directory?
>I've tried getting sneaky (but not too sneaky) with telldir() and
>system("cd .") but none of this is quite right. Is there something
>straightforward I'm missing?
>
> - Chris
>
use Cwd;
$current_dir = cwd || getcwd;
---
Yours Sincerely,
                                      ,                     
   () o                              /|   |          |      
   /\     _  _  _    __   _  _        |___|        __|   _  
  /  \|  / |/ |/ |  /  \_/ |/ |       |   |\|   | /  |  |/  
 /(__/|_/  |  |  |_/\__/   |  |_/     |   |/ \_/|/\_/|_/|__/
                                               /|           
                                               \|           
(Simon Hyde)
/****************How To Contact Me******************\
|         Internet Email: shyde@POBoxes.com         |
\***************************************************/


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

Date: 23 Mar 1997 18:20:17 GMT
From: "ster" <ster@stargazer.net>
Subject: NTserver/perl problem
Message-Id: <01bc37b5$ab20c0f0$277b65cf@cornholio>

All my scripts worked in both unix and win95, now i'm in winNT4.0. Some
perl scripts display in the browser, some pop up with a dialog box asking
if i wanna open it or save it.  What's wrong? How do i fix it?  I have
tried read only rights, execute only rights, and a combo of both to no
avail.

please reply to ster@stargazer.net
__________________________________
http://server.nich.edu/~njd


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

Date: Sun, 23 Mar 97 12:58:03 GMT
From: bgreenbe@kctera.net (Bryan Greenberg)
Subject: Perl 5.003 on HPUX10.10 with gcc2.5.8
Message-Id: <3177cd$d22a.25f@RECLUSE>

I have been trying (without much luck) to build perl5.003 on hpux10.10 using 
gcc2.5.8.  Checked the FAQ and dejanews but nothing addressed my problem.

During the make I receive the following message:
----------------------------------
       ar rcu libperl.a perl.o malloc.o gv.o toke.o perly.o op.o regcomp.o 
dump
 .o util.o mg.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o 
doop
 .o doio.o regexec.o taint.o deb.o globals.o 
        gcc  -L/usr/local/lib -o miniperl miniperlmain.o libperl.a -lnet 
-lnsl_s
 -lndbm -ldld -lm -lc -lndir -lcrypt 
        ./miniperl configpm tmp
*** Termination signal 139

Stop.
# 
----------------------------------

I am trying to build this with dynamic loading and don't currently have the hp 
ANSI C compiler.

I do get a core dump on this error but don't have the tools/knowhow to debug.

Anyone have any ideas???

                                                        TIA,
                                                        Bryan Greenberg
                                                        bgreenbe@kctera.net



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

Date: Sun, 23 Mar 1997 16:46:07 GMT
From: shyde@poboxes.com (Simon Hyde (aka Jeckyll))
Subject: Re: perl scripts
Message-Id: <33354be0.9306016@news.uni-stuttgart.de>

On Sun, 23 Mar 1997 09:55:21 GMT, kurt@rfpi.com wrote:

>I am aware that there are sites on the web where there are libraries
>of perl scripts. Does anyone know the URL's?
>
Take a look at http://www.perl.com/perl,
http://www.perl.com/CPAN/modules and http://www.perl.com/CPAN/scripts
---
Yours Sincerely,
                                      ,                     
   () o                              /|   |          |      
   /\     _  _  _    __   _  _        |___|        __|   _  
  /  \|  / |/ |/ |  /  \_/ |/ |       |   |\|   | /  |  |/  
 /(__/|_/  |  |  |_/\__/   |  |_/     |   |/ \_/|/\_/|_/|__/
                                               /|           
                                               \|           
(Simon Hyde)
/****************How To Contact Me******************\
|         Internet Email: shyde@POBoxes.com         |
\***************************************************/


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

Date: Sun, 23 Mar 1997 17:43:25 +0000
From: Niamh Walsh <niamh.walsh@gwa.ie>
Subject: sample odbc perl script
Message-Id: <33356BBD.DFC@gwa.ie>

Alas, www.roth.net is proving, er elusive and I'm looking for examples
of using Win32:ODBC (other than the test program which comes with the
standard bundle).
I would be grateful to anyone who can supply a URL/sample script
demonstrating (or discussing) the use of the module and some relevant
SQL. I can use select statements ok to extract the relevant entries
in the table but am (a) unsure about updating and (b) clueless about
locking/contention and general error diagnosis & recovery.

Background info on query:

My Win32 Perl app spends most of its existance reading a table which is 
shared with other programs (the table is being used as a form of IPC 
[stop cringing; times are hard]) and updating some of the entries. 

the skeleton of the app looks like:

select the entries fufilling condition X from the table Y
	for each entry:
		lock & read it
		do other bits
		update the entry & unlock it


Thanks for any help
Niamh


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

Date: Sun, 23 Mar 1997 19:48:21 +0000
From: Niamh Walsh <niamhw@indigo.ie>
Subject: Re: sample odbc perl script
Message-Id: <33358905.1907@indigo.ie>

Niamh Walsh wrote:
> 
> Alas, www.roth.net is proving, er elusive and I'm looking for examples
> of using Win32:ODBC (other than the test program which comes with the
> standard bundle).

Well, indirectly I found that www.roth.net approximates:
	http://198.109.165.100:80

and that useful files are:
	http://198.109.165.100:80/odbc/odbc.html (already had 
						    from mirror)
	http://198.109.165.100:80/odbc/object.html (already had 
						    from mirror)
	http://198.109.165.100:80/odbc/odbcfaq.htm

The domain roth.net doesn't seem to be recognised most of the time
which has caused me much trouble as pretty much every reference
to win32:odbc seems to point to www.roth.net!

Still interested in any examples of Perl ODBC and any words of
wisdom in that area.

Niamh


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

Date: Sun, 23 Mar 1997 21:50:34 GMT
From: infofreako@poe.org (InfoFreako)
Subject: Re: What's a good Perl book?
Message-Id: <3339a54e.17896322@news.cybernex.net>

On 17 Mar 1997 05:41:05 GMT, jgoerzen@complete.org (John Goerzen)
wrote:

>Let us not forget that it is important to get the **second edition** of this
>book!
>
>--[stuff deleted]--
>
>Or cheaper, from http://www.amazon.com, or (for the cheapest price I found),
>from http://www.cheapbytes.com.

If you have an older version of any O'Reilley book, they will give you
25% off the newer version if you send them the first page of the older
book.  Check it out at their site.  Not a bad deal!

InfoFreako
infofreako@poe.org


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

Date: Sun, 23 Mar 1997 13:03:07 GMT
From: cpm@salmon.muc.de (Christian Murphy)
Subject: Re: Wildcards in a system (mv, fn, fn) call won't work
Message-Id: <E7Hyx8.1r0@salmon.muc.de>

In article <ceolas-2203971620320001@b461-powmac7500.stanford.edu>,
Ceolas <ceolas@celtic.stanford.edu> wrote:
>I thought to avoid having to move each file
>individually, by using a system call to the mv command:
>
>   $source = "/img/www/html/submit/bod/*";
>   $dest = "/img/www/html/bod/";
>   system ("mv", $source, $dest);
>
>Running this as a script from the command line, mv tells me it can't find
>the /bod/* file or directory.

mv does not understand wild cards like "*".  When you type something like
"mv * some/where/else" at a shell prompt, the _shell_ expands the wildcard
for you before passing it onto mv.  When you run mv from system() like
you do above, perl does not invoke a shell at all, but runs mv directly,
passing it exactly what you gave it.

You can make perl invoke the mv via a shell by putting the command you
want to run into one string, like this:

    system("mv $source $dest");

The shell will expand any wild cards before _it_ runs mv for you.  This is
documented in the manual page for perlfunc (albeit not terribly clearly
for beginners -- you have to look at the section on exec and understand
what "the entire argument is passed to /bin/sh -c for parsing" means).

One more thing.  Running a shell on input from other people can be a very
dangerous thing.  In your case it might be possible for them to name files
such that they contain shell commands to arbitrary things.  If you run

	system("mv $source $dest");

on one of these files, you run all the commands they put into the file
name (which could delete all your files, or send or your e-mail to
someone, or whatever).

It's better to make your system secure, even if you trust everyone
who's going to use it.  Unfortunately, this means you have to give up
the wild cards.  Your best approach is to write a function that does
what you want, something along the lines of this.  (Tested, but not that
thoroughly: please test it yourself before you use it on "real data".
Will only run with perl 5 or greater by the way.)

------begin code----
#!/usr/local/bin/perl -Tw
use strict;

use File::Copy;
# perldoc File::Copy for details

# move all files in $src_dir to $dest_dir
sub mv_files {
        my ($src_dir, $dest_dir) = @_;
        my ($src_file, $dest_file);

        opendir(DIR, $src_dir) or die "could not read $src_dir: $!";
        my @file_list = readdir(DIR);
        closedir(DIR);

        foreach (@file_list) {
		# NB: assumes directory separator is slash
                $src_file = $src_dir . '/' . $_;
                $dest_file = $dest_dir . '/' . $_;
		next unless -f $src_file;
                copy($src_file, $dest_file)
			or die "couldn't copy $src_file to $dest_file: $!";
		unlink($src_file)
			or warn "could not delete $src_file: $!";
        }
}

# test it
mv_files('a', 'b');
-------end code-----

You should use the -T as above if your program is going to take input
from untrusted sources.  See the manual page for perlsec for details
(it talks mainly about setuid scripts, but the same caveats apply if
other people are supplying the input but you are running the script).

I hope this helps!

Regards,
-christian

-- 
Christian Murphy <cpm@muc.de>


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

Date: Sun, 23 Mar 1997 11:56:55 -0800
From: Michael Schilli <mschilli@blacksun.com>
Subject: WWW::Search - for 2 engines only??
Message-Id: <33358B07.62E8@blacksun.com>

Hi folks,

the WWW::Search module is neat - but why does it support two search
engines only? Whatever I try, only results from 'AltaVista' and 'Yahoo'
drop in, whereas 'Excite', 'HotBot', 'Lycos' and 'Infoseek::Web' don't
fail directly, but don't return any results, either.

Does anybody know when these frontends will be available?

Any help apprechiated.

-- 
Michael


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

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

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