[19168] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1363 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 23 21:05:47 2001

Date: Mon, 23 Jul 2001 18:05:08 -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: <995936707-v10-i1363@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 23 Jul 2001     Volume: 10 Number: 1363

Today's topics:
        Active Drectory <subscriber@novastar.dtdns.net>
    Re: Any perl module for XML Explorer tree display/edit? <mel2000@hotmaildot.com>
        Connecting to POP3 via Mail::POP3Client <barry@website.ws>
    Re: don't laugh (Abigail)
    Re: dumb question (Abigail)
    Re: dumb question (Abigail)
    Re: dumb question <godzilla@stomp.stomp.tokyo>
    Re: Escaped period! Someone apprehend it! (Joe Smith)
        FAQ: How do I perform an operation on a series of integ <faq@denver.pm.org>
    Re: getting users ip (Joe Smith)
    Re: How do I count the number of characters in a string (Joe Smith)
    Re: How do I count the number of characters in a string <subscriber@novastar.dtdns.net>
    Re: ksh script porting problem <ronh@iainc.com>
    Re: Large Filesystem Scrubbers <ddunham@redwood.taos.com>
    Re: manpage styles/templates??? <no@mail.addr>
    Re: newbie: storing multiple objects in a hash <buggs-clpm@splashground.de>
    Re: newbie: storing multiple objects in a hash (Logan Shaw)
    Re: newbie: storing multiple objects in a hash (Craig Berry)
    Re: sending commands <hoss@chungk.com>
    Re: sending commands (Logan Shaw)
    Re: Sorting an array of strings by 'closeness' to anoth (Logan Shaw)
    Re: Stupid Question ? How to test a form with post meth <buggs-clpm@splashground.de>
    Re: Tutorials? <ron@savage.net.au>
    Re: Who can help me about the confused (..) operator? <no@mail.addr>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 24 Jul 2001 01:49:37 +0300
From: "novastar" <subscriber@novastar.dtdns.net>
Subject: Active Drectory
Message-Id: <9ji9jm$q4k$1@usenet.otenet.gr>

How can I set / get info at w2k active directory ? netadmin can't do the job
 ...
TIA




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

Date: Mon, 23 Jul 2001 17:02:51 -0700
From: "M.L." <mel2000@hotmaildot.com>
Subject: Re: Any perl module for XML Explorer tree display/edit?
Message-Id: <9jie17$nms7a$1@ID-19545.news.dfncis.de>

> > I'm a newbie to XML currently reading up on various Perl modules to
> > manipulate XML. My first goal is to find a module that can easily slurp
an
> > XML tree into a hash, and then back to an XML tree. With all the
> > possibilities, I'm having trouble making up my mind.
>
> Use XML::Simple if that is all you are looking for.  It will create a
> perl like data structure and then dump it back to XML.
>

BINGO! That was the module I was going to use until I found a better
solution for my situation (see below).

> > After that task my greatest concern will be displaying and modifying the
> > tree. Ideally, I would like to:
> >
> > 1. Convert my spreadsheet-like database to an expanding/collapsing XML
> > folder tree resembling that of Windows Explorer
>
> Use XML::Excel or XML::SAXDriver::Excel to convert a spreadsheet to
> XML.
>
> > 2. Tree display should collapse to 1 folder by default (stylesheet
needed?)
> >
> > 3. User must be able to add new record(s) to top of folder tree just as
in
> > Explorer
>
> That you might have to code on your own, and is not very easy if you
> are talking about doing it in the browser.  But there must be apps to
> handle some part of this.
>
> > 4. User must be allowed to add new tag(s) to each record, but since each
> > record is symmetrical, each new tag must be added to all records/folders
in
> > the tree.
> >
> > I'd like to know if there is a Perl or Javascript module that can do
most of
> > what I am asking for as far as displaying and modifying the XML tree (as
> > well as slurping/restoring).

I found a tree-folding XML editor that does most of what I want, but I had
to make some major changes in my plans. Peter's XML Editor is Windows-only
solution that works off-line only. Since my database is small and will be
converted to pure XML, I decided to scrap my online database manager and
simply modify the XML database on my desktop, then upload it to my ISP. The
advantage is that I don't have to deal with password protection or
file-locking logic. In retrospect, I probably should have looked for an
off-line solution in the first place.

