[18516] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 684 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 12 09:06:03 2001

Date: Thu, 12 Apr 2001 06:05:16 -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: <987080715-v10-i684@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 12 Apr 2001     Volume: 10 Number: 684

Today's topics:
    Re: A CGI question (it works) <SiStie@nuclear-network.com>
    Re: A CGI question <flavell@mail.cern.ch>
        A fork() problem under W98 (Nim Chu)
        Check if directory exists. <uli@lab.arcor.de>
        RE: Check if directory exists. <jamesfreeman@MailAndNews.com>
        RE: Check if directory exists. <jamesfreeman@MailAndNews.com>
    Re: Check if directory exists. nobull@mail.com
    Re: Executing Perl script from C or C++ program. (Bernard El-Hagin)
    Re: Executing Perl script from C or C++ program. (Anno Siegel)
    Re: Executing Perl script from C or C++ program. (Gwyn Judd)
    Re: Executing Perl script from C or C++ program. (Gwyn Judd)
    Re: Executing Perl script from C or C++ program. (Anno Siegel)
    Re: File Upload nobull@mail.com
        RE: File Upload <jamesfreeman@MailAndNews.com>
    Re: How can I use a variable variable name? (Mark Jason Dominus)
    Re: How to send a formatted string through a socket? (Tassilo von Parseval)
    Re: inheritance within one file? (Anno Siegel)
        Q: Why perl and not Bourne/Korn scripts? <roland.rashleigh-berry@virgin.net>
    Re: Q: Why perl and not Bourne/Korn scripts? nobull@mail.com
        Unix Script in a Perl script to the Web.vvp <vprasad@americasm01.nt.com>
        use strict and sysopen <lxq79@REMOVE.CAPITALS.hotmail.com>
    Re: use strict and sysopen nobull@mail.com
        Win32::ODBC insert datetime data into Access DB <john@imining.com.tw>
        XML::DOM Problem.  Look for Some Insight. <sjutmp@msn.com>
    Re: XML::DOM Problem.  Look for Some Insight. ()
    Re: XML::DOM Problem.  Look for Some Insight. (Eric Bohlman)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 12 Apr 2001 12:29:56 +0200
From: Simon Stiefel <SiStie@nuclear-network.com>
Subject: Re: A CGI question (it works)
Message-Id: <3AD583A4.48CFC65B@nuclear-network.com>

Hi there,

nobull@mail.com wrote:
> 
> Simon Stiefel <SiStie@nuclear-network.com> writes:
> >
http://www.stiefel.priv/cgi-bin/pos/pos.cgi?entry_1=1&entry_7=1&action=
> > =do+smthg
> 
> That becomes:
> 
> http://www.stiefel.priv/cgi-bin/pos/pos.cgi?entry=1&entry=7&action=
> do+smthg
> 
> > How can I fetch them in variables??
> 
> Following my advice you can simply set a single array variable to the
> list of checked boxes with:
> 
> my @checked_boxes = param('entry');

Well, thank you. It works!

Thanks also to the other posters. 

cu later


