[19352] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1547 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 17 03:06:43 2001

Date: Fri, 17 Aug 2001 00:05:13 -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: <998031912-v10-i1547@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 17 Aug 2001     Volume: 10 Number: 1547

Today's topics:
        Determining array length <admin@CLIPMEnova1.f2s.com>
    Re: Determining array length <admin@CLIPMEnova1.f2s.com>
    Re: Determining array length <krahnj@acm.org>
    Re: Determining array length <cberry@cinenet.net>
    Re: Determining array length (Tassilo v. Parseval)
    Re: Determining array length <admin@CLIPMEnova1.f2s.com>
    Re: Exporting all files to a scalar/array <pne-news-20010817@newton.digitalspace.net>
        FAQ: How do I dup() a filehandle in Perl? <faq@denver.pm.org>
    Re: Help!  Multiple line extract from file based on use <davidhilseenews@yahoo.com>
    Re: Help!  Multiple line extract from file based on use <bcaligari@fireforged.com>
    Re: Help!  Multiple line extract from file based on use <cberry@cinenet.net>
    Re: Installing Gd-1.18 problems <pne-news-20010817@newton.digitalspace.net>
    Re: Is $! a number or a string? <pne-news-20010817@newton.digitalspace.net>
    Re: Locating Files <Tassilo.Parseval@post.rwth-aachen.de>
        need opinions (derelixir)
    Re: Nmake.exe error after generating makefile <ash@turnernewmedia.com.au>
    Re: Passing single reference into a sub assigning @_ in <pne-news-20010817@newton.digitalspace.net>
    Re: Perl hidden text, password prompt. <pne-news-20010817@newton.digitalspace.net>
    Re: Perl OO needs the opposite of SUPER:: (Chris Fedde)
        select doesn't detect pipe close <goldbb2@earthlink.net>
    Re: select doesn't detect pipe close <bkennedy99@Home.com>
    Re: Using manpages?? (Tassilo v. Parseval)
    Re: Verifying users against NT domain? (Mike Driggers)
        what do these mean in Makefile <maxim68@hotmail.com>
    Re: what do these mean in Makefile <ilya@martynov.org>
        what does this message mean? <maxim68@hotmail.com>
        why does this code print - HASH(0x80f764c) (TuNNe|ing)
    Re: why does this code print - HASH(0x80f764c) <l_pantin@hotmail.com>
    Re: Why no spaces show up in print of array - sometimes <pne-news-20010817@newton.digitalspace.net>
    Re: Will Perl report on variables no longer used?? <pne-news-20010817@newton.digitalspace.net>
    Re: Will Perl report on variables no longer used?? <pne-news-20010817@newton.digitalspace.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 17 Aug 2001 00:27:27 -0700
From: "G Harper" <admin@CLIPMEnova1.f2s.com>
Subject: Determining array length
Message-Id: <9li6g0$8kp$1@bob.news.rcn.net>

I am receiving a totally unexpected result when checking for the length of
an array I am using.
I have checked my array's length using '$#array + 1', 'scalar(@array)' and
just '$length = @array' - to no avail.

WARNING!! I am a lousy Perl programmer and the following code may make you
ill if you actually know how to program in Perl.  Proceed with caution.

I am using a framed HTML page to provide an interface to enter form values
and have those values updated on entry in a side frame. The side frame uses
the following code to load and display the entries from file:

# Open data file and read into @mine, line by line.
open(DIN, "<dat/stats.txt") or die "Unable to load file";
$top=1;
for ($i=0; $i<$top; $i++) {
  $mine[$i] = <DIN>;
  if (defined $mine[$i]) {
    $top++;
  }
  print join("", $mine[$i], "<br>");
}

# Here's where I check the array length
# I've tried a bunch of methods
$count = scalar(@mine);
print $count;

Starting with a blank stats.txt, @mine returns a length of 1, and every
entry after that a value of 2.
Any pointers would be very helpful, hey even a good roast might inspire my
intuitiveness.

Thanks.




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

Date: Fri, 17 Aug 2001 00:37:08 -0700
From: "G Harper" <admin@CLIPMEnova1.f2s.com>
Subject: Re: Determining array length
Message-Id: <9li727$bkh$1@bob.news.rcn.net>

"G Harper" <admin@CLIPMEnova1.f2s.com> wrote in message
news:9li6g0$8kp$1@bob.news.rcn.net...
> I am receiving a totally un
<clip>

Sorry, that was a waste of space.  I had changed my code and it's loading
everything into $mine[0].
Any advice would be appreciated, however, in managing this task.




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

Date: Fri, 17 Aug 2001 04:51:47 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Determining array length
Message-Id: <3B7CA34B.74E9E340@acm.org>

