[7078] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 701 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 7 21:17:31 1997

Date: Mon, 7 Jul 97 18:05:03 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 7 Jul 1997     Volume: 8 Number: 701

Today's topics:
     Re: error message: panic: pp_iter (M.J.T. Guy)
     Re: Event Log Reporting - Doesn't Work <dave@turfpit.demon.co.uk>
     example of communicating with several kids. <md4marcu@nil.se>
     Re: exec a command that has a single quote char <rootbeer@teleport.com>
     Extracting Fields from Ascii Files (Pike Peak)
     Re: Extracting Fields from Ascii Files <rootbeer@teleport.com>
     Re: Extracting Fields from Ascii Files <bat@unifi.com>
     Re: Extracting Fields from Ascii Files (A. Deckers)
     Re: Extracting Fields from Ascii Files <sfairey@adc.metrica.co.uk>
     fastest way to load large files? <thoeffel@amgen.com>
     Re: fastest way to load large files? (Ilya Zakharevich)
     Re: fastest way to load large files? (Craig Berry)
     Re: fastest way to load large files? <rootbeer@teleport.com>
     Re: FDF File Problems with Text Attachment <rootbeer@teleport.com>
     Re: FDF File Problems with Text Attachment <rootbeer@teleport.com>
     Re: file test <rootbeer@teleport.com>
     Re: FOR QUESTION <merlyn@stonehenge.com>
     Re: FOR QUESTION (Tad McClellan)
     Re: forking without wait <wayne@cta-challenge.com.au>
     Re: Function pointers in PERL web@calarts.edu
     Re: GIFgraph.pm or finance scripts <zenin@best.com>
     Re: Grade my first Perl Project (Unknown)
     Re: Grade my first Perl Project (Tad McClellan)
     Re: hashes of hashes in perl5 (M.J.T. Guy)
     help for CALBOOK installation <fenechda@zedat.fu-berlin.de>
     Re: Help with getting file contents (Carsten Schabacker)
     help: match empty line rr568@epix.net
     Re: HELP: Programming an IRC Client for X Window (Mr Andrew Snare)
     Re: Help: Using Getopt.pl (Clay Irving)
     Re: High bit char in input (Honza Pazdziora)
     Re: How do I implement Records?? (A. Deckers)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 4 Jul 1997 07:40:29 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: error message: panic: pp_iter
Message-Id: <5pi9dd$ik0@lyra.csx.cam.ac.uk>

Marek Rouchal <marek@buffalo.hl.siemens.de> wrote:
>
>foreach(@a) {
>  if(<<cond1>>) {
>    <<some commands>>
>    goto label;
>    }
>  elsif(<<cond2>>) {
>    <<some commands>>
>    goto label;
>    }
>  else {
>    <<some commands>>
>    label:
>    <<other commands>>
>    }
>  }
>
>If condition 1 is met, the foreach loop fails with this error message:
>
>> panic: pp_iter at myscript line 301 (#1)

Clearly a bug.   Still present in 5.004_01.   Reported to perlbug.

>Apart from being rather poor programming style (yes, I know :-| ), gotos did
>work as expected in other contexts.

They shouldn't ever cause (P) errors or dumps, however bad style.

And in your example, the label seems to be used simply to cause the
<<other commands>> to be obeyed on all paths.   So you could better write
that as

 foreach(@a) {
   if(<<cond1>>) {
     <<some commands>>
     }
   elsif(<<cond2>>) {
     <<some commands>>
     }
   else {
     <<some commands>>
     }
   <<other commands>>
   }

If you want the code obeyed only on some paths, just set a flag:

 foreach(@a) {
   my $do_other_commands;
   if(<<cond1>>) {
     <<some commands>>
     $do_other_commands++
     }
   elsif(<<cond2>>) {
     <<some commands>>
     }
   else {
     <<some commands>>
     $do_other_commands++
     }
   <<other commands>> if $do_other_commands;
   }


Mike Guy


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

Date: Thu, 03 Jul 1997 22:37:09 GMT
From: "David Richards" <dave@turfpit.demon.co.uk>
Subject: Re: Event Log Reporting - Doesn't Work
Message-Id: <01bc8801$b6308830$0101010a@turfpit>

Frank

Get onto	www.activeware.com
select		Related Sites
select		Philippe Leberre's Perl Pages

Here you will find detailed (correct) documentation about using Win32 Perl
with the Eventlog and Registry.

David

Frank Huddleston <Frank.Huddleston@guardian.brooks.af.mil> wrote in article
<01bc8701$072df260$70058c8c@oepc05112>...
> 
> 
> David Richards <dave@turfpit.demon.co.uk> wrote in article
> <01bc8330$a74dbd90$0101010a@turfpit>...
> > Frank
> > 
> > Try this - straight from the docs for Win32 Perl build 306.  Works for
me
> > on NT4 SP3 with build 306.
> > 
> > 	$EventLog->GetNumber($number) || die $!;
> > 	print "There are $number records in the System Event Log\n";
> 
> Yes, this works, but it returns only the number of records in the Event
> Log. Has anyone tried actually reading those records? I get a message:
> Argument "EVENTLOG_SEQUENTIAL_READ" isn't numeric in entersub at
> R:\perl5\lib/Win32/Eventlog.pm line 123.
> 
> Substitution with the actual numeric value ( 1 ) doesn't work either, but
> doesn't return that error. 
> 
> Frank Huddleston
> 
> 


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

Date: Fri, 04 Jul 1997 10:32:07 +0200
From: Marcus Engene <md4marcu@nil.se>
Subject: example of communicating with several kids.
Message-Id: <33BCB507.49BE@nil.se>

Hi!

Yesterday, I asked a question about how to communicate with several
childs at once. The problem was that I had to use open2, because I
wanted to talk to my children as well :) (yell at them)

