[11577] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5177 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 19 11:07:28 1999

Date: Fri, 19 Mar 99 08:00:21 -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           Fri, 19 Mar 1999     Volume: 8 Number: 5177

Today's topics:
    Re: 8.3 problem / win32 perl pl2bat rupert@no.spam.leeds.ac.uk
        about Date:Calc  <erpeng@cs.auc.dk>
        Bug with s/$pat/$sub/ (or not?) (Olaf Seibert)
        Can you store %hashes in a DBM file (Robert Alatalo)
    Re: Complex Structure Question (Larry Rosler)
    Re: Crypt problems <seannln@bit-net.com>
    Re: Help please....... <alex@kawo2.rwth-aachen.de>
    Re: How to connect to a SQL Server database ? (Dan Wilga)
    Re: How to connect to a SQL Server database ? (Dan Wilga)
    Re: How to let users of website know there are others p <seannln@bit-net.com>
    Re: Login, redirect, and who is the user? (Todd P.)
    Re: My hash and subroutine aren't getting along (Tad McClellan)
        Need help installing Perl modules w/o Makefile.PL melLA@west.net
        Newbie: DBI | DBD:ODBC <bill@yoder.org>
    Re: parse exception with avtivestateperl 509 (Bbirthisel)
    Re: Perl - "Command not found" <terrym@bridgewatersys.com>
    Re: Perl - "Command not found" (Andrew M. Langmead)
    Re: Perl scripts written for UNIX. Will they work on NT (Larry Rosler)
    Re: rand() Performance (Andrew M. Langmead)
    Re: Random for Hash (Larry Rosler)
    Re: Reading a file (Larry Rosler)
        script :file ownership  <gary.french@netzero.com>
    Re: Sorting with Perl (Larry Rosler)
        Subset Question <gwynne@utkux.utk.edu>
    Re: Testing if variable contains a certain word..... (Sami Rosenblad)
    Re: Web Databases als@signalinteractive.com
    Re: Win32 Perl and DOS-style interrupts (Bbirthisel)
    Re: Windows NT Path Resolution <crowe@darkspiral.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 19 Mar 1999 14:58:49 +0000 (GMT)
From: rupert@no.spam.leeds.ac.uk
Subject: Re: 8.3 problem / win32 perl pl2bat
Message-Id: <36F2D8E9.3B0F@no.spam>

> the problem is that the path info on the file that perl 'recieves' is
> 8.3 (in other words /interf~1/blahbl~1/...).  My local machine as well
> as the target machine both run the newest versions of dos and don't 
> normally constrain me to 8.3 directory names.  Is it the fact that 
> i'm running it as a batch file?  why is this happening?  anyone know 
> a work-around???

Please don't take this as an endorsement for NT.

That various operating systems differ in what they regard as
good filenames is one of the more obvious problems when writing
cross-platform scripts or tools.

I think that you need to get access to the way that your OS
encodes the real name into the short name that the directory
structure understands. Maybe NT has a means to do this for
you. There are numerous NT FAQ sheets on the web. If not, you
will perhaps have to roll your own. Maybe the Microsoft
documentation will help you.

One alternative, which I have used successfully is to encode
the files, the filenames, and the directory structure in a
tar or ZIP file, whose name can be expressed in those characters
which the OSes can handle correctly, you can then untar or unzip
at your end and re-gain the correct names.

Ben.


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

Date: Fri, 19 Mar 1999 14:54:22 GMT
From: Chen Li <erpeng@cs.auc.dk>
Subject: about Date:Calc 
Message-Id: <36F264F8.3D1E8DD6@cs.auc.dk>

Hello,

I want to generate some data in a certain period, for example: from
01/01/98 to 01/01/99, two tuples every seconds, how to do this using
Date:Calc? Could anybody help?
Thanks in advance.


Regards,
Chen Li



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

Date: 19 Mar 1999 14:39:27 GMT
From: rhialto@polder.ubc.kun.nl (Olaf Seibert)
Subject: Bug with s/$pat/$sub/ (or not?)
Message-Id: <7ctniv$8gt$1@wnnews.sci.kun.nl>

#!/usr/bin/env perl

package bug;

=head1 DESCRIPTION

A coworker came to me with a question on perl about something he was
doing with regular expressions. He was doing a substitute command with a
variable pattern and a variable substitution. In the substitution, he
wanted to refer to subexpressions from the pattern, and it didn't work.
Sure enough, the same pattern and substitution work if hardcoded into
the script. This looks like a bug. Is there a workaround?

