[15863] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3276 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 7 11:05:25 2000

Date: Wed, 7 Jun 2000 08:05:11 -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: <960390311-v9-i3276@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 7 Jun 2000     Volume: 9 Number: 3276

Today's topics:
    Re: Aol coockie: date error (Tony L. Svanstrom)
    Re: Date format [4]++ / [5]+=1900 ? (jason)
    Re: DBI and Apache 1.3 (Honza Pazdziora)
    Re: debug perl script called by webserver <tom.kralidis@ccrs.nrcanDOTgc.ca>
    Re: debug perl script called by webserver <cwilson4@lucent.com>
    Re: Dumb question.. How to prompt the user and get the  (Bart Lateur)
        dump a hash? <nasobem_hh@my-deja.com>
        Dynamic URI query strings leon@twoshortplanks.com
    Re: eventlog <boogiemonster@usa.net>
    Re: exists() on sub-hash creates a key in super-hash <aqumsieh@hyperchip.com>
        external program stdout to screen and log bradley_johnston@my-deja.com
    Re: Extracting info from /etc/printcap <real@earthling.net>
        Having some problems integrating a C-Subroutine ... <michael.maretzke@conrad.com>
    Re: mail attachments.. <sariq@texas.net>
    Re: needs help w system interaction <tony_curtis32@yahoo.com>
    Re: open an array? <szhzp2@no.spam.com>
    Re: Perl -VS- PHP <apage.net[remove]@usa.net>
    Re: perl Configure (Bart Lateur)
    Re: Perl Crypt function (5-i's)
    Re: Perl Crypt function <aqumsieh@hyperchip.com>
    Re: perlscript & wsh <cerberus40@hotmail.com>
    Re: Pseudo-hashes/OOP <aqumsieh@hyperchip.com>
    Re: Tr vs. tr !@#@!#$@#% <tzadikv@my-deja.com>
    Re: using 'exists' in a program to test for keys in a h (Bart Lateur)
    Re: Using PERL to login to Novell? <apage.net[remove]@usa.net>
    Re: Using Unix SOURCE in PERL SYSTEM?? NEED HELP <Michael.Bukowski@usa.xerox.com>
    Re: Using Unix SOURCE in PERL SYSTEM?? NEED HELP <Michael.Bukowski@usa.xerox.com>
    Re: Using Unix SOURCE in PERL SYSTEM?? NEED HELP <tony_curtis32@yahoo.com>
        why overvrite list <sezemsky@dcse.fee.vutbr.cz>
    Re: why overvrite list (Rafael Garcia-Suarez)
    Re: win32: How do i build gui app (jason)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 7 Jun 2000 17:00:06 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Aol coockie: date error
Message-Id: <1ebv8d5.1901a5wxc89qeN%tony@svanstrom.com>

Free Lance <thetrader@worldnet.att.net> wrote:

> Does anyone know about this issue?
> My script successfully writes cookies with a one year expiration date
> with AOL i get an error like :
> date error:  today's date + one year

You don't give enough information for me to be able to tell what's going
on, but here's how you can create cookies with a 100% correct date:

### begin
sub the_swedish_cookiemaker() {
   # (c)2000 svanstrom.com - vers: 2000y-06m-07d 01:10t CET
   my($name,$value,$stay,$path,$domain,$sec) = @_;
   if (($domain =~ tr/\.//) < 2) {$domain = ".$domain";}
   my @days = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday',
        'Saturday');
   my @months = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct',
        'Nov','Dec');
   (my @temptime) = gmtime(time+$stay);
   my $cookietime = "@days[$temptime[6]], $temptime[3]-@months[$temptime[4]]-".
        ($temptime[5]+1900) . " "; my @ends = (':',':',' GMT',);
   my $i; foreach ($temptime[2],$temptime[1],$temptime[0]) {
      $i++;
      if ($_ < 10) {$cookietime .= "0$_$ends[$i-1]"
      } else {$cookietime .= "$_$ends[$i-1]"
      }
   }
   return("Set-Cookie: $name=$value; expires=$cookietime; path=$path;".
   " domain=$domain; $sec\n");
}

print &the_swedish_cookiemaker('namn','value',60*60*24*365,'/','svanstrom.com',0);
### end


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
 DSS: 0x9363F1DB, Fp: 6EA2 618F 6D21 91D3 2D82  78A6 647F F247 9363 F1DB
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©1999  <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Wed, 07 Jun 2000 14:01:56 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Date format [4]++ / [5]+=1900 ?
Message-Id: <MPG.13a8f302520df194989713@news>

Eric Bohlman writes ..
>euterpe21@yahoo.com wrote:
>: Hi,
>: 
>: I'm currently using this :
>: 
>: @d_date = localtime(time);
>: $d_date[4] ++;
>: $d_date[5] += 1900;
>: 
>: but I don't know what ++ and += really do
>: 
>: + is defined as a model searching character, ok ?
>: But what means ++ applied to the month element only and not to hours,
>: minutes and seconds?
>: On the other way, what means += applied to the year element ?
>
>I think you want to read the perlop man page; it should clear up quite a 
>bit of confusion.

and

  perldoc -f localtime

will explain why you're only doing ++ to the month element

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Sat, 3 Jun 2000 11:04:54 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: DBI and Apache 1.3
Message-Id: <FvKs46.3tp@news.muni.cz>

On Fri, 02 Jun 2000 17:45:32 GMT, lennie_jarratt@my-deja.com <lennie_jarratt@my-deja.com> wrote:
> I am trying to access my database via DBI on an
> Apache 1.3.12 server.  I cannot get it to load the
> .so files for DBI.  How can I set this up?

And what does it say when it fails to load that .so?

Your env settings and file permissions are most likely the cause of
the trouble but unless you're more specific about the failure, we're
just guessing.

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
------------------------------------------------------------------------


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

Date: Wed, 07 Jun 2000 09:03:23 -0400
From: Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca>
Subject: Re: debug perl script called by webserver
Message-Id: <393E481B.18E55B7F@ccrs.nrcanDOTgc.ca>

eastking@my-deja.com wrote:
> 
> I am developing CGI application by perl under linux/Apache. Is there
> any one know how to debug perl script called by webserver. It means
> that I type a request in browser and want to debug my perl script which
> response to this request in server.Thank in advance.
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

You may want put this at the top of your CGI script:

use CGI::Carp qw(fatalsToBrowser);

 ..this will show return errors to the browser, instead of fishing
through server logs.

Note that this line should be commented out when the script is in
production.

Hope this helps.

-- 
=================================
Tom Kralidis
Geo-Spatial Developer
Canada Centre for Remote Sensing
Tel: (613) 947-1828
Fax: (613) 947-1408
http://www.ccrs.nrcan.gc.ca
=================================


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

Date: 7 Jun 2000 13:24:15 GMT
From: "chris wilson" <cwilson4@lucent.com>
Subject: Re: debug perl script called by webserver
Message-Id: <01bfd083$ba12a320$70874a87@fl0094mp39>

you can also run the script through a telnet window or at the command
prompt on the server. If you don't have carp installed, this may help.

Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca> wrote in article
<393E481B.18E55B7F@ccrs.nrcanDOTgc.ca>...
> eastking@my-deja.com wrote:
> > 
> > I am developing CGI application by perl under linux/Apache. Is there
> > any one know how to debug perl script called by webserver. It means
> > that I type a request in browser and want to debug my perl script which
> > response to this request in server.Thank in advance.
> > 
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> 
> You may want put this at the top of your CGI script:
> 
> use CGI::Carp qw(fatalsToBrowser);
> 
> ..this will show return errors to the browser, instead of fishing
> through server logs.
> 
> Note that this line should be commented out when the script is in
> production.
> 
> Hope this helps.
> 
> -- 
> =================================
> Tom Kralidis
> Geo-Spatial Developer
> Canada Centre for Remote Sensing
> Tel: (613) 947-1828
> Fax: (613) 947-1408
> http://www.ccrs.nrcan.gc.ca
> =================================
> 


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

Date: Wed, 07 Jun 2000 13:56:41 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Dumb question.. How to prompt the user and get the input.
Message-Id: <394252e8.461150@news.skynet.be>

Matt King wrote:

>I'm using Active Perl for Win32. The script will be ran from a DOS window. I
>was thinking that it would be something like $input=stdin; but I can't find
>it in the docs or with the search program nor does it work.

	$input = <STDIN>;

obviously! But don't forget that there will be a newline at the end of
the line. And it won't "work" if data was piped into the script (er...
can you even do that with perl on Win32?)

