[15555] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2968 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 6 18:05:22 2000

Date: Sat, 6 May 2000 15:05:10 -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: <957650710-v9-i2968@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 6 May 2000     Volume: 9 Number: 2968

Today's topics:
    Re: @array holding %hash <abe@ztreet.demon.nl>
    Re: @array holding %hash (Tad McClellan)
    Re: Accessing CDDB database? mschilli@perlmeister.com
    Re: associating a filename with a FileHandle (Randal L. Schwartz)
    Re: beginner: read in variable <godzilla@stomp.stomp.tokyo>
    Re: beginner: read in variable <tony_curtis32@yahoo.com>
    Re: beginner: read in variable <tony_curtis32@yahoo.com>
    Re: beginner: read in variable <godzilla@stomp.stomp.tokyo>
    Re: beginner: read in variable <tony_curtis32@yahoo.com>
    Re: beginner: read in variable <jeff@vpservices.com>
        Best way to connect to MS-SQL Server from Perl? <tom.williamson@home.com>
    Re: Cookie <flavell@mail.cern.ch>
    Re: Dynamically generate eXcel spreadsheet (Neil Kandalgaonkar)
    Re: Flame my code <dave@dave.org.uk>
    Re: global variable with perl-cgi scripts ? (Bart Lateur)
    Re: Help! Which disrtibution should I get? (Tad McClellan)
    Re: How single-line switch (/s) works in regexps? <gellyfish@gellyfish.com>
        How to merge to seniority lists? <jm.wood@home.com>
        logon script NT <spelts@lucent.com>
    Re: Perl Lazy Matching (Bart Lateur)
    Re: Quality of perl implementations (Was: Re: if file a <htp@mac.com>
    Re: Question on references... (Neil Kandalgaonkar)
    Re: re-initializing through each loop (Bart Lateur)
    Re: Should a class that exports no symbols provide an e (Bart Lateur)
        SV: Clinet/Server and inetd <thomas2@dalnet.se>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 06 May 2000 20:27:31 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: @array holding %hash
Message-Id: <qcm8hs8pj3gt1p2t3sldi5cmdd7v5lbhui@4ax.com>

On Sat, 6 May 2000 09:57:01 -0700, Larry Rosler <lr@hpl.hp.com> wrote:

>                                         It is better to create a 
> reference to an anonymous hash instead:
> 
>   push @array, { %table };
> 

I find this interesting, a few weeks ago I said in a similar post:
> > 	$All{classC} = \@tt;
> This is OK if you only do this once (and never alter @tt). Better to
> use:
> 	$All{classC} = [ @tt ];

You replied:
	In real life, it would be done in a loop, in which case every
	execution of the 'my @tt;' declaration would allocate new 
	storage.  So copying the array into another anonymous array 
	would be wasted effort.

I understand what you say here, and I can't argue with that.
My point was indeed to bring the scope of @tt to attention.

perldsc says:
    In summary:

        $AoA[$i] = [ @array ]; # usually best
        $AoA[$i] = \@array;    # perilous; just how my() was that array?
        @{ $AoA[$i] } = @array; # way too tricky for most programmers


As I do take your advice serious, I am a bit puzzled.
Is this a style issue?

-- 
Good luck,
Abe


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

Date: Sat, 6 May 2000 11:55:23 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: @array holding %hash
Message-Id: <slrn8h8g3b.80p.tadmc@magna.metronet.com>

On Sat, 6 May 2000 18:03:19 +0200, Ganix <ganix#gmx.net> wrote:

>I'm writing a cgi script, that reads in some sets of data from
>a text file. Since every set consist of several lines, I think it
>is wise to create an @array that holds one %hash for each
>set of data.
>Now my problem is that I am not able to put these hashes
>into the array.


Because it is *impossible* to put hashes into arrays in Perl!

You can, however, put *references to hashes* into arrays. That,
along with some syntactic sugar gives the _appearance_ of
"hashes in arrays".


>I have tried all I can think about. 
                        ^^^^^

Don't "think" (i.e. "guess).

Read the docs that came with your perl distribution, and "know".


   perldoc perlreftut

   perldoc perlref

   perldoc perllol

   perldoc perldsc


You will need to understand and use references to get what you want.


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


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

Date: Sat, 06 May 2000 21:19:14 GMT
From: mschilli@perlmeister.com
Subject: Re: Accessing CDDB database?
Message-Id: <m%%Q4.23$OW2.58575@news.pacbell.net>

Tom Phoenix <rootbeer@redcat.com> wrote:
> On Fri, 5 May 2000, Ric Smith wrote:

>> Has anyone had success in accessing the cddb
>> database through a web app?

There's a module on CPAN, which works pretty good:
    R/RC/RCAPUTO/CDDB-1.03.tar.gz

-- Mike

----------------------------------------------------
Mike Schilli               http://perlmeister.com
----------------------------------------------------


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

Date: 06 May 2000 11:06:45 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: associating a filename with a FileHandle
Message-Id: <m1puqzy2mi.fsf@halfdome.holdit.com>

>>>>> "Donald" == Donald Lancon <lancon@mail.ce.utexas.edu> writes:

Donald> In particular, you could store the filename for an opened FileHandle in
Donald> the hash and it would be passed around with the FileHandle:

The filename may not exist later, or may be changed.  At most, you've
recorded something of historic interest only.  What's your goal here?  What
problem are you solving?

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Sat, 06 May 2000 13:00:19 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: beginner: read in variable
Message-Id: <391479D3.561F8817@stomp.stomp.tokyo>

David wrote:
 
(snip)

> @array1 (1..5)
> @array2 ("David", "Paul", "Jim", "Pat", "Tam")
 
> and I want it to read a number 1 to 5 and print out the corresponding name,
> for example I type in 1 and it is placed into the code to print out "David",
> something like
 
> print array2( numberthatItyped - 1) <-- ought to print out the first element
> of array2, which is David, my question is how do I read in the initial
> number and then place it into that print statement? I know my code above
> isn't perfect, but I know how to do the array stuff- it's in my book...


Hi ya David!

I have set up a very simple test script for you.
This test script will exemplify two methods of
many, you may do this. My test script will also
well highlight a bug of which few people know.

In this script you will notice two methods. One
is to access a standard array, the other is to
access a random associative array. You will also
notice I have included "ZERO" as an element in
both array styles. This is included to highlight
a most amusing little known bug. You will see!

You may upload this script to your internet
server for testing or, modify it to work on
your home system. I do not know if this bug
will show up on your home system. It will
clearly jump out via an internet server
under a Mozilla browser. Unknown on MSIE.
You might want to test this first on your
server to duplicate my own test conditions.
Your home system may yield different results
and lead you to believe what works correctly
on your home system, will also work correctly
on our internet. This is an unsafe assumption
many people mistakenly make.

My intent in this script is to demonstrate
for you how a visitor may access a first
name based solely upon a number. Works
fine for either type of array. Having two
type of arrays provides you with choices,
among many other choices.

Test this first with any number 1 to 5,
inclusive, then try 0 (zero) and watch
what happens! Keep in mind this is a
very simple test script. With numbers
over 9 you will need to write a better
matching operator to avoid unintended
matches, such as 2 matching 20, 22, 200.

This script affords ZERO security. Don't
leave on your server any longer than needed.

Rather than provide printed results, I believe
you will have more enjoyment in expectation.

Try this on your internet server! This little
known bug is rather an oddity.


Godzilla!


=========

My script with which to test, modify and play:

=========

#!/usr/local/bin/perl

print "Content-Type: text/html\n\n";

print "
 <HTML><HEAD><TITLE>Test Arrays</TITLE></HEAD></BODY>
 <CENTER>
 <FORM METHOD=\"post\" ACTION=\"test.cgi\"> Enter A Number 0 to 5: 
 <INPUT TYPE=\"text\" SIZE = \"1\" MAXLENGTH=\"1\" NAME=\"Test\"><P>
 <INPUT TYPE=\"submit\" NAME=\"Test_Button\" VALUE=\"Test Button\">
 </FORM><P><P></CENTER>";

&Parse;

sub Parse
 { # Parse #
  local (*in) = @_ if @_;
  local ($i, $key, $value);
  read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
  @in = split(/&/,$in);
  foreach $i (0 .. $#in)
   {
    $in[$i] =~ s/\+/ /g;
    ($key, $value) = split(/=/,$in[$i],2);
    ($value eq "") && next;
    $key =~ s/%(..)/pack("c",hex($1))/ge;
    $value =~ s/%(..)/pack("c",hex($1))/ge;
    $in{$key} .= $value;
   }
  return 1;
 } # Parse #


@Standard_Array = ("ZERO", "David", "Paul", "Jim", "Pat", "Tam");

@Associative_Array = ("5:Tam", "4:Pat", "1:David", "3:Jim", "2:Paul",
"0:ZERO");


if ($in{Test})
 {
  print "
   Input Number Is: $in{Test}<P>
   Standard Array Name Is: $Standard_Array[$in{Test}] <P>";

  foreach $assoc_element (@Associative_Array)
   {
    local ($key_elem, $value_elem) = split (/:/, $assoc_element);
    if ($key_elem =~ /$in{Test}/)
     { print "Associative Array Name Is: $value_elem"; }
   }
 }

print "</BODY></HTML>";

exit;



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

Date: 06 May 2000 15:12:29 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: beginner: read in variable
Message-Id: <873dnvtp3m.fsf@shleppie.uh.edu>

>> On Sat, 06 May 2000 13:00:19 -0700,
>> "Godzilla!" <godzilla@stomp.stomp.tokyo> said:

> You may upload this script to your internet server for
> testing or, modify it to work on your home system. I do
> not know if this bug will show up on your home
> system. It will clearly jump out via an internet server
> under a Mozilla browser. Unknown on MSIE.  You might

WHY do you keep introducing irrelevant stuff like this?
Oh and irrelevant database stuff too.  The question has
NOTHING to do with the WWW.

That was a rhetorical question above of course -- the only
reason you do it is to introduce bad/buggy code/advice of
your own devising to irritate and mislead people.

Stop it.  Please.


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

Date: 06 May 2000 15:15:28 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: beginner: read in variable
Message-Id: <87zoq3sae7.fsf@shleppie.uh.edu>

>> On Sat, 6 May 2000 13:18:28 +0100,
>> "David" <david@celtic1888.fsbusiness.co.uk> said:

> Hi, i'm just learning perl on Win95(with some help from
> perl5 by example) and I am wondering if there is some
> way to read in a value to my perl thingies and assign it
> to a variable (i'm from a Pascal background). The
> prorgam i'm trying to create has two arrays

> @array1 (1..5) @array2 ("David", "Paul", "Jim", "Pat",
> "Tam")

> and I want it to read a number 1 to 5 and print out the
> corresponding name, for example I type in 1 and it is
> placed into the code to print out "David", something
> like

Arrays are normally subscripted from 0.  To access a
particular member,

    $array[$i]

The first part of your question is a bit vague.  Do you
want to take the array index from the command line?  Or
prompt the user for the value from standard input?

hth
t


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

Date: Sat, 06 May 2000 13:32:45 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: beginner: read in variable
Message-Id: <3914816D.173E3DE6@stomp.stomp.tokyo>

Tony Curtis wrote:
 
> >> On Sat, 06 May 2000 13:00:19 -0700,
> >> "Godzilla!" <godzilla@stomp.stomp.tokyo> said:


(snipped harassment)

If you continue to harass me with malice
intent, a formal complaint will be filed
with Dennis Fouty at the University
Of Houston and a formal complaint will
be filed with Arthur K. Smith's office.
I will provide you with no warning of
this type of unpleasant event which 
I hope can be avoided. Your choice.

I will no longer tolerate malice intent
harassment from anyone for any reason.

Godzilla!


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

Date: 06 May 2000 15:53:52 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: beginner: read in variable
Message-Id: <87wvl7s8m7.fsf@shleppie.uh.edu>

>> On Sat, 06 May 2000 13:32:45 -0700,
>> "Godzilla!" <godzilla@stomp.stomp.tokyo> said:

> If you continue to harass me with malice intent, a
> formal complaint will be filed with Dennis Fouty at the
> University Of Houston and a formal complaint will be
> filed with Arthur K. Smith's office.  I will provide you
> with no warning of this type of unpleasant event which I
> hope can be avoided. Your choice.

> I will no longer tolerate malice intent harassment from
> anyone for any reason.

"It's only USENET".  I'm not going to get excited about
this.  Look how much time and effort we expend going off
on tangents with your posts.  I don't want to see this
newsgroup fall apart.  You post bad code/advice, people
correct you and ask you to stop.  This is not harrassment,
it is a community trying to keep itself viable.


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

Date: Sat, 06 May 2000 13:57:19 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: beginner: read in variable
Message-Id: <3914872F.FC7A8D71@vpservices.com>

"Godzilla!" wrote:
> 
> David wrote:
> 
> (snip)
> 
> > @array1 (1..5)
> > @array2 ("David", "Paul", "Jim", "Pat", "Tam")
> 
> > and I want it to read a number 1 to 5 and print out the corresponding name,
> > for example I type in 1 and it is placed into the code to print out "David",
> > something like
> 
> > print array2( numberthatItyped - 1) <-- ought to print out the first element
> > of array2, which is David, my question is how do I read in the initial
> > number and then place it into that print statement? I know my code above
> > isn't perfect, but I know how to do the array stuff- it's in my book...

David, to answer the question you asked rather than the one answered by
Godzilla, aka, purlMoron (a malicious troll who purposely posts bad code
to confuse beginners)

print "Type a number between 0 and 5 and then press enter: ";
my $foo = <STDIN>;
chomp $foo;

Will pause for input from a user, then put whatever they typed into the
variable named $foo after they press enter.  If you want to ensure it's
a digit or within a certain range, you can validate, then ask for more
input if needed.  If you want to only read one character without waiting
for enter, that is more complex, see the FAQ on readining input.

Among other garbage in the stuff purlMoron typed is the ridiculous
&parse routine which minimally works for this script but will fail
miserably for many other uses and the "amusing bug" which can easily be
fixed by changing this bad line in the Moron's code:

	if ($in{Test})

to this:

        if( defined $in{Test})

The first will fail if the number entered is 0 because 0 evaluates to
false but the second will succeed because the variable is defined even
when its value is 0.  Far from being "a bug of which few people know" it
is something regularly pointed out as a problem by other, more
responsible members of this newsgroup and is not a bug, just sloppy
coding.  And, unlike purlMoron's, misleading assertion, it has nothing
to do with browsers or the Internet, it will bite anyone who writes such
sloppy code in any environment.

Oh, and to save you the bother of reading its response, the troll will
respond to these errors by saying it purposelly put them in to teach us
all something and then probably accuse me of harassing it.

-- 
Jeff


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

Date: Sat, 06 May 2000 18:08:34 GMT
From: "Tom Williamson" <tom.williamson@home.com>
Subject: Best way to connect to MS-SQL Server from Perl?
Message-Id: <CcZQ4.100910$U4.838940@news1.rdc1.az.home.com>

Hello -

I'm looking for some information - facts and/or advice - on the best way to
connect to a SQL Server 7 database running on NT, from a Linux box using
Perl.  So far I have checked www.perl.org, www.perl.com and the CPAN archive
including the FAQs and the DBI/DBD readme files (those I have been able to
locate).   I have discovered the following:

1) There is not, so far as I can tell, a DBD::SQLServer module or anything
like it (why?);
2) The DBD::ODBC module (my second choice)  cheerfully announces itself as
"ALPHA SOFTWARE - YOUR MILEAGE MAY VARY".     Is there another (non-alpha)
module that people can use for ODBC?