> --
>      \\   ( )
>   .  _\\__[oo
>  .__/  \\ /\@
>  .  l___\\
>   # ll  l\\
>  ###LL  LL\\


-- 
Mit freundlichen Grüßen,        .~.     Open Minds.
with best regards               /V\             Open Sources.
                               // \\                    Open Future!
Simon Stiefel                 /(   )\_ I N U X
                               ^ ~ ^
-- 
|Simon Stiefel | Zwerbachstrasse 17 | 72555 Metzingen-Glems | Germany |
|SimonStiefel@nuclear-network.com   |  http://www.nuclear-network.com |
|ICQ#: 20196644 | phone: +49(0)7123/379070 | fax: +49(0)179/335990106 |
|Tux#: 114751 | PingoS - Linux-User helfen Schulen | Powered by LiNUX |


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

Date: Thu, 12 Apr 2001 12:12:49 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: A CGI question
Message-Id: <Pine.LNX.4.30.0104121204580.408-100000@lxplus003.cern.ch>

On Thu, 12 Apr 2001, Karl Young wrote:

> What does the misc stand for anyway?

'misc' means the same as it does on any mainstream usenet group: it is
for questions which _do not_ have a more specific group to go to.

> Is CGI not covered under misc?

CGI has its own specific group, comp.infosystems.www.authoring.misc,
so is it automatically off-topic on a *.misc group.  It would be
on-topic _if_ it was primarily about a Perl language question, and
only incidentally related to the CGI.

> I would be interested to know what the
> consensus is in this group

Really?  I find that very hard to understand.  You don't seem to have
started finding out by reading this group, otherwise you would already
know from the postings in the last couple of days what the regulars
think about CGI postings here.  And you would know what "jeopardy
quoting" is and why it is wise for you to avoid it.



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

Date: Thu, 12 Apr 2001 10:06:59 GMT
From: nimchu@yahoo.com (Nim Chu)
Subject: A fork() problem under W98
Message-Id: <3ad5a63b.43942424@news-server.houston.rr.com>

I use ActiveState perl 5.6 build 623. My code looks like this:
Uset Tk;
(in a routine handling a button click:)
if( $pid=fork() ) { # parent
  return;
  } else { # child
  map{ sleep 1; print "child, wait=$_\n"; } (1..20);
  exit;
  }

The child process prints the dummy messages ok but at the end, it
says:
Unable to register TclNotifier window class
panic: restartop

Then a windows pops up:
This program has performed an illegal operation and will be shut down.
If the problem persists, contact the program vendor.

I will appreciate any help to solve the problem.




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

Date: Thu, 12 Apr 2001 12:49:22 +0200
From: "hanulimbe" <uli@lab.arcor.de>
Subject: Check if directory exists.
Message-Id: <9b4168$t8h$1@newsread2.nexgo.de>

Hello,

you´ve already read my question. I simply want to check if some directories
exist.
How can I? I have an array with all the paths which should be checked.

best regards
Uli




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

Date: Thu, 12 Apr 2001 07:24:14 -0400
From: james freeman <jamesfreeman@MailAndNews.com>
Subject: RE: Check if directory exists.
Message-Id: <3AE08F40@MailAndNews.com>

>=3D=3D=3D=3D=3D Original Message From "hanulimbe" <uli@lab.arcor.de> =3D=3D=3D=3D=3D
>Hello,
>
>you=B4ve already read my question. I simply want to check if some directories
>exist.
>How can I? I have an array with all the paths which should be checked.
>
>best regards
>Uli
>

You use -d file test operator. For example if the array containing the paths 
is called @dirs:

foreach my $dir(@dirs) {
    print "Found directory $dir\n" if (-d $dir)
}


Cheers

Doc



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

Date: Thu, 12 Apr 2001 07:24:45 -0400
From: james freeman <jamesfreeman@MailAndNews.com>
Subject: RE: Check if directory exists.
Message-Id: <3AE090F7@MailAndNews.com>

>=3D=3D=3D=3D=3D Original Message From "hanulimbe" <uli@lab.arcor.de> =3D=3D=3D=3D=3D
>Hello,
>
>you=B4ve already read my question. I simply want to check if some directories
>exist.
>How can I? I have an array with all the paths which should be checked.
>
>best regards
>Uli
>

You use -d file test operator. For example if the array containing the paths 
is called @dirs:

foreach my $dir(@dirs) {
    print "Found directory $dir\n" if (-d $dir)
}


Cheers

Doc



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

Date: 12 Apr 2001 12:18:07 +0100
From: nobull@mail.com
Subject: Re: Check if directory exists.
Message-Id: <u9eluy5pu8.fsf@wcl-l.bham.ac.uk>

"hanulimbe" <uli@lab.arcor.de> writes:

> you´ve already read my question. I simply want to check if some directories
> exist.

-d 

> I have an array with all the paths which should be checked.

The main Perl mechanisms for iterating over a list are for(), map() and
grep().

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 12 Apr 2001 10:08:14 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Executing Perl script from C or C++ program.
Message-Id: <slrn9davju.puu.bernard.el-hagin@gdndev32.lido-tech>


[fixed, yet again, jeopardy quoting]


On Thu, 12 Apr 2001 11:42:33 +0200, Jurgen Boerboom
<zonnebloem@zonnet.nl> wrote:
>Gwyn Judd wrote:
>> 
>> I was shocked! How could Jurgen Boerboom <zonnebloem@zonnet.nl>
>> say such a terrible thing:
>> ><!doctype html public "-//w3c//dtd html 4.0 transitional//en">
>> ><html>
>> >I&acute;m struggling creating a C program that executes a perl script from
>> >a file. I have gone through the Perl docs several times, tried several
>> >things, but can get the grip on it. (See my posting of&nbsp; Thu, 01 Mar
>> >2001 16:00:46)
>> ><p>Can any body tell if it has been done before and maybe provide me with
>> >a coding example.
>> 
>> This isn't really a Perl question. You might have better luck posting to
>> a C/C++ newsgroup. Given that, you probably want to use the system(3) or
>> exec(3) functions. And please post in plain text next time.
>> 
>> --
>> Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
>> When life hands you a lemon, it rarely offers a glass.
>
>Sorry about the format, but it should be better now..

Close, but no cigar. You shouldn't put your reply before what you're
replying to. Johnny Carson retired years ago.

>I don´t see any reason for you to be shocked.

Actually, Gwyn always starts his messages that way. I know, it's
shocking, but we're all used to it.

Cheers,
Bernard
--
perl -e'$\=qq;,\n;;s,,*Just.*another.*Perl.*hacker,e;%JaPh
=(q,*,,q, ,);s,((?:[\w]+?::)|\*),$JaPh{${((sin(32)**2)+
(cos(32)**2))}},gex;print;'


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

Date: 12 Apr 2001 10:14:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Executing Perl script from C or C++ program.
Message-Id: <9b3v6d$983$2@mamenchi.zrz.TU-Berlin.DE>

According to Jurgen Boerboom  <zonnebloem@zonnet.nl>:

[I placed your reply where it belongs: after the text you are
replying to]

> Gwyn Judd wrote:
> > 
> > I was shocked! How could Jurgen Boerboom <zonnebloem@zonnet.nl>
> > say such a terrible thing:
> > ><!doctype html public "-//w3c//dtd html 4.0 transitional//en">
> > ><html>
> > >I&acute;m struggling creating a C program that executes a perl script from
> > >a file. I have gone through the Perl docs several times, tried several
> > >things, but can get the grip on it. (See my posting of&nbsp; Thu, 01 Mar
> > >2001 16:00:46)
> > ><p>Can any body tell if it has been done before and maybe provide me with
> > >a coding example.
> > 
> > This isn't really a Perl question. You might have better luck posting to
> > a C/C++ newsgroup. Given that, you probably want to use the system(3) or
> > exec(3) functions. And please post in plain text next time.
>
> Sorry about the format, but it should be better now..
> 
> I don´t see any reason for you to be shocked.

Gwyn is easily shocked :)

>                                               Parts of this world are
> different: Like being implemented in C. And as this is a fact there
> might sometimes be a need to interface from C ´TO´  Perl, especially as
> I as Perl programmer would like to implement the required fuctionality
> in Perl.