For reading the XML, I decided to use XML::EasyObj, which allows me more
control over creating the hash that the XML will be written into, does not
slurp the entire database, and appears to be even easier than XML::Simple.
My only concern is that it uses XML::DOM, which is quite large.

Thanks to everyone for their reply.




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

Date: Mon, 23 Jul 2001 17:53:22 -0700
From: "Barry Trottier" <barry@website.ws>
Subject: Connecting to POP3 via Mail::POP3Client
Message-Id: <3b5cc67d$0$148@wodc7nh6.news.uu.net>

I have an installation of qmail setup and everything is working fine.  I can
send and receive mail flawlessly!

However, I need to have POP3 access.

So, I did the POP3 setup.

After which I was able to "telnet localhost 110".  That seemed to work
flawlessly.

However, I wasn't able to connect via perl's "Mail::POP3Client".

Does anyone have any ideas?

Thanks in advance!




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

Date: 23 Jul 2001 23:05:26 GMT
From: abigail@foad.org (Abigail)
Subject: Re: don't laugh
Message-Id: <slrn9lpbf5.9a2.abigail@alexandra.xs4all.nl>

Steve Holland (holland@origo.ifa.au.dk) wrote on MMDCCCLXXIX September
MCMXCIII in <URL:news:w47ofqgbqiy.fsf@origo.ifa.au.dk>:
## abigail@foad.org (Abigail) writes:
## > Jeff Zucker (jeff@vpservices.com) wrote:
## 
## > -: 3. no big deal but all-caps are good for filehandles but bad for
## > -: variables just on legibility
## 
## > Is it? If you take a look in 'man perlvar' and look at the
## > predefined variables in Perl, you see that all caps variables
## > massively outnumber the all lowercase variables.
## 
##      These are predefined variables.  In general it is a good idea to
## reserve all-caps for the predefined variables so that they stand out
## from the user-defined and package-defined variables.  However,
## different folk have different tastes.


Ah, so, for non-predefined variables, it's good to use all lowercase
variables, except when they are filehandles, then they should be all
uppercase. Because predefined variables are all uppercase as well.
Or something like that.

I'm sorry, but I find the rules arbitrary and not actually based on
readability. They are a convention, and we could have used as a
convention that filenames only had vowels and other variables only
had consonants too.



Abigail
-- 
use   lib sub {($\) = split /\./ => pop; print $"};
eval "use Just" || eval "use another" || eval "use Perl" || eval "use Hacker";


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

Date: 23 Jul 2001 23:15:11 GMT
From: abigail@foad.org (Abigail)
Subject: Re: dumb question
Message-Id: <slrn9lpc1e.9a2.abigail@alexandra.xs4all.nl>

Greg Bacon (gbacon@HiWAAY.net) wrote on MMDCCCLXXX September MCMXCIII in
<URL:news:tlgjcet4ickba5@corp.supernews.com>:
@@ In article <m1bsmgyd43.fsf@halfdome.holdit.com>,
@@     Randal L. Schwartz <merlyn@stonehenge.com> wrote:
@@ 
@@ : >>>>> "sycorax" == sycorax  <taghatta@midway.uchicago.edu> writes:
@@ : 
@@ : sycorax> Thanks for the responses.  Actually, I'm afraid I didn't
@@ : sycorax> really ask the question I needed answered: what I really need
@@ : sycorax> to do is select a series of random keys from a hash whose
@@ : sycorax> corresponding values add to a particular sum.
@@ : 
@@ : Ahh! The knapsack problem. [...]
@@ 
@@ The 0/1 Knapsack problem is similar, but sycorax is describing
@@ SUBSET-SUM, which is, as you noted, NP-complete.


0/1 Knapsack is NP-complete too. SUBSET-SUM trivially reduces to
0/1 Knapsack.


Abigail
-- 
BEGIN {$^H {q} = sub {pop and pop and print pop}; $^H = 2**4.2**12}
"Just "; "another "; "Perl "; "Hacker\n";


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

Date: 23 Jul 2001 23:17:23 GMT
From: abigail@foad.org (Abigail)
Subject: Re: dumb question
Message-Id: <slrn9lpc5i.9a2.abigail@alexandra.xs4all.nl>

Andras Malatinszky (andras@mortgagestats.com) wrote on MMDCCCLXXX
September MCMXCIII in <URL:news:3B585A78.AE472A1E@mortgagestats.com>:
,, 
,, "Randal L. Schwartz" wrote:
,, 
,, > >>>>> "sycorax" == sycorax  <taghatta@midway.uchicago.edu> writes:
,, >
,, > sycorax> Thanks for the responses.  Actually, I'm afraid I didn't
,, > sycorax> really ask the question I needed answered: what I really need
,, > sycorax> to do is select a series of random keys from a hash whose
,, > sycorax> corresponding values add to a particular sum.
,, >
,, > Ahh! The knapsack problem.  That's provably unsolvable
,, 
,, Unless you are prepared to show that P != NP, I must assume you made a typo a
,, you really meant "probably unsolvable" :-)