Demonstration:

=cut

# Demonstration of bug (or at least unexpected result)

use strict;
my $line0 = 'AA';

# This does not work, using expressions for pattern and substitution:
my $pat = '(A)';
my $sub = '-\1-';
my $line = $line0;
$line =~ s/$pat/$sub/g;
print "line = $line\n";

# This does work, using hardcoded pattern and substitution:
$line = $line0;
$line =~ s/(A)/-\1-/g;
print "line = $line\n";

__END__

-Olaf.
--
___ Olaf 'Rhialto' Seibert - rhialto@polder.ubc. ---- Unauthorized duplication,
\X/ .kun.nl ---- while sometimes necessary, is never as good as the real thing. 


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

Date: Fri, 19 Mar 1999 06:53:39 -0800
From: mirror@ziplink.net (Robert Alatalo)
Subject: Can you store %hashes in a DBM file
Message-Id: <OxtI2.12033$EF1.53825338@WReNphoon1>

Hello,

        I am trying to store a hash within a hash which is tied to a DBM
file.  I think the problem is that the DBM file stores a pointer to the
inner hash, which works while the script is executing.  The problem that
I am having is that once the program stops and restartes it links again
to the DBM file and pulls out the address of the inner hash but the inner
hash was stored in memory and doesn't exist anymore.

        What I wonder is if anyone knows a way to store the contents
of the inner hash in the DBM file, so when the program stops and restarts
I can query the inner hashes for values stored in it. If this isn't possible
then suggestions on how I can store multiple values associated with a single
key in a hash would be appresiated.  I need to be able to lookup values
quickly
rather than searching though a text file because of the number of lookups
and
size of the table.  I am hoping someone has a suggestion.


-Robert


#!/usr/local/bin/perl5
use DB_File;
$TEST_FILE = "test_test" ;
$DEBUG = 1 ;
if ( $#ARGV < 0 ) {
        die "Need atleast one item for a key\n" ;
}
$KEY = shift ( @ARGV );
#####################
$test= tie %TEST, "DB_File" , $TEST_FILE ,  O_CREAT|O_RDWR , 0600 , $DB_HASH
or die ("Can\'t create or open $TEST_FILE as DB_HASH\n") ;

print"Current key is \'$KEY\'\n\n" ;
&display ( $KEY );
print "\n\nChanging/Adding the follow:\n\n" ;

while ($#ARGV > 0 ) {
        $SKEY = shift ( @ARGV );
        $SVALUE = shift ( @ARGV );
        &add_key ( $KEY , $SKEY , $SVALUE );
}
if ( $#ARGV == 0 ) {
        $SKEY = shift ( @ARGV );
        &del_key ( $KEY , $SKEY );
}
print "\n\nPrinting out final result\n\n" ;
&display ( $KEY );

## Added only as part of my debugging
print "debug\n" ;
foreach $BUNK ( keys %TEST ) {
print "debug:\'$BUNK\'->\'$TEST{$BUNK}\'\n";
        foreach $BUNK1 ( keys %$BUNK ) {
                print "skeys: $BUNK1 \n";
        }
}


untie %TEST ;
print "\n\n" ;

###########################
sub display {
my ( $key ) = shift ( @_ );
my ( $subkey ) ;
foreach $subkey ( sort keys( %{$TEST{$key}} ) ) {
        print "\'$subkey\' -> \'$TEST{$key}{$subkey}\'\n";
} # end of foreach loop
} # end of display subroutine

sub del_key {
my ( $key ) = shift ( @_ );
my ( $subkey ) = shift ( @_ ) ;
print "del_key: removing \'$subkey\' from \'$key\' \n" if $DEBUG ;
$TEST{$key}{$subkey} = '';
} # end of del_key subroutine

sub add_key {
my ( $key ) = shift ( @_ );
my ( $subkey ) = shift ( @_ );
my ( $sub_value ) = shift ( @_ );
print "add_key: adding \'$subkey\' with \'$sub_value\' to \'$key\' \n" if
$DEBUG ;
$TEST{$key}{$subkey} = $sub_value;
}



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


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

Date: Tue, 16 Mar 1999 11:18:16 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Complex Structure Question
Message-Id: <MPG.11584e4f8139b294989761@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <x3yiuc18kt4.fsf@tigre.matrox.com> on Tue, 16 Mar 1999 
11:24:08 -0500, Ala Qumsieh <aqumsieh@matrox.com> says...
 ...