-- 
	Bart.


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

Date: Wed, 07 Jun 2000 14:48:39 GMT
From: Dr. Markus <nasobem_hh@my-deja.com>
Subject: dump a hash?
Message-Id: <8hlnbv$243$1@nnrp1.deja.com>

Hi,
We just came accross an interesting question:
Is it possible to dump a hash (preferrably raw) to disk for future
reference?
Best would be a selfdescribing format (i.e. the structure can be derived
when the dump is read).
Any ideas?
Markus


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


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

Date: Wed, 07 Jun 2000 14:36:01 GMT
From: leon@twoshortplanks.com
Subject: Dynamic URI query strings
Message-Id: <8hlmke$1hc$1@nnrp1.deja.com>

Heya,

I'm coming across a problem and I'm hoping that someone has solved it
in a slightly cleaner way than I have.

I want to take a URI string and manipulate the query parameters:
ie I'm given the following as a string:
/investment/detail.epl?code=FOO&display=WOTSIT&it=BAR
and want to output:
/investment/detail.epl?code=007&display=WOTSIT&it=BAR&new=YES

The only way I've come up with so far is:

my $uriprefix = '/investment/detail.epl?code=FOO&display=WOTSIT&it=BAR';
my $uri = URI->new($uriprefix);
my $q = CGI->new($uri->query);
$q->param('code', '007');
$q->param('new', 'YES');
$uriprefix = $uri->path . '?' . $q->query_string;
print $uriprefix, "\n";