I haven't seen any example of this anywere, so I think I'll post what
I figured out here. It's perhaps not an extremely qute solution, but
it works. Hope this helps someone out.

#!/usr/bin/perl

use IPC::Open2;
use IO::Select;

$s = IO::Select->new();

# Tha bad thing is that you must have as many elements in these as #
# of slaveprocs
@farr=(\*r00, \*r01, \*r02, \*r03, \*r04, \*r05, \*r06, \*r07, \*r08,
\*r09);
@farw=(\*w00, \*w01, \*w02, \*w03, \*w04, \*w05, \*w06, \*w07, \*w08,
\*w09);

for ($i=0; $i<4; $i++)
{
        $pid=open2($farr[$i], $farw[$i], "somefile");
        $s->add($farr[$i]);
}

$s->add(\*STDIN);

$timeout=2;

while (1)
{
        @ready = $s->can_read($timeout);

        foreach $fh (@ready)
        {
                $data=<$fh>;
                if (!length ($data))
                {
                        $s->remove($fh); # died
                        print "Something died\n";
                }
                print STDOUT $data;
        }
}

/Marcus
marcus [at} student.adb.gu.se

--
Staten Informerar: "Fvr vkat vdlbefinnande, genomfvr daglig
fekalieanalys!"


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

Date: Thu, 3 Jul 1997 17:50:59 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: William Byrd <wcb4@erols.com>
Subject: Re: exec a command that has a single quote char
Message-Id: <Pine.GSO.3.96.970703174606.6445O-100000@kelly.teleport.com>

On Wed, 2 Jul 1997, William Byrd wrote:

>     exec "perl txt2html.pl $infile >$outfile";

That's not what you want. You're doing this inside of a loop, and a
successful exec never returns. You probably want system instead. Since
you're doing redirection, you can use the multiple-argument form of system
like this. (I didn't read your whole message carefully enough to be sure
that this is what you want, but at least it's better than what you had! 
:-) 

    open STDOUT, "> $outfile"
	or die "Can't redirect to '$outfile': $!";
    !system 'perl', 'txt2html.pl', $infile
	or die "Subprocess had non-zero exitcode: $?";

Since you won't be using a shell, you don't have to escape single quotes
or other odd characters in $infile. Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 7 Jul 1997 16:17:48 GMT
From: peak@ulc199.residence.gatech.edu (Pike Peak)
Subject: Extracting Fields from Ascii Files
Message-Id: <5pr4rc$bur@smash.gatech.edu>


