[7661] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1287 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 7 21:07:17 1997

Date: Fri, 7 Nov 97 18:00:31 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 7 Nov 1997     Volume: 8 Number: 1287

Today's topics:
     Re: An excellent example of perl madness (or "split stu <markm@nortel.ca>
     Better Way in Perl <curtis@ei.kodak.com>
     Re: Better Way in Perl (brian d foy)
     Re: Chomp vs Chop (Faust Gertz)
     Re: Chomp vs Chop <allman@pat.lgb.cal.boeing.com>
     Re: CPAN confusion <randy@theory.uwinnipeg.ca>
     Decimal rounding and lining up decimals? (Jeff Hughes)
     Re: Decimal rounding and lining up decimals? (Mike Stok)
     Re: Declare hash of hashes in Perl4 <seay@hol.fr>
     eliminate all but a certain string jsd@bud.com
     Re: eliminate all but a certain string (brian d foy)
     Re: Getting bash history in Perl scripts <seay@hol.fr>
     glob not working (Umm)
     Re: glob not working (Faust Gertz)
     Intricate Sort help needed <hd-fxsts@liii.com>
     Re: IRIX (5.3/6.2), PERL, APACHE problem!!!! HELP !!!! <libeson@pdb.pdb.bnl.gov>
     is it possible to reference a sub-array? (Umm)
     Newbie Q: Perl @HASH and C Structures <zeropage@computek.net>
     Re: Newbie Q: Perl @HASH and C Structures <seay@hol.fr>
     Re: object serialization <tw36027@glaxowellcome.com>
     One slice of hash, please... <prl2@lehigh.edu>
     Re: One slice of hash, please... (Mike Stok)
     passing hash references to subs (Darwin O.V. Alonso)
     Re: passing hash references to subs (Mike Heins)
     Perl + Lotus Notes <Jan@chipnet.cz>
     Re: Perl 553 Malformed Header error <susan.cassidy@sandiegoca.ncr.com>
     Re: Perl/NT file rights, how do I... <see.my.sig@nospam.com>
     Re: Puzzle: palindromep (Peter Scott)
     Re: Regular Expressions <gnew@southernvirginia.edu>
     Re: Self-Modifying Perl Scripts (John Moreno)
     Re: Sorting and Counting with PERL <friedman@uci.edu>
     Re: Traversing a directory tree in Perl (Paul D. Smith)
     Re: Traversing a directory tree in Perl (John M. Klassa)
     Re: Traversing a directory tree in Perl (Jon Orwant)
     Re: Undefining an associative array element <seay@hol.fr>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 07 Nov 1997 13:39:56 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: An excellent example of perl madness (or "split stupidity")
Message-Id: <lq1g1p8v98j.fsf@bmerhe83.nortel.ca>

Gary Howland <ghowland@hotlava.com> writes:
> Randal Schwartz wrote:
> > You just don't seem to realize two things:
> >         1) the first arg to split is *always* a regex
> >         2) the | char is special in a regex
> Ah, I didn't realise that it was always a regex, and I thought that
> because this doesn't work:
> 	print join(", ", split("\s", "hello world")), "\n";
> but this does:
> 	print join(", ", split(/\s/, "hello world")), "\n";
> I reasoned that the first failed because it wasn't a regex,
> whereas I now know it failed because I'm trying to split on 's'.
>
> Life would be so much clearer if perl just refused to coerce these
> strings into regexs, and made me type them explicitly ...

I do find myself wishing at times that split() could be passed a non regular
expression, for reasons of clarity and most of all... for SPEED.

    split(/:/, "this:is:a:big:long:blah:blah:blah:blah:blah:blah");

I would think that using a regexp here is much slower than:

    split(":", "this:is:a:big:long:blah:blah:blah:blah:blah:blah");

But as of now, it's still a regexp. (unless underneath it's optimized?
there are NO special characters so it could assume the regexp was a literal
string that could search for the delimiter at a much faster speed.
(Does it do this?)

cyall :-)
mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: Fri, 07 Nov 1997 17:36:51 -0500
From: Walker Curtis <curtis@ei.kodak.com>
Subject: Better Way in Perl
Message-Id: <34639803.A2960A9F@ei.kodak.com>

I involved myself in a spirited competition to come up
with the shortest one liner that could be run from the
average tcsh,csh,ksh and sh shell.

The idea is to come up with the shortest on line way to strip
a '.cin' from each file in a directory containing
thousands of files.

There are files such as  '.cin' '88cin' '4.cinn' '6.cin.cin' also
in the directory.  There can't be any errors here.
There are also no aliases, custom programs, etc... being used.

The current best here is a 41 character perl hack that I came up with.

perl -e 'for(<*>){`mv $_ $\``if/\.cin$/}'

The closest competition is a 42 character non-perl runner up.

ls -1 *.cin|sed 's/\(.*\)\..*/mv & \1/'|sh

Does someone know of a short way, white space counts.

If someone has a real phenomenal answer, I'll send you a t-shirt.

-wc




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

Date: Fri, 07 Nov 1997 18:06:04 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Better Way in Perl
Message-Id: <comdog-ya02408000R0711971806040001@news.panix.com>

In article <34639803.A2960A9F@ei.kodak.com>, Walker Curtis <curtis@ei.kodak.com> wrote:

>I involved myself in a spirited competition to come up
>with the shortest one liner that could be run from the
>average tcsh,csh,ksh and sh shell.

>The current best here is a 41 character perl hack that I came up with.
>
>perl -e 'for(<*>){`mv $_ $\``if/\.cin$/}'