Why am I not using $q->self_url()? Becuase it prefixes an annoying
"http://localhost/./" for no apparent reason and I want a clean
way to do this.

Have I missed something? Is there a module on CPAN which makes this
manipulation easier? Should there be? I guess this can be done by
extended the URI module appropriately, say by adding a query_param()
method which works in a similar way to the CGI param() method.

Am I mad?, Leon
--
 .what?


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


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

Date: Wed, 7 Jun 2000 09:48:55 -0700
From: "J. Joseph Yusko" <boogiemonster@usa.net>
Subject: Re: eventlog
Message-Id: <8hlk2c$c24$1@usenet01.srv.cis.pitt.edu>

I apologize for not being more specific.  Nice webpage and great idea by the
way.

Here is the code:
use Win32::EventLog;
 my @Servers=("server1","server2");
 my($date)=join("-", ((split(/\s+/, scalar(localtime)))[0,1,2,4]));
 my($dest);

 foreach my $Server (@Servers) {
  for my $eventLog ("Application", "System", "Security") {
         $handle=Win32::EventLog->new($eventLog, $Server)
                 or die "Can't open Application EventLog on $Server\n";

        $dest="C:\\BackupEventLogs\\$eventLog\\$date.evt";
               $handle->Clear($dest)
                 or warn "Could not backup and clear the $eventLog EventLog
on $Server ($^E)\n";


  }
 $handle->Close;
}

now it will create the application aspect of the log but after that it gives
me an error message
"Could not backup and clear the Security EventLog on server1 (Overlapped I/O
operation is in progress)"




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

Date: Wed, 07 Jun 2000 14:23:46 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: exists() on sub-hash creates a key in super-hash
Message-Id: <7ag0qpsh7l.fsf@merlin.hyperchip.com>


Vincent <szhzp2@no.spam.com> writes:

> - $hash{'foo'}{'bar'} is set to 'foobar'. (No big deal)
> - Hence, %hash contains one key: 'foo'
> - The test with 'exists()' for $hash{'bar'}{'foo'} obviously fails. But,
>   it seems to create a key 'bar' in %hash with a reference to an empty
>   hash.
> (FYI, 'defined()' in stead of 'exists()' or an assignement like
> '$x = $hash{'bar'}{'foo'}' both produce the same behaviour)
> 
> Question:
> Is this behaviour 'as designed', an ommision in the design or a bug?

It is a feature (tm) called autovivification. It is the same reason that
allows you to execute the first step above. If it weren't for it, you
would have to do it in two steps:

	$hash{foo} = {};
	$hash{foo}{bar} = 'foobar';

So be glad it exists :-)

--Ala


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

Date: Wed, 07 Jun 2000 14:44:01 GMT
From: bradley_johnston@my-deja.com
Subject: external program stdout to screen and log
Message-Id: <8hln3b$1ut$1@nnrp1.deja.com>



I want to run external programs from my Perl program (like a "VSS GET"
and "msdev project.dsw..."). I want to log the output to file, and I
still want to see the output to screen.

Right now I am doing this...

$command = 'SS Get $/project/*.* -R -GCK';
@result = `$command`;

Then I can print the @result array to file and screen after the
external program completes, but I am looking for something a little
more real time.

I would rather do a pipe or fork of the STDOUT of the external process
to screen and file. I have been throught the faqs but I just don't get
it.

Thanks to all for any assistance...





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


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

Date: Wed, 7 Jun 2000 15:06:43 +0200
From: "Real" <real@earthling.net>
Subject: Re: Extracting info from /etc/printcap
Message-Id: <8hlhd5$qk6$1@news.surfnet.nl>

One very minor adjustment so it'll also work when # chars are used (Thu64).
Replace;

>       %{$attrs{$printer}} = map { my ($key,$value) = split /=/ ;
>                                      $value ||= '';
>                                      ($key, $value);
>                                    } @line;

with;

    %{$attrs{$printer}} = map { s/#/=/; my ($key,$value) = split /=/ ;
                                   $value ||= '';
                                   ($key, $value);
                                  } @line;

Cheers,
Real




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

