[17596] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5016 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Dec 2 14:05:51 2000

Date: Sat, 2 Dec 2000 11:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <975783909-v9-i5016@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 2 Dec 2000     Volume: 9 Number: 5016

Today's topics:
    Re: array of unique random numbers (Alan Barclay)
    Re: array of unique random numbers <joe+usenet@sunstarsys.com>
    Re: array of unique random numbers <W.Hielscher@mssys.com>
        Counting <todd@mrnoitall.com>
    Re: Counting <uri@sysarch.com>
        Does comp.lang.perl exist? <mtn_view@sirius.com>
    Re: Does comp.lang.perl exist? <uri@sysarch.com>
    Re: Does comp.lang.perl exist? <jschauma@netmeister.org>
    Re: Does comp.lang.perl exist? (Randal L. Schwartz)
    Re: Does comp.lang.perl exist? (Randal L. Schwartz)
    Re: Does comp.lang.perl exist? <bowman@montana.com>
    Re: Does comp.lang.perl exist? <mtn_view@sirius.com>
    Re: Does comp.lang.perl exist? <jschauma@netmeister.org>
    Re: Does comp.lang.perl exist? <flavell@mail.cern.ch>
    Re: Does comp.lang.perl exist? <Jodyman@usa.net>
    Re: I Have Active Perl--Now What? <bowman@montana.com>
    Re: I Have Active Perl--Now What? <mtn_view@sirius.com>
    Re: Is there a function like LaTeX's \input ? (Logan Shaw)
    Re: one question from newbie (David Efflandt)
    Re: OT Cargo Cult? (Was: Re: reformatting a perl script <bernie@fantasyfarm.com>
    Re: perl and javascript (David Efflandt)
    Re: Printing to System Que (David Efflandt)
    Re: RE:Automation rereidy@my-deja.com
    Re: Should { } always indicate a scope? <rick.delaney@home.com>
    Re: sorting a file... (Garry Williams)
    Re: sorting a file... <rick.delaney@home.com>
    Re: sorting a file... (Garry Williams)
    Re: Sorting the result of a function (Garry Williams)
    Re: Sorting the result of a function (Garry Williams)
    Re: splitting a string into an array and preserving the <bernie@fantasyfarm.com>
    Re: splitting a string into an array and preserving the <bernie@fantasyfarm.com>
        Three dimensional hash? & iteration (Stan Brown)
    Re: Three dimensional hash? & iteration <jkline@one.net>
    Re: URL Get targeting HTTPS . . . (Honza Pazdziora)
    Re: Using goto <bowman@montana.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 2 Dec 2000 15:23:24 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: array of unique random numbers
Message-Id: <975770591.835173@elaine.furryape.com>

In article <V%5W5.455$uP1.10122@news6-win.server.ntlworld.com>,
Dela Lovecraft <dela@nospam.ukonline.co.uk> wrote:
>Dear Joe,
> 
>> % perldoc -q shuffle
>> 
>> Create your array of unique elements (originally in some order first), 
>> and then mix them up:
>> 
>> my @values = (0..49); shuffle(@values);
>
>Never thought of it in that way - guess I was going the long way about

That's fine if you want contigious integers, but if you want a subrange,
say 50 out of 10000 values, it wouldn't be very efficent. You can
use a hash to store which values have been seen, such as this:

#!/usr/local/bin/perl

while($count<50){
	my $try=int rand(10000);
	if(not $got{$try}){
		$got{$try}=$count++;
	}
}

foreach(sort { $got{$a} <=> $got{$b} } keys %got){
	print "value $got{$_} is $_\n";
}


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

Date: 02 Dec 2000 11:44:38 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: array of unique random numbers
Message-Id: <m3ofyurcw9.fsf@mumonkan.sunstarsys.com>

gorilla@elaine.furryape.com (Alan Barclay) writes:

> #!/usr/local/bin/perl
> 
> while($count<50){
> 	my $try=int rand(10000);
> 	if(not $got{$try}){
> 		$got{$try}=$count++;
> 	}
> }
> 
> foreach(sort { $got{$a} <=> $got{$b} } keys %got){
> 	print "value $got{$_} is $_\n";
> }


Just curious- why sort them? Is it less random to just
use 

@values =  keys %got;

?

(i.e. does "keys" do any special reordering that's 
based on the key?)

-- 
Joe Schaefer


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

Date: Sat, 02 Dec 2000 19:30:51 +0100
From: Wolfgang Hielscher <W.Hielscher@mssys.com>
Subject: Re: array of unique random numbers
Message-Id: <3A293FDB.8270BECD@mssys.com>

Joe Schaefer wrote:
> gorilla@elaine.furryape.com (Alan Barclay) writes:
> > #!/usr/local/bin/perl
> >
> > while($count<50){
> >       my $try=int rand(10000);
> >       if(not $got{$try}){
> >               $got{$try}=$count++;
> >       }
> > }
> >
> > foreach(sort { $got{$a} <=> $got{$b} } keys %got){
> >       print "value $got{$_} is $_\n";
> > }
> 
> Just curious- why sort them? Is it less random to just
> use
> 
> @values =  keys %got;

In the foreach ( sort ... ) loop Alan prints out the random numbers in
the order they have been generated. No assignment is done.

Cheers
   Wolfgang


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

Date: Sat, 02 Dec 2000 10:09:44 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: Counting
Message-Id: <3A29196F.5EB73403@mrnoitall.com>

Dear Persons,
The code below is designed to extract the first number from a vertical
list and then reprint the remaining numbers. It is extracting the first
number but then it prints the list without leaving the first number out.

Any advice is appreciated. Thanks in advance for your help.

open(LIST,"$location_of_file");

@numbers =<LIST>;
$number_count = @numbers;
close (LIST);
$count = "0";
foreach $number(@numbers){
$count++;
chop $number;
if($count == 1){
$in{'user_name'} = $number;
}
else {
$remaining_numbers  .= "$number\n";
}
}#foreach
print LIST "$remaining_numbers\n";





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

Date: Sat, 02 Dec 2000 16:56:04 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Counting
Message-Id: <x7vgt292zh.fsf@home.sysarch.com>

>>>>> "TA" == Todd Anderson <todd@mrnoitall.com> writes:

  TA> The code below is designed to extract the first number from a
  TA> vertical list and then reprint the remaining numbers. It is
  TA> extracting the first number but then it prints the list without
  TA> leaving the first number out.

it is not designed well. many comments to follow.

  TA> open(LIST,"$location_of_file");

always check the result of open. you don't need quotes (and they can be
a bug) around a single variable. and you do the open wrong if you want
to write to the file (see below).


  TA> @numbers =<LIST>;
  TA> $number_count = @numbers;
  TA> close (LIST);
  TA> $count = "0";

  TA> foreach $number(@numbers){
  TA> $count++;

ever heard of indenting? 

  TA> chop $number;

better to just chomp @numbers before the loop. does them all and it is
faster.

  TA> if($count == 1){
  TA> $in{'user_name'} = $number;
  TA> }
  TA> else {
  TA> $remaining_numbers  .= "$number\n";

why are you building up this string? it would be easier to print out
from the list of numbers.

  TA> }
  TA> }#foreach

