[8781] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2397 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 23 00:07:41 1998

Date: Wed, 22 Apr 98 21:00:31 -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           Wed, 22 Apr 1998     Volume: 8 Number: 2397

Today's topics:
    Re: 'each' and recursion, do they mix? <jll@skynet.be>
    Re: 'each' and recursion, do they mix? <jll@skynet.be>
    Re: 'each' and recursion, do they mix? (John Klassa)
    Re: 'each' and recursion, do they mix? <rootbeer@teleport.com>
    Re: 'wait' under perl5.004 (possibly a perl bug?) <rootbeer@teleport.com>
    Re: 2 newbie questions <jdf@pobox.com>
    Re: array elements -- how to exclude when reading in? <jkry3025@comenius.ms.mff.cuni.cz>
    Re: array elements -- how to exclude when reading in? (Craig Berry)
    Re: array elements -- how to exclude when reading in? <jdf@pobox.com>
    Re: CGI.PM Question & ASCII/HEX problem <rootbeer@teleport.com>
        compile err on BSDI 2.0 otis@POPULUS.net
    Re: fixed width text files <egwong@netcom.com>
    Re: float to hex conversion (Ron Shipp)
    Re: help with s/$foo/$bar/go; oddness <uri@sysarch.com>
    Re: help with s/$foo/$bar/go; oddness <lr@hpl.hp.com>
        Help: crypt for Win32 ?? <vish@netscape.com>
        How to get times in different timezones? <petere@atg.com>
    Re: How to save an external program output in a var? <rootbeer@teleport.com>
    Re: Local paths on W95 <rootbeer@teleport.com>
    Re: Memory usage <rootbeer@teleport.com>
    Re: Perl for WIN32 & SNMP (Martien Verbruggen)
    Re: Perl lets you change constant value (Abigail)
        perl library to read excel file (Karel.DeBruyne)
    Re: print multiple lines before or after match ? (Tad McClellan)
    Re: Problem creating users on an NT server via Perl scr (Abigail)
        Program to generate HTML call tree info? (EXCHANGE:CAR:5J42)
    Re: Regular Expression to match a valid IP address <tchrist@mox.perl.com>
    Re: Regular Expression to match a valid IP address (Kevin Reid)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 22 Apr 1998 16:35:55 +0200
From: Jean-Louis Leroy <jll@skynet.be>
Subject: Re: 'each' and recursion, do they mix?
Message-Id: <VA.0000009e.5cf54f52@jll>

> > it seems that 'each' uses a single iterator per hash. That's
> > disappointing,
>  
> Sorry to hear that you're disappointed.

Well, you see...<g> this is my first year of Serious Perl Programming and 
I've become accustomed to see that everything's Just Perfect.

> > 1) Can I say 'local' to something and have it save & restore the 
> > iterator?
>  
> Sorry, no. AFAIK.

I've read (in either Advanced- or Efficient Perl Programming) that, in 
principle, almost anything could be made localizable. Perhaps the idea will 
make it to a mighty Perl Porter.

> Make it a tied hash, and make hooks to let you save and restore the
> iterator.

Uh, won't that slow down every other hash operation?

> There! That's the documentation, and everybody knows that that's the
> hardest part! :-)  Now, we merely need the patch. Let us know when it's
> ready! :-)

ROFL! Nope, that's the second hardest...testing...no...forcing yourself to 
test...is the hardest part ;)

Jean-Louis Leroy
http://ourworld.compuserve.com/homepages/jl_leroy



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

Date: Wed, 22 Apr 1998 16:35:57 +0200
From: Jean-Louis Leroy <jll@skynet.be>
Subject: Re: 'each' and recursion, do they mix?
Message-Id: <VA.0000009f.5cf5577f@jll>

> Urm... I doubt if it's efficient, but I'm sure it's reentrant. Make a
> local copy of the hash!
>  
>  local (%hash) = %hash;

Well, since I was using 'each' for efficiency in the first place...