Is anyone out there actually interfacing Perl to SQL Server?   And please -
how are you doing it?  If you are using ODBC, how are you creating your DSN
on the Unix client box?

Thanks....




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

Date: Sat, 6 May 2000 20:51:34 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Cookie
Message-Id: <Pine.GHP.4.21.0005062033310.2874-100000@hpplus01.cern.ch>

On Fri, 5 May 2000, Randall Woodman turned usenet on its head and
blurted out:

> Visit Matt's Script Archive and grap the cookie library.

would that be grep or grab?

>  It will make life easier for you.

Well, Matt's scripts are reputed to have made life easier for lots of
crackers, is this one likely to be better than the rest?

It looked to me as if the original poster had one of the several well
known problems with cookies, but instead of including enough detail in
their question for a useful answer to be possible, they had used lots
of exclamation marks.  That usually warns-off the serious respondents.

CGI.pm is a reliable and respectable module: it works, when used
appropriately.  So the original poster was doing something wrong, but
just what it was, was not evident from the details that were posted.

I would not recommend trying to solve the problem by exchanging a
known-reliable Perl module that's in the standard Perl distribution,
for one of unknown provenance.  I would rather advise them to
investigate their problem in more detail and/or provide a test URL
where interested parties can visit their cookie-sender and advise 
of their findings.