Date: Wed, 7 Jun 2000 15:20:46 +0200
From: "Michael Maretzke" <michael.maretzke@conrad.com>
Subject: Having some problems integrating a C-Subroutine ...
Message-Id: <393e4c8f$0$25912@businessnews.de.uu.net>

Hey, out there !

I've got a question about memory handling using XS-Files ...

----------------------------------------------------------------------------
------------
char*
SoundEx(pszWord)
    char* pszWord
    CODE:
        char* pszPhonWord;
        pszPhonWord = (char *) malloc(6);

        SoundEx(pszWord, pszPhonWord);

        RETVAL = pszPhonWord;
        // free(pszPhonWord); // ATTENTION ATTENTION

OUTPUT:
RETVAL
----------------------------------------------------------------------------
------------

This is my definition in my XS-File. I call a function coded myself in C
which transforms
pszWord into pszPhonWord.
My specific question to the real PERL gurus is now ...
The line marked with "Attention" must be commented cause if it's enabled my
return
value will be empty. Not that what I want. If I comment this line ... who
frees the
reserved memory (this 6 bytes) ???
Does this PERL or is it simply the wrong way I go ? Should I read more about
this
magic SV-Values ?

Any ideas would be appreciated !

Thanx a lot ... Michael (the PERL newbie ;-) )




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

Date: Wed, 07 Jun 2000 09:22:41 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: mail attachments..
Message-Id: <393E5AB1.EACCCBDC@texas.net>

MegaGiga wrote:
> 
> How do I add attachments to mail sent through a form?

use MIME::Lite;

- Tom


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

Date: 07 Jun 2000 08:23:13 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: needs help w system interaction
Message-Id: <874s754oce.fsf@limey.hpcc.uh.edu>

>> On Wed, 07 Jun 2000 02:05:27 GMT,
>> "news" <toa@home.com> said:

> gang, Is there anyway to run a unix program from within
> a perl script??

perldoc -f system
perldoc -f fork
perldoc -f exec
perldoc -f open
perldoc perlipc

> I am trying to set some views in Clearcase from a perl
> script.  as soon as the perl script execution gets to
> the setview line it stops and does not go further.

> even if I try to start a unix "rsh" from a perl script
> it stops again, I think both problems are the same.

> I am using

> system "Clearcase setview user_view";

run the clearcase program with args, wait for it to
terminate and then continue in the perl.

> system "rsh ck15";

rlogin to ck15 and wait for the login session to
terminate, then continue in perl.

If that's what you want to happen, then the syntax is
perfectly correct.

However, it sounds like you want to capture the (standard)
output from a command's execution, yes?  In which case,
either use a piped open to run the command and slurp its
output back into perl, or use qx(), "perldoc perlop" has
a number of examples of "qx".

hth
t
-- 
"Trying is the first step towards failure"
                                           Homer Simpson


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

Date: Wed, 7 Jun 2000 14:32:23 +0200
From: Vincent <szhzp2@no.spam.com>
To: "Dr. Markus" <nasobem_hh@my-deja.com>
Subject: Re: open an array?
Message-Id: <Pine.LNX.4.21.0006071422380.2879-100000@w01b04vc.flur.zuerich.ubs.ch>

On Wed, 7 Jun 2000, Dr. Markus wrote:

> I wrote a little script that calls an external program (which runs
> rather long) in a loop.

So you have a long deterministic program (it's output is directly derrived
from the input parameters). And you want to cache its output for faster
processing.

Following program calls echo twice (to have multiple output lines) for
each parameter set. It chaches the output in %hist. It might do what you
want.

$mycmd = 'echo';
@params = (
        ['a', 'b', 'c'],
        ['b', 'c', 'd'],
        ['a', 'b', 'c'],        # Same as [0]
        ['c', 'd', 'e'],
        ['a', 'b', 'c'],        # Same as [0]
);
foreach $params(@params) {
        $paramkey = join(';', @{$params});
        if (exists($hist{$paramkey})) {
                print "HIST @{$params} :\n", $hist{$paramkey};
        } else {
                $hist{$paramkey} = `$mycmd @{$params}; $mycmd @{$params}`;
                print "CALL @{$params} :\n", $hist{$paramkey};
        }
}

-- 
Vincent Zocca
Vincent.Zocca@UBS.com
Usual disclaimer:
Opinions expressed here are explicitly my own and not of UBS!!!



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

Date: Wed, 7 Jun 2000 08:56:13 -0400
From: "Zowwie" <apage.net[remove]@usa.net>
Subject: Re: Perl -VS- PHP
Message-Id: <sjsjhm3m2t5113@corp.supernews.com>

"To explain: I asked this because my ~boss~ is complaining because one..."

Here is some advise I saw in the group awhile back in discussion on NT -VS-
Linux w/ Perl... "Upgrade your employer!"









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