> Anyway, any good programmer should be using
> 'strict' (at least in development stages), so it shouldn't be a
> problem.

Any good programmer should be using 'strict' at all times.  Some people 
object to using '-w' on production code, for fear that future versions 
of perl may introduce warnings where there were none previously.  But 
'use strict;' cannot change, so why not keep it in forever?

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


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

Date: Fri, 19 Mar 1999 08:56:18 -0500
From: Sean Phillips <seannln@bit-net.com>
To: dccobb@yahoo.com
Subject: Re: Crypt problems
Message-Id: <36F25782.E2B6EFE7@bit-net.com>

You should not have to be root in order to use htpasswd...   unless tou
are using it on /etc/passwd.   In fact, I have written CGI which allows
the user (actually the web server account) to interact with htpasswd.
If you are using /etc/passwd you are creating yourself a real security
risk...

- Sean

dccobb@yahoo.com wrote:

> Problem: I have installed an apache server on top of an existing
> apache
> server, however as I am not root user I cannot use the htpasswd
> program to
> create passwords for users.
>
> Am I right in saying that Apache uses "Cd" as its encrytion key (salt)
> or does
> it use a random key?
>
> As I cannot use htpasswd I have created a Perl program which uses
> crypt()
> will this do the same job as htpasswd?
>
> Any help is much appreciated, Dave
>
> "Everything should be as simple as possible, but no simpler",
> Albert Einstein.
>
> -----------== Posted via Deja News, The Discussion Network
> ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your
> Own





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

Date: Fri, 19 Mar 1999 15:55:29 -0500
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: MW <oursDELETE-THIS@casema.net>
Subject: Re: Help please.......
Message-Id: <36F2B9C1.824A133B@kawo2.rwth-aachen.de>

MW wrote:
> How can I test if a variable contains a certain word?
> I want to test $ENV{'HTTP_ACCEPT_LANGUAGE'} for   'nl'
> to redirect people to other pages.

if ($ENV{HTTP_ACCEPT_LANGUAGE} =~ /nl/i)  # case insensitive
{
    print .........
}

/Alex

--
http://www.simplex.ru/pref.html


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

Date: Fri, 19 Mar 1999 10:46:40 -0500
From: dwilgaREMOVE@mtholyoke.edu (Dan Wilga)
Subject: Re: How to connect to a SQL Server database ?
Message-Id: <dwilgaREMOVE-1903991046400001@wilga.mtholyoke.edu>

In article <36F23D17.1B60112B@pacific.net.sg>, Simon Ng
<simon_ng@pacific.net.sg> wrote:

> Hi how to connect to a SQL Server database using ODBC.

Try DBI::ODBC. You can get it from CPAN.

Dan Wilga          dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply  **


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

Date: Fri, 19 Mar 1999 10:48:02 -0500
From: dwilgaREMOVE@mtholyoke.edu (Dan Wilga)
Subject: Re: How to connect to a SQL Server database ?
Message-Id: <dwilgaREMOVE-1903991048020001@wilga.mtholyoke.edu>

In article <36F23D17.1B60112B@pacific.net.sg>, Simon Ng
<simon_ng@pacific.net.sg> wrote:

> Hi how to connect to a SQL Server database using ODBC.

Woops. In my previous post, I meant you should try the combination of DBI
and DBD::ODBC, both available from CPAN.

Dan Wilga          dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply  **


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

Date: Fri, 19 Mar 1999 08:58:21 -0500
From: Sean Phillips <seannln@bit-net.com>
To: Steve miles <smiles@wfubmc.edu>
Subject: Re: How to let users of website know there are others present
Message-Id: <36F257FD.74BC40F2@bit-net.com>

or look through the web logs for the same information, taking only the
ip's from requests that occurred in the last n minutes...

- Sean

Steve miles wrote:

> > im looking for a way to let visitors of my site know if there are
> others at
> > the time.
>
> Why not have a script that runs via SSI that puts the users IP address
> into a
> file for 5 minutes. If they load any page with the SSI the IP stays
> again for
> another 5 minutes. Everytime the script is run it checks for stale IPs
> and
> removes them. So, then with another SSI you have a script that says
> how many
> IPs are in the database at any given moment. May get slow if you have
> a ton of
> users!
>
> Steve Miles
> nsurfer@bellsouth.net





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