>Does someone know of a short way, white space counts.
>
>If someone has a real phenomenal answer, I'll send you a t-shirt.

% a

if you can use sed or perl, i can write a program called "a" to do it.
one letter from the command line. :)

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Fri, 07 Nov 1997 20:01:30 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Chomp vs Chop
Message-Id: <34687163.2374737@news.wwa.com>

On Fri, 07 Nov 1997 12:40:41 -0500, Matt Pezzuto <mpezzuto@link.com>
wrote:

>My one friend and I got in an argument about chomp vs chop.

Very bloody wars have be fought over this very topic.

>My one friend is an perl guru and I am a newbie and I'm 
>reading books and stuff.  Well,I few weeks ago I had my friend
>write a perl script for me and he used chop to get ride of an
>eol.  

Sounds legitimate.

>While I was learning perl I learned it was safer to use
>chomp if your only purpose is to get ride of an eol. 

Did you also learn TIMTOWTDI?

>I asked my friend why he didn't use chomp.  He didn't know about it
>and asked what it did and I told him. 

Some guru.

>But after thinking for a second he replied by saying,
>"When would ever not know what your chopping off?" 

Not a native speaker of english either.

>I failed to come up with an example and he claimed that using chomp was half-hazard
>way of programming because the programmer should know whether or
>not an eol is expected to not and chop is quicker than chomp because
>it doesn't have to check to make sure the last character is an eol.

I don't know if it is 'half-hazard' way of programming.  *chop* and
*chomp* are usually used to remove the newline character from the end
of a string and are probably almost always more efficient than
s/\n$//.  *chop* removes (and returns) the last character of the
string passed to it.  *chomp* removes the record separator, the value
of  $/, and returns the number of characters removed.  So they do
different things and return different things.    It is my feeling that
*chomp* is probably better to use than *chop* for removing newline
characters as it will only chop off the last character(s) if equal to
the value of $/ and thus takes care of some cross-platform issues.  On
Windows it will remove both the return character and the newline
character instead of just lobbing off the last character.  This might
be the type of example your guru friend was seeking.

>I replied with then why did they make chomp?  I do not totally agree
>with him but I have to admit that he has a point.  Who is right, the
>newbie or the guru?

You are both wrong.  :-)


Streben nach Wahrheit

Faust Gertz
Philosopher at Large

"Diego used to be a guard at the Museum of Modern Art. He was on the
night shift. His job was to go around the museum and tell people to
leave. Or, as he put it, 'Snap them out of their art trances.'
People who'd been standing in front of one thing for hours, he would
jump in front of them and snap his fingers, and he'd say, 'Time to
go.'"  -- Laurie Anderson, 'Time To Go (for Diego)'





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

Date: Fri, 7 Nov 1997 20:22:01 GMT
From: Mark Allman <allman@pat.lgb.cal.boeing.com>
Subject: Re: Chomp vs Chop
Message-Id: <34637869.1C050D84@pat.lgb.cal.boeing.com>

An example:  If you write a script to process certain text files,
and perhaps an instance of the text file is missing the newline
character(s) on the last line of the file, then chomp() wouldn't
harm the last line where chop() would.

The chomp() function is better to handle the unknown exception to
the rule that all lines end with an end-of-line sequence (<CR> on 
a Mac, <LF> on Unix, and <CR><LF> on Windows, by the way).  Using
chomp() instead of chop() results in a more "robust" program (said
with a sly smile).

-- Mark Allman
-- Sr. Engineer, The Boeing Company, allman@lgb.cal.boeing.com
-- Allman Professional Consulting, http://www.neosoft.com/~ghost/

Matt Pezzuto wrote:
> 
> My one friend and I got in an
> argument about chomp vs chop.
> My one friend is an perl guru
> and I am a newbie and I'm
> reading books and stuff.  Well,
> I few weeks ago I had my friend
> write a perl script for me and
> he used chop to get ride of an
> eol.  While I was learning perl
> I learned it was safer to use
> chomp if your only purpose is
> to get ride of an eol.  I asked
> my friend why he didn't use
> chomp.  He didn't know about it
> and asked what it did and I told
> him.  But after thinking for a
> second he replied by saying,
> "When would ever not know what
> your chopping off?"  I failed to
> come up with an example and he
> claimed that using chomp was half-hazard
> way of programming because the
> programmer should know whether or
> not an eol is expected to not and
> chop is quicker than chomp because
> it doesn't have to check to make
> sure the last character is an eol.
> I replied with then why did they
> make chomp?  I do not totally agree
> with him but I have to admit that
> he has a point.  Who is right, the
> newbie or the guru?


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

Date: Fri, 7 Nov 1997 15:20:58 -0600
From: Randy Kobes <randy@theory.uwinnipeg.ca>
To: "William R. Ward" <hermit@cats.ucsc.edu>
Subject: Re: CPAN confusion
Message-Id: <Pine.GSO.3.96.971107145943.19868A-100000@theory.uwinnipeg.ca>

On 5 Nov 1997, William R. Ward wrote:

> comdog@computerdog.com (brian d foy) writes:
> > In article <waan2jkyss9.fsf@am.UCSC.EDU>, hermit@cats.ucsc.edu (William R. Ward) wrote:
> > >Maybe I'm just missing something here, but I find CPAN to be a total
> > >pain in the ass to browse.  If I access the module list I am unable to
> > >find any documentation or detaile descriptions of the modules.  It
> > >seems to me that the package name should be a hyperlink to that
> > >package's manpage.  If I go to the author's page I can usually find
> > >the docs I'm looking for but it's awkward to do it that way.
> > 
> > PAUSE (Perl Authors Upload Server) automatically extracts the README
> > file from distributions and makes a link to it in that module's directory
> > (the filename ends in .readme).
> > 
> > It's not really a problem with CPAN since it already has the functionlity
> > you request.  If module authors use README files, or put more helpful
> > information in their README's (such as the SYNOPSIS of the POD), then you
> > would have the information that you want.
> 
> I want to be able to see detailed information, not just the README.
> Why ask authors to duplicate the POD contents in a README file when
> the documentation itself could be made available?
> 
> > However, I disagree that detailed information, such as the entire
> > manpage, should be made available on CPAN.  One can simply download
> > the module and run it through pod2man or another pod translator.  
> 
> That's asking an awful lot to find out whether a module does what I
> want.  I think having all the POD online and web-accessible would be a
> very good thing.
> 
> I think that CPAN is a good thing in general but I find that it is
> awkward to use through the web (does anyone still use ftp clients
> these days?) and could use some user interface improvements.
> 
> --Bill.
> 
> -- 
> William R Ward          Bay View Consulting   http://www.bayview.com/~hermit/
> hermit@bayview.com     1803 Mission St. #339        voicemail +1 408/479-4072
> hermit@cats.ucsc.edu  Santa Cruz CA 95060 USA           pager +1 408/458-8862
> 
> 

Hi,
   As also mentioned in
	http://www.per.com/CPAN/CPAN.html
there's a couple of search engines of CPAN, if the information can't
be found in this link itself. One is the WAIT text search of PAUSE at
	http://ls6-www.informatik.uni-dortmund.de/CPAN.html
which can search by a number of different types of fields; another is at
	http://theory.uwinnipeg.ca/search/cpan-search.html
which searches file, directory, module or script names throughout CPAN,
as well as providing an interface to an Excite-based search of the
perl documentation. As well, using the WAIT PAUSE system, we put
together an HTML collection of most of the module pod files; this is at
	http://theory.uwinnipeg.ca/CPAN/
which also can be searched via an Excite-based form.

			Best regards,
			Randy Kobes
	
Physics Department		Phone: 	   (204) 786-9399
University of Winnipeg		Fax: 	   (204) 774-4134
Winnipeg, Manitoba R3B 2E9	e-mail:	   randy@theory.uwinnipeg.ca
Canada				WWW/ftp/gopher:	theory.uwinnipeg.ca





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

Date: 7 Nov 1997 19:49:42 GMT
From: jhughes@iastate.edu (Jeff Hughes)
Subject: Decimal rounding and lining up decimals?
Message-Id: <63vrcm$7uc$1@news.iastate.edu>


    I'm working with dollar amounts, which sometimes get multiplied and
result in something like  45.375   Other than breaking it apart and putting
it back together as a string, what's the quickest way to turn it into 45.38?
I have something right now, but it just looks/seems too slow.

    Also the Camel book mentions output formatting using # and . for lining
up numerical values but doesn't give any suggestions.  Nothing I've tried
seems to work.

Please mail any suggestions, thanks.


	Jeff


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

Date: 7 Nov 1997 20:10:58 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Decimal rounding and lining up decimals?
Message-Id: <63vski$hr5@news-central.tiac.net>

In article <63vrcm$7uc$1@news.iastate.edu>,
Jeff Hughes <jhughes@iastate.edu> wrote:
>
>    I'm working with dollar amounts, which sometimes get multiplied and
>result in something like  45.375   Other than breaking it apart and putting
>it back together as a string, what's the quickest way to turn it into 45.38?
>I have something right now, but it just looks/seems too slow.

One way to do it is to use sprintf e.g.

  $formatted = sprintf ("%.2f", $unformatted);

this, and many similar questions, are answered in the FAQ which should
come with most recent perl distributions, try

  perldoc perlfaq

on your system.  If it's not there then you might try a CPAN
(comprehensive perl archive network) site, visiting http://www.perl.com
and following the CPAN link is a quick way to get there.

Section 4 starts like this:

Data: Numbers
       Why am I getting long decimals (eg, 19.9499999999999)
       instead of the numbers I should be getting (eg, 19.95)?

       Internally, your computer represents floating-point
       numbers in binary.  Floating-point numbers read in from a
       file, or appearing as literals in your program, are
       converted from their decimal floating-point representation
       (eg, 19.95) to the internal binary representation.

       However, 19.95 can't be precisely represented as a binary
       floating-point number, just like 1/3 can't be exactly
       represented as a decimal floating-point number.  The
       computer's binary representation of 19.95, therefore,
       isn't exactly 19.95.

       When a floating-point number gets printed, the binary
       floating-point representation is converted back to
       decimal.  These decimal numbers are displayed in either
       the format you specify with printf(), or the current
       output format for numbers (see the section on $# in the
       perlvar manpage if you use print.  $# has a different
       default value in Perl5 than it did in Perl4.  Changing $#
       yourself is deprecated.

       This affects all computer languages that represent decimal
       floating-point numbers in binary, not just Perl.  Perl
       provides arbitrary-precision decimal numbers with the
       Math::BigFloat module (part of the standard Perl
       distribution), but mathematical operations are
       consequently slower.

       To get rid of the superfluous digits, just use a format
       (eg, printf("%.2f", 19.95)) to get the required precision.

Once you have found or retrieved a cpy of the FAQ it';s probably quicker
than USENET...

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Fri, 07 Nov 1997 23:59:33 +0100
From: Douglas Seay <seay@hol.fr>
Subject: Re: Declare hash of hashes in Perl4
Message-Id: <34639D55.27A8CA91@hol.fr>

Yoz Grahame wrote:
> 
> >: For some reason, I am still using Perl4. But I don't know how to declare
> >: Hash of Hashes.
> >
> >Unfortunately for you, Perl 4 doesn't support references, which are
> >essential for creating complex data structures ( {key1=>val1,key2=>val2}
> >creates a reference to a hash with two keys.  This reference can be stored
> >anywhere a scalar can, particularly in the value of another hash).  It
> >*might* be possible to simulate an HOH in Perl 4 by means of some rather
> >lengthy magical incantations involving typeglobs, but it would definitely
> >not be pretty; remember that what you'd be doing is essentially casting
> >spells that are supposed to resurrect a dead camel.
> 
> As someone who has attempted things like this in an earlier, more innocent
> life, and who knows there *are* valid reasons to code Perl4 (such as, you're
> running on DOS, or your server sysadmin is stuck in 1991), I can't help but
> think, "Ah, what the hell, let's give it a go."
> 
> I've never been much cop with typeglobs so I'm just going to use the
> stupidly-extended-hash-keys solution, which is:
> $multihash{"tophash{secondhash}"}=$value;
> to set up an identical set of keys in a list of subhashes:

This can sometimes be mimiced much more simply with

	$hash{$a,$b,$c} = 'x';

but I leave reading that god-awful monster man page of Perl 4.0036 as a
punishment to anyone who wants continue using Perl4.


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

Date: 7 Nov 1997 16:43:35 GMT
From: jsd@bud.com
Subject: eliminate all but a certain string
Message-Id: <63vgfn$5kr$1@its.hooked.net>

i just looked in the faq but i didn't find what i needed.

i have an html file and i want to find all the comments (actually
just certain ones).                                          

i tried this:
perl -pe 's:.*(<\!--include virtual.*-->?):$1:s' psx/index.html

but it didn't work.  what am i doing wrong?

i also tried with the s and g options to the replace but that didn't
work either.

-j-


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

Date: Fri, 07 Nov 1997 17:21:52 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: eliminate all but a certain string
Message-Id: <comdog-ya02408000R0711971721520001@news.panix.com>

In article <63vgfn$5kr$1@its.hooked.net>, jsd@bud.com wrote:

>i have an html file and i want to find all the comments (actually
>just certain ones).                                          
>
>i tried this:
>perl -pe 's:.*(<\!--include virtual.*-->?):$1:s' psx/index.html
>
>but it didn't work.  what am i doing wrong?

what does "didn't work" mean?

   * did it not replace anything?

   * replace too much?

there could be a couple of things:

   * SSI's usually begin with <!--#, but i don't see the # in 
   your regex

   * what happens if there is extra space between include and virtual?
   how about using \s+

   * why is there a ? after the >

   * if you want to find all of them, why are you doing it this way?
   it looks like it will find the last one.

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
correct punctuation is diffect with embedded Perl


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

Date: Fri, 07 Nov 1997 23:51:02 +0100
From: Douglas Seay <seay@hol.fr>
Subject: Re: Getting bash history in Perl scripts
Message-Id: <34639B56.1FCA3DF0@hol.fr>

[posted, not mailed due to spam block]

Pat Neave wrote:
> 
> Hi,
> 
> I would like to write a Perl script to display the command history saved
> by the bash shell. Problem is that `history` is a bash internal command
> so using history in back ticks fails with command not found.
> Alternatively using history in a shell script means that a new instance
> of the shell is run with a new history list.

Can't you set bash to dump everything to $HOME/.bash_history and then
just read in this file?  Actually, I think that HISTFILE will let you
use any file name you like.  "man bash" for the details.

- doug


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

Date: 7 Nov 1997 17:45:07 GMT
From: l41484@alfa.ist.utl.pt (Umm)
Subject: glob not working
Message-Id: <63vk33$458$1@ci.ist.utl.pt>

Is there any reason, why glob doesn't work???

$tst = glob("*.pl");

puts "" $tst, any clues??

thanks.

--
                         Tiago Umm Pascoal
                    'The unstoppable mail machine'
                        l41484@alfa.ist.utl.pt

 I believe in making trouble. If women have any duty at all, essentially
it's to be a pain in the arse. (avital ronell)



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

Date: Fri, 07 Nov 1997 19:49:28 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: glob not working
Message-Id: <34666fc1.1956648@news.wwa.com>

On 7 Nov 1997 17:45:07 GMT, l41484@alfa.ist.utl.pt (Umm) wrote:

>Is there any reason, why glob doesn't work???
>
>$tst = glob("*.pl");

This statement sets $tst equal to the _first_ file found in the glob
array.  It does not copy the glob array to $tst.  Is this what you
want?

>puts "" $tst, any clues??

Actually, it probably doesn't find any files with that pattern and so
doesn't put anything in $tst.  :-)  If you run -w, see is it tells you
that $tst is an uninitialized value.

>thanks.

Any time.


Streben nach Wahrheit

Faust Gertz
Philosopher at Large


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

Date: Fri, 07 Nov 1997 17:34:05 -0500
From: "Bruce P. Schuck" <hd-fxsts@liii.com>
Subject: Intricate Sort help needed
Message-Id: <3463975D.F4E539EC@liii.com>

Ok, here is my quest.  I am processing a hash table (actually two) that
is a relation to a internal paper ID (Physics papers published at my day
job at aps.org) and an article ID that is a 6 digit number that
represents issue, section, sequence-in-section.  In example
012001
012002
012003
011001
011002
013001
013002
These would be keys that return the paper ID from a hash table.  There
is also a hash table that returns the 6 digit number for a given paper
ID.  

The need has arisen that at one time, I need to sort this list where the
section numbers ascend and the sequence numbers ascend; and at another
time the section numbers ascend, but the sequence descends.  The first
scenario is easy, just sort the hash table and I'd get:
011001
011002
012001
012002
012003
013001
013002

*But*  I need to easily get this list to sort as:
011002
011001
012003
012002
012001
013002
013001

So perhaps someone perhaps knows of a tricky way to do this?  Perhaps
one of the sort-gods has a module that you pass the fields and rules
into that will return your list in the order desired?

I tried to install the Sort-PolySort module, but had problem but the
"perl Makefile.PL" failed:
********
Checking if your kit is complete...
Looks good
Could not eval '
            package ExtUtils::MakeMaker::_version;
            no strict;

            $Sort::PolySort::VERSION=undef; do {
                $Sort::PolySort::VERSION = 
            }; $Sort::PolySort::VERSION
        ' in lib/Sort/PolySort.pm: syntax error at (eval 6) line 7, at
EOF
********

Any help is much appreciated.
Thanks.

-- 
Just me,
Bruce Schuck
bruce@sponge.com
hd-fxsts@liii.com


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

Date: Fri, 07 Nov 1997 12:54:30 -0500
From: libeson <libeson@pdb.pdb.bnl.gov>
Subject: Re: IRIX (5.3/6.2), PERL, APACHE problem!!!! HELP !!!!
Message-Id: <346355D6.41C6@pdb.pdb.bnl.gov>

I R A Aggie wrote:
> 
> In article <3460FC7B.15FB@pdb.pdb.bnl.gov>, libeson
> <libeson@pdb.pdb.bnl.gov> wrote:
> 
> + The new web service is running on a 6.2 IRIX64 machine r8000, with
> + 4 90 mhz processors. Could the machine be to fast sometimes?
> 
> I would go ahead and get the INSTable version of perl from SGI.
> 
> <url:http://reality.sgi.com/scotth/info/perl5.html>
> 
> It would appear that SGI is getting a clue, and will be including perl5
> as the default in future system software distributions. Yeah!
> 
> Out of curiousity, are you using the cgi-lib.pl CGI library? My feeling
> is that it is...incoherently buggy. We had a CGI that would work and
> not work intermittently. After I converted it from using the cgi-lib.pl
> to CGI.pm, it works consistently.
> 
> James
> 
> --
> Consulting Minister for Consultants, DNRC
> Support the anti-Spam amendment <url:http://www.cauce.org/>
> To cure your perl CGI problems, please look at:
> <url:http://www.perl.com/perl/faq/idiots-guide.html>

I tried the CGI.pm approach and did not get anywhere.


-- 
libeson


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

Date: 7 Nov 1997 19:58:27 GMT
From: l41484@alfa.ist.utl.pt (Umm)
Subject: is it possible to reference a sub-array?
Message-Id: <63vrt3$fga$1@ci.ist.utl.pt>

I want to do something like:

&function(\@ARGV[2]);

is it possible???

i mean directly without:

shift;shift;
&function(\@ARGV);


thanks.


--
                         Tiago Umm Pascoal
                    'The unstoppable mail machine'
                        l41484@alfa.ist.utl.pt

 I believe in making trouble. If women have any duty at all, essentially
it's to be a pain in the arse. (avital ronell)



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

Date: Mon, 03 Nov 1997 20:09:44 -0600
From: coyote ghost <zeropage@computek.net>
Subject: Newbie Q: Perl @HASH and C Structures
Message-Id: <345E83E8.61AF9A3B@computek.net>

Hello o' venerable Perl Programmers,

I'm a seasoned C programmer, but I am just now getting into Perl.  I
have some C binary database files that I.ve created and I'd like to
create a library for perl to access them.

It appears that the closest thing to a C structure in perl is an
associative array, so is it possible to create an associative array to
duplicate my C structure, then use that array to read and write to a
file, as I would with a structure in C?  (The key to this being that the
C structure and the Perl Array will be set up to be the exact same size
in terms of bytes used.)

I'd really appreciate hearing from anyone that has any ideas on how this
task might be accomplished.

Thanks,
Bryan Ingram
zeropage@computek.net





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

Date: Fri, 07 Nov 1997 23:34:33 +0100
From: Douglas Seay <seay@hol.fr>
To: coyote ghost <zeropage@computek.net>
Subject: Re: Newbie Q: Perl @HASH and C Structures
Message-Id: <34639779.323B82C5@hol.fr>

[posted and mailed]

coyote ghost wrote:
> 
> Hello o' venerable Perl Programmers,

I'm just 30, don't start calling me "venerable" or I'll make you go
clean up your room, you young whipper-snapper.

> I'm a seasoned C programmer, but I am just now getting into Perl.  I
> have some C binary database files that I.ve created and I'd like to
> create a library for perl to access them.
> 
> It appears that the closest thing to a C structure in perl is an
> associative array, so is it possible to create an associative array to
> duplicate my C structure, then use that array to read and write to a
> file, as I would with a structure in C?  (The key to this being that the
> C structure and the Perl Array will be set up to be the exact same size
> in terms of bytes used.)
> 
> I'd really appreciate hearing from anyone that has any ideas on how this
> task might be accomplished.

Bad news.  A Perl hash might fill the semantic role as a C structure,
but they don't map together at all.  You'll need to use unpack() to
break apart your C structure.  Note that the definition of a structure
varies from implementation, so don't expect

	typedef struct {
		char	one;
		int	two;
		} my_struct;

to be the same on every system.   On most PCs sizeof(my_struct)==5 while
for most Unix boxes sizeof(my_struct)==8.  You'll need to play with your
particular compiler to discover how it lays things out in memory.  There
is no single solution that will work for every compiler.  Sorry but the
C standard isn't very standard.  Don't forget that sizeof(int) doesnt
always return 4.

This general question comes up every two months or so, so you can go to
DejaNews and find more information.  My advice has always been to avoid
"raw structures" in files and sockets, but to come up with some sort of
standard that you can easily represent for any platform.  I like text
for this, other come up with binary formats that don't map one-to-one to
C structures.  How ever you do it, you will need to put a bit of effort
into it.  It isn't rocket science, but it isn't trivial either.

Your question ended with

> file, as I would with a structure in C?  (The key to this being that the
> C structure and the Perl Array will be set up to be the exact same size
> in terms of bytes used.)

Not just overall size, but the offset of each field is important too.  I
don't remember the details, but I think I was doing this sort of thing
in C (I inherited code that sent raw structures across TCP/IP links)
between Solaris and VMS and the size of the overall structure was the
same, but the offset of some of the fields varied.  This is one case
where you have to double check everything to be sure that you're getting
what you think you should be.  No automatic type checking at this level.

Good luck.

- doug

PS - about your Subject:, @ isn't for hashes, it is for lists.  % is
used for hashes.  No big deal, just trying to prevent confusion.


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

Date: Fri, 07 Nov 1997 13:59:20 -0500
From: Thad Welch <tw36027@glaxowellcome.com>
To: "Neil . Goodgame" <goodgn00@hau153.ha.uk.sbphrd.com>
Subject: Re: object serialization
Message-Id: <34636508.132A8E3F@glaxowellcome.com>



Neil . Goodgame wrote:

> Are there any perl modules that will serialize a perl object to a file
> and back again, similar to sequential_io in Ada 95.
> --
> ======================================================
> Neil Goodgame                   Smithkilne Beacham
> Neil_Goodgame-1@sbphrd.com
> ======================================================


There is Data::Dumper.  It recursively creates the perl code necessary to
re-insatiate the perl object at a later time by using the eval statement.
In general,
    my $perlCode = Data::Dumper->new( [ $perlObj] );
    write $perlCode to a file.

    to insaitate
    my $perlCode  = read from file
    my $VAR1; #$perlObj
    eval "$perlCode";






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

Date: 7 Nov 1997 19:54:45 GMT
From: "Phil R Lawrence" <prl2@lehigh.edu>
Subject: One slice of hash, please...
Message-Id: <01bcebb6$fe6a8420$3e03b480@mm.CC.lehigh.EDU>

I am doing something like:
	print "$hash{key5} $hash{key2} $hash{key8} $hash{key4} $hash{key12}\n";

but I tire of typing that hash name over and over.  Is there anything like:
	print "$hash{key5, key2, key8, key4, key12}\n";			# ?




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

Date: 7 Nov 1997 20:53:12 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: One slice of hash, please...
Message-Id: <63vv3o$kqu@news-central.tiac.net>

In article <01bcebb6$fe6a8420$3e03b480@mm.CC.lehigh.EDU>,
Phil R Lawrence <prl2@lehigh.edu> wrote:
>I am doing something like:
>	print "$hash{key5} $hash{key2} $hash{key8} $hash{key4} $hash{key12}\n";
>
>but I tire of typing that hash name over and over.  Is there anything like:
>	print "$hash{key5, key2, key8, key4, key12}\n";			# 

You're close.  You need an @ as the prefix to the slice rather than the $
- in the debugger:

  DB<1> %hash = (key5 => 5, key2 => 'two', key8 => 8, key4 => 4, key12 =>
12)

  DB<2> print "$hash{key5, key2, key8, key4, key12}\n"


  DB<3> print "@hash{key5, key2, key8, key4, key12}\n"
5 two 8 4 12

Hope this helps,

Mike



-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: 7 Nov 1997 20:50:33 GMT
From: dalonso@u.washington.edu (Darwin O.V. Alonso)
Subject: passing hash references to subs
Message-Id: <63vuup$n8g$1@nntp6.u.washington.edu>
Keywords: subroutines hash references dereference



Following is a simplified example of passing hash references to a subroutine, 
and then dereferencing them.
I would like to know:
  Is that the best way to pass a hash to a subroutine?
  What would "use strict" do?
  How dangerous is it to use %foo{x} vs %foo{"x"}?
  Should I be locked up for trying to write numerical analysis scripts in perl? ;-)