Fortunately, you quoted upside-down, so few discerning usenauts will
take your contribution seriously.

f'ups narrowed , auch wegen deutschsprachige Gruppen, wo diese
Postings vermutlich ungern gesehen werden.




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

Date: 6 May 2000 20:51:41 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: Dynamically generate eXcel spreadsheet
Message-Id: <8f20kt$lgm$1@newsflash.concordia.ca>

In article <8euo4l$136$1@nnrp1.deja.com>,  <wjair@my-deja.com> wrote:
>Hi,
>
>Is there a way to dynamically generate eXcel spreadsheet
>and eXcel's chart on client's browser from the data that
>got send back from the server?


AFAIK the only way to do that is with the Win32::OLE modules 
talking directly to an Excel app. (There are some things that can write Excel
files, or Excel-compatible file, but I don't think charts are doable).

There was a good Perl Journal article on this ... if you pay up you can
get access to that article, 
<http://www.itknowledge.com/tpj/issues/vol3_2/tpj0302-0008.html>

The next question is: why do you want to do this client-side? 
Unless you have complete control over what is installed on the client, 
generate it server-side. 

-- 
Neil Kandalgaonkar
neil@brevity.org


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

Date: Sat, 06 May 2000 19:09:58 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: Flame my code
Message-Id: <ihn8hsg88mvrd87f34snhr910c3b0hfg81@4ax.com>

On Sat, 6 May 2000 13:24:18 -0400, "E. Preble" <preble@ipass.net>
wrote:

>I have a code snippet below.  Can it be better? (of course
>it can)
>
>purpose:
>Search a list of names in a array and create a new array
>with unique names only.
>For Example, if the array is:
>file1.txt
>file2.txt
>file2.txt
>file3.txt
>file2.txt
>
>The new array will have:
>file1.txt
>file2.txt
>file3.txt
>
>with NO duplicate entries of file2.txt. Here's my code
>(written in PerlAmateur v1.0):
>
>foreach $FileName (@File) {
>  $found = 0;
>  foreach $Entry (@ListOfFileNames) {
>   if ($FileName eq $Entry) {
>    $found=1;
>   }
>  }
>  if ($found == 0) {
>   @ListOfFileNames = (@ListOfFileNames, "$FileName");
>  }
>}

You probably want to turn your original list into a hash like this:

my %ListofFileNames;
@UniqueFiles{@File} = (1) x @Files;

and then the unique file names are the key of this hash:

my @ListOfFileNames = keys %UniqueFiles;

All of which is much faster and more 'Perlish' than your example.

The only tricky part of my solution is the hash slice in the second
line (but I can't remember where in the standard docs, hash slices are
described - can anyone help?)

hth,

Dave...

-- 
<http://www.dave.org.uk>  SMS: sms@dave.org.uk
YAPC::Europe - London, 22 - 24 Sep <http://www.yapc.org/Europe/>

"There ain't half been some clever bastards" - Ian Dury [RIP]


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

Date: Sat, 06 May 2000 21:04:28 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: global variable with perl-cgi scripts ?
Message-Id: <39157fcb.1064666@news.skynet.be>

Ed Bras wrote:

>what about session depend variables ?
>That is that one person can change the variable value of another when they
>both have web connection with the same page. Do you have  a solution for
>that ?

If you have a unique session ID, save a data file with the name based on
it, containing the data for that session. For simple cases, a tab
delimited text file will do nicely: one column for the keys, and one for
the values.

-- 
	Bart.


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

Date: Sat, 6 May 2000 14:26:44 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help! Which disrtibution should I get?
Message-Id: <slrn8h8ov4.84d.tadmc@magna.metronet.com>

On Sun, 07 May 2000 00:19:26 +0800, Preston <prestoncheung@hongkong.com> wrote:

>I'm a beginner to perl.


And to programming too, it appears.


>I'm intended to write perl scripts to be run on Debian Linux Server.
>However, my system is Win98. I see on activestate.com that there are two
>binary distribution (one for Win9X, one for Debian Linux).
>Which one should i get?


Get the Win version for running on Windows systems.

Get the Linux version for running on Linux systems (though
you rarely need binaries for "unix like" OSes, as perl
builds fine out of the box on those system).


I expect what you are trying to say is that you will develop
on Windows, and move to Linux for production?


>do perl scripts writen in perl for win32 work in debian linux server?


Probably, unless you have programmed in something system-specific.
(so don't do that :-)


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


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

Date: 6 May 2000 21:52:46 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How single-line switch (/s) works in regexps?
Message-Id: <8f20mu$9be$1@orpheus.gellyfish.com>

On 05 May 2000 12:53:52 +0100 nobull@mail.com wrote:
> Larry Rosler <lr@hpl.hp.com> writes:
> 
>> In article <u9ya5qfrmr.fsf@wcl-l.bham.ac.uk> on 04 May 2000 13:04:44 
>> +0100, nobull@mail.com <nobull@mail.com> says...
>> 
>> ...
>> 
>> > Given a prefix of string and a pattern is it possible to test if is
>> > necessary to read in more to know if (or what) the pattern will match
>> > in that prefix.
>> > 
>> > eg. 
>> > 
>> >   ("foo" . $unread) =~ /f/ # Matches
>> >   ("foo" . $unread) =~ /o+/ # Matches but we dont know how many
>> >   ("foo" . $unread) =~ /od/ # Don't know if is maches
>> >   ("foo" . $unread) =~ /d/ # Doesn't match
>> 
>> Your example code bears little relation to your question.
> 
> It's not code, it's pseudo-code using the syntax of Perl.  This should
> be blantently obvious since I'm taking about something that AFAIK
> can't be done in Perl.  We are for ever telling people to write
> pseudo-code following Perl syntax.
> 

I'm not aware of that.  I dont believe I have ever heard any call for
people to write 'pseudo-code following Perl syntax.'

/J\
-- 
And how is education supposed to make me feel smarter? Besides, every time
I learn something new, it pushes some old stuff out of my brain. Remember
when I took that home winemaking course, and I forgot how to drive?
-- 
fortune oscar homer


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

Date: Sat, 06 May 2000 20:18:50 GMT
From: "AEF" <jm.wood@home.com>
Subject: How to merge to seniority lists?
Message-Id: <K6%Q4.11007$95.111974@news1.rdc1.mb.home.com>

This is not for any commecial activity. This is for a proposed merger of two
unions seniority lists.

Please give me a break if I am not stating my problem in the correct manner
for this
group.

I would like help please, I am stuck on how to proceed, and still fairly new
to this. Included is what I have attempted so far, and isn't working. I've
included it only to point out that I have tried on my own - for better or
worse.

Am I on the right track?  Suggestions for a better way or how to proceed
from here please.

Thanks.

Problem:

Merge two seniority lists with date of hire as the basic sorting goal.

Some of the dates of hire have been adjusted for furlough time. The sort
will have to look at the adjusted date if the
date of hire is not greater than or equal to the previous date in the list
(the more senior date).

Many dates of hire are the same dates, on the same list and across the
lists. The seniority order of the original list will still have to be
honored on a combined list even if people from the second company slot in
ahead.

  #sen numb, company, lastname, intials, adjusted date, date of hire,
percentile

  # current list of THATCO
  #1 THATCO Jones, DR 17 JUN 1965 22 FEB 1965 0.04%

  # current list of THISCO
  #1 THISCO Smith, HR 15 OCT 1962 15 OCT 1962 0.04%

  # eventually the goal is to create a combined list
  #new sn, old sen, company, ln, in, adj_doh, doh, old_pct, combined_pct.

  1 1 THISCO Smith, HR 15 OCT 1962 15 OCT 1962 .04% .03%
  2 1 THATCO Jones, DR 17 JUN 1965 17 FEB 1965 .04% .04%

# there are items in the seniority lists that do not flow exactly to date of
hire
# because of furlough time, and have been adjusted

#once data file is open create and index foreach of the inputs

create_index($sn, $co, $ln, $in, $adj, $doh, $pct);

sub create_index
{
my($sn, $co, $ln, $in, $adj, $doh, $pct) = @_;
$rdata = [ $sn, $co, $ln, $in, $adj, $doh, $pct ];
push (@rdata, $rdata);
}

# HOW do I find the dates that are not flowing in a
# date of hire order, so that I
# can sort on the adjusted date of hire??

# lowest 8 digit sen date number
# is most senior ie 0  < 19621015 < 19659222
my %lowest;
 for (@rdata) {
  my ($sn, $co, $ln, $in, $adj, $doh, $pct) = @$_;

   $last = $lowest{$sn} || 0;
    #next if $last <= $doh;
    if ($last <= $doh) {
    next;
   }
   # try to get this working before moving on! This is NOT working.
   elsif($last > $doh) {
    push(@irreg, @$_);
   next;
   }
     $lowest{$sn} = $doh;
  }


 for (@irreg) {
  print "$_\n";
 }
 exit;

 # some sketches for ideas for sorting a combined list later!!
 # top loads company A over B?

 @rdata = sort

   $a->[5] <=> $b->[5]
    ||
   $a->[6] <=> $b->[6]
    ||
   $a->[1] cmp $b->[1]
                       } @rdata;
for (@rdata) {
my ($sen_num, $company, $lname, $initials, $line_date, $sen_date, $pct) =
@$_;
$comb++;
print "$comb $sen_num $company $lname $initials $sen_date $pct\n";

}





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

Date: Sat, 6 May 2000 16:21:05 -0400
From: "steve pelts" <spelts@lucent.com>
Subject: logon script NT
Message-Id: <8f1urj$jv5@nntpb.cb.lucent.com>

I am creating a logon script and one of the things I need to do is know if
the user is a member of a local group on a member server.  I can do this in
PERL.
what do I need to do to run a perl script on a win95/NT client at logon.  I
know the PERL script will be in the netlogon directory.  I don't want to
have to load perl on each machine.  what needs to happen for the client to
be able to run PERL
thanks
spelts@lucent.com




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

Date: Sat, 06 May 2000 21:04:34 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Perl Lazy Matching
Message-Id: <39188481.2270105@news.skynet.be>

edlong@yahoo.com wrote:

>The crux of the question, is there are multiple variables in my hash
>that start similiar
>(ie: ab, abc, abcd).  And there are sections of text that I want to
>replace
>(ie: "This ab, is abc, the next abcd")  And Perl picks up the first ab
>and replaces it with the ab replacement, but I want Perl to match the
>WHOLE string and replace the whole string with the correct replacement.

I don't understand the relation between this text snippet and your code
example.

Is this anywhere close to what you want?

	$_ = $replacement if /ab/;

-- 
	Bart.


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

Date: Sun, 07 May 2000 06:33:24 +0930
From: Henry <htp@mac.com>
Subject: Re: Quality of perl implementations (Was: Re: if file already exists then remove...)
Message-Id: <htp-6B969B.06332407052000@news.metropolis.net.au>

In article <MPG.137cc17b59c765498aa08@nntp.hpl.hp.com>, Larry Rosler 
<lr@hpl.hp.com> wrote:

> > Look, don't get me wrong, I think Perl's great.  It forgives me when I 
> > make mistakes, and I forgive it when it makes mistakes.  That makes for 
> > a very warm and fuzzy relationship.  Tolerance is, however, not a trait 
> > of mission-critical programming languages (and compilers) - they are 
> > cold, prickly, but can be relied upon when the <objectionable object> 
> > hits the fan.
 ...
> I am troubled by your laissez-faire attitude with regard to perl.  

???  My dictionary (getting a lot of use lately, it seems) defines 
laissez-faire as a government policy of non-interference.  Given that 
definition, I'm not sure I understand the above sentence.  Sorry.


> Should encouraging willing contributors to invest more time on quality 
> of implementation become a higher priority than continually adding 
> features?

I don't think so.  If someone needs mission-critical code, they already 
have plenty of languages and compilers to choose from that will give it 
to them.  I don't think we need another one.

Perl has snuggled into its Swiss-army-knife role admirably.  Flexibility 
is the prime attribute for such tools, and they are vastly more useful 
for the average camper, casually exploring the great unknown.

I consider myself to be a somewhat average camper, and Perl (as it is) 
suits me to a tee.  I'd rather see people push the limits of what Perl 
can do, and not get bogged down benchmarking how well it does them.

Four-wheel drives do not race Formula 1 for precisely the same reason, 
yet they still have a role to play.

Henry.


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

Date: 6 May 2000 20:01:54 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: Question on references...
Message-Id: <8f1tni$jji$1@newsflash.concordia.ca>

In article <39145406.D1C9B7E9@mediaone.net>,
PropART  <propart@mediaone.net> wrote:

>My difficulty is definitely a grokking thing, because I've never really used
>anonymous arrays.
>
>So, I guess you'd use an anonymous array when you just want to start out with
>array's values for some reason and you don't need a named array hanging around?

Not quite. 

$ref = \@foo; 

# $ref is a now a reference to a pre-existing 
# array named @foo.


$ref = [ @foo ]; 

# [ ] constructs a whole new array, but doesn't bother to give it a name,
# and just returns the reference to this new array.

In this case the anonymous array is constructed by taking @foo in list context,
which just happens to be the list of its elements. But you could also have
used [ sort @foo ] or [ @foo, "quux", @bar ] or [ 1, 2, 3 ].  

See man perlreftut (or perldoc perlreftut) for a great tutorial
on the subject; and man perllol and perldsc for many examples.

-- 
Neil Kandalgaonkar
neil@brevity.org


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

Date: Sat, 06 May 2000 21:04:30 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: re-initializing through each loop
Message-Id: <391781cd.1578489@news.skynet.be>

Jonah wrote:

>Is there anything wrong with re-intializing a variable
>through each loop.
>
>for instance, like this
>
>while (something)
>{
>    my $var = "hi";
>    print $var;
>}
>
>as opposed to
>
>my $var;
>while (something)
>{
>    $var = "hi";
>    print $var;
>}

Both are OK. But in some cases, in particular when you're trying to save
references to the original values, and usually hashes or arrays, then
you need to make sue you get a different hash or array every time.
Otherwise you'll just overwrite the old variaiable, and render the
stored reference useless.

So you usually will have to put the "my" declaration inside the loop.

	#useless:
	my @ary;
	for (qw(one two three)) {
	    @ary = split //;
	    push @all, \@ary;
	}
	print map "@$_\n", @all;
-->
	t h r e e
	t h r e e
	t h r e e

vs.
	#useful:
	for (qw(one two three)) {
	    my @ary = split //;
	    push @all, \@ary;
	}
	print map "@$_\n", @all;
-->
	o n e
	t w o
	t h r e e

BTW I don't think that the speed penalty for always declaring the
lexical variables inside the loop isn't any reason for not doing it all
the time.

-- 
	Bart.


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

Date: Sat, 06 May 2000 21:04:24 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Should a class that exports no symbols provide an empty import method?
Message-Id: <39147f20.893355@news.skynet.be>

M.J.T. Guy wrote:

>Current versions of the Perl documentation say 
> 
>      If no `import' method can be found then the call is skipped.

Yes, but...

If AUTOLOAD is activated for the module, a missing 'import' will trigger
it. For some modules, this can be a pretty expensive operation. Hearsay,
mind you, so don't ask me for an example.

-- 
	Bart.


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

Date: Sat, 06 May 2000 19:31:33 GMT
From: "Thomas Åhlen" <thomas2@dalnet.se>
Subject: SV: Clinet/Server and inetd
Message-Id: <pq_Q4.30$c2.4626@dummy.bahnhof.se>

Thanx!
It was to obvious now that i see it..:)

-Thomas

Calle Dybedahl <calle@lysator.liu.se> skrev i
diskussionsgruppsmeddelandet:86r9bf3dfq.fsf@tezcatlipoca.algonet.se...
> >>>>> "Thomas" == Thomas Åhlen <thomas2@dalnet.se> writes:
>
> > Since i only got STDIN, STDOUT, STDERR to play with and i need the
> > socket from inetd to get this information.
>
> STDIN is the socket from inetd.
> --
>  Calle Dybedahl, Vasav. 82, S-177 52 Jaerfaella,SWEDEN |
calle@lysator.liu.se
> "I'd rather hang on to madness than normality" -- KaTe Bush




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

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


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