Regardless whether of the status of P ?= NP, *all* NP problems are solvable.



Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


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

Date: Mon, 23 Jul 2001 17:48:32 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: dumb question
Message-Id: <3B5CC5E0.ECF29B54@stomp.stomp.tokyo>

Abigail wrote:
 
> Greg Bacon wrote:
> @@  Randal L. Schwartz wrote:
> @@ : >>>>> sycorax wrote:

> @@ : sycorax> Thanks for the responses.  Actually, I'm afraid I didn't
> @@ : sycorax> really ask the question I needed answered:

(snipped)

> 0/1 Knapsack is NP-complete too. SUBSET-SUM trivially reduces to
> 0/1 Knapsack.



This is a good time for enlightenment of sissified geeks.
For this thread, the originating author has described no
problem to solve but rather posted pure gibberish and,
quite entertaining, later posted a solution using a fake
name, a solution to a problem never described, a very
flawed solution at that.

In both articles posted by this lame troll, his wording was
such as to convey incoherent blatherings. This problem he
attempted to conceal so as not to give away his troll game,
cannot be determined to be any of the three classic time
complexity problems. He is not describing a classic polynomial
problem, nor a non-deterministic polynomial problem nor even
an expontential problem.

I am curioius why so many of you have made firm decisions
based on the idiotic blatherings of this troll. You have
zero parameters and no coherent description of his problem.

What this ignorant troll has accomplished is to establish a
classic Infinity Cube problem, which has nothing to do with
cubes but rather has to do with good Scientific Method, more
precisely, the critical importance of establishing extensive
and well defined parameters along with a well planned and
well worded description of a problem to solve.

Read, learn and become enlightened.

Given a large box, how many smaller boxes can be fit inside?

This problem has two answers, opposed to strict requirement
of a "yes" or "no" answer, Abigail's 0/1, for classic poly
type problems. For this large box, there is no solution and
a solution is an infinite amount of number sets. No parameters
have been set thus a reader sets the parameters.

Given a large box comprising forty cubic inches, how many smaller
boxes can fit inside? 

Some two answers; no solution, infinite solutions. No parameters
have been set displaying poor Scientific Method.

Given a large box comprising forty cubic inches and a set of
smaller boxes, forty at one cubic inch of volume, ten at four
cubic inches of volume and two at twenty cubic inches of volume,
how many smaller boxes will fit into the larger box?

For this there are also two solutions; no solution and a finite
solution set. Correct answer is no solution. Why this is correct
is no length, width and height parameters are set. It could very
well be none of the smaller boxes will fit into the larger box
being too tall, or too wide, or too deep or any combination.
Additionally, the finite solution set is extremely large; this
question does not ask what is the "minimum" or "maximum" number
of smaller boxes which will fit inside the larger box. This is
another display of poor Scientific Method; no concise parameters
and, no concise description of a problem.

Given a perfect cube comprising forty cubic inches of volume
and a smaller set of perfect cubes, forty at one cubic inch
of volume, ten at four cubic inches of volume and two at twenty
cubic inches of volume, what is the maximum number of smaller
cubes which will fit into the large cube of forty cubic inches?

All you geeks will provide "forty" as an answer. In response,
I will slip on my Star Fleet uniform and in my ever so typical
Captain Jamie Kirk voice, announce,

All of you are wrong. The correct answer is fifty-two.
No volumetric parameters have been set to establish any
cube wall thickness.