if you indented you wouldn't have to comment where the end of the loop is.

  TA> print LIST "$remaining_numbers\n";

LIST was closed before so how could you print to it? also you opened it
for read (which is moot since it is closed now). either open for
read/write and seek to the beginning (clumsy) or just reopen the file
for write. or even better and safer, open a new file for writing and
when done, close it and rename it to the original file.

and if all you are doing is that, why the loop?

	chomp( $in{'user_name'} = shift @numbers )
	print NEW_LIST @numbers ;

that assumes no global chomping since you need the newlines and that you
opened the file already. i leave that as an exercise to the reader.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sat, 02 Dec 2000 08:12:38 -0800
From: Wayne Watson <mtn_view@sirius.com>
Subject: Does comp.lang.perl exist?
Message-Id: <3A291F76.4714058C@sirius.com>

When I  subscribe to comp.lang.perl and then access it, I get a message that says it is
non-existent. Is this true?

--
                              "It's better to wear out than rust out"
                                 -- Theodore Roosevelt, 26th U.S. President

                                            Wayne T. Watson




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

Date: Sat, 02 Dec 2000 16:30:12 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Does comp.lang.perl exist?
Message-Id: <x7zoie946k.fsf@home.sysarch.com>

>>>>> "WW" == Wayne Watson <mtn_view@sirius.com> writes:

  WW> When I subscribe to comp.lang.perl and then access it, I get a
  WW> message that says it is non-existent. Is this true?

it hasn't existed in over 5 years (maybe 6 now). why do you think there
is a hierarchy of groups below comp.lang.perl now? any server that still
carries c.l.p is b0rken and its admins are clueless.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sat, 02 Dec 2000 11:29:39 -0500
From: "Jan Schaumann" <jschauma@netmeister.org>
Subject: Re: Does comp.lang.perl exist?
Message-Id: <up9W5.10605$4k2.457487@news-east.usenetserver.com>

* "Wayne Watson" <mtn_view@sirius.com> wrote:

> When I  subscribe to comp.lang.perl and then access it, I get a message
> that says it is non-existent. Is this true?

No - it does exist - check with your news-provider.

Also, a sign-delimiter is "-- " and NOT "--", and the sig should be no
longer than 4 lines.

-Jan

-- 
Jan Schaumann <http://www.netmeister.org>