G Harper wrote:
> 
> I am receiving a totally unexpected result when checking for the length of
> an array I am using.
> I have checked my array's length using '$#array + 1', 'scalar(@array)' and
> just '$length = @array' - to no avail.
> 
> WARNING!! I am a lousy Perl programmer and the following code may make you
> ill if you actually know how to program in Perl.  Proceed with caution.
> 
> I am using a framed HTML page to provide an interface to enter form values
> and have those values updated on entry in a side frame. The side frame uses
> the following code to load and display the entries from file:
> 
> # Open data file and read into @mine, line by line.
> open(DIN, "<dat/stats.txt") or die "Unable to load file";
> $top=1;
> for ($i=0; $i<$top; $i++) {
>   $mine[$i] = <DIN>;

You are reading from the file whether there is data in it or not.


>   if (defined $mine[$i]) {
>     $top++;
>   }
>   print join("", $mine[$i], "<br>");
> }
> 
> # Here's where I check the array length
> # I've tried a bunch of methods
> $count = scalar(@mine);
> print $count;
> 
> Starting with a blank stats.txt, @mine returns a length of 1, and every
> entry after that a value of 2.
> Any pointers would be very helpful, hey even a good roast might inspire my
> intuitiveness.


# Open data file and read into @mine, line by line.
open DIN, '< dat/stats.txt' or die "Unable to load 'dat/stats.txt': $!";
my @mine;
while ( <DIN> ) {
    push @mine, $_;
    print "$_<br>";
    }
# Here's where I check the array length
# I've tried a bunch of methods
my $count = @mine;
print $count;



John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 17 Aug 2001 05:10:15 -0000
From: Craig Berry <cberry@cinenet.net>
Subject: Re: Determining array length
Message-Id: <Xns90FFE18882B9cberrycinenetnet1@207.126.101.92>

"G Harper" <admin@CLIPMEnova1.f2s.com> wrote in
news:9li6g0$8kp$1@bob.news.rcn.net: 
> I am receiving a totally unexpected result when checking for the length
> of an array I am using.
> I have checked my array's length using '$#array + 1', 'scalar(@array)'
> and just '$length = @array' - to no avail.

All of those do accurately determine an array's length, so clearly something 
else is wrong, as you no doubt suspect.

> WARNING!! I am a lousy Perl programmer and the following code may make
> you ill if you actually know how to program in Perl.  Proceed with
> caution. 

No worries.  We all start out with baby talk and improve from there.

> # Open data file and read into @mine, line by line.
> open(DIN, "<dat/stats.txt") or die "Unable to load file";

You get many bonus points for checking the result of open(), by the way.

> $top=1;
> for ($i=0; $i<$top; $i++) {
>   $mine[$i] = <DIN>;
>   if (defined $mine[$i]) {
>     $top++;
>   }
>   print join("", $mine[$i], "<br>");
> }

more idiomatically:

  my @mine = <DIN>;
  print "$_<br>" foreach @mine;

> # Here's where I check the array length
> # I've tried a bunch of methods
> $count = scalar(@mine);
> print $count;

That will work as you've written it; you can even eliminate the intermediate 
variable:

  print scalar @mine;

-- 
Craig Berry <http://www.cinenet.net/~cberry/>
"That which is now known, was once only imagined." - William Blake



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

Date: 17 Aug 2001 05:36:03 GMT
From: Tassilo.Parseval@post.rwth-aachen.de (Tassilo v. Parseval)
Subject: Re: Determining array length
Message-Id: <9liag3$2tu$1@nets3.rz.RWTH-Aachen.DE>

On Fri, 17 Aug 2001 00:27:27 -0700, G Harper <admin@CLIPMEnova1.f2s.com> wrote:
> I am receiving a totally unexpected result when checking for the length of
> an array I am using.
> I have checked my array's length using '$#array + 1', 'scalar(@array)' and
> just '$length = @array' - to no avail.

Probably your for-loop didn't do what you expected.

> I am using a framed HTML page to provide an interface to enter form values
> and have those values updated on entry in a side frame. The side frame uses
> the following code to load and display the entries from file:

First of all: Always enable warnings and strictures.

#! perl -w

use strict; 

> # Open data file and read into @mine, line by line.
> open(DIN, "<dat/stats.txt") or die "Unable to load file";

open DIN, "dat/stats.txt or die "unable to load file: $!";
# $! will give you more information when opening fails

> $top=1;

my $top = 1;