Date: Wed, 07 Jun 2000 14:10:24 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: perl Configure
Message-Id: <39455770.1621495@news.skynet.be>

www.hinet.net wrote:

>what is CWD?

Current Working Directory. "curdir" in VB lingo.

There's even a Perl module named after it.

	use Cwd; print cwd;

cwd is a function. It will return a string with the current working
directory.

-- 
	Bart.


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

Date: Wed, 07 Jun 2000 14:29:00 GMT
From: fiveyes@bellsouth.net (5-i's)
Subject: Re: Perl Crypt function
Message-Id: <394c51e1.155118881@news.msy.bellsouth.net>

On Wed, 07 Jun 2000 06:46:17 GMT, GuruMuhk <gurumuhk@my-deja.com>
wrote:

>Hi there,
>
>I just have a little question about crypt function,..
>
>while testing my login form which require a nickname/password,
>the password was encrypted using the crypt() function
>
>and for examples my password is
>$pass = 'thisismypass';
>$encryptedpass = 'Fd\.lfdkjdsf'; <- fake I came up with for examples..
>
>if ( crypt( $pass, $encryptedpass ) eq $encryptedpass )
>{
>      print "worked\n";
>}
>
>this works perfectly, but if I set $pass to
>'thisismypassANDTHISISIGNORED';
>
>this will also show as a valid password,
>and I also tried adding random chars at my linux login prompt and it
>also saw my password as valid even though I added extra chars after the
>password..
>
>so I was just wondering if this was normal or not, is it ?
>
In fact it's even _worse_ than that, you don't even need your 'pass'!
Try 'thisismy' and you're still going to get "worked".

Why?  Because when you map an infinite set (all possible strings of
characters of any length) onto a finite set (the 11 character group of
encrypted characters following the 2 character salt value), you are
going to get a bit of overlap somewhere along the way.  This is why
the crypt function is considered one-way, you can't derive the
encrypted string from the end result - both 'thisismy' and
'thisismypasswordinencryptedform' encrypt the same, as do an infinite
number of other strings.  Keep in mind that putting an infinite amount
of anything into a finite number of bins still fills each bin with an
infinite amount of stuff!

So, just as the first two characters of any string used as the salt
are the only ones that get used, anything after the first 8 characters
of the string being encrypted is ignored.  And we've just touched upon
why it's advisable to have a randomly generated 2 character salt.  If
a password list is obtained, it isn't obvious that two passwords will
encrypt the same (such as 'thisismy' and 'thisismypass' would) if
their salt seeds differ, making it necessary to crack each one
separately.


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

Date: Wed, 07 Jun 2000 14:35:43 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Perl Crypt function
Message-Id: <7ad7ltsgn3.fsf@merlin.hyperchip.com>


GuruMuhk <gurumuhk@my-deja.com> writes:

> and for examples my password is
> $pass = 'thisismypass';
> $encryptedpass = 'Fd\.lfdkjdsf'; <- fake I came up with for examples..
> 
> if ( crypt( $pass, $encryptedpass ) eq $encryptedpass )
> {
>       print "worked\n";
> }
> 
> this works perfectly, but if I set $pass to
> 'thisismypassANDTHISISIGNORED';
> 
> this will also show as a valid password,
> and I also tried adding random chars at my linux login prompt and it
> also saw my password as valid even though I added extra chars after the
> password..
> 
> so I was just wondering if this was normal or not, is it ?

Yes it is. crypt(), which is derived from the unix command of the same
name, only looks at the first 8 characters of your key. It takes the
lowest 7 bits of each of these characters to create a 56-bit key, which
is used to repeatedly encrypt a constant string (usually a string of
zeros). At the end, this results in an encrypted password of 13
characters, the first two of which are the specified salt.

--Ala


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

Date: Wed, 7 Jun 2000 09:01:06 -0400
From: "Steve Fulton" <cerberus40@hotmail.com>
Subject: Re: perlscript & wsh
Message-Id: <eavSldI0$GA.267@cppssbbsa04>

Script arguments are available through the Arguments property of the WScript
object. Whether or not these should be loaded into the @ARGV array when
PerlScript starts is something you could take up with ActiveState.

Here's a simple PerlScript that echoes the command line arguments:

  for ($i=0; $i<$WScript->Arguments->Count; $i++) {
    $WScript->echo ($WScript->Arguments($i));
  }

=-=-=
Steve
-=-=-

"mao" <phantomias@hotmail.com> wrote in message
news:393E1E60.352AD0F0@hotmail.com...
> hello,
>
> i've downloaded and installed the windows scripting host on my win95
> system and i registered my activeperl installation to work with the WSH.
>
> but wether i run it via "cscript test.plc foo bar" or "cscript test.plc
> /foo /bar", the @ARGV is always empty.
> do i need another array or even a function to get the parameters in my
> perl script?
> or is there another way to pass them to the script?
> i'v already spent hours for searching any helpful sourcecode or faq but
> i found no solution at all so i would appreciate any help.
>
> thanks,
> mao




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

Date: Wed, 07 Jun 2000 14:52:58 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Pseudo-hashes/OOP
Message-Id: <7aaegxsfuc.fsf@merlin.hyperchip.com>


Daniel Fisher <danielf@unc.edu> writes:

> I'm planning to make an OOP framework with the following features:
> 
> - I'm using a pseudo-hash to prevent autovivification.
> - AND -
> - I will only know the attributes' names in the object by way of a 
> config file.
> 
> My question is:
> Is it possible to -
> 1) parse the config file and get the attribute names into an array, 
> 2) and then put them into the 
> use fields (@array_of_attribute_names_from_the_just_parsed_config_file)
> 
> just before compile time (... say in a BEGIN {} )
> ?