Microsoft broke Volkswagen's world record: Volkswagen only made 22
million bugs!


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

Date: 02 Dec 2000 08:40:58 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Does comp.lang.perl exist?
Message-Id: <m1g0k6wzc5.fsf@halfdome.holdit.com>

>>>>> "Wayne" == Wayne Watson <mtn_view@sirius.com> writes:

Wayne> When I subscribe to comp.lang.perl and then access it, I get a
Wayne> message that says it is non-existent. Is this true?

That's right.  Hasn't existed since May 1995.  In spite of what some
lame so-called "news admins" still believe.  The powers-that-be
approved the removal of comp.lang.perl at the same time that
comp.lang.perl.misc, comp.lang.perl.announce, comp.lang.perl.modules,
and comp.lang.perl.tk were created.

Just another guy who has been around Usenet since 1980 (yes, 19*80*),
-- 
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: 02 Dec 2000 08:43:24 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Does comp.lang.perl exist?
Message-Id: <m18zpywz83.fsf@halfdome.holdit.com>

>>>>> "Jan" == Jan Schaumann <jschauma@netmeister.org> writes:

Jan> * "Wayne Watson" <mtn_view@sirius.com> wrote:
>> When I  subscribe to comp.lang.perl and then access it, I get a message
>> that says it is non-existent. Is this true?

Jan> No - it does exist - check with your news-provider.

No, it authoritatively DOES NOT EXIST.  See my other posting.
If your news provider provides it, you have a lame news service.

Jan> Also, a sign-delimiter is "-- " and NOT "--", and the sig should be no
Jan> longer than 4 lines.

You got that right.

-- 
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, 2 Dec 2000 09:52:56 -0700
From: "bowman" <bowman@montana.com>
Subject: Re: Does comp.lang.perl exist?
Message-Id: <PI9W5.1161$NN6.4614@newsfeed.slurp.net>


Uri Guttman <uri@sysarch.com> wrote
> it hasn't existed in over 5 years (maybe 6 now). why do you think there
> is a hierarchy of groups below comp.lang.perl now? any server that still
> carries c.l.p is b0rken and its admins are clueless.

aw, come on....  c.l.p is a nice quiet low volume ng for newbies that can't
find
the real one. Think of it as the first obstacle in the natural selection of
acolytes.






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

Date: Sat, 02 Dec 2000 09:08:32 -0800
From: Wayne Watson <mtn_view@sirius.com>
Subject: Re: Does comp.lang.perl exist?
Message-Id: <3A292C90.7C78186@sirius.com>

Thanks. I'll see if I can get my ISP to remove it.

"Randal L. Schwartz" wrote:

> >>>>> "Wayne" == Wayne Watson <mtn_view@sirius.com> writes:
>
> Wayne> When I subscribe to comp.lang.perl and then access it, I get a
> Wayne> message that says it is non-existent. Is this true?
>
> That's right.  Hasn't existed since May 1995.  In spite of what some
> lame so-called "news admins" still believe.  The powers-that-be
> approved the removal of comp.lang.perl at the same time that
> comp.lang.perl.misc, comp.lang.perl.announce, comp.lang.perl.modules,
> and comp.lang.perl.tk were created.
>
> Just another guy who has been around Usenet since 1980 (yes, 19*80*),
> --
> 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!

--
                              "It's better to wear out than rust out"
                                 -- Theodore Roosevelt, 26th U.S. President

                                            Wayne T. Watson




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

Date: Sat, 02 Dec 2000 12:18:12 -0500
From: "Jan Schaumann" <jschauma@netmeister.org>
Subject: Re: Does comp.lang.perl exist?
Message-Id: <%6aW5.10640$4k2.465367@news-east.usenetserver.com>

* "Randal L. Schwartz" <merlyn@stonehenge.com> wrote:

>>>>>> "Jan" == Jan Schaumann <jschauma@netmeister.org> writes:
> 
> Jan> * "Wayne Watson" <mtn_view@sirius.com> wrote:
>>> When I  subscribe to comp.lang.perl and then access it, I get a
>>> message that says it is non-existent. Is this true?
> 
> Jan> No - it does exist - check with your news-provider.
> 
> No, it authoritatively DOES NOT EXIST.  See my other posting. If your
> news provider provides it, you have a lame news service.

I stand corrected and cover my head with ashes (and kick my news-provider
in the nuts).

-Jan

-- 
Jan Schaumann <http://www.netmeister.org>

 "Maybe you can't understand this, but I finally found what I need to be
happy, and it's not friends, it's things." -Fry


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

Date: Sat, 2 Dec 2000 18:36:40 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Does comp.lang.perl exist?
Message-Id: <Pine.GHP.4.21.0012021749280.28407-100000@hpplus03.cern.ch>

On Sat, 2 Dec 2000, Jan Schaumann wrote:

> No - it does exist 

For some value of the term "exist", maybe.

It's in a sort of twilight world, of newsgroups that have been
officially abolished but some news admins didn't honour that
abolition.

You'll get no benefit (and a lot of flak) if you try to cross-post to
it from here.  And you'll miss a lot of well-informed responses if you
were to limit your participation to that undead zombie of a group.

The proper place to discuss the technicalities of this part of the
usenet "tree" is the news.* hierarchy.  But I'll risk a few comments
that may point you in the right direction.  Of course there are
massive numbers of usenet groups which are outside of the major
hierarchies in this sense, and where these rules aren't applied.

There's a recent checkgroups announcement archived at
ftp://rtfm.mit.edu/pub/usenet-by-hierarchy/news/groups/
which lists the "standard" groups currently in the major hierarchies
(now big-8).

> - check with your news-provider.

You might do that - as a sort of bogosity detector to find out whether
they really understand the job  ;-)

Bit of history: Usenet administration of the major hierarchies (was it
big-5 or big-6 at that time - Randal? - anyone?) was in something of a
muddle (so what's new?) for a period which covers the time that the
comp.lang.perl* hierarchy was reorgansied and comp.lang.perl should
have been abolished - which I think goes some way to explaining the
anomaly.

ttfn



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

Date: Sat, 2 Dec 2000 13:29:08 -0500
From: "Jody Fedor" <Jodyman@usa.net>
Subject: Re: Does comp.lang.perl exist?
Message-Id: <90bfqc$ilu$1@plonk.apk.net>


Randal L. Schwartz wrote in message ...
>Just another guy who has been around Usenet since 1980 (yes, 19*80*),

Gee Randal,

            You're OLD!

Jody (LOL)




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

Date: Sat, 2 Dec 2000 09:48:49 -0700
From: "bowman" <bowman@montana.com>
Subject: Re: I Have Active Perl--Now What?
Message-Id: <ZE9W5.1159$NN6.4979@newsfeed.slurp.net>


Wayne Watson <mtn_view@sirius.com> wrote
> My question is how do I go about creating some simple Perl program and
> executing it?

Same way as on unix. Open your favorite editor and create the script. I
usually go
to a DOS box and do 'perl foobar.pl' but if you RTFM that came with the AP
installation,
you'll find out how to associate the extension so you could just click on
the script, if
that fluffs your fur.







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

Date: Sat, 02 Dec 2000 09:05:35 -0800
From: Wayne Watson <mtn_view@sirius.com>
Subject: Re: I Have Active Perl--Now What?
Message-Id: <3A292BDF.148F0702@sirius.com>

I discovered that by finding a tutorial on the web. However, I'd like to see you find that in TFM
that is provided with the package. Just copy the section and send it to me as proof that it is in
TFM.

While you're at it maybe you can tell me the following:

1. Is the only item in the Start menu ActivePerl->Online Documentation?
2. How does one uninstall ActivePerl?

bowman wrote:

> Wayne Watson <mtn_view@sirius.com> wrote
> > My question is how do I go about creating some simple Perl program and
> > executing it?
>
> Same way as on unix. Open your favorite editor and create the script. I
> usually go
> to a DOS box and do 'perl foobar.pl' but if you RTFM that came with the AP
> installation,
> you'll find out how to associate the extension so you could just click on
> the script, if
> that fluffs your fur.

--
                              "It's better to wear out than rust out"
                                 -- Theodore Roosevelt, 26th U.S. President

                                            Wayne T. Watson




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

Date: 2 Dec 2000 10:53:38 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Is there a function like LaTeX's \input ?
Message-Id: <90b9ei$hio$1@boomer.cs.utexas.edu>

In article <Pine.GSO.4.21.0012011613070.20968-100000@mtwhitney.nsc.com>,
Steven Kuo x7914  <skuo@mtwhitney.nsc.com> wrote:
>On Fri, 1 Dec 2000, Neil Montgomery wrote:
>> I would like to split up a Perl program into several parts, for ease
>> of editing. Making my own modules would be overkill in my situation.  
>> 
>> Is there a Perl function which will insert the contents of a file into
>> the code (like the LaTeX function \input)? 
>
>Well, you may be able to use: do 'filename'; see perldoc -f do
>for details.

If you're going to do this, it might be helpful to compare "do" and
"require".  They're similar but not the same.  The difference is that
"do" literally does what you want, but "require" does something which
might be better and more efficient.  But the "require" will only work
if you restrict yourself to things like only putting functions and
global initialization code in the other files.

On the other hand, I find it hard to be believe that modules are
overkill in very many situations.  (Although I can think of a few, like
if you're having another program generate only a small portion of a
perl script and you don't want to go pasting files together every time
it updates that part.)

  - Logan


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

Date: Sat, 2 Dec 2000 18:12:12 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: one question from newbie
Message-Id: <slrn92ieri.hvd.efflandt@efflandt.xnet.com>

On Sat, 02 Dec 2000 00:56:10 -0500, WEI WANG <wangwei18@163.net> wrote:
>I want to get time of web server, then use it as start point, to display
>a dynamic clock on my homepage. I know how to use javascript to make it
>dynamic, but I do not know how to return the server time to javascript.

This is not a Perl question unless you are having trouble generating a
specific (unspecified here) date format from a Perl script.

Either CGI generate your html with the necessary date already inserted or
use server side include (SSI) to run a CGI to insert the necessary date
within your JavaScript.  See your server docs for more about SSI.

Maybe someone on a javascript newsgroup would know some other way to grab
a suitable date from a server.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Sat, 02 Dec 2000 14:01:50 -0500
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: OT Cargo Cult? (Was: Re: reformatting a perl script)
Message-Id: <b23i2t46qlr6ljjk9o0a74oam338ftnsf9@news.supernews.net>

"Tim Schmelter" <schmelter_tim@hotmail.com> wrote:

} "Randal L. Schwartz" <merlyn@stonehenge.com> wrote in message
} news:m1g0k913s3.fsf@halfdome.holdit.com...
} > Get many answers here usually, some of which will be relatively
} > correct, some of which will be wrong, a few of which will likely be
} > wrong in a cargo-cult sense, republished from previous cargo-cult
} > answers from the previous time. :)
} 
} I've seen the phrase in this newsgroup a couple of times, but it's
} significance eludes me. What exactly is meant by "cargo-cult"?