Date: Fri, 19 Mar 1999 08:05:36 -0600
From: email@domain.com (Todd P.)
Subject: Re: Login, redirect, and who is the user?
Message-Id: <email-1903990818360001@the-cure.adtran.com>

I can get REMOTE_HOST and REMOTE_ADDR and other variables. But the other
ones will not....

In article <36F00659.8C25AA0F@genesis.co.nz>, Meh <aghaeim@genesis.co.nz> wrote:

> "Todd P." wrote:
> > 
> > Im trying to get the user login information from Netscape Enterprise
> > server 3.5.1. What I would like to do is, after the person logs in, they
> > will be redirected to an specific area for them. I have tried the
> > environment variables remote_user, auth_type, and remote_ident, but I get
> > nothing. I have set the restriced areas up with the admin server that
> > comes with netscape....
> > 
> > Is there something that I am missing, do I need to set somthing up on the
> > server?
> > 
> > Pleas help...
> > 
> > Todd
> 
> -- 
> I you can't get REMOTE_HOST  and  REMOTE_ADDR, you may need look at your
> server.
> 
> eg. my $remoteHost = $ENV{"REMOTE_HOST"};
> ---------------------------------------------------------------------
> Protect privacy, boycott Intel PIII: http://www.bigbrotherinside.org
> ---------------------------------------------------------------------


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

Date: Thu, 18 Mar 1999 18:14:22 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: My hash and subroutine aren't getting along
Message-Id: <ec1sc7.ml.ln@magna.metronet.com>

Steve Kohrs (skohrs@homee.com) wrote:
: I'm having a problem using a hash in a subroutine. 

[snip]

:   foreach (@keyWords) {
:     printf $filehandle ("%8d%8.2f\t%s\n", %$hashReference{$_},
                                            ^
                                            ^
: (%$hashReference{$_}/$totalcount),  $_);
:   }
: }

: The errors I'm receiving are, "Can't use subscript on hash deref at
: logprocess.pl line 102, near "$_}"
: (Did you mean $ or @ instead of %?)" .  The printf is in line 102.  If I
: drop the '%' I get "Global symbol requires explicit package" errors.


   But you didn't try what the error message suggested.

   Use $ instead of % since you are accessing a scalar rather
   that an entire hash.


: If I code the printf outside the subroutine it works just fine.


   That is strange...


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 19 Mar 1999 14:50:27 GMT
From: melLA@west.net
Subject: Need help installing Perl modules w/o Makefile.PL
Message-Id: <36f2600e.4792008@news.west.net>

I'm trying to install the Perl DBI module but cannot get Makefile.PL
to work on my ISP's system. (currently using perl500402), so I need
guidance on how to install those modules manually.

My method of attack after WinZipping the archive is to upload the
files in the same directory structure as the archive, and then insert
the appropriate directory path at the top of the module.

For CGI.pm I inserted the path as:

use lib '/home/users/.../.../cgi-bin/lib';

Other directories include:

/home/users/.../.../cgi-bin/lib/CGI (contains Carp.pm, Cookie.pm, etc)
/home/users/.../.../cgi-bin/lib/examples (contains cookie.cgi)
/home/users/.../.../cgi-bin/lib/t

And many of the test modules worked. I then tried to install DBI as:

use lib '/home/users/.../.../cgi-bin/DBI';

But I get an error when I try to run test.pl (part of the DBI archive)

DBI test application $Revision: 10.2 $
Can't locate blib.pm in @INC at (eval 1) line 1.
Can't find loadable object for module DBI in @INC
(/usr/local/lib/perl5/sun4-sol
aris/5.003 /usr/local/lib/perl5
/usr/local/lib/perl5/site_perl/sun4-solaris /usr
/local/lib/perl5/site_perl /usr/local/lib/perl5/sun4-solaris .) at
DBI.pm line 1
67
BEGIN failed--compilation aborted at DBI.pm line 168.
BEGIN failed--compilation aborted at test.pl line 23.

("use DBI" is the statement located at line 23)

DBI.pm at line 168 says that the error is due to incorrect
installation.

How should I manually install CGI.pm and DBI.pm so that they share
directories and can "talk" to each other if necessary?

Thanks,
Milt

(remove all CAPS from my e-addr)

x-no-archive: yes




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

Date: Thu, 18 Mar 1999 07:38:42 -0500
From: "Bill Yoder" <bill@yoder.org>
Subject: Newbie: DBI | DBD:ODBC
Message-Id: <7cr8r5$15ab@enews1.newsguy.com>