This originating author is a fake, a troll and has posted
nothing but nonsense in both of his articles. He has only
succeeded in describing a classic teacher's lesson about
the dangers of not describing a problem precisely and
not providing clear and concise parameters. He has created
the classic Infinity Cube lesson, which I have taught
innumerable times over the years and, have briefly taught
you with hopes of your enlightenment.

Again, I am curious how all of you translated the originating
author's idiotic blatherings into a non-deterministic polynomial
problem, either hard or complete, very curious.


Godzilla!  Queen Of Infinity.


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

Date: Mon, 23 Jul 2001 22:17:05 +0000 (UTC)
From: inwap@best.com (Joe Smith)
Subject: Re: Escaped period! Someone apprehend it!
Message-Id: <9ji7p1$2k3c$1@nntp1.ba.best.com>

In article <JMZ67.3974$LP2.418733@bgtnsc06-news.ops.worldnet.att.net>,
Jay <ReplyToTheGroup@DoNotEmailMe.Com> wrote:
>Steve Holland <holland@origo.ifa.au.dk> wrote in message
>news:w47puar5y9j.fsf@origo.ifa.au.dk...
>| "Jay" <ReplyToTheGroup@DoNotEmailMe.Com> writes:
>|
>| >     Sorry for the pun in the subject.  I had the following in a program.
>|
>|      Don't be.  Puns are the highest form of humour.
>|
>|
>| > if(/\d+\.?\d+/) {
>| >     print "OK!";
>| > }
>|
>| > Now what I wanted was it to accept numbers which can be either whole
>| > numbers or decimal numbers(hence the period).  This doesn't work,
>| > though.  It accepts numbers alright, and anything else too.  If I
>| > put it as /\d+\.\d+/ it works fine, but then the decimal is
>| > required(not what I wanted).  Shouldn't adding the ? make it so it
>| > accepts one or more numbers zero or one decimal and one or more
>| > numbers?  Obviously not, otherwise I wouldn't be here.  I appreciate
>| > any help.
>|
>| print "OK!" if ( /\d+\.*\d+/ );
>| print "OK!" if ( \/d*\.*\d*/ ); # if you want to accept .39 or 89. as
>valid.
>
>I tried that, but it seems to accept anything also.  I tried
>
>12fd32
>43.....12
>etc.
>
>All return TRUE, which aren't right.  I can't figure it out for nothing.

0) Optional minus sign.
1) String of digits, a period, then 0 or more digits.
2) A period followed by 1 or more digits
3) Digits only

	print "OK!" if /^-?(\d+\.\d*|\.\d+|\d+)$/;

		-Joe

--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Tue, 24 Jul 2001 00:16:53 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I perform an operation on a series of integers?
Message-Id: <V7377.6$os9.170716672@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  How do I perform an operation on a series of integers?

    To call a function on each element in an array, and collect the results,
    use:

        @results = map { my_func($_) } @array;

    For example:

        @triple = map { 3 * $_ } @single;

    To call a function on each element of an array, but ignore the results:

        foreach $iterator (@array) {
            some_func($iterator);
        }

    To call a function on each integer in a (small) range, you can use:

        @results = map { some_func($_) } (5 .. 25);

    but you should be aware that the ".." operator creates an array of all
    integers in the range. This can take a lot of memory for large ranges.
    Instead use:

        @results = ();
        for ($i=5; $i < 500_005; $i++) {
            push(@results, some_func($i));
        }

    This situation has been fixed in Perl5.005. Use of ".." in a "for" loop
    will iterate over the range, without creating the entire range.

        for my $i (5 .. 500_005) {
            push(@results, some_func($i));
        }

    will not create a list of 500,000 integers.

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           04.07
-- 
    This space intentionally left blank


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

Date: Mon, 23 Jul 2001 22:39:51 +0000 (UTC)
From: inwap@best.com (Joe Smith)
Subject: Re: getting users ip
Message-Id: <9ji93n$2kn6$1@nntp1.ba.best.com>