I have an ascii file and I'm trying to extract a number
from it.  I can do the split to get the entire field,
the problem is that I need to split up that field.
I.E.  I have a 7 digit number & I'd like to use only
the last five digits of the number. (nope, there's no
regular pattern to the first two numbers.)

Also, if any one has any ideas on search algorithms
for flat ascii files, that would also be of some great
help.

Thanks gang.

Jason Peak
peak@ulc199.residence.gatech.edu


P.S.  Yes, I've already looked online for modules that would
do what I'm looking for and have come up empty.



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

Date: Mon, 7 Jul 1997 10:21:21 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Pike Peak <peak@ulc199.residence.gatech.edu>
Subject: Re: Extracting Fields from Ascii Files
Message-Id: <Pine.GSO.3.96.970707102003.9019b-100000@kelly.teleport.com>

On 7 Jul 1997, Pike Peak wrote:

> I have a 7 digit number & I'd like to use only
> the last five digits of the number. 

    $last5 = substr($number, -5);

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 07 Jul 1997 13:05:27 -0400
From: Boris Tabenkin <bat@unifi.com>
To: Pike Peak <peak@ulc199.residence.gatech.edu>
Subject: Re: Extracting Fields from Ascii Files
Message-Id: <33C121D7.EC4FEFD5@unifi.com>

You can use $bar=substr($foo,2,5) or you can be more intelegent and say
someting like
$bar=subsr($foo,-5) where just the last 5 chars are returned.

Regards,
Boris Tabenkin
bat@ziplink.net

Pike Peak wrote:

> I have an ascii file and I'm trying to extract a number
> from it.  I can do the split to get the entire field,
> the problem is that I need to split up that field.
> I.E.  I have a 7 digit number & I'd like to use only
> the last five digits of the number. (nope, there's no
> regular pattern to the first two numbers.)
>
> Also, if any one has any ideas on search algorithms
> for flat ascii files, that would also be of some great
> help.
>
> Thanks gang.
>
> Jason Peak
> peak@ulc199.residence.gatech.edu
>
> P.S.  Yes, I've already looked online for modules that would
> do what I'm looking for and have come up empty.





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

Date: 7 Jul 1997 20:09:24 GMT
From: deckers@man.ac.uk (A. Deckers)
Subject: Re: Extracting Fields from Ascii Files
Message-Id: <slrn5s2j7j.li.deckers@nessie.mcc.ac.uk>

In <5pr4rc$bur@smash.gatech.edu>,
	Pike Peak <peak@ulc199.residence.gatech.edu> wrote:
>
>I have an ascii file and I'm trying to extract a number
>from it.  I can do the split to get the entire field,
>the problem is that I need to split up that field.
>I.E.  I have a 7 digit number & I'd like to use only
>the last five digits of the number. (nope, there's no
>regular pattern to the first two numbers.)

$last5chars = substr $string, -5;

Look up substr in the documentation.

HTH,

Alain

-- 
Perl information: <URL:http://www.perl.com/perl/>
        Perl FAQ: <URL:http://www.perl.com/perl/faq/>
    Perl archive: <URL:http://www.perl.com/CPAN/>
>>>>>>>> comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<


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

Date: Mon, 07 Jul 1997 18:01:13 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Pike Peak <peak@ulc199.residence.gatech.edu>
Subject: Re: Extracting Fields from Ascii Files
Message-Id: <33C120D9.15FB@adc.metrica.co.uk>

Pike Peak wrote:
> 
> I have an ascii file and I'm trying to extract a number
> from it.  I can do the split to get the entire field,
> the problem is that I need to split up that field.
> I.E.  I have a 7 digit number & I'd like to use only
> the last five digits of the number. (nope, there's no
> regular pattern to the first two numbers.)
> 
> Also, if any one has any ideas on search algorithms
> for flat ascii files, that would also be of some great
> help.
> 
> Thanks gang.
> 
> Jason Peak
> peak@ulc199.residence.gatech.edu
> 
> P.S.  Yes, I've already looked online for modules that would
> do what I'm looking for and have come up empty.

Coupla options spring to mind:

$numbers='1234567';

($last_five) = $numbers =~ /..(.....)/;
or
($last_five) = $numbers =~ /\d\d(\d*)/;
or
$last_five = substr( $numbers, 2, 5 );

Hope this gives you some ideas.