I'm getting an error when attemptnig to connect to an Access DB. Does anyone
know what might cause this. I'm pretty sure it's a configuration issue, but
I don't know how I could have messed up. I used the perl package manager to
install DBI, DBD-ODBC, and Getopt-Long, in that order(I tried first without
GetOpt-Long, and then with; same results).

Here's the error:

>"DBI::db=HASH(0xdd13b4)" is not exported by the DBI module at
D:\Perl\Wig\MyPerl
>\DBTest.pl line 3
>Can't continue after import errors at D:\Perl\Wig\MyPerl\DBTest.pl line 3
>BEGIN failed--compilation aborted at D:\Perl\Wig\MyPerl\DBTest.pl line 3.

Here is the source:

>use DBI
>
$dbh = DBI->connect( 'DBI:ODBC:ACCESS', '', '');
>
>$SQL = "SELECT FNAME FROM CONTACTS;"
>$dbh->do($SQL);
>$sth = $dbh->prepare($SQL);
>$sth->execute();
>while (@row = $sth->fetchrow_array)
>{
>    print $row(0);
>}
>
>$sth->finish();
>$dbh->disconnect();


Thanks in advance for any clues,
Bill Yoder






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

Date: 19 Mar 1999 14:17:37 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: parse exception with avtivestateperl 509
Message-Id: <19990319091737.15304.00000426@ng-fq1.aol.com>

Hi Uwe:

>I changed from another distribution to the recent ActiveState Perl 509.
>I install it on a NT-Server and share the perl-directory for the
>clients, which map the share as drive x: With the former distribution,
>eaach workstation could execute perl scripts from x:\bin\ Now I get
>"Error: Parse exception" even when I just try to run "perl -V" (but
>"perl -v" works). I already set the env var PERLLIB and set the same
>registry key as on the server, but this changes nothing.

This problem is periodically reported on Win32-Users. The
most common situation is "leftover" pieces of your earlier
distribution in either the default PATH or one of the lib
directories. Second is trying to use the wrong binary pieces
of a locally installed module (most modules must be reinstalled
when going to 5.005 from an earlier release).

Unfortunately, the "safe" way to fix this is to uninstall all traces
any perl distribution - then reinstall just the 509 build and the
modules you need. A number of us with "early" versions of
the Win32 PRK ended up taking an approach like this when
moving to the 509 build (SP1). It's severe, but it works and is
quicker than "piecemeal debugging".

-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)


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

Date: Fri, 19 Mar 1999 09:28:50 -0500
From: terrym <terrym@bridgewatersys.com>
Subject: Re: Perl - "Command not found"
Message-Id: <36F25F22.A7B075D6@bridgewatersys.com>

Jay,

I've got it.

The problem was that the first line of the script ended in
carriage return plus line feed.

Once I ran 'od' on both the perldoc script and the bad script,
the difference was obvious. Carriage returns (\r) in the bad script
but none in the perldoc script. Ran the script through 'tr' to clean
up the carriage returns.

Thanks for your help!

Terry

Jay Glascoe wrote:
> 
> [posted and mailed]
> 
> terrym wrote:
> >
> > The error messages are:
> >
> >   "Command not found"
> >   "print: Command not found"
> 
> did you "chmod +x" the script?
> 
>         Jay Glascoe
> --
> MSDOS was created to keep idiots away from Unix
>   --anon.


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

Date: Fri, 19 Mar 1999 15:40:10 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Perl - "Command not found"
Message-Id: <F8uM6y.IG1@world.std.com>

terrym <terrym@bridgewatersys.com> writes:

>The error messages are:

>  "Command not found"
>  "print: Command not found"

>Perl does exist in /usr/bin/perl and it does work.

According to the perldiag man page, that command is not a perl
diagnostic but rather one that is emitted from csh. So somehow the
system seems to be trying to run your script with the csh instead of
perl.

My guess that the script that you gave was retyped into your article
(not pasted or inserted with your text editor) and does not contain
the typo in the original. Either that or you have a blank line above
the line that has the "#!" magic cookie. (The sequence "#!" must be
the first two characters of the file for the system to recognize it as
a script that you want to specify the interpreter. If the system
doesn't see that sequence, and it doesn't see the markings that say
that it is a binary executable, it assumes that it is a shell script.)