> for ($i=0; $i<$top; $i++) {
>   $mine[$i] = <DIN>;
>   if (defined $mine[$i]) {
>     $top++;
>   }

my @mine = <DIN>; # slurp file into array

>   print join("", $mine[$i], "<br>");

map { $_."<br>" } @mine; # append <br> to each array-element

> }
> 
> # Here's where I check the array length
> # I've tried a bunch of methods
> $count = scalar(@mine);

# This would work, or just: 

my $count = @mine; # scalar context

> print $count;

Check whether the above now produces reasonable results. Your for-loop is quite confusing and certainly a far too complicated way to read a file into an array.

Tassilo
-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Fri, 17 Aug 2001 01:36:49 -0700
From: "G Harper" <admin@CLIPMEnova1.f2s.com>
Subject: Re: Determining array length
Message-Id: <9liai5$qt7$1@bob.news.rcn.net>

Thank you both!




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

Date: Fri, 17 Aug 2001 06:58:59 +0200
From: Philip Newton <pne-news-20010817@newton.digitalspace.net>
Subject: Re: Exporting all files to a scalar/array
Message-Id: <1u8pntsrbjd5vhqgu5jrohur706l7s07pa@4ax.com>

On Thu, 16 Aug 2001 19:06:38 -0000, Craig Berry <cberry@cinenet.net>
wrote:

> Note that there is a difference between the two variants; the explicit-split 
> version will have no newlines on the strings in the aray, and a zero-length 
> string at the end split from behind the last newline.

Then you have a buggy Perl :). Standard Perl does this:

: If LIMIT is unspecified or zero, trailing null fields
: are stripped

perldoc -f split :)

> The list-context version will have newlines on the strings in the array,

which you can get rid of all at once with chomp(@array);

> and no spurious last element.

just like the the split version.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Fri, 17 Aug 2001 06:17:01 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I dup() a filehandle in Perl?
Message-Id: <xF2f7.190$V3.170994688@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 dup() a filehandle in Perl?

    If you check the open entry in the perlfunc manpage, you'll see that
    several of the ways to call open() should do the trick. For example:

        open(LOG, ">>/tmp/logfile");
        open(STDERR, ">&LOG");

    Or even with a literal numeric descriptor:

       $fd = $ENV{MHCONTEXTFD};
       open(MHCONTEXT, "<&=$fd");   # like fdopen(3S)

    Note that "<&STDIN" makes a copy, but "<&=STDIN" make an alias. That
    means if you close an aliased handle, all aliases become inaccessible.
    This is not true with a copied one.

    Error checking, as always, has been left as an exercise for the reader.

- 

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.

                                                           05.29
-- 
    This space intentionally left blank


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

Date: Fri, 17 Aug 2001 04:32:44 GMT
From: "David Hilsee" <davidhilseenews@yahoo.com>
Subject: Re: Help!  Multiple line extract from file based on user input.
Message-Id: <M71f7.17069$L9.5569251@news1.rdc1.md.home.com>


"Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
news:m31ymb4psk.fsf@mumonkan.sunstarsys.com...
> tadmc@augustmail.com (Tad McClellan) writes:
>
> > Lyle <lbeckm3@hotmail.com> wrote:
> > >I am trying to write a perl script that will extract the given lines
> > >from a file based on a list the user types in, i.e.
> > >
> > >Records to print: 2,15,34-60,87
> > >
> > >Is it possible to do this without iterating through the file multiple
> > >times for each number or range?
> >
> >
> > Yes, if the whole file will fit into memory.
>        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> If that's not the case, here's another way:
>
> #!/usr/bin/perl -wT
>   use strict;
>   my $input = '2,34-60,15'; # detaint if taken from user input !!!
>
>   my @range = map {s/-/../ or $_ .= "..$_"; "scalar($_)"}
>                 split /,/, $input;
>   $"=",";
>   my $matched_ranges = eval << "CODE";
>
>     sub {
>         my \@match = (@range);
>         grep \$match[\$_] => (0..$#range);
>     }
>
> CODE
>
>   die $@ if $@; # eval failed?
>
>   my @lolines; # ordered LoL of matched lines
>
>   while (<>) {
>     foreach my $ary ( @lolines[$matched_ranges->()] ) {
>         push @$ary, $_;
>     }
>   }
>
>   print @$_ foreach @lolines; # print lines in correct order
> __END__
>
>
> The basic idea here is to turn 2,34-60,15 into an array
> of line number tests:
>
>   @range = ( scalar(2..2), scalar(34..60), scalar(15..15) );
>
> While reading through the file (one time), $matched_ranges->()
> then returns a list of successful indices from this list.
>
> HTH
> --
> Joe Schaefer   "I must have a prodigious quantity of mind; it takes me as
much
>                              as a week sometimes to make it up."
>                                                --Mark Twain
>

That's the way I was thinking of going too.  I boiled it down to this (after
swiping some of your code):