Simon


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

Date: Thu, 03 Jul 1997 16:16:38 -0700
From: Thomas J Hoeffel <thoeffel@amgen.com>
Subject: fastest way to load large files?
Message-Id: <33BC32D6.1CFB@amgen.com>

hello,

i'm am currently loading an array from STDIN  via

while (<>) {
  chop;
  @file=(@file,$_);
  ...etc
}

i've recently needed to load much larger files (70k-80k lines) into 
@file.  it's extremely slow.  am i doing something wrong?
is it faster to load from an open filehandle?
can i set memory allocations in perl?

thanks for any and all replies

thomas
-- 

"heaven is just like where you are now, only much, much nicer."
*** Disclaimer: These are the opinions of the poster not Amgen Inc.***


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

Date: 5 Jul 1997 18:58:51 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: fastest way to load large files?
Message-Id: <5pm5hb$oc@agate.berkeley.edu>

In article <Pine.GSO.3.96.970703223014.1127P-100000@kelly.teleport.com>,
Tom Phoenix  <rootbeer@teleport.com> wrote:
> On Thu, 3 Jul 1997, Thomas J Hoeffel wrote:
> 
> > while (<>) {
> >   chop;
> >   @file=(@file,$_);
> 
> Eeek! Do you see what happens when @file has, say, 1000 entries? At that
> point, you're building a new list of 1001 items and assigning those 1001
> entries to replace the current value of @file!
> 
> You probably wanted to use push() to do that. But if you're going to read
> the whole file (or files) into memory, you might just do this.
> 
>     chomp(@file=<>);

Note though that your remark is still applicable to your construction
too.  While 
	$line = <>;
is optimized in the sense that perl writes the data directly _into_
$line, 
	@file = <>;
is not.  The array is created on stack first, then it is copied to
@file.

Anyone wanting to optimize it in the way split() works (with stack
switching)? 

Ilya


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

Date: 3 Jul 1997 23:48:42 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: fastest way to load large files?
Message-Id: <5phdoq$2tv$1@marina.cinenet.net>

Thomas J Hoeffel (thoeffel@amgen.com) wrote:
: i'm am currently loading an array from STDIN  via
: 
: while (<>) {
:   chop;
:   @file=(@file,$_);
:   ...etc
: }
: 
: i've recently needed to load much larger files (70k-80k lines) into 
: @file.  it's extremely slow.  am i doing something wrong?
: is it faster to load from an open filehandle?
: can i set memory allocations in perl?

It will probably be much faster to read in the entire list of lines as a
single operation:

  @file = <>;
  chomp @file;

Note that <> in a list context (like assignment to a list variable, in 
this case) reads in all (remaining) lines as elements of the list, and 
that chomp applied to a list chomps each line of the list.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Thu, 3 Jul 1997 22:32:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Thomas J Hoeffel <thoeffel@amgen.com>
Subject: Re: fastest way to load large files?
Message-Id: <Pine.GSO.3.96.970703223014.1127P-100000@kelly.teleport.com>

On Thu, 3 Jul 1997, Thomas J Hoeffel wrote:

> while (<>) {
>   chop;
>   @file=(@file,$_);

Eeek! Do you see what happens when @file has, say, 1000 entries? At that
point, you're building a new list of 1001 items and assigning those 1001
entries to replace the current value of @file!

You probably wanted to use push() to do that. But if you're going to read
the whole file (or files) into memory, you might just do this.

    chomp(@file=<>);

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 4 Jul 1997 13:03:31 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Jared M (SBN2)" <MeGuitar@usa.net>
Subject: Re: FDF File Problems with Text Attachment
Message-Id: <Pine.GSO.3.96.970704125757.18569D-100000@kelly.teleport.com>

On 4 Jul 1997, Jared M (SBN2) wrote:

> What can I do to edit and print these insurance forms in the FDF format?

Do you know what the file format is? That's probably the first step, since
you'll probably want to write a module that can read and write those
files. Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/




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

Date: Fri, 4 Jul 1997 16:36:33 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Jared M (SBN2)" <MeGuitar@usa.net>
Subject: Re: FDF File Problems with Text Attachment
Message-Id: <Pine.GSO.3.96.970704163432.6484G-100000@kelly.teleport.com>

On 4 Jul 1997, Jared M (SBN2) wrote:

> > Do you know what the file format is? >
> 
> No I do not, that is why I need someone to tell me what the format is! 

Ah. Well, that's not a Perl question, so you might have some luck checking
elsewhere. If it's not documented with your software, you might see
whether the vendor offers information about the file format. Or, you could
check with other people who use that file format to see whether they can
tell you. Failing that, you could attempt to decode it yourself. Good
luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 7 Jul 1997 07:41:06 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: SHILUV Naama Westreich 3945 <naama@sysdep.elex.co.il>
Subject: Re: file test
Message-Id: <Pine.GSO.3.96.970707073847.9019N-100000@kelly.teleport.com>

On Mon, 7 Jul 1997, SHILUV Naama Westreich 3945 wrote:

> Is there a way to test files on OTHER host? 

Sure. You need to use some kind of protocol to talk to the other host and
ask it to tell you what you need to know. (You will need to trust what it
tells you, of course!) Some common protocols used for this sort of thing
are HTTP and FTP. There are Perl modules which are able to work with these
protocols. Hope this helps! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 07 Jul 1997 08:59:03 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: iap@iis.sinica.edu.tw (Iap SinGuan)
Subject: Re: FOR QUESTION
Message-Id: <8ciuym97lk.fsf@gadget.cscaper.com>

>>>>> "Iap" == Iap SinGuan <iap@iis.sinica.edu.tw> writes:

Iap> In article <33c15d56.18863371@news.prodigy.net>, FANNGMAIL@prodigy.net says...
>> 
>> hi there:
>> Is someone know that    for ( ; <STDIN> ; )  
>> {print;}
>> why stdin can't in the first or last???? and what kind the still to put in that
>> three EXPR in FOR.

Iap> It can be in the last if of  the following form:
Iap>   for(;;$a=<STDIN>){
Iap>      print $a;
Iap>   }

Nope.  That prints "undef" the first time around (which you see as an
empty string).  The third for-expression is executed *after* the body
of the loop.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 421 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Mon, 7 Jul 1997 06:29:15 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: FOR QUESTION
Message-Id: <bujqp5.ql.ln@localhost>

Iap SinGuan (iap@iis.sinica.edu.tw) wrote:
: In article <33c15d56.18863371@news.prodigy.net>, FANNGMAIL@prodigy.net says...
: >
: >hi there:
: >    Is someone know that    for ( ; <STDIN> ; )  
: >                                               {print;}
: >why stdin can't in the first or last???? and what kind the still to put in that
: >three EXPR in FOR.

: It can be in the last if of  the following form:
:   for(;;$a=<STDIN>){
:      print $a;
:   }


Which would be OK for an obfuscated perl contest ;-)

If you want a while loop (which the followup code is, I can't figure
out what the original poster's code was meant to do...),
then just use a while loop  ;-)


while(defined($a=<STDIN>)){  # and check the value too
   print $a;
}


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Sun, 06 Jul 1997 19:10:00 +1000
From: Wayne Blick <wayne@cta-challenge.com.au>
Subject: Re: forking without wait
Message-Id: <33BF60E8.5414@cta-challenge.com.au>

Sanford Morton wrote:
> 
> lloyd Vancil  <lev@apple.com> wrote:
>  >Is it possible in perl to fork a child using fork or system or ``,
>  >without having to wait for the child to exit?
> 
> If you don't need the control fork() offers, you can use open()
> without a corresponding close() in the parent. It's the close() that
> causes the parent to wait. See Camel II, p. 194 and its warnings on
> flushing buffers.


The Perl interpreter seems to catch children that die if you just ignore
it in your script.

Try:

$SIG{CHLD} = 'IGNORE';

Regards.
Wayne Blick


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

Date: Mon, 07 Jul 1997 14:37:23 -0600
From: web@calarts.edu
Subject: Re: Function pointers in PERL
Message-Id: <868303563.18962@dejanews.com>

In article <868255371.18225@dejanews.com>,
  crr026@email.mot.com wrote:

> In C (my mother tongue, :-}), there's a construct called function
> pointers. I can load an array with pointers to the functions concerned,
> and instead of going through the if-else chain, work out the index and
> jump to the function right away. Is there such a beast or technique I can
> use in Perl?