Since it is saying "print: Command not found.", that indicates that
permissions *are* set correctly, (despite what other posters have
suggested. The error you are getting proves that something is trying
to execute the contents of the script.) and there is no reason to
think that the perl interpreter is missing or mislocated (despite what
other posters have suggested. If the system was correctly trying
finding which program you wanted to interpret the script, but couldn't
find it, you would get "No such file or directory" message.)


-- 
Andrew Langmead


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

Date: Tue, 16 Mar 1999 12:43:36 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl scripts written for UNIX. Will they work on NT?
Message-Id: <MPG.1158625692c24991989764@nntp.hpl.hp.com>

In article <7cjpdp$ojn@world6.bellatlantic.net> on Mon, 15 Mar 99 
19:05:11 GMT, ICG's opinionated tripe <postmaster@uu.net> says...
+ In article <920998806.27852.0.nnrp-11.c1ed40e5@news.demon.co.uk>, 
"Chris" <chris.ball@spsg.org> wrote:
+ >Can you help?  We are about to move our web site from a UNIX server
+ >to one running Windows NT 4.0.  Does anyone know if we will encounter
+ >any problems with our Perl scripts when we move them over? (these are
+ >currently used to accomplish tasks such as; Logging information,
+ >updating pages, and managing a chat room).
+ >
+ >also,
+ >
+ >If their is going to be a problem with compatibility, then will the
+ >perl scripts need significant alterations, or is as simple as
+ >changing the file names/references?
+ >
+ >I would really appreciate any help regarding this problem.
+ 
+ Not any help, but a lot of opinion.  We made this same shift two years 
+ ago.  We run a win32 port of Perl, and I will not touch it.  The other
+ sysops use it, but I insisted on keeping a Linux box on the network 
+ just so I could script in Perl's natural environment.  There are a few 
+ things that you couldn't do in the NT version of perl that I could 
+ knock out with a single system call in Linux's Perl.  I'm sure the 
+ newer versions of windows Perl have probably taken care of most of 
+ them.  Now, 2 years later, our most powerful scripts run under Linux
+ Perl.  (Forms and Mailback routines, Port monitors, 
+ SNMP query and graphing, User status.  All using TCP/IP/SNMP calls to
+ the different machines in the network, and no clunky NT port of cron
+ needed!)  The only thing we have in the Win32 version is a page
+ counter.  
+ 
+ Just my opinion. 

I seldom resort to this form of dialogue, but your opinion is indeed a 
load of tripe, as you say in your pseudo-address.

s/\b(?:[Pp]erl)\b/C/g in your paragraph, and you get the same degree of 
truth value -- none.  Unix is C's "natural environment" to the same (or 
an even greater) degree that it is Perl's "natural environment".  That 
has not inhibited the standardization and proliferation of C to dozens 
(hundreds by now?) of disparate operating environments.

All you are really saying is that programs that rely on Unix-specific 
commands or system calls run better on Unix-derived systems.  D'uh.  
This has nothing *whatever* to do with the language from which the
commands or system calls are invoked.

Please don't let your negative feelings about 90% or more of the systems 
run on computers today overflow into disparaging Perl.  We should all 
want Perl to be as successful and productive on those systems as C has 
become.

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


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

Date: Fri, 19 Mar 1999 15:21:34 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: rand() Performance
Message-Id: <F8uLBy.3pv@world.std.com>

"William H. Asquith" <asquith@macconnect.com> writes:

>Can I
>use the rand() function and be assured that for simulations
>lengths (calls to rand()) on the order of 10**6 and statistically
>independent?

The rand() function gets its data from the C library that it was
compiled with. This means that its randomness is not guaranteed, and
anecdotal evidence seems to indicate that it will be rather
poor. (There has been a couple of articles in the magazine "The Perl
Journal" <URL:http://www.tpj.com/tpj/contents> about random number
generators. I think that one had a comparison for different
platforms.)

I haven't used it, but you might want to look into the
Math::TrulyRandom module on CPAN. 
<URL:http://reference.perl.com/module.cgi?Math::TrulyRandom>
-- 
Andrew Langmead


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

Date: Tue, 16 Mar 1999 13:00:33 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Random for Hash
Message-Id: <MPG.11586649d4a2cf09989765@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7cmerf$skr$5@bison.rosnet.ru> on Tue, 16 Mar 1999 22:45:13 
+0300, Michael Yevdokimov <flanker@sonnet.ru> says...
> %Datas = ('0' => 'aaa'
>           '3' => 'bbb'
>           '4' => 'ccc'
>           '6' => 'ddd'
>          '10' => 'eee');