Perhaps flattening the hash into a list and iterating over that would work 
well...

Jean-Louis Leroy
http://ourworld.compuserve.com/homepages/jl_leroy



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

Date: 22 Apr 1998 17:14:50 GMT
From: klassa@aursgh.aur.alcatel.com (John Klassa)
Subject: Re: 'each' and recursion, do they mix?
Message-Id: <6hl8ia$99d$1@aurwww.aur.alcatel.com>

On Tue, 21 Apr 1998 22:19:07 +0200, Jean-Louis Leroy <jll@skynet.be> wrote:
->it seems that 'each' uses a single iterator per hash. That's 
->disappointing, and makes 'each' unsuitable for recursive algorithm that 
->iterate over the same hash at different levels of recursion. Hence my 

I was just looking at the man page for "each" and noticed the phrase
"single iterator for each hash, shared by all each(), keys(), and values()
function calls in the program"...  Can one of the p5p folks elaborate on
this?  I'm sure there's a sound technical reason, but it's not readily
apparent to me.

Thanks,
John

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


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

Date: Wed, 22 Apr 1998 17:02:00 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Jean-Louis Leroy <jll@skynet.be>
Subject: Re: 'each' and recursion, do they mix?
Message-Id: <Pine.GSO.3.96.980422100130.6132R-100000@user2.teleport.com>

On Wed, 22 Apr 1998, Jean-Louis Leroy wrote:

> It seems that the most obvious method is also the best...

That's good to know!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 22 Apr 1998 16:42:57 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Michael Francis FIR LDN <Michael.Francis@gs.com>
Subject: Re: 'wait' under perl5.004 (possibly a perl bug?)
Message-Id: <Pine.GSO.3.96.980422092614.6132N-100000@user2.teleport.com>

On Wed, 22 Apr 1998, Michael Francis FIR LDN wrote:

> [spud:~/perltest]%./test.pl -alarm
> All children are dead

Well, that's not right... But I can't duplicate it on my system. This
leads me to think that it's either a problem with your perl binary or your
system, but I don't know which. 

I've tweaked your test code to be a little more verbose. Does it still
show the problem for you?

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/

#!/usr/bin/perl -w
#
# Simple program showing the problem with wait.

use strict;

$| = 1;		# Flushing output
my $time_out = 5;

for (0..9) {
    # Set a delay between 10 and 30 secs
    my $delay = int(rand(20))+10;

    # 'bulletproof' checks .....
    FORK: {
	if (my $pid = fork) {
	    # This is the parent process
	} elsif ( defined $pid ) {
	    # $pid is 0, this is the child process
	    print "Process $$ will sleep for $delay seconds\n";
	    exec("/bin/sleep", $delay)
		or die "Can't exec: $!";
	} else {
	    # assume temp failure, but warn
	    warn "Problem with fork ($!), trying again...";
	    sleep 2;
	    redo FORK;
	}
    }
}

# Install the signal handler
$SIG{'ALRM'} = sub { print "Beep!\n"; alarm $time_out } ;

# Start the timer
if (@ARGV and $ARGV[0] eq '-alarm') {
    print "Using alarm...\n";
    alarm($time_out);
} else {
    print "No alarm...\n";
}

while((my $pid = wait) != -1) {
    print "Child $pid exited\n";
}

print "All children are dead\n";

exit(0);
__END__



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

Date: 20 Apr 1998 19:25:49 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: 2 newbie questions
Message-Id: <yax0c96a.fsf@mailhost.panix.com>

"Matthew Bell" <mbell@thedomaingroup.com> writes:

> 1. Can someone point me to a set of FAQs that would be
> understandable to a non-UNIXhead?  I'm teaching myself Perl on NT,
> using the Camel book, but I need more basic beginning help since
> examples like "It's just like grep or awk, except for the ...."
> don't mean much to me, never having used grep or awk.