Gwyn understood you perfectly well.  Unlike you, she also understands
that the question has nothing to do with Perl.

A Perl script is an executable like any other.  When you want to
call it from a C program, the fact that it happens to be written in
Perl doesn't enter the equation.  Use the method you use to call
*any* external program.  So the suggestion of system() or exec()
is spot on,  as is the pointer to C/C++ newsgroups.

> The alternative is to re-write PVCS Dimensions in Perl. I dont think
> this is an alternative, or are you offering ....

The alternatives you have don't seem to be very clear to you.  In light
of this fact, your remark is a little off, hmmm?

Anno


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

Date: Thu, 12 Apr 2001 10:31:34 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Executing Perl script from C or C++ program.
Message-Id: <slrn9db102.m1u.tjla@thislove.dyndns.org>

I was shocked! How could Jurgen Boerboom <zonnebloem@zonnet.nl>
say such a terrible thing:
>I don´t see any reason for you to be shocked. Parts of this world are
>different: Like being implemented in C. And as this is a fact there

This still isn't a Perl question. You execute a program written in Perl
from a C program, just like you would execute any other program from a C
program. You really should be asking this question in another group.
Nevertheless, I maintain that system() or exec() will probably do what
you want.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
To the philosophic eye, the vices of the clergy
are far less dangerous than their virtues.
  Atheism/Freethought fortune cookie file


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

Date: Thu, 12 Apr 2001 10:35:11 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Executing Perl script from C or C++ program.
Message-Id: <slrn9db16s.m1u.tjla@thislove.dyndns.org>

I was shocked! How could Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
say such a terrible thing:
>Gwyn understood you perfectly well.  Unlike you, she also understands
>that the question has nothing to do with Perl.

s/\bs(?=he\b)//

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
You have to make it happen.
-Joe Greene


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

Date: 12 Apr 2001 12:27:08 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Executing Perl script from C or C++ program.
Message-Id: <9b46us$fdo$2@mamenchi.zrz.TU-Berlin.DE>

According to Gwyn Judd <tjla@guvfybir.qlaqaf.bet>:
> I was shocked! How could Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
> say such a terrible thing:
> >Gwyn understood you perfectly well.  Unlike you, she also understands
> >that the question has nothing to do with Perl.
> 
> s/\bs(?=he\b)//

Oh.  I see.

Anno


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

Date: 12 Apr 2001 12:16:39 +0100
From: nobull@mail.com
Subject: Re: File Upload
Message-Id: <u9hezu5pwo.fsf@wcl-l.bham.ac.uk>

"Vassilis G. Tavoultsidhs" <ixanthi@ixanthi.gr> writes:

> I am trying to create a cgi script which will send among other things and a
> file to the server in a specified location.

I think you are confused about what CGI scripts are.  The CGI script
runs on the server so it recieves things sent to the server, it does
not send them.

> I have made the form in HTML but
> I don't know how to handle the file which I get from it in order to send it
> to my server. Anybody who has any idea please help.

The Perl module for implementing CGI scripts in Perl is called CGI.

It is a standard part of the Perl distribution.

The Perl manpage documenting this module is called CGI.  

The section of this manual "CREATING A FILE UPLOAD FIELD"
describes how to do file uploads.

Please do not treat Usenet as a "read the manual to me" service.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 12 Apr 2001 07:43:15 -0400
From: james freeman <jamesfreeman@MailAndNews.com>
Subject: RE: File Upload
Message-Id: <3AE0CDDE@MailAndNews.com>

>===== Original Message From "Vassilis G. Tavoultsidhs" <ixanthi@ixanthi.gr> 
=====
>I am trying to create a cgi script which will send among other things and a
>file to the server in a specified location. I have made the form in HTML but
>I don't know how to handle the file which I get from it in order to send it
>to my server. Anybody who has any idea please help.
>
>Thank you
>
>ixanthi@ixanthi.gr
>

There are two very well know scripts that aid with CGI tasks,
including file upload. These are cgi-lib.pm and CGI.pm

Look up CGI.pm here:
http://stein.cshl.org/WWW/software/CGI/

or look up cgi-lib.pl here:
http://cgi-lib.berkeley.edu/

Cheers

Doc



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

Date: Thu, 12 Apr 2001 00:26:52 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: How can I use a variable variable name?
Message-Id: <3ad4f64c.590$c3@news.op.net>

In article <3AD496F5.480BA82C@cfl.rr.com>, tuxy  <nospam@cfl.rr.com> wrote:
>I think I've managed to get this to work before but I can't seem to get
>it working now. I want to access various hashes- something like:
>
> my (%A,%B,%C);
> my $x='A';
> $A{cat}=qq(dog);
> my $y=${$x}{cat}; # or just $$x{cat}
> print "val is $y\n";
>
>which doesn't work since I cannot use $x as a hashref (its not
>interpolating?).

Instead of trying to access hashes by name, I suggest you use a hash
of hashes.  The code would look like this:

        my %hash;
        my $x = 'A';
        $hash{A}{cat} = qq(dog);
        my $y = $hashes{$x}{$cat};
        print "val is $y\n";


>I read perlref again today but I didn't see this in there, but I may
>have missed it as its very long.

You may want to have a look at 'perlreftut', if you have it.  It is a
much shorter tutorial of just the few most important uses of references.

If you don't have it, you may find a copy at

        http://perl.plover.com/FAQs/perlreftut.html

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Thu, 12 Apr 2001 11:44:26 GMT
From: Tassilo.Parseval@post.rwth-aachen.de (Tassilo von Parseval)
Subject: Re: How to send a formatted string through a socket?
Message-Id: <3ad59208.7182035@news.rwth-aachen.de>