Thanks,
Darwin  Univ. Washington
dalonso@u.washington.edu



#!/usr/local/bin/perl -w
{
 my (%xyz1, %xyz2);
 $xyz1{"x"} = 1; $xyz1{"y"} = 2; $xyz1{"z"} = 3;
 $xyz2{"x"} = 6; $xyz2{"y"} = 7; $xyz2{"z"} = 8;
 
 &dih( \%xyz1, \%xyz2);
}

sub dih{
 my ( %xyz1, %xyz2);
 %xyz1 = %{$_[0]}; %xyz2 = %{$_[1]};
 foreach $key ( keys(%xyz1) ) {print "$key  $xyz1{$key}\n";}
 foreach $key ( keys(%xyz2) ) {print "$key  $xyz1{$key}\n";}
}



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

Date: 7 Nov 1997 21:23:20 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: passing hash references to subs
Message-Id: <6400s8$pjb$1@vixen.cso.uiuc.edu>

Darwin O.V. Alonso (dalonso@u.washington.edu) wrote:
: 
: 
: Following is a simplified example of passing hash references to a subroutine, 
: and then dereferencing them.
: I would like to know:
:   Is that the best way to pass a hash to a subroutine?

Passing yes, it's fine -- dereferencing, no.

Better is:

sub dih {
    my ($xyz1, $xyz2) = @_;
    foreach $key ( keys %$xyz1 ) {
	print "$key  $xyz1->{$key}\n";
    }
}