Check the Jargon dictionary [In this case
<http://www.tuxedo.org/~esr/jargon/html/entry/cargo-cult-programming.html>
will get you what you want].

The definition there includes, in part:

>>> A style of (incompetent) programming dominated by ritual inclusion of code
>>> or program structures that serve no real purpose. A cargo cult programmer
>>> will usually explain the extra code as a way of working around some bug
>>> encountered in the past, but usually neither the bug nor the reason the
>>> code apparently avoided the bug was ever fully understood

   /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
bernie@fantasyfarm.com            Pearisburg, VA
    -->  Too many people, too few sheep  <--          


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

Date: Sat, 2 Dec 2000 18:19:14 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: perl and javascript
Message-Id: <slrn92if8p.hvd.efflandt@efflandt.xnet.com>

On Sat, 2 Dec 2000, Alex Thomas <alex.thomas@mindspring.com> wrote:
>is there a way to use perl and JavaScript so that an array created in perl
>can be accessed by JavaScript and vice-versa?

Most likely.  Perl is made for manipulating data, but you do not say what
vehicle you are using to transport the data between them.  'perldoc
perlipc' lists a number of methods that processes can use for
communication, from sockets to named pipes (fifo) that can be read and
written to like a regular file.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Sat, 2 Dec 2000 18:31:58 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Printing to System Que
Message-Id: <slrn92ig0k.hvd.efflandt@efflandt.xnet.com>

On Sat, 02 Dec 2000, Rudy Hermawan <rhermawan@kafelinux.com> wrote:
>
>Pls guide me to print to system queue.
>
>My code is printing directly to the local printer.
>
>
>=========
>
>open (STDPRT, ">/dev/lp0");
>
>print STDPRT "This will be printed directly to the port.....";
>
>close (STDPRT);

Try this (if you have lpr set up properly):

open (PRN, "| /usr/bin/lpr") || die "Can't print: $!";
print PRN <<EOF;
This should print to the print spooler
and if your print filter is working
this will be on 3 lines at left margin.
EOF
close PRN;


-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Sat, 02 Dec 2000 18:04:20 GMT
From: rereidy@my-deja.com
Subject: Re: RE:Automation
Message-Id: <90bdj2$gh8$1@nnrp1.deja.com>

You need to look at the WIN32 modules (specifically Win32::OLE).  The
books Win32 Perl Scripting and Win32 Perl Programming have lots of
examples on the Win32 modules.


In article <909ajl$e4j$1@qvarsx.er.usgs.gov>,
  rrknight@usgs.gov wrote:
> I have managed to get the process to run (simple DOS style program).
But,
> When the program rns, it is waiting on commands from the user which I
> assume can be fed through the PERL script, but have yet to determine
the
> correct method for this.  Does anyone have any examples?
>
>


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


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

Date: Sat, 02 Dec 2000 15:56:47 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Should { } always indicate a scope?
Message-Id: <3A291F21.84B1DA02@home.com>