On 12 Apr 2001 09:58:25 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:

>According to Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de>:
>
>[...]
> 
>> # The server goes like that:
>> 
>> use Socket;
>> sub start_server {
>> 
>>         my $port = shift || 9876;
>> 	my $proto = getprotobyname('tcp');
>> 
>> 	socket SERVER, PF_INET, SOCK_STREAM, $proto   || die "socket: $!";
>>   	bind SERVER, sockaddr_in($port, INADDR_ANY)   || die "bind: $!";
>> 	listen SERVER, SOMAXCONN                      || die "listen: $!";
>> 
>> 	print "server started on port $port";
>> 
>> 	my $paddr;
>> 
>> 	for ( ; $paddr = accept(CLIENT,SERVER); close CLIENT) {
>> 
>> 		my($port,$iaddr) = sockaddr_in($paddr);
>> 		my $name = gethostbyaddr($iaddr,AF_INET);
>> 		recv CLIENT, my $msg, 1000, 0;
>> 														    my @ret = some_function($msg);
>> 	}
>> 
>> 	send CLIENT, $_, 0 for (@ret);
>
>This looks funny.  You are accepting any number of client requests
>in the for loop, generating a reply to each in @ret, but you're
>returning only the last reply (after the loop).  Is that how it's
>supposed to work?

Eventually this is supposed  work a little bit differently, I might
restrict incoming connections, probably only one makes sense anyway.
But lately I have been busy with how to send arrays and not lines, so
this is yet a side-issue. You might here from me on this newsgroup
again when I am up to the actual and final implementation. ;-)

>
>Further, you are sending the array elements with no delimiters between
>them.  This means they will coalesce in the data stream.  There is
>no way the receiving side can tell which part of the data came from
>what call of send().

That's the problem. In between I tried it with delimiters (I used
'##') but that's not practical as some functions return really complex
stuff. Besides: The program is still supposed to work without using
this client/server thing...and this would break everything.

>
>[part of client code snipped]
>
>> my @reply;
>> while (defined($line = <SOCK>)) {
>
>Here you are reading the data in a line-oriented manner, but the
>sending side made no efforts to control what goes in each line.

That was what my question was about. :-)

>
>>         push @reply, $line;
>> }
>> 
>> printf @reply;
>
>You don't want printf here.  Use print.
>
>> print "\n";
>> print @reply; # just to test whether I receive the whole array
>> 
>> close (SOCK)            || die "close: $!";
>> exit;
>> 
>> __END__
>> 
>> If some_function() returns 
>> 
>> (GREEN."%-8.8s%-8.8s%-8.8s%-8.8s\n".
>>  "%-8.8s%-8.8s%-8.8s%-8.8s\n".
>>  "%-8.8s%-8.8s%-8.8s%-8.8s",
>>  "a", "b","c", "d",
>>  "e", "f", "g", "h",
>>  "i", "j", "k", "l")
>> 
>> the client will print out:
>> %-8.8s%-%-8.8s%- 
>> 
>> %-8.8s%-8.8s%-8.8s%-8.8s
>> %-8.8s%-8.8s%-8.8s%-8.8s
>> %-8.8s%-8.8s%-8.8s%-8.8sabcdefghijkl
>> 
>> What I am probably looking for is a way to receive the server's reponse not by 
>> lines but by array-elements but I have no idea how to achieve that.  
>
>There are many ways to do that, but in any case you will have to
>establish some sort of mini-protocol that sender and receiver use
>to tell array elements from another.  A socket transfers an ASCII
>stream, not Perl data.

Grrr.....that was what I was afraid of having to do in the end. It
means a lot more work, probably fiddling around with pack, unpack and
these mischivious templates. :-(

>
>Another more general method is to use one of the data-persistence
>modules on CPAN (Data::Dumper, FreezeThaw or Storable).  All of
>these transform a Perl data structure into an ASCII string that
>can be sent over a socket.  The receiver uses the inverse function
>to get the data structure back.  This way you can send the whole
>array @ret in one go.

Now we are approaching the matter from a more promising direction. :-)
That was probably what I was seeking...I did not know it existed

So, thanks a lot for your help...I think this points me the way to go
for!

Regards,
Tassilo


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

Date: 12 Apr 2001 12:22:43 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: inheritance within one file?
Message-Id: <9b46mj$fdo$1@mamenchi.zrz.TU-Berlin.DE>

According to Abigail <abigail@foad.org>:
> Uri Guttman (uri@sysarch.com) wrote on MMDCCLXXX September MCMXCIII in
> <URL:news:x7wv8rnyhk.fsf@home.sysarch.com>:
> $$ 
> $$ that was similar to what i thought you meant. the problem i see is with
> $$ constructor name collision. that is why naming constructors 'new' and
> $$ using the direct method call with the class name never has a name space
> $$ problem or any ambiguity:
> $$ 
> $$ 	$obj = FOO->new() ;
> $$ 
> $$ can mean only one thing.
> $$ 
> $$ 	$obj = constructor( blah ... ) ;
> $$ 
> $$ is not clear what it is constructing. so the name needs to reflect the
> $$ class anyway and needs to be unique enough to not collide with other
> $$ similar names.
> 
> FUD. Pure FUD. Of course can subs give name clashes, but then, so can
> classes. It's easier to deal with a name clash for an exported function
> though: don't run import. It's not so easy to deal with class name
> collision though.

As for clashes with export, it isn't hard to let Exporter change
not only the package but also the name of the sub.  In fact, I have
modified Exporter to do that in simple cases.  This lets you avoid
name clashes.