In article <3B5B98F6.21D02821@playground.net>,
Chris Micallef  <cmicallef@playground.net> wrote:
>I am using perl to write cgi scripts for a web page.
>
>Can some one explain to me how and why the following code successfully
>obtains users ip.
>
>$RemoteHost = (gethostbyaddr(pack('C4',$1,$2,$3,$4),2))[0] ||
>$ENV{'REMOTE_ADDR'};

It doesn't.  It obtains the user's host name.

  # Split "204.71.200.67" into four parts
  $ENV{REMOTE_ADDR} =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/;

  # Pack the four sets of 8-bit numbers into a single 32-bit string
  $ip_addr_32bits = pack 'C4',$1,$2,$3,$4;

  # Get list of host names and aliases for this addr in INET domain
  @hostnames = gethostbyaddr $ip_addr_32bits,2;

  # Use IP address if gethostbyaddr() was not able to find a host name
  $RemoteHost = $hostnames[0] || $ENV{REMOTE_ADDR};

	-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Mon, 23 Jul 2001 22:27:19 +0000 (UTC)
From: inwap@best.com (Joe Smith)
Subject: Re: How do I count the number of characters in a string
Message-Id: <9ji8c7$2kcv$1@nntp1.ba.best.com>

In article <3B5C0795.A79D7050@csc.liv.ac.uk>,
J.D. Fieldsend <u9jdf@csc.liv.ac.uk> wrote:
>Hi
>
>I want to be able to tabulate text without knowing beforehand how many
>characters are in each string.

Start tabulating after you know the maximum lengths of each string.

For instance:
	Read input data from file one line at a time.
	Split line into fields.
	Use the length() operator on the fields one at a time, memorize
	  the maximum width for each.
	Place record into an array of arrays.
	Loop back to top until end of data.
	Based on column widths, output table header.
	For each row in the array of arrays, output the fields.

		-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Tue, 24 Jul 2001 01:44:02 +0300
From: "novastar" <subscriber@novastar.dtdns.net>
Subject: Re: How do I count the number of characters in a string
Message-Id: <9ji997$pud$1@usenet.otenet.gr>

you could also do th following
print $myline=~s/././g ;

"J.D. Fieldsend" <u9jdf@csc.liv.ac.uk> wrote in message
news:3B5C0795.A79D7050@csc.liv.ac.uk...
> Hi
>
> I want to be able to tabulate text without knowing beforehand how many
> characters are in each string.
>
> Thanks
>
> John




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

Date: Tue, 24 Jul 2001 00:04:00 GMT
From: "Ron Hartikka" <ronh@iainc.com>
Subject: Re: ksh script porting problem
Message-Id: <QX277.16931$bU6.313656@typhoon.mw.mediaone.net>


If it is ok for these environment vars to be defined from the beginning of
the perl script try invoking your script this way:

prompt%. env_file_1; . env_file_2; perl script.pl

If VAR is defined in one of the files, you can now get at its value in
perl's built in %ENV hash as  $ENV{VAR}.

If it is not ok for these environment variables to be defined from the
beginning of the perl script,  you could divide the perl script into
multiple perl scripts. Each perl script would end by exec'ing a shell
script. The shell script(s) dot in an env_file and exec next bit of perl on
one line.

You can also make the multiple perl scripts in to one. It branches either to
get the env_file's or use them depending on whether the vars are defined.

Or....you can write perl code to put parse the env_file's; something like:

open(ENV_FILE, "env_file_1");
while (<ENV_FILE>){
    ($key, $value) = split "=";
    $ENV{$key} = $value;

}

Don't take my word for it; there is a more complete example of this in
Recipe 8.16 of the Perl Cookbook.


"John Blevin" <blevin@lucent.com> wrote in message
news:3B5C943D.40191A07@lucent.com...
> I have a UNIX ksh script that I would like to port to perl.
> The ksh script has a few lines like:
>
> . env_file_1
> . env_file_2
>
> It is "dotting in" these environment configuration files which define
> environment variables used in this script.
>
> I would like to port over this script without yet having to change these
> environment files.  Is there a way I can port over these lines?  The
system(),
> exec() and backtick don't work.
>
> Thanks!
>
> - John




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

Date: Mon, 23 Jul 2001 23:21:50 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Large Filesystem Scrubbers
Message-Id: <ik277.211877$qv3.48090422@nnrp5-w.sbc.net>

Rob Kirby <kirbyr@ucar.edu> wrote:
> Hi,