There certainly is!  Try:

    $someArray[$someIndex] = \&someFunction;

    &{$someArray[$someIndex]};   # calls &someFunction

For more info, take a look at the perlref manpage:

    http://www.perl.org/CPAN/doc/manual/html/pod/perlref.html

Hope this helps!

-jason

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 3 Jul 1997 19:38:41 GMT
From: Zenin <zenin@best.com>
Subject: Re: GIFgraph.pm or finance scripts
Message-Id: <5pgv41$9m7$2@nntp2.ba.best.com>

Kevin Luff <kluff@enterprise.net> wrote:
> as for the GIFgraph module....that code is why i asked the question !!
> I think of my self as an average++ programmer (when sober) and held the
> faint hope that some poor soul had been there and done it, got the t-shirt,
> etc.
> still....lets wait and see. I might even leave the
> gin/wife/child/car/garden/housework etc alone for a few days and knuckle
> down to it myself
	>snip<

	The basic problems I see with the module code for your problem
	(using negitive values) is that there is no base support for moving
	the min value.  To make it work you'll need to add options for a
	min-value to go with the max-value, and maybe even a
	centerline-value.  You'll probably need to hack both
	GIFgraph::axestype and GIFgraph::line (or points, or whatever).  I'm
	adding this support into my rewrite, Image::Graph, but it's no were
	near finshed...