The (tentative) syntax is 

    use Module qw( aaa bbb->xxx);

This would import aaa as usual and bbb under the name of xxx.

The situation is comparable to the action of rename() on the file
system where you can not only change the directory of a file but
also its name.

I don't see any big problems with extending export semantics in
this way.  Would it be worth wile?

Anno


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

Date: Thu, 12 Apr 2001 11:47:42 +0100
From: Roland <roland.rashleigh-berry@virgin.net>
Subject: Q: Why perl and not Bourne/Korn scripts?
Message-Id: <3AD587CE.378@virgin.net>

Where does perl "sit" in Unix? Is it a shell like Korn or Bourne? Should
I spend the time to get heavily into writing Bourne or Korn scripts or
both or can perl do the same and should I learn perl and do it in perl
instead?

Feel free to email me the answer if you can help.

Roland


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

Date: 12 Apr 2001 12:13:35 +0100
From: nobull@mail.com
Subject: Re: Q: Why perl and not Bourne/Korn scripts?
Message-Id: <u9itka5q1s.fsf@wcl-l.bham.ac.uk>

Roland <roland.rashleigh-berry@virgin.net> writes:

> Where does perl "sit" in Unix?

http://www.wall.org/~larry/als/hatching.gif

> Is it a shell like Korn or Bourne?

No, only very few people use Perl as an interactive shell.

See also FAQ: "What is Perl?"

> Should
> I spend the time to get heavily into writing Bourne or Korn scripts or
> both or can perl do the same and should I learn perl and do it in perl
> instead?

Everything you can do in shell can be done in Perl.

Complex shell scripts are almost always written in Perl unless
portability to machines lacking Perl is an issue.

Simple pipelining is simpler in shell.  (i.e if you want to launch two
or more subprocesses and connect them STDOUT->STDIN).  That said I'd
be amazed if there's not a module on CPAN to simplify it.

In Perl you can use shell pipelines in open() and readpipe() so get
the best of both worlds.

My advice is get only lightly into shell scripts, use Perl for
anything heavy.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 12 Apr 2001 06:12:04 -0400
From: "Prasad, Victor [FITZ:K500:EXCH]" <vprasad@americasm01.nt.com>
Subject: Unix Script in a Perl script to the Web.vvp
Message-Id: <3AD57F74.73BB433F@americasm01.nt.com>

Hello,

I would like to use a pre-existing Unix script in a perl script.

I have a unix script that accepts up to two parameters.  Once entered it
performs its task and spits out output as it is working.  I have to
output the data from the Unix script to a Web page - hopefully - as in
realtime.  Sometimes the output takes a long time to finish - so buy
displaying it as it output would let the user know it is working.

The only think I can think of it redirecting the Unix output to a file -
then printing the file to the webscreen - but that would only work after
the process completed.

I have to pass the parameters to the Unix script - but am not sure how
to get the output from the script to Perl then the web.

Basically it the Unix script looks like this:

Catalog?  10
Item? 5

Working...

Updated catalog 10
Max items 1000
1 - previous
2 - previous
3 - previous
4 - altered
5 - inserted
6
7
8
9
10
 .
 .
 .
100

Inserted 5
New total 5

Successful.

I was going to use the system command to make the script run.  But am
not sure how to get the output to let the use know all is OK.

Any advice?

Thanks,

V


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

Date: Thu, 12 Apr 2001 20:06:20 +0900
From: LXQ <lxq79@REMOVE.CAPITALS.hotmail.com>
Subject: use strict and sysopen
Message-Id: <20010412200620.021ea35c.lxq79@REMOVE.CAPITALS.hotmail.com>

Hi,

I wrote a program like this:

use Fcntl qw(:flock);
use strict;

[... trimmed ...]

    sysopen(DATABASE, $dataFile, O_APPEND)
	or die("ERROR: Can not open database file");

[... trimmed ...]

But when I tried to run it, Perl complained that:
Bareword "O_APPEND" not allowed while "strict subs" in use at
/home/bk/public_html/guestbook/sign.cgi line 62

How can I deal with this problem without commenting the 'use strict'?
Thanks so much.

-LXQ-


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

Date: 12 Apr 2001 12:25:09 +0100
From: nobull@mail.com
Subject: Re: use strict and sysopen
Message-Id: <u9bsq25pii.fsf@wcl-l.bham.ac.uk>

LXQ <lxq79@REMOVE.CAPITALS.hotmail.com> writes:

> use Fcntl qw(:flock);

> Bareword "O_APPEND" not allowed while "strict subs" in use at
> /home/bk/public_html/guestbook/sign.cgi line 62
> 
> How can I deal with this problem without commenting the 'use strict'?

Q: My smoke alarms are making a loud noise. How can I deal with this
   problem without removing the batteries?

A: Put out the fire.

Commenting out the 'use strict' won't make your program do what you
want, it'll just prevent Perl detecting your mistake.

use Fcntl qw(:DEFAULT :flock);

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 12 Apr 2001 20:23:45 +0800
From: "John" <john@imining.com.tw>
Subject: Win32::ODBC insert datetime data into Access DB
Message-Id: <9b46vp$79j@netnews.hinet.net>

Hi,