> We have a relatively large GPFS filesystem that we support (~2TB), 
> and we have a home grown filesystem scrubber which will get rid of files
> based on thresholds, i.e. if %utilization reaches a certain high 
> level then the scrubber will scrub the oldest files down to 
> a certain low level. Also, it supports an "exempt" list for
> those files and users who are exempt from the scrubber. That's
> it in a nutshell. 

> The problem I currently have though is that I have inherited the 
> scrubber and it was written by different people no longer involved 
> and consists of a half dozen home-brew utilities written very generically, 
> to work on other platforms besides AIX. I would like to convert the
> whole thing from C code into Perl code, but I fear that performance
> will suffer seeings how I need to walk the complete tree and stat every
> single file, excluding open files, then sorting on the oldest files 
> first.......... if you catch my drift ;-)

I doubt that the C code can 'stat' or 'open' any faster than the perl
can, and that's probably the slow part.  Unless you change your
algorithms so that you do things stupidly in the perl program (use
O(n^2) stuff), the performance is likely to be almost identical.

> My question for the forum is, given a 1TB or greater size 
> filesystem, is there anything out there that anyone is using
> that claims to have good performance on tera scale filesystems, 
> that will do what our scrubber is doing?

Try to avoid needing to read in or sort contents.  If you can design
your scrubber to operate while doing a treewalk, you should be fine.

-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
          < How are you gentlemen!! Take off every '.SIG'!! >


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

Date: Tue, 24 Jul 2001 08:29:35 +0800
From: MMX166+2.1G HD <no@mail.addr>
Subject: Re: manpage styles/templates???
Message-Id: <066nltov73ko1mbaudu2orsr365v83merk@4ax.com>

thanks.
yes I know the usage. but I can't find the pod file.(for
NEWS:NNTPClient) What shall I do? write one myself?
--
On Sun, 22 Jul 2001 18:22:27 -0700, in comp.lang.perl.misc Jeff Zucker
<jeff@vpservices.com> wrote:

>This is a somewhat recursive answer, but pod2html has its own pod so
>this will tell you how to use it:
>
>   perldoc pod2html
>
>You'll notice that the syntax uses --infile and --outfile.



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

Date: Tue, 24 Jul 2001 00:16:25 +0200
From: Buggs <buggs-clpm@splashground.de>
Subject: Re: newbie: storing multiple objects in a hash
Message-Id: <9ji7ev$p7i$07$1@news.t-online.com>

Joe Smith wrote:

> In article <VI077.429460$6b.16636998@Flipper>,
> Rolf Deenen <r.deenen@chello.nl> wrote:
>>
--snip--
>>Like:
>>user1: John Doe, jdoe@hotmail.com, 01234-567890
>>user2: Bert Smith, bsmith@netscape.com, 56789-012345
>>
>>I'm having trouble visualising this...
> 
> Use a hash of hashes.
> 
> $key = "user001";
> $name="John Doe";
> $email='jdoe@hotmail.com';
> $phone="01234-567890";
> $users{$key} = { name => $name, email => $email, phone => $phone };
> 
> is the same as
> 
> $users{"user001"}{"name"} = "John Doe";
> $users{"user001"}{"email"} = 'jdoe@hotmail.com';
> $users{"user001"}{"phone"} = "01234-567890";

Or to save a hash use an array
$users[0]{"name"} = "John Doe";
$users[1]{"name"} = "Jane Doe";

and see
perldoc perldsc
perldoc perllol


Buggs


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

Date: 23 Jul 2001 17:22:42 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: newbie: storing multiple objects in a hash
Message-Id: <9ji83i$2la$1@charity.cs.utexas.edu>

In article <VI077.429460$6b.16636998@Flipper>,
Rolf Deenen <r.deenen@chello.nl> wrote:
>
>Hi,
>
>'m just starting to getting to learn perl and i have a small question about
>storing data in a hash.
>You can store object-pairs in a hash like in this example:
>
>%users (name, John Doe, email, jdoe@hotmail.com, telephone, 01234-567890)
>
>In this fasion it is possible to recall variables by there "type", like name
>or telephone-number...
>$johndoe_telephone=%users[telephone];