$input = '2,6,4,90-100';

my @command =
    map { s/-/../ or $_ .= "..$_"; "print if $_;" }
split /,/, $input;

eval "while ( <> ) { @command }";

die $@ if $@;

David Hilsee




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

Date: Fri, 17 Aug 2001 07:04:17 -0000
From: "B. Caligari" <bcaligari@fireforged.com>
Subject: Re: Help!  Multiple line extract from file based on user input.
Message-Id: <9li89j066m@enews1.newsguy.com>


"David Hilsee" <davidhilseenews@yahoo.com> wrote in message
news:M71f7.17069$L9.5569251@news1.rdc1.md.home.com...
>
> "Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
>
> $input = '2,6,4,90-100';
>
> my @command =
>     map { s/-/../ or $_ .= "..$_"; "print if $_;" }
> split /,/, $input;
>
> eval "while ( <> ) { @command }";
>
> die $@ if $@;
>
> David Hilsee
>

Cool, but the order of the 'print list' is not preserved.

B.




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

Date: Fri, 17 Aug 2001 06:02:26 -0000
From: Craig Berry <cberry@cinenet.net>
Subject: Re: Help!  Multiple line extract from file based on user input.
Message-Id: <Xns90FFEA6122E64cberrycinenetnet1@207.126.101.92>

lbeckm3@hotmail.com (Lyle) wrote in news:d3e3ca54.0108161214.481e2727
@posting.google.com:

> I am trying to write a perl script that will extract the given lines
> from a file based on a list the user types in, i.e.
> 
> Records to print: 2,15,34-60,87
> 
> Is it possible to do this without iterating through the file multiple
> times for each number or range?  I could see doing this in a sorted
> array but my brain can't get past the "how do I handle the ranges"
> such as the 34-60 listed above?  Also the order that the operator
> selects must remain the same, i.e. if the operator puts
> 
> ..print:  3,7,4,26
> 
> The file must be in that order in the end.  TIA!!

#!/usr/bin/perl -w
# ranger - print selected line numbers from stdin
# Ranges are specified as only arg:  e.g. 1-4,7,9-13,5,12
# Lines can appear more than once, and ranges can overlap
# Craig Berry (20010816)

use strict;

(my $selStr = shift) =~ s/(\d+)-(\d+)/join ',', $1 .. $2/eg;
print( ('dummy', <>)[split /,/, $selStr] );

-- 
Craig Berry <http://www.cinenet.net/~cberry/>
"That which is now known, was once only imagined." - William Blake



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

Date: Fri, 17 Aug 2001 06:58:56 +0200
From: Philip Newton <pne-news-20010817@newton.digitalspace.net>
Subject: Re: Installing Gd-1.18 problems
Message-Id: <3i7pntse0rg1ktaeqvghbdjno8hvcfn49v@4ax.com>

On Wed, 15 Aug 2001 13:06:32 -0500, Steve Postlewait
<porter96@lycos.com> wrote:

> This will probably be classified by some as a "off topic" question, and
> if so ... please point me in the correct direction.

Maybe comp.lang.perl.modules? Cross-posted there and followups set to
there.

> I'm trying to install the GD-1.18 graphics program on a Windows 2000
> Advanced Server.  Since I'm tying to install a Perl module, I figured
> that someone here will have had a similar problem.

* Are you running ActiveState's ActivePerl? If so, you should be able to
download and install GD with the PPM utility. This will save you having
to compile it yourself. 'ppm install GD' should work.

* If you're running something else (such as compiled version of 'core'
Perl), then read on.

Have you got libgd compiled and installed already? As far as I know, the
GD module depends on libgd being there, but does not include it in the
download, so you'll have to fetch it separately (from www.boutell.com,
for example).

GD includes XS components, so you'll need a C compiler. Have you got
one? If not, you'll have a problem anyway unless you can get a
precompiled version. If you do, you probably also have a make utility.
If your C compiler is Microsoft's Visual C, it'll be called 'nmake'. So
follow the instructions but say 'nmake; nmake test; nmake install'
instead of 'make; make test; make install'.

You can find out which make your Perl was built with by saying

    perl -V:make

 .

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Fri, 17 Aug 2001 06:28:36 +0200
From: Philip Newton <pne-news-20010817@newton.digitalspace.net>
Subject: Re: Is $! a number or a string?
Message-Id: <sv6pntkis4i1cfinb3aq3k73afm86cqqip@4ax.com>

On 15 Aug 2001 22:21:08 GMT, abigail@foad.org (Abigail) wrote:

> Philip Newton (pne-news-20010815@newton.digitalspace.net) wrote on MMCMVI
> September MCMXCIII in <URL:news:ns4kntcvqi3apie87d64cj2hksq3r5qqu0@4ax.com>:
> '' On 14 Aug 2001 19:18:38 -0700, johnlin@chttl.com.tw (John Lin) wrote:
> '' 
[dual-valued scalars]
> '' > Can I make this magic of my own?  (I believe the answer is "Yes".)
> '' 
> '' Correct. You need XS code, however; you can't do it in pure Perl.
> 
> Of course you can. Just use a combination of overload and tie.

What you get then is not the same thing (an SV with both IV/NV and PV
slots filled (with unrelated things) *and* that's both IOK/NOK and POK).

However, your method looks and smells the same to the user, so in a
sense you're right. Thanks for the insight; I was thinking more in terms
of the implementation and not in terms of the interface.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Fri, 17 Aug 2001 08:06:37 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Locating Files
Message-Id: <3B7CB46D.70700@post.rwth-aachen.de>

Koen Verbeke wrote:

> It looks like they're using Debian/GNU Linux. If they are, they probably
> upgraded their system-perl to 5.6.0. That's not a good idea with Debian as
> it depends on its own perl (/etc/alternatives). It is wise to leave it
> alone. The system will be broken for a great part when not taken care of
> this.

This is, sorry, utterly nonsense. I am using Debian and I am certainly 
using Perl 5.6.1 without having compiled it myself. Perl 5.6.1 is in the 
  testing-distribution and I'd advise anyone to let Debian know which 
Perl is installed by using the provided .deb package.

Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: 16 Aug 2001 23:11:31 -0700
From: derelixir@my-deja.com (derelixir)
Subject: need opinions
Message-Id: <fd50a1dc.0108162211.327b5414@posting.google.com>

Hello...

I have a text file which contains something like this:

500,California,87,88,90
501,Sepang,88,88,83

500 & 501 are id and unique

I want to read this text file and duplicate the locations based on the
id ...
e.g.

if it finds id 500, it will extract the location name, write it other
file
(newlocations.txt) and at the same time duplicate it but with the
different location name...

basically the output will be something like this:
California,87,88,90
Hollywood,87,88,90
(same data but with different location name)

I'm not sure of a better and less complicated way of doing it..
One thing is maybe by using hash of array...

e.g.
%locations = (
            '500' => ["California", "Hollywood",  "Oklahoma"],
            '501' => ["London", "Leeds" ],
            '502' => ["Washington", "New York" ],
            
);

I'm thinking about long term on how to maintain it...
because I might be adding more locations to the list 

e.g. 
            '500' => ["California", "Hollywood",  "Oklahoma",
"Connecticut",  "Philadelphia"],

in future...
Maybe there are easier ways of doing it besides having to use this
hash of array?

Any opinions are really appreciated....

Thanks!
Regards.


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

Date: Fri, 17 Aug 2001 15:38:39 +1000
From: Ash Turner <ash@turnernewmedia.com.au>
Subject: Re: Nmake.exe error after generating makefile
Message-Id: <B7A2EAFF.8D7%ash@turnernewmedia.com.au>

HI

Ok, now can we go a bit slower for the dummies like me. I've tried changing
the pathname in so many ways, and have it set up in IIS and still get that
bloddy error.

Anyone help me out?

Cheers


Ash


in article jyiRvGADVae7Ewi$@r-davies.demon.co.uk, Ronnie Davies at
ronnie@r-davies.demon.co.uk wrote on 15/8/01 8:25 AM:

> I am running Windows 98 and have read about problems with the 2>&1
> string in mm_win32 and mm_unix when compiling makefile.pl.  I am trying
> to install the Borland Interbase 6 DBD.
> 
> By removing the 2>&1 string from mm_win32 and one from mm_unix, I have
> made a makefile without any errors being thrown up.  However, I still
> get the following output when running nmake directly after generating
> makefile:-
> 
> c:\perl\bin\perl.exe -p -e "s/~DRIVER~/InterBase/g" <
> C:/Perl/site/lib/a
> uto/DBI/Driver.xst > InterBase.xsi
> File not found
> c:\perl\bin\perl.exe -IC:\Perl\lib -IC:\Perl\lib
> C:\Perl\lib\ExtUtils/xs
> ubpp   -typemap C:\Perl\lib\ExtUtils\typemap InterBase.xs > InterBase.c
> Cannot open 'InterBase.xsi': No such file or directory in InterBase.xs,
> line 19
> NMAKE : fatal error U1077: 'C:\PERL\BIN\PERL.EXE' : return code '0x1'
> Stop.
> 
> How do I get nmake to work without errors?  I really need to get this
> DBD installed!
> 
> Thanks in advance



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

Date: Fri, 17 Aug 2001 06:58:57 +0200
From: Philip Newton <pne-news-20010817@newton.digitalspace.net>
Subject: Re: Passing single reference into a sub assigning @_ into a hash??
Message-Id: <nj8pnts46309cq4ua1ultbi9p0d3g82not@4ax.com>

On Thu, 16 Aug 2001 17:30:47 GMT, Carlos C. Gonzalez
<miscellaneousemail@yahoo.com> wrote:

> I called it by either ...
> 
> print_contents(\*STDOUT);
> print_contents();

If you still want to use a hash, then the way to call it would be

    print_contents(); # or
    print_contents(IO_HANDLE => \*STDOUT);

Bingo -- even number of elements in the hash assignment again.

However, using a hash is probably not necessary here.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Fri, 17 Aug 2001 06:59:00 +0200
From: Philip Newton <pne-news-20010817@newton.digitalspace.net>
Subject: Re: Perl hidden text, password prompt.
Message-Id: <429pntoq0aknv340ckn0dahd8gbqhdvdmc@4ax.com>

On Thu, 16 Aug 2001 11:59:32 -0700, Helene Grossman
<hlg@socrates.berkeley.edu> wrote:

> password prompt

That's a FAQ: 

    perldoc -q password 

shows the answer to the question (which other posters have already
given) as the first item.

Please check the FAQ before posting with a few "obvious" keywords.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Fri, 17 Aug 2001 05:22:18 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Perl OO needs the opposite of SUPER::
Message-Id: <eS1f7.189$V3.189818880@news.frii.net>

In article <a73bcad1.0108161723.552eb26a@posting.google.com>,
John Lin <johnlin@chttl.com.tw> wrote:
>Suppose the inheritance-tree is MyBase <- MyDerived <- X <- Y <- Z
>It happens that MyDerived::_init also need to call X's init() in between some
>statements of MyDerived::_init.  Then, you cannot name it as X::init (occupied
>by MyBase), neither X::_init (occupied by MyDerived), right?
>So you have to rename it again, let's say  sub X::__init;
>

I might be missing something here.   In fact I'm sure that I am. Are we
talking about class behavior or object behavior.  If the object is of
type MyDerived then what business does it have calling on behaviors of
type X?   That would break encapsulation. 

A factory class might be creating objects of some other type but the object
type must be derived from the parameters passed to the factory. The
factory is not a super class of the object types it builds.
-- 
    This space intentionally left blank


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

Date: Fri, 17 Aug 2001 01:38:17 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: select doesn't detect pipe close
Message-Id: <3B7CADC8.5459E419@earthlink.net>

I have a program which makes a pipe, then forks.

The child uses the 4-argument select() on the read end of the pipe to
wait until it has work to do.  The parent either writes data for the
child to process, or else closes the writer.

I *thought* that select would return, indicating that the filehandle is
either readable or has an exception, when there's an eof on the pipe,
but apparently this is untrue -- "$$: select returned" is never printed,
nor does the die "select: $!" get executed.

Here's the code:
    vec(my($rflags)="", fileno $reader, 1) = 1;
    my $eflags = $rflags;
    print STDERR "$$: entering select...\n";
    select($rflags, undef, $eflags, undef)
        or die "$$: select: $!";
    print STDERR "$$: select returned.\n";
    if( !vec($rflags, fileno $reader, 1) ) {
        print STDERR "$$: EOF seen, exiting\n";
        exit;
    }

Could someone please enlighten me?

-- 
I'm not a programmer but I play one on TV...


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

Date: Fri, 17 Aug 2001 05:48:19 GMT
From: "Ben Kennedy" <bkennedy99@Home.com>
Subject: Re: select doesn't detect pipe close
Message-Id: <De2f7.110214$EP6.29240951@news1.rdc2.pa.home.com>


"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3B7CADC8.5459E419@earthlink.net...
> I have a program which makes a pipe, then forks.
>
> The child uses the 4-argument select() on the read end of the pipe to
> wait until it has work to do.  The parent either writes data for the
> child to process, or else closes the writer.

Make sure you close the read end of the pipe in the parent, and the write
end in the child as soon after you fork.  This will allow the child to
detect when the pipe actually closes on the parent side

--Ben Kennedy




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

Date: 17 Aug 2001 05:49:55 GMT
From: Tassilo.Parseval@post.rwth-aachen.de (Tassilo v. Parseval)
Subject: Re: Using manpages??
Message-Id: <9liba3$2tu$2@nets3.rz.RWTH-Aachen.DE>

On Fri, 17 Aug 2001 02:03:41 GMT, Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote:

> Anyway (settle down here Carlos...) I was wondering if anyone knew of a 
> good link on how to view and access manpages?  I know that for most of 
> you such a question is like breathing but perhaps you could breath a 
> little in my direction =:).