John Lin wrote:
> 
> "Ren Maddox" writes
> > "John Lin" writes:
> >
> > >     my @x = @{ 1,2,3,[4,5,6] };    # exactly the same BLOCK
> > >     print @x;
> > > syntax error at line 1, near "@{ "
> > > Execution aborted due to compilation errors.
> >
> > I found it interesting that adding parens *inside* the braces "fixes"
> > this:
> >
> >     my @x = @{ (1,2,3,[4,5,6]) };
> >     print "@x\n";
> > 4 5 6
> 
> They are different in meaning, right?  The parenthesis change the commas
> from "evaluate, throw away the result and return the right side"
> into "list element separator".

Not in general.  It is list context that changes the meaning of comma. 
Parentheses are rarely the architects of list context.  In 

    my @x = @{ 1,2,3,[4,5,6] };

@x should force list context on the expression to the right of =, and it
does.  @{ } should force scalar context on whatever is inside it since
it is looking for an identifier or an array ref.  There should be no
need for parentheses on the inside.  This appears to be a tokenizing bug
and also exists with

    my $x = ${ 1, 2, \3 };

If you put the reference \3 or [4,5,6] at the start of the expression,
then all works as expected, if not as wanted.  This can also be
"deambiguated" like

    my $x = ${ +1, 2, \3 };

This isn't much of a bug though, since if it were fixed you'd only end
up with "Useless use of a constant in void context" warnings anyway.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sat, 02 Dec 2000 17:27:32 GMT
From: garry@zweb.zvolve.net (Garry Williams)
Subject: Re: sorting a file...
Message-Id: <8iaW5.179$Xq5.9228@eagle.america.net>

On Fri, 01 Dec 2000 14:09:07 GMT, texasreddog@my-deja.com
<texasreddog@my-deja.com> wrote:
>I have a calendar script on our servers that contains a text file of
>events.  The file looks like this:
>
>#id|datestamp|label|description
>29|20001206|Holiday Party|Location ???
>30|20001225|Christmas Day|Office Closed
>31|20001226|Christmas Holiday|Office Closed
>33|20001227|Out Of Office|Joe Blow - Vacation
>34|20001228|Out Of Office|Joe Blow - Vacation
>35|20010101|New Years Day|Office Closed
>36|20001207|Annual Stockholders Meeting |10:00am
>37|20001201|Jane Doe - doctor's appt|11:00 doctor's appt.
>
>I want to be able to sort this file by id & datestamp, because the e-
>...
>If anyone knows of a better sort solution than this, let me know.

    $ sort -t\| -k1,1 -k2,2 <unsorted-filename >sorted-filename

-- 
Garry Williams


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

Date: Sat, 02 Dec 2000 18:07:49 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: sorting a file...
Message-Id: <3A293DD7.F2996D24@home.com>


Garry Williams wrote:
> 
> On Fri, 01 Dec 2000 14:09:07 GMT, texasreddog@my-deja.com
> <texasreddog@my-deja.com> wrote:
> >
> >#id|datestamp|label|description
> >29|20001206|Holiday Party|Location ???
> >30|20001225|Christmas Day|Office Closed

> >
> >I want to be able to sort this file by id & datestamp, because the e-
> >...
> >If anyone knows of a better sort solution than this, let me know.
> 
>     $ sort -t\| -k1,1 -k2,2 <unsorted-filename >sorted-filename

That might as well be

    $ sort unsorted-filename >sorted-filename

But it probably really should be 

    $ sort -t\| -k1n,2 unsorted-filename >sorted-filename

or, if your sort(1) orders otherwise equal lines by all bytes:

    $ sort -n unsorted-filename >sorted-filename

ObPerl:

Perl's sort function is for sorting lists, not files.  Files should not
be processed as lists.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sat, 02 Dec 2000 18:34:56 GMT
From: garry@zweb.zvolve.net (Garry Williams)
Subject: Re: sorting a file...
Message-Id: <khbW5.207$Xq5.9432@eagle.america.net>

On Sat, 02 Dec 2000 18:07:49 GMT, Rick Delaney <rick.delaney@home.com> wrote:
>
>Garry Williams wrote:
>> 
>> On Fri, 01 Dec 2000 14:09:07 GMT, texasreddog@my-deja.com
>> <texasreddog@my-deja.com> wrote:
>> >
>> >#id|datestamp|label|description
>> >29|20001206|Holiday Party|Location ???
>> >30|20001225|Christmas Day|Office Closed
>
>> >
>> >I want to be able to sort this file by id & datestamp, because the e-
>> >...
>> >If anyone knows of a better sort solution than this, let me know.
>> 
>>     $ sort -t\| -k1,1 -k2,2 <unsorted-filename >sorted-filename
>
>That might as well be
>
>    $ sort unsorted-filename >sorted-filename

Not unless the first field is a fixed length field.  

>But it probably really should be 
>
>    $ sort -t\| -k1n,2 unsorted-filename >sorted-filename

The data sample indicated that there were non-numeric values in the
first field.  