Yes, except that the syntax is wrong and should be this instead:

	$johndoe_telephone = $users{telephone};

>But what happens when I want to put in more than one users in a hash and how
>can i recall them?

You can't really do that.

However, you can store a list of hashes.  Think of it as doing this:

	$user1{name} = "John Doe";
	$user1{email} = "jdoe@hotmail.com";
	$user2{name} = "Bert Smith";
	$user2{email} = "bsmith@netscape.com";

Only, instead of having separate names for each hash, you create
hashes without names at all, and store those hashes in an array.

Of course, you have to have *some* way to refer to the hashes if they
don't have names.  Perl handles this by allowing you to create a scalar
value called a reference; this reference can be stored anywhere that a
regular scalar (i.e. string or number) can be.  References are a lot
like pointers in languages like C and C++, but they're different
because sometimes they're automatically created when you need them and
sometimes they're automatically destroyed when you no longer need
them.

So, even though arrays only contain scalars, those scalars can be
references to hashes, so an array can be used as if it contains a
bunch of hashes.

The syntax you'd want to use woul be something like this:

	$users[0]{name} = "John Doe";
	$users[0]{email} = "jdoe@hotmail.com";
	$users[1]{name} = "Bert Smith";
	$users[1]{email} = "bsmith@netscape.com";

There's a lot more to explain about this, including an alternate way of
creating the same data structure:

	$users[0] = { name => "John Doe", email => "jdoe@hotmail.com" };
	$users[1] = { name => "Bert Smith", email => "bsmith@netscape.com" };

Or even this:

	@users =
	(
		{ name => "John Doe", email => "jdoe@hotmail.com" },
		{ name => "Bert Smith", email => "bsmith@netscape.com" }
	);

I don't have time to explain all of it.  The best thing to do
is to read the tutorial on this subject that comes with Perl.
Do a "perldoc perlreftut" for that tutorial.  Then, when you
need to know more, do a "perldoc perlref" for the full story.

Hope that helps.

  - Logan
-- 
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)


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

Date: Mon, 23 Jul 2001 22:31:35 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: newbie: storing multiple objects in a hash
Message-Id: <tlp9e7q2j011e7@corp.supernews.com>

Rolf Deenen (r.deenen@chello.nl) wrote:
: I'm just starting to getting to learn perl and i have a small question
: about storing data in a hash. You can store object-pairs in a hash like
: in this example:
: 
: %users (name, John Doe, email, jdoe@hotmail.com, telephone, 01234-567890)

To avoid irrelevant criticisms, it's usually best to use syntactically
correct code even in examples like this.  So:

  %users = ( name      => 'John Doe',
             email     => 'jdoe@hotmail.com',
             telephone => '01234-567890' );

: In this fasion it is possible to recall variables by there "type", like name
: or telephone-number...
: $johndoe_telephone=%users[telephone];

Not quite:

  $johndoe_telephone = $users{telephone};

: But what happens when I want to put in more than one users in a hash and how
: can i recall them?

See perllol for details.  The general idea is you figure out which item is
your "primary key" (a unique identifier for the record), make that the
hash key, and store the other fields in a hash by reference.  Note that
given name is usually a bad choice for primary key, since the world is
filled with John Smiths, but we'll stick with that key for this example.

  %users = ( 'John Doe',  { email     => 'jdoe@hotmail.com',
                            telephone => '01234-567890' },
             'Mary Zoe',  { email     => 'maryz@yahoo.com',
                            telephone => '987-654-3210' } );

  $marys_email = $users{'Mary Zoe'}{email};

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Brute force done fast enough looks slick."
   |             - William Purves


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

Date: Mon, 23 Jul 2001 22:20:36 GMT
From: "Devon Perez" <hoss@chungk.com>
Subject: Re: sending commands
Message-Id: <Uq177.38073$k33.3582570@typhoon.kc.rr.com>

how do i use that?


"Logan Shaw" <logan@cs.utexas.edu> wrote in message
news:9ji2br$pp3$1@charity.cs.utexas.edu...
> In article <Hn%67.35801$k33.3483200@typhoon.kc.rr.com>,
> Devon Perez <hoss@chungk.com> wrote:
> >how do i send a command to the operating system, with a cgi script?
>
> system().  I'm not sure why it should be any different from a CGI
> script than from some other script.
>
>   - Logan
> --
> "Our grandkids love that we get Roadrunner and digital cable."
> (Advertisement for Time Warner cable TV and internet access, July 2001)




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