-- 
-Zenin
 zenin@best.com


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

Date: Mon, 07 Jul 1997 17:51:02 GMT
From: unknown3@geocities.com (Unknown)
Subject: Re: Grade my first Perl Project
Message-Id: <33c12c69.254279534@news.bctel.ca>

On 26 Jun 1997 00:29:33 GMT, nvp@shore.net (Nathan V. Patwardhan)
wrote:

>: > BTW: comp.lang.perl no longer exists.
>: What do you mean it no longer exists?
>It means that it should be removed from your newsfeed's active file.
>Someone told me (about two weeks ago) that their site still carried
>comp.lang.perl, but it should not be so.  Wonder how many people are
>still feeding it to and fro?

comp.lang.perl seems to exist here.  Where else is there for Perl
talk?



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

Date: Mon, 7 Jul 1997 13:38:59 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Grade my first Perl Project
Message-Id: <34drp5.cp6.ln@localhost>


[ Newsgroups and Followup-To set to a newsgroup that actually exists ]


Unknown (unknown3@geocities.com) wrote:
: On 26 Jun 1997 00:29:33 GMT, nvp@shore.net (Nathan V. Patwardhan)
: wrote:

: >: > BTW: comp.lang.perl no longer exists.
: >: What do you mean it no longer exists?
: >It means that it should be removed from your newsfeed's active file.
: >Someone told me (about two weeks ago) that their site still carried
: >comp.lang.perl, but it should not be so.  Wonder how many people are
: >still feeding it to and fro?

: comp.lang.perl seems to exist here.  

Then your news server is misconfigured. Ask your sysadmin to delete it.

More importantly, folks that are able to answer questions know that is
is a non-group and hence do not read it...


: Where else is there for Perl
: talk?

comp.lang.perl.misc 


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 4 Jul 1997 07:02:35 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: hashes of hashes in perl5
Message-Id: <5pi76b$grm@lyra.csx.cam.ac.uk>

In article <33B934D5.73058FCE@absyss.fr>, Doug Seay  <seay@absyss.fr> wrote:
>Ivar Hxsteng wrote:
>> 
>> I am trying to access the second level hashes in a hash of hashes like
>> this:
>> 
>> #!/usr/bin/perl -w
>> 
>> $$hh{"foo"}{"test1"}="some data";
>> $$hh{"foo"}{"test2"}="some other data";
>> $$hh{"bar"}{"tst1"}="some data2";
>> $$hh{"bar"}{"tst2"}="some other data2";
>> 
>> foreach $i (sort keys %$hh) {
>>         print "Starting dataset $i:\n";
>>         foreach $j (sort keys %$hh{$i}) {              #<<<<<<<<<<<<<<<<<<<<
>>                 print "Data for $j is $$hh{$i}{$j}\n"; #<<<<<<<<<<<<<<<<<<<<
>>         }
>> }
>
>You left out a few steps, namely:
>   - where define $hh to be a hash ref?
>   - where did you define $$hh{foo} to be an hash ref?
>   - where did you define $$hh{bar} to be an hash ref?
>
>These things don't magically spring into existance.