Stay away from $_[0] is my advice. It doesn't save much over
using lexical variables.

:   What would "use strict" do?

Try it. Your program, as shown, would pass if you added a 
"my $key;" to the subroutine. If you use strict you get
a lot fewer unpleasant runtime surprises.

:   How dangerous is it to use %foo{x} vs %foo{"x"}?

Not at all -- Perl will almost always do the right thing.

:   Should I be locked up for trying to write numerical analysis scripts in perl? ;-)

Perhaps, unless you look at PDL, which to all accounts provides some 
great tools for that purpose.

: 
: #!/usr/local/bin/perl -w
: {
:  my (%xyz1, %xyz2);
:  $xyz1{"x"} = 1; $xyz1{"y"} = 2; $xyz1{"z"} = 3;
:  $xyz2{"x"} = 6; $xyz2{"y"} = 7; $xyz2{"z"} = 8;
:  
:  &dih( \%xyz1, \%xyz2);
: }
: 
: sub dih{
:  my ( %xyz1, %xyz2);
:  %xyz1 = %{$_[0]}; %xyz2 = %{$_[1]};
:  foreach $key ( keys(%xyz1) ) {print "$key  $xyz1{$key}\n";}
:  foreach $key ( keys(%xyz2) ) {print "$key  $xyz1{$key}\n";}
					          ^
					          ^ 2 maybe?
: }
: 