I'd like to insert datetime data into an Access 2000 database.
I use the Win32::ODBC module with sql insert command.
When the sql string is
  INSERT INTO table (time,...) VALUES (#2001/04/05 12:00:00#,....)
or
  INSERT INTO table (time,...) VALUES ('2001/04/05 12:00:00',....)
I always get a -3502 error.
Other data types are ok.
What's wrong?
Thanks in advance.

John Hsieh




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

Date: Thu, 12 Apr 2001 08:03:24 -0400
From: "Steven Ulbrich" <sjutmp@msn.com>
Subject: XML::DOM Problem.  Look for Some Insight.
Message-Id: <tdb6afola1aq27@news.supernews.com>

I have a XML document that needs some regular experssion work done on it.  I
am new to the use of Perl XML::DOM to cycle thru the document and extract
the data.  So could use some help on my code.  The responses are odd to me.
I getting extra responses show as TEXT_NODE, but no data or corresponding
Tag.

I'm including the XML doc, output and Perl Code.

Thank you.

Steven Ulbrich


XML:

<!-- edited with XML Spy v3.5 NT (http://www.xmlspy.com) by Steven Ulbrich
(private) -->
<!--Steven J Ulbrich Jan 19, 2001-->
<ClientFile_1_0>
 <ClientFile>
  <ClientFileTypeDisplayHeader>
   <FileInd>P</FileInd>
   <DataInd>C</DataInd>
   <CRSID>1V</CRSID>
   <PCC>1W5O</PCC>
   <AgncyDesc><![CDATA[TMP]]></AgncyDesc>
   <BusinessTitle>RWD</BusinessTitle>
   <PersonalTitle>BUCKON</PersonalTitle>
   <CreationDt>19970620</CreationDt>
   <PrefInd>P</PrefInd>
  </ClientFileTypeDisplayHeader>
  <ClientFileFixedLineData>
   <LineNum>1</LineNum>
   <MoveInd>Y</MoveInd>
   <ClientInd/>
   <SecondaryInd/>
   <TertiaryInd/>
   <DataType>1</DataType>
  </ClientFileFixedLineData>
  <ClientFileVariableLineData>
   <Data>N:1BUCKON/ANDREW*D4204</Data>
  </ClientFileVariableLineData>
  <ClientFileFixedLineData>
   <LineNum>2</LineNum>
   <MoveInd>Y</MoveInd>
   <ClientInd/>
   <SecondaryInd/>
   <TertiaryInd/>
   <DataType>10</DataType>
  </ClientFileFixedLineData>
  <ClientFileVariableLineData>
   <Data>¤:5TITLE:*** STAFF ENGINEER ***</Data>
  </ClientFileVariableLineData>
  <ClientFileFixedLineData>
   <LineNum>5</LineNum>
   <MoveInd>N</MoveInd>
   <ClientInd/>
   <SecondaryInd/>
   <TertiaryInd/>
   <DataType>31</DataType>
  </ClientFileFixedLineData>
  <ClientFileVariableLineData>
   <Data>***CORPTRIP BETA TEST***</Data>
  </ClientFileVariableLineData>
  <ClientFileFixedLineData>
   <LineNum>11</LineNum>
   <MoveInd>Y</MoveInd>
   <ClientInd/>
   <SecondaryInd/>
   <TertiaryInd/>
   <DataType>2</DataType>
  </ClientFileFixedLineData>
  <ClientFileVariableLineData>
   <Data>P:BWIB/410-884-2442/R/410-280-6440</Data>
  </ClientFileVariableLineData>
  <ClientFileFixedLineData>
   <LineNum>12</LineNum>
   <MoveInd>Y</MoveInd>
   <ClientInd/>
   <SecondaryInd/>
   <TertiaryInd/>
   <DataType>2</DataType>
  </ClientFileFixedLineData>
  <ClientFileVariableLineData>
   <Data>P:BWIB/555-831-9825 CELL PHONE</Data>
  </ClientFileVariableLineData>
  <ClientFileFixedLineData>
   <LineNum>20</LineNum>
   <MoveInd>Y</MoveInd>
   <ClientInd/>
   <SecondaryInd/>
   <TertiaryInd/>
   <DataType>4</DataType>
  </ClientFileFixedLineData>
  <ClientFileVariableLineData>
   <Data>D-ANDY BUCKON</Data>
  </ClientFileVariableLineData>
  <ClientFileFixedLineData>
   <LineNum>22</LineNum>
   <MoveInd>O</MoveInd>
   <ClientInd/>
   <SecondaryInd/>
   <TertiaryInd/>
   <DataType>3</DataType>
  </ClientFileFixedLineData>
  <ClientFileVariableLineData>
   <Data>W-ANDREW BUCKON¤109 ST ANDREWS RD¤SEVERNA PARK MD Z/21146</Data>
  </ClientFileVariableLineData>
  <ClientFileFixedLineData>
   <LineNum>41</LineNum>
   <MoveInd>Y</MoveInd>
   <ClientInd/>
   <SecondaryInd/>
   <TertiaryInd/>
   <DataType>20</DataType>
  </ClientFileFixedLineData>
  <ClientFileVariableLineData>
   <Data>T-CA-35¤3500</Data>
  </ClientFileVariableLineData>
  <ClientFileFixedLineData>
   <LineNum>42</LineNum>
   <MoveInd>O</MoveInd>
   <ClientInd/>
   <SecondaryInd>T</SecondaryInd>
   <TertiaryInd/>
   <DataType>21</DataType>
  </ClientFileFixedLineData>
  <ClientFileVariableLineData>
   <Data>F-555552121421005</Data>
  </ClientFileVariableLineData>
  <ClientFileFixedLineData>
   <LineNum>50</LineNum>
   <MoveInd>Y</MoveInd>
   <ClientInd/>
   <SecondaryInd>S</SecondaryInd>
   <TertiaryInd/>
   <DataType>10</DataType>
  </ClientFileFixedLineData>
  <ClientFileVariableLineData>
   <Data>¤:5S/SEAT-NW</Data>
  </ClientFileVariableLineData>
  <ClientFileFixedLineData>
   <LineNum>55</LineNum>
   <MoveInd>O</MoveInd>
   <ClientInd/>
   <SecondaryInd>A</SecondaryInd>
   <TertiaryInd/>
   <DataType>5</DataType>
  </ClientFileFixedLineData>
  <ClientFileVariableLineData>
   <Data>MP*AA2AM555*US255555*DL2195834631*NW78551178</Data>
  </ClientFileVariableLineData>
  <ClientFileFixedLineData>
   <LineNum>56</LineNum>
   <MoveInd>O</MoveInd>
   <ClientInd/>
   <SecondaryInd>A</SecondaryInd>
   <TertiaryInd/>
   <DataType>5</DataType>
  </ClientFileFixedLineData>
  <ClientFileVariableLineData>
   <Data>MP*COWH721828</Data>
  </ClientFileVariableLineData>
  <ClientFileFixedLineData>
   <LineNum>61</LineNum>
   <MoveInd>Y</MoveInd>
   <ClientInd/>
   <SecondaryInd>C</SecondaryInd>
   <TertiaryInd/>
   <DataType>10</DataType>
  </ClientFileFixedLineData>
  <ClientFileVariableLineData>
   <Data>¤:5C/ZE ID-55550572</Data>
  </ClientFileVariableLineData>
  <ClientFileFixedLineData>
   <LineNum>71</LineNum>
   <MoveInd>Y</MoveInd>
   <ClientInd/>
   <SecondaryInd>H</SecondaryInd>
   <TertiaryInd/>
   <DataType>10</DataType>
  </ClientFileFixedLineData>
  <ClientFileVariableLineData>
   <Data>¤:5H/CY ID-55555555</Data>
  </ClientFileVariableLineData>
  <ClientFileFixedLineData>
   <LineNum>72</LineNum>
   <MoveInd>Y</MoveInd>
   <ClientInd/>
   <SecondaryInd>H</SecondaryInd>
   <TertiaryInd/>
   <DataType>10</DataType>
  </ClientFileFixedLineData>
  <ClientFileVariableLineData>
   <Data>¤:5H/HH ID-455555574</Data>
  </ClientFileVariableLineData>
 </ClientFile>
</ClientFile_1_0>



OutPut from my Perl Code:

readclientv2.pl 2.xml
Data

ClientFileTypeDisplayHeader
Data

FileInd
Data P
Data

DataInd
Data C
Data

CRSID
Data 1V
Data

PCC
Data 1W5O
Data

AgncyDesc
Data TMP
Data

BusinessTitle
Data RWD
Data

PersonalTitle
Data BUCKON
Data

CreationDt
Data 19970620
Data

PrefInd
Data P
Data

Data

ClientFileFixedLineData
Data

LineNum
Data 1
Data

MoveInd
Data Y
Data

ClientInd
Data

SecondaryInd
Data

TertiaryInd
Data

DataType
Data 1
Data

Data

ClientFileVariableLineData
Data

Data
Data N:1BUCKON/ANDREW*D4204
Data

Data

ClientFileFixedLineData
Data

LineNum
Data 2
Data

MoveInd
Data Y
Data

ClientInd
Data

SecondaryInd
Data

TertiaryInd
Data

DataType
Data 10
Data

Data

ClientFileVariableLineData
Data

Data
Data ¤:5TITLE:*** STAFF ENGINEER ***
Data

Data

ClientFileFixedLineData
Data

LineNum
Data 5
Data

MoveInd
Data N
Data

ClientInd
Data

SecondaryInd
Data

TertiaryInd
Data

DataType
Data 31
Data

Data

ClientFileVariableLineData
Data

Data
Data ***CORPTRIP BETA TEST***
Data

Data

ClientFileFixedLineData
Data

LineNum
Data 11
Data

MoveInd
Data Y
Data

ClientInd
Data

SecondaryInd
Data

TertiaryInd
Data

DataType
Data 2
Data

Data

ClientFileVariableLineData
Data

Data
Data P:BWIB/410-884-2442/R/410-280-6440
Data

Data

ClientFileFixedLineData
Data

LineNum
Data 12
Data

MoveInd
Data Y
Data

ClientInd
Data

SecondaryInd
Data

TertiaryInd
Data

DataType
Data 2
Data

Data

ClientFileVariableLineData
Data

Data
Data P:BWIB/555-831-9825 CELL PHONE
Data

Data

ClientFileFixedLineData
Data

LineNum
Data 20
Data

MoveInd
Data Y
Data

ClientInd
Data

SecondaryInd
Data

TertiaryInd
Data

DataType
Data 4
Data

Data

ClientFileVariableLineData
Data

Data
Data D-ANDY BUCKON
Data

Data

ClientFileFixedLineData
Data

LineNum
Data 22
Data

MoveInd
Data O
Data

ClientInd
Data

SecondaryInd
Data

TertiaryInd
Data

DataType
Data 3
Data

Data

ClientFileVariableLineData
Data

Data
Data W-ANDREW BUCKON¤109 ST ANDREWS RD¤SEVERNA PARK MD Z/21146
Data

Data

ClientFileFixedLineData
Data

LineNum
Data 41
Data

MoveInd
Data Y
Data

ClientInd
Data

SecondaryInd
Data

TertiaryInd
Data

DataType
Data 20
Data

Data

ClientFileVariableLineData
Data

Data
Data T-CA-35¤3500
Data

Data

ClientFileFixedLineData
Data

LineNum
Data 42
Data

MoveInd
Data O
Data

ClientInd
Data

SecondaryInd
Data T
Data

TertiaryInd
Data

DataType
Data 21
Data

Data

ClientFileVariableLineData
Data

Data
Data F-555552121421005
Data

Data

ClientFileFixedLineData
Data

LineNum
Data 50
Data

MoveInd
Data Y
Data

ClientInd
Data

SecondaryInd
Data S
Data

TertiaryInd
Data

DataType
Data 10
Data

Data

ClientFileVariableLineData
Data

Data
Data ¤:5S/SEAT-NW
Data

Data

ClientFileFixedLineData
Data

LineNum
Data 55
Data

MoveInd
Data O
Data

ClientInd
Data

SecondaryInd
Data A
Data

TertiaryInd
Data

DataType
Data 5
Data

Data

ClientFileVariableLineData
Data

Data
Data MP*AA2AM555*US255555*DL2195834631*NW78551178
Data

Data

ClientFileFixedLineData
Data

LineNum
Data 56
Data

MoveInd
Data O
Data

ClientInd
Data

SecondaryInd
Data A
Data

TertiaryInd
Data

DataType
Data 5
Data

Data

ClientFileVariableLineData
Data

Data
Data MP*COWH721828
Data

Data

ClientFileFixedLineData
Data

LineNum
Data 61
Data

MoveInd
Data Y
Data

ClientInd
Data

SecondaryInd
Data C
Data

TertiaryInd
Data

DataType
Data 10
Data

Data

ClientFileVariableLineData
Data

Data
Data ¤:5C/ZE ID-55550572
Data

Data

ClientFileFixedLineData
Data

LineNum
Data 71
Data

MoveInd
Data Y
Data

ClientInd
Data

SecondaryInd
Data H
Data

TertiaryInd
Data

DataType
Data 10
Data

Data

ClientFileVariableLineData
Data

Data
Data ¤:5H/CY ID-55555555
Data

Data

ClientFileFixedLineData
Data

LineNum
Data 72
Data

MoveInd
Data Y
Data

ClientInd
Data

SecondaryInd
Data H
Data

TertiaryInd
Data

DataType
Data 10
Data

Data

ClientFileVariableLineData
Data

Data
Data ¤:5H/HH ID-455555574
Data

Data


Perl Code:


#! /usr/bin/perl -w

# include the XML-DOM package for Perl
use XML::DOM;
$, = " ";

# use strict is always a good idea in any perl script
use strict;

my $file = shift;

use vars qw($NodeName $ParentNode $DataValue);

# Initialize the parser object
my $parser = new XML::DOM::Parser;


my $doc = $parser->parsefile ($file);

my $top_list = $doc->getElementsByTagName ("ClientFile");


my $top_node;
if (@{$top_list}) {
    $top_node = $top_list->item (0);
}
else {
    die "1001"; #No such node:ClientFile
}

dump_xml_data ($top_node);

sub dump_xml_data {

    # Get our argument list
    my ($parent_node) = @_;

    my $child_list = $parent_node->getChildNodes;

    # Go through and iteratively print bodies of text, or print
    # information about the node and recurse when necessary
    my $child_node;
    foreach $child_node (@{$child_list}) {

         my $nodeType = $child_node->getNodeType();

         if ($nodeType == ELEMENT_NODE ) {
            my $nodeTagName =$child_node->getTagName();
            print "$nodeTagName\n";


               #dump_xml_data ($child_node);
            }
         if ($nodeType == TEXT_NODE) {
               #my $node_name = $child_node->getName;
               my $node_data = $child_node->getData;
               print "Data $node_data\n";
            }
            dump_xml_data ($child_node);

         }



    }








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

Date: Thu, 12 Apr 2001 12:32:17 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net ()
Subject: Re: XML::DOM Problem.  Look for Some Insight.
Message-Id: <slrn9db7p6.3vvl3ph.bernard.el-hagin@gdndev25.dev.lido-tech>

On Thu, 12 Apr 2001 08:03:24 -0400, Steven Ulbrich <sjutmp@msn.com> wrote:
::I have a XML document that needs some regular experssion work done on it.  I
::am new to the use of Perl XML::DOM to cycle thru the document and extract
::the data.  So could use some help on my code.  The responses are odd to me.
::I getting extra responses show as TEXT_NODE, but no data or corresponding
::Tag.
::
::I'm including the XML doc, output and Perl Code.

Please don't post such insane amounts of code. Next time just put the
source up somewhere and post a link to it. Some people have to pay per
byte for downloading newsgroups, you know.

Cheers,
Bernard
--
perl -e'$\=qq;,\n;;s,,*Just.*another.*Perl.*hacker,e;%JaPh
=(q,*,,q, ,);s,((?:[\w]+?::)|\*),$JaPh{${((sin(32)**2)+
(cos(32)**2))}},gex;print;'


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

Date: 12 Apr 2001 13:04:44 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: XML::DOM Problem.  Look for Some Insight.
Message-Id: <9b495c$j6v$1@bob.news.rcn.net>

Steven Ulbrich <sjutmp@msn.com> wrote:
> I have a XML document that needs some regular experssion work done on it.  I
> am new to the use of Perl XML::DOM to cycle thru the document and extract
> the data.  So could use some help on my code.  The responses are odd to me.
> I getting extra responses show as TEXT_NODE, but no data or corresponding
> Tag.

[please don't post huge amounts of data]

What you're almost certainly running into is the fact that in XML, *all*
whitespace outside of markup is significant.  This means that when you
read an XML document into a DOM, there will be text nodes for any line
breaks and indentations that follow a tag.  For example, in

<parent>
  <child/>
</parent>

the "parent" element has three children: a text node, the "child" element, 
and another text node.  Your code will fail if it expects "child" to be 
the first child of "parent."


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 684
**************************************


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