Date: 23 Jul 2001 17:25:49 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: sending commands
Message-Id: <9ji89d$2qt$1@charity.cs.utexas.edu>

In article <Uq177.38073$k33.3582570@typhoon.kc.rr.com>,
Devon Perez <hoss@chungk.com> wrote:
>how do i use that?

It's kind of complicated.  "perldoc -f system" will give you the full
description.

Here's an example:

	system ("ls -l");

That assumes you're on Unix and you want to list the current
directory.  If you want the output from your command to be stored
into a variable instead of sent to your script's output, then
you'll probably want to use backticks instead, like this:

	$output = `ls -l`;

Documentation on that can be found by searching through the output of
"perldoc perlop".

  - Logan
-- 
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)


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

Date: 23 Jul 2001 17:36:05 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Sorting an array of strings by 'closeness' to another string
Message-Id: <9ji8sl$3ng$1@charity.cs.utexas.edu>

In article <f06plts0n3rdpig7u2moer3b7ess0s9e52@4ax.com>,
jbp  <jpixton@dircon.co.uk> wrote:
>Howdy
>
>I have a string containing, say, 'transeint' (sic). After some
>massaging the string a little, then grepping a dictionary, then some
>more massaging, i get an array of strings like so:
>
>anastasia
>anisettes
>anteaters
>assassins
>assistant
>easterner
  :
  :
>testiness
>transient
>treatises
>trinities
>triteness
>
>Now, what I want to do is sort this array into an order such that the
>ones near the top of the array (viewing it as a stack) are:
>
>transient
>treatises
>trinities
>... etc

If you're going to sort in the traditional sense, then you have to have
a function that can always compare two items and tell you which one
comes first.  In other words, you have to have an ordering defined.
In other other words, I'm not sure what you're trying to accomplish.

>How would I go about this? I've looked at String::Approx and one of
>the functions would be ideal, except I can't install the module on my
>host (the goddamn service provider won't do it).

"The service provider won't" and "I can't" aren't equivalent,
especially if you can login to the web server.

  - Logan
-- 
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)


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

Date: Tue, 24 Jul 2001 00:53:39 +0200
From: Buggs <buggs-clpm@splashground.de>
Subject: Re: Stupid Question ? How to test a form with post method only ?
Message-Id: <9ji9ku$crl$01$1@news.t-online.com>

Jeff Zucker wrote:

> Buggs wrote:
>> 
>> Kev wrote:
>> 
>> > Hi All
>> >
>> > We have the following scenario-
>> > . We would like to test a script that we have
>> > which can only be accessed via a form using the
>> > post method.
> 
> Anything that can be accessed by the post method can be accessed without
> a form.  That's one of the reasons never to depend on client-side
> scripting to clean forms for you.
> 
>> 
>> I doubt one can't do a POST without a form.
> 
> If your triple negative means that yes, one *can* do a POST without a
> form, then you are correct:
--snip--
>> Sorry, but maybe you should ask in a more CGI centered NG,
>> after reading a bit about CGI itself.
> 
> Why?  There is a perfectly perlish answer.

I also wonder why.
Now if we could only answer
question number two.

Buggs


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

Date: Tue, 24 Jul 2001 10:32:56 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Tutorials?
Message-Id: <Lp377.96857$Rr4.538546@ozemail.com.au>

http://savage.net.au/Perl-tutorials.html

--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html





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

Date: Tue, 24 Jul 2001 08:29:47 +0800
From: MMX166+2.1G HD <no@mail.addr>
Subject: Re: Who can help me about the confused (..) operator?
Message-Id: <iknnltsp1faoqt5p8et8qs13rpspb4kr4a@4ax.com>

btw:what a strange complex signature. I see it in many posts. Is it
used for a special "perl" news reader? what's that? Agent?
--
On Sat, 21 Jul 2001 04:55:03 GMT, in comp.lang.perl.misc
mjd@plover.com (Mark Jason Dominus) wrote:

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



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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


------------------------------
End of Perl-Users Digest V10 Issue 1363
***************************************


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