Ah.  You're using the wrong book.  You want either the Llama or the
Gecko (which are different flavors of _Learning Perl_).  The Camel is
both a reference manual and the best possible bathroom reading for
someone who already has a firm grasp on Perlish fundamentals.  The
Camel is *not* a tutorial.

> 2. I'm trying to write a line of code that will strip an ending
> space character from a string, and it's not working.

That's because you're not using chomp.

   chomp $some_variable;

> I thought "/$ /" meant "match at the end of the string [space
> character]",

It means "match the end of the string followed by a space character"
which is, of course, impossible.  If, for some reason, you didn't want
to use chomp or chop, then you'd match / $/ (although better would be
/\s*$/, which means "whatever whitespace may be before the end of the
string").

Your homework:
   _Learning Perl on Win32 Systems_ (the Gecko)
   perldoc -f chop
   perldoc perlre
   perldoc perlop

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Wed, 22 Apr 1998 19:22:46 -0700
From: Jan Krynicky <jkry3025@comenius.ms.mff.cuni.cz>
Subject: Re: array elements -- how to exclude when reading in?
Message-Id: <353EA5F6.5298@comenius.ms.mff.cuni.cz>

Andre L. wrote:
> 
> In article <353C198B.54D732B9@coos.dartmouth.edu>, rjk@coos.dartmouth.edu wrote:
> 
> > Andre L. wrote:
> > >
> > > It would be nice if one could write:
> > >
> > > @records = map { next if /\026/;
> > >                  $_ } <>
> > >
> > > or
> > >
> > > @records = map { $_ unless /\026/ } <>
> > >
> > > Is there a way to do this sort of thing with map? (having map not return a
> > > value if we don't want it to?) I guess not. Maybe in Perl6?
> >
> > Isn't that what grep is for?
> 
> In this case, of course (is my face red).
> 
> Actually, I was thinking of a mapping function that would return a
> _modified_ value conditionally, like a hybrid between map and grep, and
> which would allow this kind of statement, to keep the resulting array as
> small as possible:
> 
> @b = grap { [ split /\t/ ] if Matches_criteria($_) } <MYFILE>;
> 
> rather than doing:
> 
> @b = map  { [ split /\t/ ] }
>      grep { Matches_criteria($_) } <MYFILE>;
> 
> which seems like too much looping for nothing.
> 
> Anyway.
> 
> A.L.

while (<MYFILE>) {
 next unless Matches_criteria($_);
 push @b,[split /\t/, $_];
}

This one uses much less memory, because it doesn't slurp
the whole file into an array at once, but rather reads
it one line at a time and stores it anywhere only if 
the line matches the condition.

And (at least if you do not omit the variables) it is more readable.

Jenda


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

Date: 22 Apr 1998 17:26:33 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: array elements -- how to exclude when reading in?
Message-Id: <6hl989$o01$1@marina.cinenet.net>

Jason Gloudon (jgloudon@hyssop.bbn.com.bbn.com) wrote:
: Jonathan Feinberg <jdf@pobox.com> wrote:
: >mshavel@erols.com (Michael Shavel) writes:
: >In which case
: >
: >   while(<>) {
: >      next if /\026/;
: >      push @records, $_;
: >   }
: 
: or if he's just interested in filtering before processing one could say
: 
: @records = map { /\026/ ? () : $_ } <>;

How's that different (other than being less clear) from

  @records = grep !/\026/, <>;

?

---------------------------------------------------------------------
   |   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: 20 Apr 1998 19:06:16 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: array elements -- how to exclude when reading in?
Message-Id: <zphgca2v.fsf@mailhost.panix.com>

cberry@cinenet.net (Craig Berry) writes:

> Or
> 
>   while (<>) {
>     push @records, $_ unless /\026/;
>   }

You asked for it...

   /\026/ || push @records, $_ while <>;

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Wed, 22 Apr 1998 15:52:55 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: squid@fish.net
Subject: Re: CGI.PM Question & ASCII/HEX problem
Message-Id: <Pine.GSO.3.96.980422085015.6132J-100000@user2.teleport.com>

On Wed, 22 Apr 1998 squid@fish.net wrote:

> Scenario:  Graphics files and a user fill-out form being uploaded via
> http file upload from both PC and Macintosh(ugh).

You mis-placed that groan. :-)