Well, you are not on a UNIX-flavoured system, yet - from what I understood here - you are not easily giving up. Hence I can recommend you something that wont force you to abandon Win altogether, but instead add some nice and helpful features to your setup:

Go to http://www.cygwin.com and download the Cygwin environment. This will give you a complete shell (a real shell, not the DOS-box), the gcc-compiler...well, in short a reasonable emulation of a UNIX-system working under Win. You'd be compatible with all those hints here that sound strange to you (like 'perldoc -f open'). Moreover, you could thus replace ActiveState's Perl and compile your own using the gcc and having all the documentations that we UNIX-people are so fond of. And you'd have the man-program as well.
In addition to that: You could use the CPAN as it was meant to use. No longer any fiddling with PPM but instead directly using the powerful and convenient CPAN-shell for installing and browsing the modules.

If someone forced me to use Win, it'd be the first thing I'd do...secretly installing cygwin! You'd quickly realize that a _real_ text-mode is much more powerful than any click-and-point interface.

Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: 16 Aug 2001 22:01:29 -0700
From: mike.driggers@xo.com (Mike Driggers)
Subject: Re: Verifying users against NT domain?
Message-Id: <1fd3ee27.0108162101.63ec3529@posting.google.com>

You should try the nmblookup shell tool... you can parse the return
and get the WinNT domain.