-- 
Regards,
Mike Heins

This post reflects the
opinion of my employer.


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

Date: Fri, 07 Nov 1997 22:42:22 -0800
From: Jan Krynicky <Jan@chipnet.cz>
To: Perl-Win32-Users@ActiveState.com
Subject: Perl + Lotus Notes
Message-Id: <346409CE.139B@chipnet.cz>

I need to export some data from the address book of our notes server,
is there any way to do it by a perl script so that I could
export it regularly and compare the data with the WinNT user list 
and the list of emplayee changes I get from our admin department.

I'd like some (semi)automatic way to delete vanished users
and add new ones etc.

Is there a module for perl-to-notes comunication?
Could I use OLE to control notes?

The server runs on WinNT4.0, I use Activeware Perl 5.003 build 310.

Thanks for any info.

Jenda


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

Date: Fri, 07 Nov 1997 10:27:59 -0800
From: Susan Cassidy <susan.cassidy@sandiegoca.ncr.com>
Subject: Re: Perl 553 Malformed Header error
Message-Id: <34635DAF.4A06@sandiegoca.ncr.com>

Greg wrote:
> 
> What is a 553: Malformed header error?
> 
> Greg Shepard
> gshepard@remc7.k12.mi.us
You might want to do a syntax check on the script from the command
line: e.g. perl -c myscript.cgi

That will often show you syntax errors you didn't expect.  Also, you
might want to check the server error file: often there is useful
information in there.


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

Date: Fri, 07 Nov 1997 11:16:50 -0800
From: Lokisdog <see.my.sig@nospam.com>
Subject: Re: Perl/NT file rights, how do I...
Message-Id: <34636922.57D6@nospam.com>

Brent Michalski wrote:
> 
> I am trying to find a way, in Perl, to enter an arbitrary file or
> directory name and retrieve the groups that have rights to it as well as
> which rights the group has.
> 
> I have tried the command line CACSL program but it strips off the group
> names if you pipe or redirect the output for some reason.
> 
> I am looking either for a library that will offer me this information or
> if someone has done it already, how did you do it?
> 
> I have checked the FAQ's, that is how I found out about the CACSL
> program, but it isn't working like it should...
> 
> Thanks,
> 
> Brent Michalski

Try using XACLS, form the Resource Kit. It is what CACLS should have
been, and it does what you want.
_________________________________________________

Eric Arnold                     earnold@hitech.eds.com
Information Systems Engineer    408.524.2844
EDS/Philips, Sunnyvale


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

Date: 7 Nov 1997 19:37:02 GMT
From: pjscott-remove-to-email@euclid.jpl.nasa.gov (Peter Scott)
Subject: Re: Puzzle: palindromep
Message-Id: <63vqku$7bu@netline.jpl.nasa.gov>

> But this one was.  While those expressions do indeed recognize 
> expressions that cannot be recognized by pure regular expressions, they 
> don't recognize palindromes.  Of course ^(.+).?(?&reverse(\1))$ *would* 
> work if only the "?&" extension for embedding a match-time expression in 
> a regex were implemented...

Or if either (a) you could tie $1, or (b) $1 was not as local as it is.
Because then you could (recalling the original poster's specification
that the palindrome could be embedded in a larger string) do:
/.*?(.*)(.?)$x.*?/ and either tie $1 so that you set $x to the reverse
of $1, or tie $x to read $1 and return the reverse.  Unfortunately,
you can't do either (I tried).  I would be interested to hear a guru
evaluate the implications of implementing (a) or (b).  This question
really made me wish for the "?&" extension... does any language/utility
implement that, or did you just make it up?

-- 
This is news.  This is your      |  Peter Scott, NASA/JPL/Caltech
brain on news.  Any questions?   |  (Peter.J.Scott at jpl.nasa.gov)

Disclaimer:  These comments are the personal opinions of the author, and 
have not been adopted, authorized, ratified, or approved by JPL.


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