You need commas on each of those first four lines!
 
> How to generate a random number which will be one of the listed keys in
> hash? I.e. I need to choose a string value from hash by random method but
> the generated key must be equal to one of the listed hash keys!

  my @keys = keys %Datas;
  print $Datas{$keys[rand @keys]}, "\n";

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


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

Date: Tue, 16 Mar 1999 11:28:38 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Reading a file
Message-Id: <MPG.115850c48374ec4f989762@nntp.hpl.hp.com>

In article <7cluqj$aaj$1@nnrp1.dejanews.com> on Tue, 16 Mar 1999 
15:54:01 GMT, JAG <greenej@my-dejanews.com> says...
 ...
> If you are outputing text to a web browser, you have to tell it what you are
> sending it, e.g.
> 
> print "Content-type: text/http\n\n";

I've never hear of that MIME type.  I think you mean 'text/html'.

> print "<body><pre>\n";

And that looks like HTML, but of course it isn't complete.  Why not use 
MIME type 'text/plain'  and be done with all the formatting stuff?

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


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

Date: Fri, 19 Mar 1999 15:56:06 GMT
From: "garyfrench" <gary.french@netzero.com>
Subject: script :file ownership 
Message-Id: <qsuI2.3898$2G6.1585@c01read02.service.talkway.com>

Looking for a script to retrieve file(s) permissions NT platform.
--
Posted via Talkway - http://www.talkway.com
Surf Usenet at home, on the road, and by email -- always at Talkway.



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

Date: Tue, 16 Mar 1999 12:27:06 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sorting with Perl
Message-Id: <MPG.11585e7437e83401989763@nntp.hpl.hp.com>

In article <comdog-ya02408000R1603991420130001@news.panix.com> on Tue, 
16 Mar 1999 14:20:13 -0500, brian d foy <comdog@computerdog.com> says...
 ...