Oh yes they do.   Didn't you try it?


And the problem with the original code is in the expressions  %$hh{$i}
and  $$hh{$i}{$j}  in the flagged lines.   Your code produces a compile time
error, even without -w.   There are two errors:

i)    the % dereference binds more tightly than the subscript, so your
      expression parses as  %{$hh}{$i}  rather than as  %{$hh{$i}}.

ii)   The subexpression $hh{$i} gives you element $i of the hash %hh,
      whereas you want the hash  %$hh  obtained by dereferencing  $hh.

Write the two flagged lines as

           foreach $j (sort keys %{$hh{$i}}) {
                   print "Data for $j is ${$hh{$i}}{$j}\n";

and you get the output

Starting dataset bar:
Data for tst1 is some data2
Data for tst2 is some other data2
Starting dataset foo:
Data for test1 is some data
Data for test2 is some other data



Mike Guy


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

Date: Mon, 07 Jul 1997 21:56:29 +0200
From: Richard Feneberg <fenechda@zedat.fu-berlin.de>
Subject: help for CALBOOK installation
Message-Id: <33C149ED.1D02@zedat.fu-berlin.de>

I'm looking for help on installing the CALBOOK reservation room program
by Jan Snellman.

The used environment: 
CALBOOK_current.tar.gz, perl-library CGI.pm-2.36, Windows95, WebSite
1.1, Perl for Win32 Build 306 Version 5.003_07.

Though strictly following the instructions to install the program - 
the cgi.pm in the directory Perl/lib is available, because the examples
in the cgi-package and the cgitest.pl in CALBOOK are working. The
desired extensions .pl are added to each of the perl-scripts, the paths
and variables in the files CalConf.pm and .htaccess are changed -, 
some curious things happens:
1.	Message: CGI output from
        ../cgi-shl/CALBOOK/cal_show_day.pl	#or any other
	contained no blank line separating header and data.
2.	The compilation in dos-shell sometimes breaks because on this machine
is no dbm (?).
3.	An alarming thing is, that several files in the CALBOOK directory are
destroyed or deleted after an restart of Windows95. The use of an
virus-detection program shows no viruses. Is this perhaps caused by
perl?

Many thanks for every tip to repair one of the faults
Richard


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

Date: 04 Jul 1997 10:08:50 +0200
From: c.schabacker@gis.ibfs.de (Carsten Schabacker)
Subject: Re: Help with getting file contents
Message-Id: <u2wwn7i6i5.fsf@aix1.ibfs.de>

perrella andrew c <perrella@ehsn6.cen.uiuc.edu> writes:

> How do you get read the contents of a file into a scalar variable?
> 
> This has me stumped.  I'd like to take a file in the same directory as my
> script and end up with a scalar, for example $file_contents, that contains
> the contents of the file I want.
Try this:

open(FILE, "filename") || die("open error");
$file_contents=<FILE>;
close(FILE) || die("Error while reading");

cs.
-- 
GiS - Gesellschaft fuer integrierte Systemplanung mbH   Tel. +49-6201-503-38
Carsten Schabacker                                      Fax  +49-6201-503-66
Junkersstr. 2                               E-Mail  c.schabacker@gis.ibfs.de
D-69469 Weinheim                      private  cschaba@spock.rhein-neckar.de


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

Date: Mon, 07 Jul 1997 20:32:05 GMT
From: rr568@epix.net
Subject: help: match empty line
Message-Id: <5prj2q$qci$1@nando.pfmc.net>

It's driving me nuts!  I want my perl script to 
  if ($this =~ m/(an empty line)/) {
    do something...
  }

I want to replace a \n with something else, only if there's nothing else on 
the line

RR.


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

Date: 4 Jul 1997 16:49:37 +1000
From: ajs@silas.cc.monash.edu.au (Mr Andrew Snare)
Subject: Re: HELP: Programming an IRC Client for X Window
Message-Id: <5pi6e1$5bc@silas.cc.monash.edu.au>

Moh <moh@geocities.com> writes:

[stuff about wanting to write an IRC client snipped]

>PS: I am going to send this to several groups so that
>it would be great to *email* me the stuff instead of
>sending it to the groups as I don't know if I can look
>through all of them and filter out the stuff. Thanks :)
>....and in German written material is as helpful as
>in English written meterial, just both langs.