Yes. Did you try it?
Basically, you do something like:

	BEGIN {
		open F, 'config' or die $!;
		chomp(my @array = <F>);
		close F;
		use fields @array;
	}

> My next question is:
> If this is possible, what kind of speed benefit will I see?

It depends on your program and the size of your hash, amongst other
(more controllable) things.

The best thing is to try and see.

Your main point seems to be that you want to prevent
autovivification. If this is true, then let me suggest that you look
into using tie() to control your hash. You can pass the config file as
one of the arguments to tie(), and then read this config file inside the
TIEHASH method of the module that implements the hash
functions. Whenever you attempt to set a key-value pair in the hash, you
can make your STORE method check first for the validity of the key.

If this suggestion sounds like chinese to you, then you'd better read
'perltie' (unless of course you speak chinese ;-)

--Ala


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

Date: Wed, 07 Jun 2000 13:50:11 GMT
From: Tzadik Vanderhoof <tzadikv@my-deja.com>
Subject: Re: Tr vs. tr !@#@!#$@#%
Message-Id: <8hljub$vad$1@nnrp1.deja.com>


> > > do you mean CGI.pm? it's already been done - just read the docs.
> > >
> > > if you don't read the docs, then who is to blame?
>
> > I've read the docs.  I'd appreciate if you'd clue me in on where in
the
> > docs it points out a way to solve this problem.
>
> it's the part of the CGI.pm docs that discusses the Tr() function.
> i thought that it woudl be obvious...
>
> --
> brian d foy

Although your response is (somewhat annoyingly) terse, I believe that
this is the section of the documentation that you're referring to:

------
Because of conflicts with built-in Perl functions, the following
functions begin with initial caps:

    Select
    Tr
    Link
    Delete
    Accept
    Sub
------

Yes, I agree with you that the documentation tells you that you need to
use "Tr" not "tr" because of a conflict with a built-in Perl function.
Yes, I'd read that documentation and I knew about that.  Are you
implying that this solves the problem I was complaining about?

That sounds similar to a serious design flaw I encountered in the old
TI-99/4A computer some 15 years ago.  That computer (believe it or not)
had a way of erasing all memory with one keystroke... a keystroke that
was very similar to another keystroke that was very commonly used in
regular programming.  Would you say that that computer had no design
flaw since the documentation clearly stated that the keystroke in
question would erase all memory?

Getting back to Perl, what I'm referring to is a programmer
*mistake*... that is, *accidentally* typing "tr" instead of "Tr", which
I hope you'd admit, is quite feasible for an imperfect person to do.
The problem is that the error message that Perl gives you has no
relation to the actual error and actually points you to a completely
different line in the program than the one on which the error ocurred.
This causes a great deal of frustration and wasted effort tracking down
the real error.  This is a problem.  The documentation does not solve
this problem.


--

Tzadik


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


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

Date: Wed, 07 Jun 2000 13:56:44 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: using 'exists' in a program to test for keys in a hash
Message-Id: <39435392.631857@news.skynet.be>

Anno Siegel wrote:

>>This effectively says that the way you access %hash is governed by 
>>functions defined in SDBM_File.pm. Specifically, in your case, if you 
>>try to use exists() on a hash entry, Perl will go and find the EXISTS 
>>method in SDBM_File and execute it, instead of executing the built-in 
>>exists() function. Apparently, this method is missing for some reason.
>
>...the reason being that the underlying database mechanism doesn't
>support entries of just a key with no value.  This is true for all of
>the databases supported by perl.  The closest you get is a key with an
>empty string for a value, so there is no difference between exists()
>and defined().  Implementors have variously decided to provide exists()
>as an alias for defined() or not.

This is nonsense.

Isn't it obvious that you should be able to test if a key is in a
database at all? After all, that is what exists() is for? exists returns
false iff key not found.

-- 
	Bart.


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