> while ($bytesread = read($filename,$buffer,1024)) {

Is $filename, as the name implies, a file name? That's odd...

> Problem: P.C. uploads work like a champ but the friggin' Mac's uploads

If you're following the proper protocol but some browser doesn't
cooperate, then it's the other program's fault. If you're not following
the protocol, then it's your fault. If you aren't sure about the protocol,
you should read the protocol specification. If you've read it and you're
still not sure, you should ask in a newsgroup about the protocol. 

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 22 Apr 1998 02:07:09 -0600
From: otis@POPULUS.net
Subject: compile err on BSDI 2.0
Message-Id: <6hk4ut$cev$1@nnrp1.dejanews.com>

Hi,

while trying to compile perl 5.004_4 with dynamic linking on a BSDI 2.0 box I
got these errors (the critical one is at the bottom):

        Making DynaLoader (static)
Makefile out-of-date with respect to ../../lib/Config.pm ../../config.h
Cleaning current config before rebuilding Makefile...
make -f Makefile.old clean > /dev/null 2>&1 || /bin/sh -c true
 ../../miniperl "-I../../lib" "-I../../lib" Makefile.PL "INSTALLDIRS=perl"
"LIBPERL_A=libperl.a"
Writing Makefile for DynaLoader
==> Your Makefile has been rebuilt. <==
==> Please rerun the make command.  <==
false
*** Error code 1

Stop.
make config failed, continuing anyway...
Skip ../../lib/DynaLoader.pm (unchanged)
 .
 .
 .
[NOTE: this one makes sense...
       #ls -l /usr/local/lib/
       libdld.a  libfl.a   libgd.a       -- no libdl.a :(
]
        Making DB_File (dynamic)
Makefile out-of-date with respect to ../../lib/Config.pm ../../config.h
Cleaning current config before rebuilding Makefile...
make -f Makefile.old clean > /dev/null 2>&1 || /bin/sh -c true
 ../../miniperl "-I../../lib" "-I../../lib" Makefile.PL "INSTALLDIRS=perl"
"LIBPERL_A=libperl.a"
Note (probably harmless): No library found for -ldb
Writing Makefile for DB_File
==> Your Makefile has been rebuilt. <==
==> Please rerun the make command.  <==
false
*** Error code 1

Stop.
make config failed, continuing anyway...
Skip ../../lib/DB_File.pm (unchanged)
 .
 .
 .
 ../../miniperl -I../../lib -I../../lib ../../lib/ExtUtils/xsubpp -noprototypes
-typemap ../../lib/ExtUtils/typ
emap -typemap typemap DB_File.xs >DB_File.tc && mv DB_File.tc DB_File.c
shlicc2 -c  -I/usr/local/include -O2     -DVERSION=\"1.15\"
-DXS_VERSION=\"1.15\"  -I../..  DB_File.c
 Running Mkbootstrap for DB_File ()
Writing DB_File.bs
chmod 644 DB_File.bs
LD_RUN_PATH="" ld -o ../../lib/auto/DB_File/DB_File.none  none -L/usr/X11/lib
-L/usr/local/lib DB_File.o
ld: No such file or directory for none
*** Error code 1

Stop.
*** Error code 1

Stop.

And of the story :(
What should I do?
It looks like I don't have ldb.a and this 'ld' doesn't like it.
I know perl's Configure script asked me for the names of all extensions that I
want dynamically built. DB_File was one of them.
Should I remove it from the list and hope to be okay?

THanks!

Otis
P.S.
not sure if it matters, but find / -name DB_File.none -print
yielded nothing. I'm not sure if 'ld' up there was expecting it...

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Wed, 22 Apr 1998 18:18:16 GMT
From: Eric Wong <egwong@netcom.com>
Subject: Re: fixed width text files
Message-Id: <egwongErtuuG.6A3@netcom.com>

Jeff <jeffmcc@mindspring.com> wrote:
: I have a text file with approximately 400 rows.  Each row has 31
: columns, and each column has a different width.  I'm a newbie so if
: this elementary question frustrates anyone I apologize.  But, how can
: I read from this file and set the width for each individual column so
: I can reference them?

I assume that when you say "each column has a different width",
you mean a different width between the columns, not between rows.
(i.e. the first column is always 5 chars, the second is 6, etc.)

If I understand your question correctly, you might try something
like this:

  open(F, $filename) || die "Can't open $filename";
  while $line (<F>) {
    @data = $line =~ /(.{5})(.{6}) ... /;
  }

Replace the ellpisis with the rest of the pertinent widths.
Now $data[0] has the first column's data, $data[1] has the
second, etc. within the while loop.

This handy-dandy use of the match operator is documented
in the perlop manpage.  To quote:

    If used in a context that requires a list value, a
    pattern match returns a list consisting of the
    subexpressions matched by the parentheses in the
    pattern, i.e., ($1, $2, $3...).  ...

G'luck.

[ cc'd ]


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

Date: Thu, 23 Apr 1998 01:50:57 GMT
From: crshipp@texas.net (Ron Shipp)
Subject: Re: float to hex conversion
Message-Id: <353eba31.3054762@news.texas.net>

On Wed, 22 Apr 1998 15:24:54 -0700, "Igor Krivokon" <igor.k@usa.net>
wrote:

>Ron Shipp wrote in message <6hli6p$90s@news.outer.net>...
>>A colleague generated some C code to convert a floating point number
>>into a hex value. This code works fine, and looks like this:
>>
>>    int main (argc, argv)
>>    int   argc;
>>    char *argv[];
>>    {
>>      float fval;
>>      sscanf( argv[1], "%f", &fval );
>>      printf("%08x \n", *((int*)&fval) );
>>    }
>>
>>Is there an equivalent to this in perl? I realize that I can compile this
>>into an executable, and use some sort of system call, but I would like
>>to do it without that.
>
>
>print unpack("H8", pack "f", $ARGV[0]) . "\n"; 
>
>Byte order here is system-dependent (as well as in your C code), so be careful.
>
>Regards,
>
>Igor Krivokon
><igor.k@usa.net>
>

Thanks, that did the trick. I will have to re-read the pack unpack
definitions!


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

Date: 22 Apr 1998 23:13:56 -0400
From: Uri Guttman <uri@sysarch.com>
To: xie@netcom.com (Sheppard)
Subject: Re: help with s/$foo/$bar/go; oddness
Message-Id: <x71zupz0uj.fsf@sysarch.com>

>>>>> "S" == Sheppard  <xie@netcom.com> writes:

  S> #!/usr/local/gnu/bin/perl # the object is to globally replace all
  S> instances of the bar character (|) # with the colon character (:).
  S> however...

  S> want... but I want to do it # from within a string whose contents
  S> *may or may not* # contain the bar character.

use \Q to quote any metachars in the string. 

hth,

uri


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----  8 Years of Perl Experience, Available Immediately
uri@sysarch.com  ---------  Resume and Perl Example at http://www.sysarch.com
Use the Best Search Engine on the Net  --------  http://www.northernlight.com


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

Date: Wed, 22 Apr 1998 20:30:06 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: help with s/$foo/$bar/go; oddness
Message-Id: <6hmcpm$f0n@hplntx.hpl.hp.com>

If I understand your general goal correctly (to substitute for a match
on a string which may or may not contain characters that have special
meanings in regular expressions):

You can suppress metacharacter interpretation like this:

$new =~ s/\Q$foo\E/$bar/go;

For further information, read the description of the function quotemeta.

--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com




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

Date: Wed, 22 Apr 1998 22:26:03 -0400
From: Vish Viswanathan <vish@netscape.com>
Subject: Help: crypt for Win32 ??
Message-Id: <353EA6BB.867BA2DC@netscape.com>

Where can I find UNIX-like "crypt" function for Win32 Perl ?? Does
anyone have a crypt lib for NT Perl ??
thanks

- vish




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

Date: Wed, 22 Apr 1998 12:30:19 -0400
From: Peter Eddy <petere@atg.com>
Subject: How to get times in different timezones?
Message-Id: <353E1B1B.A9AA7337@atg.com>

Hi, I'm a Perl newbie trying to figure out how to calculate time of day
in various time zones taking into account daylight savings time.  For
example, getting GMT was easy, but how do I then figure out the correct
time in Hong Kong if my machine's not in Hong Kong?

Thanks,
Peter


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

Date: Wed, 22 Apr 1998 18:54:49 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Yong Huang <yong@shell.com>
Subject: Re: How to save an external program output in a var?
Message-Id: <Pine.GSO.3.96.980422115420.6132d-100000@user2.teleport.com>

On Wed, 22 Apr 1998, Yong Huang wrote:

> Subject: How to save an external program output in a var?

Look up qx`` in perlop. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 22 Apr 1998 19:03:35 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: m144103303@abonados.cplus.es
Subject: Re: Local paths on W95
Message-Id: <Pine.GSO.3.96.980422115931.6132h-100000@user2.teleport.com>

On Wed, 22 Apr 1998 m144103303@abonados.cplus.es wrote:

> How I put a local path in a perl script????

I don't know what a "local path" means, in this context. But probably, you
put it into your script with your text editor. :-)  If you mean a local
search path for @INC, check out the docs for lib.pm. If you mean a local
path to perl for the first line of your script, ask your local expert
what goes there on your system. If you mean a local file path, you'll
probably want to enter it within single quotes. 

> Where I can find documentation about running perl under W95??

Have you tried the FAQ?

    http://cpan.perl.org/doc/FAQs/win32/Perl_for_Win32_FAQ.html
    http://cpan.perl.org/doc/FAQs/ 

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 22 Apr 1998 16:58:18 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Robert Friberg <robban@it-konsult.com>
Subject: Re: Memory usage
Message-Id: <Pine.GSO.3.96.980422094947.6132Q-100000@user2.teleport.com>

On 22 Apr 1998, Robert Friberg wrote:

> The following script runs happily except under cgi-wrap, where
> it sometimes fails with an internal error. 

> Please observe that the program is miles from completion and has tons of
> logical errors, is badly structured, has security holes and plenty of
> other bugs. 

But, besides that, is there anything wrong with it? :-)

How can you be sure that one of those "other bugs" is not the reason it's
failing? Fix the known bugs before you try to find the unknown ones! :-)

>    $_ = $ENV{'QUERY_STRING'};

You shouldn't be doing this. Use a module...

>    @par = split /&/;
>    for (@par){ 
> 	/(.*)=(.*)/;
> 	$d{$1} = $2;
>    }

 ...which will do the job right!

> 	      $hitdata[$hits++] = buildrow and last if 
>                    join( '',(split /\t/)[@fields]) =~ /$w/i;

I'm not at all sure that that does what you think it does. But maybe
that's because I'm not sure what you think it does. :-)

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 23 Apr 1998 01:41:57 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl for WIN32 & SNMP
Message-Id: <6hm695$9va$8@comdyn.comdyn.com.au>