-- Mike


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

Date: Fri, 17 Aug 2001 12:15:26 +0800
From: "meow" <maxim68@hotmail.com>
Subject: what do these mean in Makefile
Message-Id: <9li5p2$1k7@news.or.intel.com>

all,

in the Makefile for module install,
anyone out there can give me brief explanation for the below lines found in
the Makefile, what does this for?

Thanks
meow


INSTALLDIRS = site
INSTALLPRIVLIB = /$path/lib/perl5
INSTALLARCHLIB = /$path1/lib/perl5/hp_ux102/5.004
INSTALLSITELIB = /$path1/lib/perl5/site_perl
INSTALLSITEARCH = /$path1/perl5/site_perl/hp_ux102
INSTALLBIN = /$path/bin
INSTALLSCRIPT = /$path/bin




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

Date: 17 Aug 2001 10:41:41 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: what do these mean in Makefile
Message-Id: <87y9oj89y2.fsf@abra.ru>


m> all,
m> in the Makefile for module install,
m> anyone out there can give me brief explanation for the below lines found in
m> the Makefile, what does this for?

Read 'perldoc ExtUtils::MakeMaker'

m> Thanks
m> meow


m> INSTALLDIRS = site
m> INSTALLPRIVLIB = /$path/lib/perl5
m> INSTALLARCHLIB = /$path1/lib/perl5/hp_ux102/5.004
m> INSTALLSITELIB = /$path1/lib/perl5/site_perl
m> INSTALLSITEARCH = /$path1/perl5/site_perl/hp_ux102
m> INSTALLBIN = /$path/bin
m> INSTALLSCRIPT = /$path/bin



-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: Fri, 17 Aug 2001 14:49:43 +0800
From: "meow" <maxim68@hotmail.com>
Subject: what does this message mean?
Message-Id: <9lieqa$7r9@news.or.intel.com>

what does the below means?
thanks.


Can't locate loadable object for module IO::Tty in @INC (@INC contains:
/$path1 /$path2 $path3
  .) at  /$path1/Tty.pm line 26






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

Date: Fri, 17 Aug 2001 06:24:42 GMT
From: troll@gimptroll.com (TuNNe|ing)
Subject: why does this code print - HASH(0x80f764c)
Message-Id: <3b7cb6c7.9620863@news.coserv.net>

Why does this code.
http://www.gimptroll.com/sorty.txt

[begin code]
#!/usr/bin/perl -w

use CGI;
use CGI qw/:standard :html3/;
use CGI::Carp "fatalsToBrowser";
use strict;

my @row;

push(@row,td ([("A","B","C","D")])); #push the header back on