Date: Fri, 07 Nov 1997 18:02:38 -0500
From: "Gary C. New" <gnew@southernvirginia.edu>
To: Bart Lateur <bart.mediamind@tornado.be>
Subject: Re: Regular Expressions
Message-Id: <34639E0E.6D5E@southernvirginia.edu>

Bart Lateur wrote:
> 
> >In article <comdog-ya02408000R0611971707560001@news.panix.com>,
> comdog@computerdog.com (brian d foy) writes:
> > i hate this sort of data manipulation - it seems that a lot of systems
> > do this - and i should know :)
> 
> "Brian D Foy"?
> 
> mgjv@comdyn.com.au (Martien Verbruggen) wrote:
> >Yeah,
> >
> >what if your last name is McBeth, O'Donnell, or Lloyd Webber ?
> 
> Lettin' [ s/(/w+)/\u\L$1/g ] loose on these, I get:
> 
>         Mcbeth  (oops)
>         O'Donnell       (ok)
>         Lloyd Webber    (ok)
> 
>         Bart.

How would it be possible to write the expression to include names such
as McBeth also?

gnew@southernvirginia.edu


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

Date: Fri, 7 Nov 1997 14:29:01 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: Self-Modifying Perl Scripts
Message-Id: <1997110714124041512360N@roxboro-163.interpath.net>

Dan Zink <zink@uiuc.edu> wrote:

] Is it possible to write a perl script that modifies itself? I tried to
] do this, but was unable to open the script file for write access while
] it was running. Is there any way to get around this?

It looks like you are using a Mac (and hence MacPerl) and the answer is
probably no  - although you can if the file isn't opened for editing at
the time, i.e. use Run Script.  Or if used in conjunction with the
preference setting - run script when opened from finder.

-- 
John Moreno


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

Date: 7 Nov 1997 19:01:45 GMT
From: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: Sorting and Counting with PERL
Message-Id: <63voip$5hd@news.service.uci.edu>

In article <slrn664hpa.kcu.abigail@betelgeuse.wayne.fnx.com>,
Abigail <abigail@fnx.com> wrote:
<
<What, an even bigger monster list is ok, because you will
<print it? ;) If you get rid of the first map, get rid of the
<second one as well:
<
<      foreach (@list)      {$hash {$_} ++;}
<      foreach (keys %hash) {print "$_ occurs $hash{$_} times\n";}

But your (keys %hash) still produces a list that you don't use.
If you sorted the output, that would be one thing, but you don't.
Mike Stok's 

print "$key occurs $count times\n" while ($key, $count) = each %hash;

is therefore the best choice if extraneous lists are the bugbear o' the
day.

-- 
Eric D. Friedman
friedman@uci.edu


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

Date: 07 Nov 1997 14:53:01 -0500
From: psmith@baynetworks.com (Paul D. Smith)
To: skumar@umi.com
Subject: Re: Traversing a directory tree in Perl
Message-Id: <p5pvoc4h2a.fsf@baynetworks.com>

Why don't you just use the excellent File::Find module?  It takes care
of all the hard parts, and will be much faster than anything you could
write yourself (without a lot of practice and experience!)

perldoc File::Find

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <psmith@baynetworks.com>         Network Management Development
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
     These are my opinions--Bay Networks takes no responsibility for them.


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

Date: 7 Nov 1997 20:59:01 GMT
From: klassa@aursgh.aur.alcatel.com (John M. Klassa)
Subject: Re: Traversing a directory tree in Perl
Message-Id: <63vvel$jam$1@aurwww.aur.alcatel.com>

On Fri, 07 Nov 1997 11:12:41 -0600, skumar@umi.com <skumar@umi.com> wrote:

->    I'm relatively a newbie in the world of Perl. I would like to know
->how to traverse a directory tree using Perl. I've written a script that

Sounds like what you want is the File::Find module...  It's what find2perl
uses now, I think.  Anyway, it traverses a directory tree and lets you
execute arbitrary code along the way.

John

-- 
John Klassa / Alcatel Telecom / Raleigh, NC, USA <><

	All those who believe in psychokinesis, raise my hand...


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

Date: 07 Nov 1997 21:22:47 GMT
From: orwant@fahrenheit-451.media.mit.edu (Jon Orwant)
To: skumar@umi.com
Subject: Re: Traversing a directory tree in Perl
Message-Id: <ORWANT.97Nov7162247@fahrenheit-451.media.mit.edu>


In article <878922310.2758@dejanews.com> skumar@umi.com writes:

>        I'm relatively a newbie in the world of Perl. I would like to know
>    how to traverse a directory tree using Perl. I've written a script that
>    uses opendir and readdir to supposedly do the job. In this script,

Consider using the File::Find module already bundled with Perl.
It does exactly what you want.

-Jon

------------------------------------
Jon Orwant            http://tpj.com
Editor & Publisher, The Perl Journal


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

Date: Sat, 08 Nov 1997 00:01:28 +0100
From: Douglas Seay <seay@hol.fr>
To: Wart <wart@ugcs.caltech.edu>
Subject: Re: Undefining an associative array element
Message-Id: <34639DC8.573E74AC@hol.fr>

[posted and mailed]

Wart wrote:
> 
> I left my camel book at work, else I'd look it up myself.

Why not RTFM?

> I'm using a dbm to store some info that can be submitted/displayed
> using a cgi-bin.  I want to add an option to delete an entry stored
> in the dbm file.  My attempt at this failed:
> 
> dbmopen(%info, $filename, 0644);
> if ($remove) {
>     undef $info{$key_to_delete};
> }
> dbmclose(%info);

try incanting

	"perldoc -f delete"

and while your at it, look up "tie" because dbmopen() is ancient
history.

- doug


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

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

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

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


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

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