Well, I tried replying to that address and it bounced. Since it's
off-topic I won't put my whole reply here -- email me with a correct
return address if you really want a reply. :)

 - Andrew


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

Date: 3 Jul 1997 19:04:42 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: Help: Using Getopt.pl
Message-Id: <5phb6a$63c@panix.com>

In <33BBAB1C.1321@bnr.ca> Raju Gadiraju <rajug@bnr.ca> writes:

>Hello Netters,

>I've a problem using getopt.pl.

>The book (Programming Perl: nutshell book by Wall / Schwartz ) says 
>that if an option is given at the command line $opt_x will be set to
>that option and if its not given it is set to 1. 

>But when I give "execname -h", I find that $opt_h is still NULL.
>Would any one of you know why.

Are you really "using" it? -- Example code usually makes the diagnosis
easier.

-- 
Clay Irving                                        See the happy moron,
clay@panix.com                                     He doesn't give a damn,
http://www.panix.com/~clay                         I wish I were a moron,
                                                   My God! Perhaps I am!


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

Date: Mon, 7 Jul 1997 17:21:40 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: High bit char in input
Message-Id: <adelton.868296100@aisa.fi.muni.cz>

adelton@fi.muni.cz (Honza Pazdziora) writes:

> the pod2man says
> 
> 	=item high bit char in input stream

I am sorry about the post. I have used the old pod2man, the new one
from 5.004_01 version of Perl is quite happy even with eight bits.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 3 Jul 1997 18:03:27 GMT
From: deckers@man.ac.uk (A. Deckers)
Subject: Re: How do I implement Records??
Message-Id: <slrn5rnqba.d10.deckers@news.rediris.es>

In <01bc86ef$7e747b80$3e080a0a@mashfiel.miti.nb.ca>,
	mashfiel <ashfield.matthew@miti.nb.ca> wrote:
>Hi all, my apologies if this a total newbie question. 
>My problem is simple. I need an array of records. I don't know how many
>records would be in the array, but the record would have say 4 fields. I
>looked in the FAQ, Part 5, qestion 5.3. It said to use an associative
>array, then a list of my associative arrays. For example:
>
>%Record = (
>		$time 		=> $timeofday,
>		$direction 	=> $dir,
>		$count 		=>$count,
>		$percentage 	=>$perc,
>	);
>and then,
>@allRecords = (\%Record);
>
>This seems like it would work fine, but if I had say a hundred records,
>wouldn't I have to come up with a 100 names for my records. ie. a 100
>copies of:
>
>%Record = (
>		$time 		=> $timeofday,
>		$direction 	=> $dir,
>		$count 		=>$count,
>		$percentage 	=>$perc,
>	);
>And then have 
>@allRecords = (\%Record, \%Record1.....\%Record99);
>
>This seems like a ton of work, and I am sure there must be a much simpler
>way, or maybe I am interpreting the FAQ incorrectly. Either way, I'm stuck,
>so if anybody has any advice/solution/help, it would be greatly
>appreciated.

It's not so much work if you use a loop. Lets assume we get our data
from a colon-separated flat file:

my $file = '/some/path/name';

my @records = ();

open FH, $file or die "can't open $file: $!\n";

while (<FH>) {
	chomp;

	my($time, $dir, $count, $perc) = split /:/, $_;

	my $hashref = {
		'time'		=> $time,
		'direction'	=> $dir,
		'count'		=> $count,
		'percentage'	=> $perc,
	};

	push @records, $hashref;

}

close FH;

Now you can recover your data in another loop by derefing each element
of the array.

HTH,

Alain

-- 
Perl information: <URL:http://www.perl.com/perl/>
    Perl archive: <URL:http://www.perl.com/CPAN/>
        Perl FAQ: <URL:http://www.perl.com/CPAN/doc/FAQs/FAQ/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<


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

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

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