my @goods =  table({-style=>'font-size:
10pt'},{-border=>1,-width=>'90%'},
            Tr(\@row)
           );                      

print "Content-type: text/html\n\n";
print @goods;
exit;
[end code]

print this:
http://www.gimptroll.com/cgi-bin/sorty.cgi

[result]
HASH(0x80f764c)  A B C D 
[end result]

I see if I take out the _{-style=>'font-size: 10pt'}_ it does not
print the address, but then my fonts are not formated.

Regards,
Jason A. LeBlanc
http://www.gimptroll.com


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

Date: Fri, 17 Aug 2001 06:23:10 GMT
From: "Kevin Bartz" <l_pantin@hotmail.com>
Subject: Re: why does this code print - HASH(0x80f764c)
Message-Id: <iL2f7.12746$Ki1.1032080@bgtnsc06-news.ops.worldnet.att.net>

You're passing multiple hash references to table() when it only expects
one. Try this on for size:

#!/usr/bin/perl -w

use CGI;
use CGI qw/:standard :html3/;
use CGI::Carp "fatalsToBrowser";
use strict;

my @row;

push(@row,td ([("A","B","C","D")])); #push the header back on

my @goods =  table({-style=>'font-size: 10pt',
		    -border=>1,
		    -width=>'90%'},
		   Tr(\@row)
		   );               

print "Content-type: text/html\n\n";
print @goods;
exit;

Kevin

In article <3b7cb6c7.9620863@news.coserv.net>, "TuNNe|ing"
<troll@gimptroll.com> wrote:

> Why does this code.
> http://www.gimptroll.com/sorty.txt
> 
> [begin code]
> #!/usr/bin/perl -w
> 
> use CGI;
> use CGI qw/:standard :html3/;
> use CGI::Carp "fatalsToBrowser";
> use strict;
> 
> my @row;
> 
> push(@row,td ([("A","B","C","D")])); #push the header back on
> 
> my @goods =  table({-style=>'font-size:
> 10pt'},{-border=>1,-width=>'90%'},
>             Tr(\@row)
>            );
> 
> print "Content-type: text/html\n\n";
> print @goods;
> exit;
> [end code]
> 
> print this:
> http://www.gimptroll.com/cgi-bin/sorty.cgi
> 
> [result]
> HASH(0x80f764c)  A B C D
> [end result]
> 
> I see if I take out the _{-style=>'font-size: 10pt'}_ it does not print
> the address, but then my fonts are not formated.
> 
> Regards,
> Jason A. LeBlanc
> http://www.gimptroll.com


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

Date: Fri, 17 Aug 2001 06:58:57 +0200
From: Philip Newton <pne-news-20010817@newton.digitalspace.net>
Subject: Re: Why no spaces show up in print of array - sometimes??
Message-Id: <p48pnt470jvhna5ols5dfen01oj82ihqh6@4ax.com>

On Wed, 15 Aug 2001 19:08:36 -0400, tadmc@augustmail.com (Tad McClellan)
wrote:

> Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote:
> 
> >Can someone explain to me why the second print (after the call to the 
> >temp sub) prints out without any spaces between the names in the 
> >following code?  
> 
> 
> Because
> 
>   $, = '';

And this variable was used because you said 'print @a;'

> >Or for that matter why there are spaces in the first 
> >print?  
> 
> 
> Because
> 
>   $" = ' ';

And that variable was used because you said 'print "@a\n";' (it would
also have been used for 'print "@a";').

>    perldoc perlvar

Still a good idea.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Fri, 17 Aug 2001 06:58:58 +0200
From: Philip Newton <pne-news-20010817@newton.digitalspace.net>
Subject: Re: Will Perl report on variables no longer used??
Message-Id: <nm8pntcq6nbuv24iveub2mch97tem9qna8@4ax.com>

On Thu, 16 Aug 2001 21:11:34 +0200, "Steffen Müller" <tsee@gmx.net>
wrote:

> >   sub foo {
> >     my $bar;
> >     1;
> >   }
> 
> Isn't bar destroyed when the sub exits?

It is, but it's re-created the next time the sub is called, so it still
takes up unnecessary space.

> Hasn't Perl got a GC?

It has.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Fri, 17 Aug 2001 06:58:59 +0200
From: Philip Newton <pne-news-20010817@newton.digitalspace.net>
Subject: Re: Will Perl report on variables no longer used??
Message-Id: <dp8pntsdrqc2if661gkmqgpfmvhadfjg09@4ax.com>

On Thu, 16 Aug 2001 20:35:13 +0200, "Steffen Müller" <tsee@gmx.net>
wrote:

> If you declare your vars with 'my' in your subs (and you definetly should),
> the vars will go out of scope when the program exits the sub. Perl's garbage
> collector will take care of deleting them.

I think he doesn't want to create them in the first place if he's never
going to use them. That's sort of like saying "when you get spam, you
can press the delete key to get rid of it", but I'd prefer not getting
any spam that I'd have to delete.

> I'm not quite sure if $foo = undef; actually *deletes* the var from
> namespace.

I am. It doesn't. Nor does "undef $foo;" do so. (Which one you use makes
a difference with arrays and hashes.)

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

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


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