> sub my_way
>    {
>    my @a = split /\./, $a;
>    my @b = split /\./, $b;
> 
>    foreach my $index ( 0..$#a )
>       {
>       return  1 if $a[$index] >  $b[$index];
>       return -1 if $a[$index] <  $b[$index];
>       next      if $a[$index] == $b[$index]; #not really needed
>       }
> 
>    return 0;
>    }
> 
> @sorted = sort my_way keys %hash; #i did it my waaaay...

Of course, as you know, your waaaay is waaaay too slow if the data set 
is large.  Here are two other waaaays.

One faster waaaay (the Schwartz Transform):

@sorted = map $_->[0] =>
          sort { $a->[1] cmp $b->[1] }
          map { [ $_, join "" => map sprintf('%.10d', $_) =>
              split /\./ ] } keys %hash;

An even faster waaaay (the packed default sort):

@sorted = map substr($_, 1 + index $_, "\0") =>
          sort
          map join("" => map(sprintf('%.10d', $_) =>
                  split /\./), "\0$_") => keys %hash;

The differences are dramatic even with the small data set (27 items) 
provided in the problem statement.

Benchmark: timing 1024 iterations of ST, brian, packed...
        ST:  5 wallclock secs ( 4.20 usr +  0.00 sys =  4.20 CPU)
     brian: 16 wallclock secs (15.80 usr +  0.00 sys = 15.80 CPU)
    packed:  3 wallclock secs ( 3.44 usr +  0.00 sys =  3.44 CPU)

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


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

Date: Fri, 19 Mar 1999 10:00:40 -0500
From: "Robert Gwynne" <gwynne@utkux.utk.edu>
Subject: Subset Question
Message-Id: <7ctpag$gu4$1@gaia.ns.utk.edu>

I'm trying to write an algorithm that gives me all combinations of an array
such that  if @array = (a b c d), it produces:
ab ac ad bc bd cd
    or
 aa ab ac ad bb bc bd cc cd

I've tried variations on the example program below to no avail. It seems
that I should be able to delete the first item of the array each time
through the loop and end up with all the combinations. However, if I comment
out the penultimate line "shift(@array);", I get all of the combinations.
For example:
aa ab ac ad ba bb bc bd ca cb cc cd da db dc dd
They are there, but there's too much redundancy for what I want.

It looks like a problem for CS101, but I'm at a loss to figure out what the
problem is.

#!/usr/local/bin/perl -w

@array = qw(a b c d);

foreach $item(@array){

    foreach $element(@array){

        print "$item times $element\n";

}

    shift(@array);

}

---------------------------
Bob Gwynne
gwynne@utkux.utk.edu
Speech Comm
University of Tennessee, Knoxville

JAPN (Just Another Perl Newbie)









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

Date: Fri, 19 Mar 1999 17:43:07 +0200
From: blade@leela.janton.fi (Sami Rosenblad)
Subject: Re: Testing if variable contains a certain word.....
Message-Id: <blade-1903991743070001@durandal.janton.fi>

In article <7ctj6o$9lf$1@news.casema.net>, "MW"
<oursDELETE-THIS@casema.net> wrote:

> How can I test if a variable contains a certain word?
> I want to test $ENV{'HTTP_ACCEPT_LANGUAGE'} for   'nl'
> to redirect people to other pages.

Try matching:

if ($ENV{'HTTP_ACCEPT_LANGUAGE'} =~ /nl/i) { ...
                                        ^
                           remove 'i' if you don't want
                           to match case insensitively

-- 
Sami Rosenblad | blade@leela.janton.fi | running Linux since 1999


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

Date: Fri, 19 Mar 1999 15:37:23 GMT
From: als@signalinteractive.com
Subject: Re: Web Databases
Message-Id: <7ctqvi$1av$1@nnrp1.dejanews.com>

In article <7cdpv1$4vn$1@client2.news.psi.net>,
  Jeff Doak <jdoak@MailAndNews.com> wrote:
> I am creating a web site, and I want to add an interactive database.  One
> that users can add/change/delete records.  Can I do that using Perl,

Yes.  I am on an NT system so directions for you may differ if you are on
UNIX. First go to http://www.roth.net/odbc/ and download the software. This
includes a sample Access database and a test script to verify that it opens
and closes connections and retrieves information correctly.  Next, install,
test, and if necessary fix settings on your systme to get it to work.  Last,
your script will make SQL calls to manipulate tyhe database, so you must
learn SQL.

>and is there  a  good book to tell me how it's done?

Not to my knowledge, so let me know if you find one.

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


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

Date: 19 Mar 1999 14:27:52 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: Win32 Perl and DOS-style interrupts
Message-Id: <19990319092752.15304.00000427@ng-fq1.aol.com>

Hi:

>proprietary ERP
>system we use that is Win32-based using Perl and Perl/Tk.

With this interface, it is DOS-based. You are merely running
it on Win32.

>Unfortunately, I think I'm stuck on getting data in and out of the system.
>The system's documentation refers to stuffing values onto various
>registers (BX,CX) and generating interrupt 16H to return information to
>the calling application.

You need an assembler (ASM). Whether you use a free-standing
DOS application and interface via "system" or in-line the assembly
code in a C  wrapper (which could create a DLL for use with
Win32::API or calling via  XS) depends on your choice of
compiler and how many of these calls you need to support.

-bill

Making computers work in Manufacturing for over 25 years (inquiries welcome)


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

Date: Fri, 19 Mar 1999 09:46:44 -0600
From: "The Crowe" <crowe@darkspiral.com>
Subject: Re: Windows NT Path Resolution
Message-Id: <a02RR7hc#GA.280@newstoo.hiwaay.net>


NT dir must be FULL path INCLUDING Drive letter..

example

D:\InetPub\wwwroot\yourdomain\yourdir\cgi-bin\filename.db

or something like that.

Also, depending on the nature of the script, you may have to use

D:\\Inetpub\\wwwroot\\yourdomain\\yourdir\\cgi-bin\\filename.db

Remember "\" is the escape character so you may have to use it to
get your paths right :)


Crowe


David Twaddell <david@123uk.net> wrote in message
news:36F18AD8.94FB6D19@123uk.net...
>If I refer to a file with no path extension, eg. "textfile.db" then my
>script finds the file ok. But if I provide a path extension,
>"/cgi-bin/links/textfile.db", my script says that it cannot find the
>file. The file is definitely in the directory "/cgi-bin/links" and so I
>deduce that for some reason Perl and Windows NT is getting the paths
>confused somehow.
>
>Please help me if you can. I am off to purchase the best book on Perl I
>can find tomorrow, but your expertise may save me some time!
>
>Appreciatively yours,
>
>David Twaddell
>




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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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


------------------------------
End of Perl-Users Digest V8 Issue 5177
**************************************

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