Date: Wed, 7 Jun 2000 08:24:53 -0400
From: "Zowwie" <apage.net[remove]@usa.net>
Subject: Re: Using PERL to login to Novell?
Message-Id: <sjsjhlmg2t523@corp.supernews.com>

What OS?


"Terence McAndrew" <t.j.mcandrew@leeds.ac.uk> wrote in message
news:393D7BB0.D61C0AB8@leeds.ac.uk...
> How can I use PERL to execute a login to Novell (both 5 and 3.12) ?
>




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

Date: Wed, 07 Jun 2000 13:30:03 GMT
From: Mike <Michael.Bukowski@usa.xerox.com>
Subject: Re: Using Unix SOURCE in PERL SYSTEM?? NEED HELP
Message-Id: <sjsjirj62t5124@corp.supernews.com>


Phil Eschallier wrote:
> 
> >>>>> "Mike" == Mike  <Michael.Bukowski@usa.xerox.com> writes:
> 
>     > I am writing a Perl script that must run a shell script in the
>     > middle of the process. The command that is used to run the
>     > script from the commandprompt is:
> 
>     > source systembuild
> 
>     > The command that I have been using is Perl is:
> 
>     > system("source systembuild");
> 
>     > The command does not seem to do anything at all. I have also
>     > tried to execute this using back ticks and exec. Nothing seems
>     > to work. Does anyone know if there is something special that
>     > needs to be done in order to use the Unix SOURCE command inside
>     > the system() funcion???
> 
>     > Thanks, Mike
> 
> 
>     > -- Posted via CNET Help.com http://www.help.com/
> 
> Mike;
> 
> I believe that you'll find that 'source' is /bin/csh builtin, not a
> UNIX binary.  I think you'll also find that the perl5 system command
> is spawning a /bin/sh session (vs. your expected /bin/csh).
> 
> Assuming that I've assessed your post properly, this would explain why
> you are experiencing the errors you've reported.  However, this
> explain does not address semantics ... specifically, from my
> experience, the common use for 'source' under /bin/csh to to affect
> the current environment.  Are you trying to set environment variables
> for use within your perl5 program?  If so, you don't want to use
> system() as that spawns a sub-shell ...
> 
> Please post more on your actual goals if this discuss needs to go
> further.
> 
> Best of luck ...
> 
> -- 
> Phil Eschallier        | Bux Technical Services | Systems, software,
>  inet phil@BuxTech.Com | 131 Wells Road         | security and Inter-
>   tel 215 348 9721     | Doylestown, PA  18901  | networking for your
>   fax 215 230 8265     | http://www.BuxTech.Com | business!
> KeyID D6E9B193


Yeah.. The shell script that I am trying to run sets up a bunch of 
environment variables that are used here. I need to use those variables in 
my Perl script. There have been people around here that have tried to 
convert the systembuild (shell script) into Perl but have had no success. 
I would like to be able to run the script and then be able to use the 
variables within the current Perl process. Is there a way I can run the 
script so that is sets the environment variables for more than the current 
perl processs? My script spawns other scripts as It goes along which may 
need to use the variables in the future. I hope this makes a little more 
sense. Thanks for the help.

Mike



--
Posted via CNET Help.com
http://www.help.com/


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

Date: Wed, 07 Jun 2000 13:30:04 GMT
From: Mike <Michael.Bukowski@usa.xerox.com>
Subject: Re: Using Unix SOURCE in PERL SYSTEM?? NEED HELP
Message-Id: <sjsjis2d2t583@corp.supernews.com>


Abigail wrote:
> 
> 
> On Tue, 06 Jun 2000 22:30:24 GMT, Mike <Michael.Bukowski@usa.xerox.com> 
wrote:
> ++ I am writing a Perl script that must run a shell script in the middle 
of 
> ++ the process. The command that is used to run the script from the 
> ++ commandprompt is:
> ++ 
> ++ source systembuild
> ++ 
> ++ The command that I have been using is Perl is:
> ++ 
> ++ system("source systembuild");
> ++ 
> ++ The command does not seem to do anything at all. I have also tried to 
> ++ execute this using back ticks and exec. Nothing seems to work. Does 
anyone 
> ++ know if there is something special that needs to be done in order to 
use 
> ++ the Unix SOURCE command inside the system() funcion???
> 
> 
> *IF* there was a "unix" source command, system() would work.
> However, there isn't.
> 
> Did you try to do "man source" or "which source"? The results might be
> enlightning. BTW, this question was asked and discussed only a few
> days ago as well.
> 
> 
> Abigail

To respond to your statement I have posted the output from the 
command "man source".

{mbukowsk} fidelity: /home/mbukowsk [1] man source
Reformatting page.  Wait... done

User Commands                                             exec(1)