[text reformatted]

In article <6hihhg$mdi$1@news.seicom.net>,
	101.129682@germanynet.de (Jochen Goerner) writes:

> I am searching for a perl modul to send SNMP traps or a CLI-Tool
> which can do the same is also OK !!!

Have you tried http://www.perl.com/CPAN/modules?

If there is such a thing, it should be there.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | 
Commercial Dynamics Pty. Ltd.       | Curiouser and curiouser, said Alice.
NSW, Australia                      | 


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

Date: 22 Apr 1998 18:21:24 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl lets you change constant value
Message-Id: <6hlcf4$ti$5@client2.news.psi.net>

irishman@technologist.com (irishman@technologist.com) wrote on MDCXCV
September MCMXCIII in <URL: news:6hl5v5$lpj$1@nnrp1.dejanews.com>:
++ % cat test.pl
++ #!/usr/local/bin/perl -w
++ *CONST = \40;
++ $CONST++;
++ print STDOUT "CONST = $CONST\n";
++ % test.pl
++ CONST = 41
++ 
++ Call me a pedant, but I think constants should stay constant. Note that
++ $CONST-- also works and produces the result 39. Any other operation that I
++ tried returns "Modification of a read-only value attempted at test.pl line 3."
++ which is what I expect.
++ 
++ I'm running perl5.002 (yeah, yeah, I know) on a Sun Sparcstation 5.
++ 
++ Can anyone shed some light on this behavior?