-- 
Garry Williams


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

Date: Sat, 02 Dec 2000 17:44:05 GMT
From: garry@zweb.zvolve.net (Garry Williams)
Subject: Re: Sorting the result of a function
Message-Id: <FxaW5.194$Xq5.9662@eagle.america.net>

On Thu, 30 Nov 2000 17:08:05 GMT, John Wiersba <jrw32982@my-deja.com> wrote:
>How can I sort the (list) result of a function without assigning it to a
>temporary variable?  ...
>
>   perl -e 'sub f { (3,2,1) } @a = sort   f() ; print "@a\n"'

    perl -wle 'sub f { (3,2,1) } print join " ", sort +f()'

>Why doesn't sort produce the expected result

Because sort interprets `f()' as a compare function.  

See the sort() entry in the perlfunc manual page.  

-- 
Garry Williams


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

Date: Sat, 02 Dec 2000 17:49:25 GMT
From: garry@zweb.zvolve.net (Garry Williams)
Subject: Re: Sorting the result of a function
Message-Id: <FCaW5.200$Xq5.9662@eagle.america.net>

On 30 Nov 2000 19:36:09 +0000, nobull@mail.com <nobull@mail.com> wrote:
>Wolfgang Hielscher <W.Hielscher@mssys.com> writes:
>
>> I don't know if it is the most "perlish" way, but you can fix the
>> problem by 
>> 
>> my @a = sort &f( 'foo', 'bar', 'baz' );	# sort LIST
>
>More Perlish ways:
>
>my @a = sort +f( 'foo', 'bar', 'baz' );
>my @a = sort (f( 'foo', 'bar', 'baz' ));

 $ perl -we 'my @a = sort (f( "foo", "bar", "baz" ))'
 sort (...) interpreted as function at -e line 1.
 Unquoted string "f" may clash with future reserved word at -e line 1.
 Undefined subroutine in sort at -e line 1.

-- 
Garry Williams


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

Date: Sat, 02 Dec 2000 14:01:47 -0500
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: splitting a string into an array and preserving the "\n"
Message-Id: <528i2tsf13ekrqbqft44u6t1knhlmn153u@news.supernews.net>

kevin metcalf <xzrgpnys@yvtugubhfrovm.pbz> wrote:

} 
} So your saying that because people use America Online, we have to start
} dumming down our vocabulary to greet them?

No, *EVERYONE* (except tom and perhaps you) uses "online" (in an
unrestricted sense) to mean somehow relating to the Internet these days.  I
don't want to belabor this silly side issue any more, but when most of the
'online' users did so through shell accounts [or the equivalent on other
operating systems] saying things like "man THIS" [for unix fans] wasn't a
bad start for 'online'.  But these days, even without AOL you have
Earthlink, and Mindspring and ATT Worldwide and millions and millions of
users for whom online means primarily "connected to the Internet" or
"accessible via the Internet"

} ...  When I read his post I see
} the 'kiddies' as being the uninformed that you are conversing with.

Not at all -- it is the sort-of-old-timers who *think* they have a hotline
to the truth and think they ought to be given the final say on common usage
to whom I was addressing my comments...  Virtually everyone else knew what
Bart meant [when he told me that he couldn't seem to find a copy of the
latest perlre "online"] and figured that it was decent of him to try to
help me locate a copy of a doc that I don't have available locally [Now
that I know what to look for, I did find a copy].

You and tom can talk to each other all you like and be constantly befuddled
by the usage of everyone else and believe that everyone else is wrong...

  /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
bernie@fantasyfarm.com            Pearisburg, VA
    -->  Too many people, too few sheep  <--          


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

Date: Sat, 02 Dec 2000 14:01:49 -0500
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: splitting a string into an array and preserving the "\n"
Message-Id: <ho8i2tg7rrg80lammbc251fenink7rhg5s@news.supernews.net>

"Ed Grosvenor" <secursrver@hotmail.com> wrote:

} The fact is that those who hide behind technical jargon and semantics and
} would sooner criticize you for your misuse of the term "online" than answer
} your question are usually the least qualified to help you.

But that's wrong in this case.  The critic of the misuse of 'online' was
*TOM* and if there is anyone in this forum qualified to have helped me, it
is probably him [remember the original question: I'm not running 5.6 and so
I don't recognize what "(?<=" meant].  The *HELP* would be "there's a copy
of the latest perlre at <perlmongers> or <oreillly> or <redhat> and sending
me there to go RTFM on my own [which I would have happily done].

Advising me that on *HIS* system 'man perle' gets him a man page that
explains lookbehind operatos isn't very helpful no matter *how* you slice
things [the question of whether *TOM* knew what (?<= meant wasn't an
issue], and then couching that in a screed about how "it's online for *ME*
so you're misusing the term online" still strikes me as mean spirited,
unhelpful, and pedantic.

  /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
bernie@fantasyfarm.com            Pearisburg, VA
    -->  Too many people, too few sheep  <--          


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

Date: 2 Dec 2000 10:53:33 -0500
From: stanb@panix.com (Stan Brown)
Subject: Three dimensional hash? & iteration
Message-Id: <90b5tt$pai$1@panix6.panix.com>

	I'm trying to do some thing like have a has that looks like this:

	%my_has{TABLE}{VALUYE}{STMT_HDL}

	What I want to do is iterate through this like:

	foreach $key keys(%my_hash{TABLE})
	(
		foreach $key2{%my_has{hTABLE}{VALUE}
		(
			if (%my_hash{$key}{$key2} eq soemthing)
				print "found\n"
		)
	)


	But I am strugling with the exact syntax of this. 

	How can I do this?



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

Date: Sat, 02 Dec 2000 13:09:03 -0500
From: Joe Kline <jkline@one.net>
To: Stan Brown <stanb@panix.com>
Subject: Re: Three dimensional hash? & iteration
Message-Id: <3A293ABF.93D18FDF@one.net>

[posted and mailed]

Stan Brown wrote:
> 
>         I'm trying to do some thing like have a has that looks like this:
> 
>         %my_has{TABLE}{VALUYE}{STMT_HDL}
> 
>         What I want to do is iterate through this like:
> 
>         foreach $key keys(%my_hash{TABLE})
>         (
>                 foreach $key2{%my_has{hTABLE}{VALUE}
>                 (
>                         if (%my_hash{$key}{$key2} eq soemthing)
>                                 print "found\n"
>                 )
>         )
> 

You're close. Did you try 'perldoc perldsc'?

A hash of hashes of hashes are really a hash of hashrefs of hashrefs.
The following is a good way to walk through hashes (Uri Guttman showed
me the light on this one):

my %my_hash = (
   'one' => {
            'a' => {
	           '1' => 'somethingelse',
	           '2' => 'something',
	           },
            'z' => {
	           '13' => 'somethingelse',
	           '32' => 'not it',
	           },
            },
   'two' => {
            'b' => {
	           '4' => 'nope',
	           },
            },
);
KEY2:while( my ($key2, $ref2) = each %{ $my_hash{'one'} } )
{
   print "key2: $key2\n";

   KEY3:while ( my ( $key3, $value3) = each %{ $ref2 } )
   {
      print "key3: $key3\n";
      print "found\n" if ( $value3 eq 'something' );
   } # KEY3
} # KEY2

However, if you are walking the entire hash then it would look like:

KEY1:while (my ( $key1, $ref1) = each %my_hash)
{
   KEY2:while( my ($key2, $ref2) = each %{ $ref1 } )
   {
      print "key2: $key2\n";

      KEY3:while ( my ( $key3, $value3) = each %{ $ref2 } )
      {
         print "key3: $key3\n";
         print "found\n" if ( $value3 eq 'something' );
      } # KEY3
   } # KEY2
} # KEY1


Definitely read the documentation pertaining to references and data
structures.

-- 
Joe Kline

It takes a lot of brains to enjoy satire, humor, and wit;
but none to be offended by them.  ---The Midnight Skulker


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

Date: Fri, 1 Dec 2000 08:30:55 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: URL Get targeting HTTPS . . .
Message-Id: <G4vrnJ.LsG@news.muni.cz>

On Thu, 30 Nov 2000 23:43:45 GMT, Ameen Dausha <ameen@dausha.net> wrote:
> How would I go about accessing HTTPS in Perl? In a discussion today
> with some peers I was told it was impossible in Perl without using an
> unreliable hack.

What doesn't work for you?

	$ perl -MLWP::Simple -e 'getprint "https://pause.kbx.de/pause/"'

prints the output happily.

Yours,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: Sat, 2 Dec 2000 09:41:24 -0700
From: "bowman" <bowman@montana.com>
Subject: Re: Using goto
Message-Id: <1y9W5.1157$NN6.506@newsfeed.slurp.net>


Shawn Smith <SPAM_loginprompt@yahoo.com> wrote
>
> Yes. Rereading the camel it said (something like) for maintainability
> gotos should be avoided.

I am not fond of goto, but at the end of the day, you are using the
construct a lot,
although it is usually dressed up in finer clothing. At the assembler level,
the
various relative and absolute jmp instructions are gotos. setjmp and friends
are complex variations, as are most of the try/catch constructs.

Sure, they can be abused, but in many cases they will make for clearer and
more
robust error handling than deeply nested conditionals.

If you want to attack anything, the pages long functions are the place to
start.
I violate my own rule constantly, but ideally I like to see the entire
function in the
fifty lines I usually have displayed in gvim.





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

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


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