NAME
     exec, eval, source - shell  built-in  functions  to  execute
     other commands

SYNOPSIS
  sh
     exec [ argument...  ]
     eval [ argument...  ]

  csh
     exec command
     eval argument...
     source [ -h ] name

  ksh
     * exec [ arg ... ]
     * eval [ arg ... ]

DESCRIPTION
--More--
(12%)                                                                  

--
Posted via CNET Help.com
http://www.help.com/


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

Date: 07 Jun 2000 08:35:14 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Using Unix SOURCE in PERL SYSTEM?? NEED HELP
Message-Id: <871z294nsd.fsf@limey.hpcc.uh.edu>

>> On Wed, 07 Jun 2000 13:30:04 GMT,
>> Mike <Michael.Bukowski@usa.xerox.com> said:

>> Abigail wrote:

>> Did you try to do "man source" or "which source"? The
>> results might be enlightning. BTW, this question was
>> asked and discussed only a few days ago as well.

> To respond to your statement I have posted the output
> from the command "man source".

> NAME exec, eval, source - shell built-in functions to

namely ...                  ^^^^^^^^^^^^^^

i.e. source is part of the shell, not a runnable command.

One way of doing this is to wrap the perl inside a shell
script which sources the required setup file, and then
exec's the perl program, but as Abigail said, this has
been done to death yet agin recently.

hth
t
-- 
"Trying is the first step towards failure"
                                           Homer Simpson


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

Date: Tue, 6 Jun 2000 12:08:54 +0200
From: =?ISO-8859-2?Q?Petr_Sezemsk=FD?= <sezemsky@dcse.fee.vutbr.cz>
Subject: why overvrite list
Message-Id: <Pine.BSF.4.21.0006061113530.38593-100000@kazi.dcse.fee.vutbr.cz>


I have found some queer behavior.

Let imagine that we have three files called a, b and c in current
directory. In the perl script we have their names in the list @files.

The problem is that during while (<PO>) loop the entries of
@files array are overwritten. I don't know why. If I use any
different while condition the behavior is correct.

Any idea?
Thank you.

I'm using version 5.005_03 built for i586-linux on Debian GNU Linux 2.1

The code is:

#!/usr/bin/perl
@files = ("a", "b", "c");
foreach (@files) {
  open(PO, $_) or die "Error:";
  for($i=0; $i<=$#files; $i++) { print "1:$i:$files[$i]\n"; }
  while (<PO>) {
#    for($i=0; $i<=$#files; $i++) { print "2:$i:$files[$i]\n"; }
  }
  for($i=0; $i<=$#files; $i++) { print "3:$i:$files[$i]\n"; }
  close(PO);
}




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

Date: Wed, 07 Jun 2000 14:50:58 GMT
From: garcia_suarez@hotmail.com (Rafael Garcia-Suarez)
Subject: Re: why overvrite list
Message-Id: <slrn8jsohg.alo.garcia_suarez@rafael.kazibao.net>

Petr Sezemský wrote in comp.lang.perl.misc:
>
>I have found some queer behavior.
>
>Let imagine that we have three files called a, b and c in current
>directory. In the perl script we have their names in the list @files.
>
>The problem is that during while (<PO>) loop the entries of
>@files array are overwritten. I don't know why. If I use any
>different while condition the behavior is correct.
>
>Any idea?
>Thank you.
>
>I'm using version 5.005_03 built for i586-linux on Debian GNU Linux 2.1
>
>The code is:
>
>#!/usr/bin/perl
>@files = ("a", "b", "c");
>foreach (@files) {
>  open(PO, $_) or die "Error:";
>  for($i=0; $i<=$#files; $i++) { print "1:$i:$files[$i]\n"; }
>  while (<PO>) {
>#    for($i=0; $i<=$#files; $i++) { print "2:$i:$files[$i]\n"; }
>  }
>  for($i=0; $i<=$#files; $i++) { print "3:$i:$files[$i]\n"; }
>  close(PO);
>}

This is because $_ is aliased to the elements of @files and it is
modified by the inner while loop.

This can be fixed (for example) by localizing $_:
  {
    local $_;
    while (<PO>) {
      ...
    }
  }

See the perlsyn manpage for the gory details about foreach.

-- 
Rafael Garcia-Suarez


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

Date: Wed, 07 Jun 2000 13:41:45 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: win32: How do i build gui app
Message-Id: <MPG.13a8ee42bc739479989712@news>

mmfiber@my-deja.com writes ..
>I'm looking to build a gui app around my perl script on Win NT.  Which
>tools make sense and if you have a preference let me know which is your
>favorite.

NT or not - use Tk .. O'Reilly has some good books on it too if you 
can't find your way through the large volume of online documentation

-- 
 jason - elephant@squirrelgroup.com -


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 3276
**************************************


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