Upgrade.

$ perl -we '*CONST = \40; $CONST++;'
Modification of a read-only value attempted at -e line 1.
$ perl -we 'use constant CONST => 40; CONST ++'
Can't modify constant item in postincrement at -e line 1, near "CONST ++"
Execution of -e aborted due to compilation errors.
$ perl -v | grep perl
This is perl, version 5.004_04 built for sun4-solaris
$


Abigail
-- 
perl -pwle '$_ .= reverse'


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

Date: Wed, 22 Apr 1998 06:55:02 GMT
From: dbruyne@uia.ua.ac.be (Karel.DeBruyne)
Subject: perl library to read excel file
Message-Id: <Ersz7q.L2s@uia.ua.ac.be>

Hi,

I need a tool to fetch me some information out of an excel file.
Is there any perl library available to do this (or anything else :
c, c++, ... anything as long as it runs on solaris)

Karel
-- 
=======================================================================
Karel De Bruyne
System/Network Manager                      phone      + 32 3 820 22 04
UIA - Computer Centre                       fax        + 32 3 820 22 49


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

Date: Wed, 22 Apr 1998 17:25:26 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: print multiple lines before or after match ?
Message-Id: <moqlh6.324.ln@localhost>

Mike Hammernik (mhammer@execpc.com) wrote:

: I put the information in and forgot to ask the question.

: I would like to print the matched line and the next x lines whether that
: might be 2 or 10 additional lines.  

-----------------------
#!/usr/bin/perl -w

$x = 4;   # number of lines of trailing context to be printed

while (<DATA>) {
   if (/three/) {
      for ($i=0; $i<$x; $i++) {      # might go reading past the end of the
         print STDOUT scalar <DATA>; # file if there are not at least $x
      }                              # lines left...
   }
}

__DATA__
one
two
three
four
five
six
seven
eight
nine
-----------------------


: Conversely it seems to make sense to
: be able to do it in reverse.  $prev is one line but how to print the
: previous 2 or 10 lines. 


That is possible, though harder. You would need to save the
previous $x lines somewhere in case you later discover that you
need to print them...


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 22 Apr 1998 19:24:00 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Problem creating users on an NT server via Perl script
Message-Id: <6hlg4g$2rb$1@client2.news.psi.net>

Scott LeWarne (Scott_LeWarne@BigFoot.com) wrote on MDCXCV September
MCMXCIII in <URL: news:6hl8n6$a8q@news.or.intel.com>:
++ I have a PERL script that takes new user info and creates a user account on
++ an NT server.  The script works fine when run locally on the server, but not
++ when run from a web browser.
++ 
++ I think it has something to do with the fact that when I run it locally, I
++ am running under the Administrator account and when it goes through the web
++ it uses the internet guest account.
++ 
++ I've gone back and given the guest account all the same access as the
++ Administrator account.  I've even setup IIS to use the Administrator account
++ for anonymous access instead of the internet guest account.  It still
++ doesn't work.
++ 
++ Does anyone know if there is something else going on here besides a
++ permission problem?  The same code works locally when run from a command
++ prompt, but not when run through IIS.
++ 
++ Here is the code that I'm using:
++ 
++ #system("createuser $accountname $password $firstname $lastname $company");
++ open("NET","createuser $accountname $password $firstname $lastname $company
++ | ");
++ 
++ Both the system and open approaches work locally.


Well, it seems you have carefully any possible Perl cause.

Perhaps ask elsewhere? In a group about CGI or if you think permissions
are fine, in a group about NT software?



Abigail
-- 
perl -pwle '$_ .= reverse'


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

Date: Wed, 22 Apr 1998 11:26:08 -0400
From: "Totten, Grant (EXCHANGE:CAR:5J42)" <grantt@americasm01.nt.com>
Subject: Program to generate HTML call tree info?
Message-Id: <353E0C10.533FFE7D@americasm01.nt.com>

Hi all,

Has anyone seen a tool that will generate web pages (or text files, I
suppose) that document the calling hierarchy of a perl script or set of
scripts?  Ideally, I'd like to be able to generate a complete,
cross-linked set of documentation on the web that shows what functions
are used by what programs.

I'm looking around on CPAN and can't seem to find anything that does the
trick...

Thanks in advance,

Grant Totten
grantt@nortel.ca




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

Date: 22 Apr 1998 15:55:50 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Regular Expression to match a valid IP address
Message-Id: <6hl3u6$81m$1@csnews.cs.colorado.edu>

You argument is spurious.   Notations such as 10.8 or 127.1 are not
alternate whacky ways of writing things, such as writing then in the
base -3i might be.  They are the proper and correct way.  

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

  "It's a cult.  Don't encourage them."
	  --Rob Pike on the FSF


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

Date: Wed, 22 Apr 1998 23:12:50 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Regular Expression to match a valid IP address
Message-Id: <1d7wshv.70fj5pzkazwbN@slip166-72-108-111.ny.us.ibm.net>

John Porter <jdporter@min.net> wrote:

> > By using the common
> > dotted-quad representation we can visually (or via regex) check for
> > basic errors.
> 
> The regex to test that a number is in (0..255) is far too hairy.
> Regexes can ensure that the components are decimal numbers; but 
> range-checking is better done after the regex.  And this is true
> regardless of whether we're looking at 8.8.8.8, 8.8.16, or 8.24.
> 
> > Most folks want what most folks recognize, dotted quad addresses.
> 
> Perhaps. But that doesn't mean that your application should reject
> valid IP addresses as invalid.
> http://137.3406855 is valid; it points to my employer's web page.
> 666.234345868349843 is not valid.  And discriminating between valid and
> invalid is certainly easy enough to do.
> 
> Restricting input to the "dotted quad" notation strikes me as being
> a very Microsoftian thing to do.
> The internet standards are there for all to see and follow.
> That's why they're called "standards".

#!perl -w

sub split_bytes (;$) {
  my $data = @_ ? $_[0] : $_;
  
  return $data unless $data >> 8;
  return split_bytes($data >> 8), $data & 0xFF;
}

sub checkIP (;$) {
  my $IP = @_ ? $_[0] : $_;
  
  return 0 if $IP =~ /[^0-9.]/;
  my @bytes = map {split_bytes} split /\./, $IP;
  return @bytes <= 4;
}

# demonstration code follows

@IPs = qw(
  1.2.3.4
  137.3406855
  666.234345868349843
  666.3406855
  not.an.IP
  166.72.108.223
  1:2.3.4
);

foreach (@IPs) {
  my $OK = checkIP;
  print "$_: @{[$OK ? 'OK' : 'bad']}\n";
}

__END__

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

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

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