[11548] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5148 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 16 13:07:23 1999

Date: Tue, 16 Mar 99 10:00:23 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 16 Mar 1999     Volume: 8 Number: 5148

Today's topics:
    Re: any perl4 hackers want to try their hand at this? <dave@mag-sol.com>
    Re: any perl4 hackers want to try their hand at this? <jay@rgrs.com>
    Re: Are negative array indeces allowed? <john.chambers@gte.com>
    Re: Are negative array indeces allowed? <john.chambers@gte.com>
    Re: Array-Sort (Larry Rosler)
    Re: Can I carry a variable form 1 page to another? (Abigail)
    Re: Complex Structure Question <aqumsieh@matrox.com>
    Re: Deletion of a List Array Entry (Larry Rosler)
    Re: Detecting a whitespace at the end of a string <eedalf@eed.ericsson.se>
    Re: Finding end of line (M.J.T. Guy)
    Re: Finding end of line <juex@my-dejanews.com>
        flock() on Alpha/VMS <techno@umbriel.demon.co.uk>
        gethostbyname on AIX vs Solaris florcsk@boulder.nist.gov
        Hash of structs <pgangala@i2.com>
    Re: help with pattern matching <khowe@performance-net.com>
    Re: how to get system date? <newsgroups@kidkaboom.frogspace.net>
    Re: I want to run win32 program by running CGI under wi (Mark Leighton Fisher)
    Re: Incrementing several values in a hash (Sami Rosenblad)
    Re: Interrupting "print FH" <prlawrence@lehigh.edu>
    Re: Interrupting "print FH" (Andrew M. Langmead)
    Re: Newbie question... <freddy@warmduscher.arnooo.de>
        perlcc error rolm@my-dejanews.com
    Re: Reading a file <greenej@my-dejanews.com>
    Re: Reading a file (M.J.T. Guy)
        Regex limits for regex/function calls within subsitutio <burton.not.spam@lucent.com>
    Re: Segmentation Fault (Abigail)
    Re: Shopping Cart with Email Encryption? (Effie Rover)
        Slurping multiple files as input (Eric Smith)
    Re: Sorting Problem (Kjetil Skotheim)
    Re: traversing a directory tree <droby@copyright.com>
    Re: Unpack question (Kjetil Skotheim)
    Re: Which is better for Windows use: perl or python (Abigail)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 16 Mar 1999 16:44:37 GMT
From: Dave Cross <dave@mag-sol.com>
Subject: Re: any perl4 hackers want to try their hand at this?
Message-Id: <7cm1pi$db2$1@nnrp1.dejanews.com>

In article <36EE74D4.43B9E169@kidkaboom.frogspace.net>,
  Kid Kaboom <newsgroups@kidkaboom.frogspace.net> wrote:
> > in article <36ED1E19.2E7E443D@kidkaboom.frogspace.net>,
> >   Kid Kaboom <kidkaboom@techplus.com> wrote:
> > > Hi, I'm a beginning perl (v5.004) programmer and I found this totally
> > > awesome access statistic script. You may be familiar with it. Its Matt
> > > Kruse's POV Ray access stat one
> > > <http://mkruse.netexpress.net/www/scripts/access3/> but it it written
> > > for perl 4.036 and my server doesn't have that version of perl, and my
> > > sysadmin doesn't want to install perl 4.036.  I have also found (I;m a
> > > win32 user) that when I downloaded perl 4.036 for dos it can't handle 9
> > > meg files, but perl 5 can, so I would like to port (I believe this is
> > > teh right word) this script to the latest version of perl.
> > >
> > > If anyone here is knowledgeable in perl 4.036 and would like to help me,
> > > I would be very grateful.
> >
> > Have you tried running the script under your latest version of Perl? Many
> > older Perl scripts will run unchanged under newer version of Perl. If you
> > need pointers as to the sorts of things that might cause problems, look at
> > perldoc perltrap.
>
> Yep, tried running it under perl 5.005_02 and it has a division by 0 error if
> I follow what the other guy posted (which helped I might add, but now i have
> this division by 0 error)  I also looked at perldoc perltrap but I'm not
> really sure what I'm looking for.

perldoc perltrap has a section called 'Perl4 to Perl5 Traps' which lists the
things that might cause problems when porting perl4 code to perl5. Don't think
it'll solve your Div/0 error tho'.

Dave...

--
Dave Cross
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 16 Mar 1999 12:44:14 -0500
From: Jay Rogers <jay@rgrs.com>
Subject: Re: any perl4 hackers want to try their hand at this?
Message-Id: <82ww0hcosx.fsf@shell2.shore.net>

Kid Kaboom <newsgroups@kidkaboom.frogspace.net> writes:

> > in article <36ED1E19.2E7E443D@kidkaboom.frogspace.net>,
> >   Kid Kaboom <kidkaboom@techplus.com> wrote:
> > > If anyone here is knowledgeable in perl 4.036 and would like to help me,
> > > I would be very grateful.
> >
> > Have you tried running the script under your latest version of Perl? Many
> > older Perl scripts will run unchanged under newer version of Perl. If you
> > need pointers as to the sorts of things that might cause problems, look at
> > perldoc perltrap.
> 
> Yep, tried running it under perl 5.005_02 and it has a division by 0 error if
> I follow what the other guy posted (which helped I might add, but now i have
> this division by 0 error)  I also looked at perldoc perltrap but I'm not
> really sure what I'm looking for.

Learn how to use the perl debugger.  While you're tracking down
the bug you'll learn a lot about how the program works.

--
Jay Rogers
jay@rgrs.com


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

Date: Tue, 16 Mar 1999 12:37:12 -0500
From: John Chambers <john.chambers@gte.com>
Subject: Re: Are negative array indeces allowed?
Message-Id: <36EE96C8.5735F5AD@gte.com>

Don Roby wrote:
> 
> In article <36E92390.308C6E84@gte.com>,
>   jc@eddie.mit.edu wrote:
> > Sam Holden wrote:
> > >
> > > On 12 Mar 1999 12:43:27 +0100, Alex Farber <eedalf@eed.ericsson.se> wrote:
> > > >Hi,
> > > >
> > > >I have just discovered that perl -e '@x = qw (a b c); print $x[-3]'
> > > >prints "a" on my Solaris workstation (perl 5.004_04). So, is a
> > > >negative array index allowed? Amazing, I haven't ever read about it
> > > >in the 5 perl books I have or in "perldoc perldata"... When was it
> > > >introduced? Can I rely on it now?
 ...
> >
> > Jeez; it'd have been a lot less typing to simply answer the question:
> >       No.
> 
> Jeez.  Try at least answering it correctly, as Sam did.
>         Yes.
> 
> Conciseness isn't everything.

Hmmm .. You're probably right. But I'd still say, on re-reading Alex's
question, that the answer to the question that he was asking is "No".
That is, perl does accept negative numbers as array indexes, but perl
doesn't implement negative array indexes.  It does something *very*
different with a negative index than would be expected by anyone who
uses the phrase "negative array index".  A programmer who notices the
use of a negative number as an index, thinks "Oh, negative indexes now
work" and writes code to use them is in for a rather nasty surprise.

(Of course, we could just post a large warning: "Perl may be dangerous
to the mental health of people with any mathematical background. RTFM
with great care before use." ;-)

Not that it's any worse than most other common programming languages,
of course.


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

Date: Tue, 16 Mar 1999 12:46:45 -0500
From: John Chambers <john.chambers@gte.com>
Subject: Re: Are negative array indeces allowed?
Message-Id: <36EE9905.11D9988D@gte.com>

Abigail wrote:
> 
> Eric The Read (emschwar@mail.uccs.edu) wrote on MMXX September MCMXCIII
> in <URL:news:xkfn21ikzyr.fsf@valdemar.col.hp.com>:
> <> John Chambers <john.chambers@gte.com> writes:
> <> > (Perhaps it would also help the supplicant^Wposter to observe that
> <> > negative subscripts work just fine with hashes; aka associative
> <> > arrays.
> <>
> <> Er, can hashes actually have negative subscripts?  That same first
> <> paragraph of perldata says they're indexed by string.  Unless you mean
> <> that you can use "-1" as an index to a hash, which is true enough, I
> <> suppose.
> 
> Indexed by string indeed. And given that Perl automagically translates
> number to strings, and strings to numbers, the answer is "yes".
> 
> Of course, there's not "begin" or "end" in a hash, so the meaning
> of "-1" you have with array indexing doesn't exist with hash indexing.

Indeed.  Negative numbers work quite well as hash indexes, because they
are converted to strings in the obvious manner.  But there are a couple
of limitations.  One is that perl doesn't understand that they are
numbers, and doesn't keep track of minimum and maximum values.  Another
problem is that it's not entirely trivial to get the indexes out in
numeric order; you have to write your own (one-line) sort routine. The
{0} and {'00'} entries are different.  And so on.  But if your code
keeps track of the min and max values, for most purposes a hash works
with numeric indexes just like a vector.  There's a performance cost,
of course, since you're doing a lookup, but that may or may not be
anything significant.

Then there's the perl4 trick of faking a multi-dimensional array with
things like $x{"$i,$j"}.  This works just fine in perl5, too, and in
some situations is simpler than a true 2-D array.


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

Date: Sat, 13 Mar 1999 07:23:45 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Array-Sort
Message-Id: <MPG.115422d6bd420934989733@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7cdmu2$ekv$1@nnrp1.dejanews.com> on Sat, 13 Mar 1999 
12:50:12 GMT, stefan_0815@my-dejanews.com <stefan_0815@my-dejanews.com 
>says...
> @Data = ( ("1", "Hans", Hamburg), ("5", "Maria", "Mainz"), ("2", "Frank",
> "Frankfurt") );
> 
> Now I need a new array (@Data2) which is sorted by the first Item of @Data:
> 
> @Data2 = ( ("1", "Hans", Hamburg), ("2", "Frank", "Frankfurt"), ("5", "Maria",
> "Mainz") );

You are not using an appropriate data structure, so sorting on it is 
awkward.  There are no sub-lists within a list, so all your interior 
parentheses are ignored, and @Data is a flat array of scalars.

What you really want to sort is an array of arrays, where each sub-array 
is a triplet.  This is done by grouping your triplets into anonymous 
arrays.

I have rewritten @Data to show numbers as numbers (not strings), and I 
presume you want a numerical sort on the numbers.  I have also used 
single quotes because there are no interpolations required, and quoted 
the bareword Hamburg in your data.

#!/usr/local/bin/perl -w
use strict;

my @Data = ( (1, 'Hans', 'Hamburg'), (5, 'Maria', 'Mainz'), (2, 'Frank',
    'Frankfurt') );  # Note again -- interior parentheses are ignored!

# One might want to copy @Data here, because the next step destroys it.
my @triplets;
push @triplets, [ splice @Data, 0, 3 ] while @Data;
my @Data2 = map @$_ => sort { $a->[0] <=> $b->[0] } @triplets;

{ local $" = ', '; print "( @Data2 )\n" }
__END__

The output is:

( 1, Hans, Hamburg, 2, Frank, Frankfurt, 5, Maria, Mainz )

I could *print* interior parentheses around the triplets, but why 
bother?  They're not in the data, in any case.  There are no sub-lists 
within a list.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com


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

Date: 16 Mar 1999 16:35:04 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Can I carry a variable form 1 page to another?
Message-Id: <7cm17o$eoo$2@client2.news.psi.net>

Doc (Doc@goforit.demon.co.uk) wrote on MMXXIII September MCMXCIII in
<URL:news:VnoruAAYJg72EwZQ@goforit.demon.co.uk>:
$$ Hi
$$ I have a database on a server.  I can build a web page from it 'on the
$$ fly' using a CGI script (+ODBC for win95 etc.).  I want the user to be
$$ able to press a button to call for the next relevant page.  This
$$ requires that the script called for by the button press knows the values
$$ of several variables from the current page.  I presume that my first
$$ script, which formed the current page is now dead.  How can I do this?

Easily answered, but not a Perl question. Go ask in the CGI group.



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: Tue, 16 Mar 1999 11:24:08 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Complex Structure Question
Message-Id: <x3yiuc18kt4.fsf@tigre.matrox.com>


ehood@medusa.acs.uci.edu (Earl Hood) writes:

> I think you are expecting Perl to override the 'a' assignment with an
> auto-created hash reference.  However, Perl does not work this way.
> Perl sees you have a value for $hash{'a'} and tries "cast" it to how
> you use it.  It is like how Perl converts a scalar value between
> numbers and strings depending on how you use it.

I see that now. Thanks for the clarification.

% perl -w
$h{'a'} = 'a';
$h{'a'}{'b'} = 'b';
$c = 'a';
print $c->{'b'}, "..\n";
__END__
b..

It all makes sense now. I can also see that "fixing it" would break a
lot of existing code. Anyway, any good programmer should be using
'strict' (at least in development stages), so it shouldn't be a
problem.

Ala



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

Date: Sat, 13 Mar 1999 07:32:22 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Deletion of a List Array Entry
Message-Id: <MPG.115424e28db7332d989734@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7cdpkj$eq8$1@pegasus.csx.cam.ac.uk> on 13 Mar 1999 13:36:19 
GMT, M.J.T. Guy <mjtg@cus.cam.ac.uk >says...
> In article <36E99DAF.8DF462D6@idt.net>, James Tolley  <jamesht@idt.net> wrote:
>     [ Please don't cut attributions of quoted text. ]
> >> Is it possible to delete an entry of a list array? I know it is possible to
> >> delete an entry in an associative array through the use of its key and its
> >> corresponding value, but how about an @list?
> >
> >There's no single command to do this, but you can do it this way:
> 
> Yes there is  -  see "split".

Surely you meant to write "splice"!  :-)
 
> >@list = ('one','two','three');
> ># we want to delete the middle entry.
> >$index_to_delete = 1;
> >@lists[$index_to_delete..$#lists-1] = @lists[$index_to_delete+1..$#lists]
> >$lists[$#lists] = undef;
> 
> That last line doesn't truncate the array.   Instead, you want
> 
>  $#lists--;

Yes, but *I* wouldn't want any of it!  It is hard to imagine a less 
efficient way of solving this problem.  (No, that's not a challenge for 
a pessimization contest. :-) 

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 16 Mar 1999 17:52:07 +0100
From: Alex Farber <eedalf@eed.ericsson.se>
To: kate_stafford@my-dejanews.com
Subject: Re: Detecting a whitespace at the end of a string
Message-Id: <36EE8C37.68D67674@eed.ericsson.se>

kate_stafford@my-dejanews.com wrote:
> Users"). The program that is generating the group names sticks a whitespace
> or sometimes 2 at the end of the string that I wish to chop. I came up with
> the following until loop:
> 
> until ($group =~ /^[A-Za-z][_0=9a-zA-Z]*$\b/)
> {
>    chop $group;
> }
> 

Kate,

maybe I've completely misunderstood your problem, but why don't you

$group =~ s/\s+\n//;

Or if you have several groups on a line

@groups = split ' ', $group;

Regards
/Alex


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

Date: 16 Mar 1999 16:41:06 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Finding end of line
Message-Id: <7cm1j2$ct4$1@pegasus.csx.cam.ac.uk>

Jay Glascoe  <jglascoe@giss.nasa.gov> wrote:
>The newline character, usually written "\n", is
>a single character.  It has ascii value 10.

That might be true on your platform, but in general, it has the same
value as the C \n.    On some platforms, this has value 13.

And then there's the EBCDIC port of Perl ...

But you're quite right that it's always a *single character*.


Mike Guy


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

Date: Tue, 16 Mar 1999 09:17:55 -0800
From: "J|rgen Exner" <juex@my-dejanews.com>
Subject: Re: Finding end of line
Message-Id: <7cm3jp$gl@news.dns.microsoft.com>

Tad McClellan <tadmc@metronet.com> wrote in message
news:damjc7.126.ln@magna.metronet.com...
> George (fred222@mauimail.com) wrote:
> : In article <7cjj51$84a$1@nnrp1.dejanews.com>, mmartina@my-dejanews.com
wrote:
>
> : > I an trying to scan characters in one at a time using getc().  This is
working
> : > but I an unable to determine when I hit the end of line character.  I
am
> : > running perl5 on a HP Unix machine.  Any suggestions.
>
> : I could be horribly wrong, but I think the end-of-line "character" is
> : actually two characters (backslash-n, or "\n")

Actually an "end-of-line" character does not exist.

However there is a
- line-feed character (LF)
- and a carriage return character (CR)

The "\n" notation will be replaced with the proper combination of LF and CR
for the current operating system.

jue
--
J|rgen Exner





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

Date: Tue, 16 Mar 1999 09:50:38 -0500
From: "Techno" <techno@umbriel.demon.co.uk>
Subject: flock() on Alpha/VMS
Message-Id: <7clr41$et7i$1@newssvr04-int.news.prodigy.com>

Hi,

I've written a perl script that needs to be multi-platform (HP-UX, NT,
Alpha/VMS).  It works fine on HP-UX & NT, but on Alpha/VMS, it crashes when
I attempt to use flock(HANDLE, LOCK_EX).  Since multiple copies of the
script can be running, I need to ensure exclusive access to the file in
question.

Any help/workarounds/alternative suggestions would be appreciated (I'm
already doing some OS-specific stuff for NT, so I'm quite happy to code an
alternative locking mechanism for VMS if that's what's needed, but I don't
know what would be required off-hand).

I'm using Perl 5.005_02 on Alpha/VMS, and perl 5.004_02 on NT & HP.

Thanks in advance,
Techno.


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

Date: Tue, 16 Mar 1999 16:23:15 GMT
From: florcsk@boulder.nist.gov
Subject: gethostbyname on AIX vs Solaris
Message-Id: <7cm0h5$c2t$1@nnrp1.dejanews.com>

Don't know if anyone else has found this out (or found a way around it), but
it seems like the gethostby....() calls return different results on AIX and
on Solaris. For the following call:

@bytes = split(/\./, $ip_address);
$packaddr = pack ("C4", @bytes);
($name, $aliases, $addrtype, $len, @addrlist) = gethostbyaddr ($packaddr, 2);

The $name always returns fine, but $aliases are empty (on AIX, not Solaris).

What I haven't figured out yet, is whether it's due to built-in AIX system
calls or to something in the PERL compilation (i.e. is it an AIX thing or a
PERL-on-AIX thing?). This is using the Bull (www.bull.de) PERL compilation of
5.005.

I thought it might be the "2" value I used for AF_INET, but that's not it. Oh
well. Just thought I'd share an interesting finding.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 16 Mar 1999 11:03:21 -0600
From: Prem Gangalakunta <pgangala@i2.com>
Subject: Hash of structs
Message-Id: <36EE8ED9.1D91B9ED@technologist.com>


Hello

I am trying to use a H0H (Hashes of Hashes) where each element is a structure(array) of two
elements.

I was expecting the following statement to push the array of 2 fields into HoH
push(
      @HoH{$fields[$idx_date]}{$fields[$idx_model_size]},
      ($fields[$idx_duration], $fields[idx_process_size])
       );

The Error encountered is:
Can't use subscript on associative array slice at BenchmarkIndustryByDate.pl line 110, near "]}"
Type of arg 1 to push must be array (not associative array elem) at BenchmarkIndustryByDate.pl line
110, near ") )"
 ....
(line 110 is the above push statement)

HoH is declared as just "my %HoH;"

What am I missing here? Is there a better way of doing it?

I appreciate your help.

Thank You,
Prem




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

Date: Tue, 16 Mar 1999 13:57:40 -0400
From: "Kevin Howe" <khowe@performance-net.com>
Subject: Re: help with pattern matching
Message-Id: <1YwH2.13833$134.137009@tor-nn1.netcom.ca>

Hi, the code below works great. Now what I would like do is do it for more
that one pattern, but still in the same expression, which I'm pretty sure
can be done.

Here's the idea of what I want to do:
$var = "<on>   this  <off>...<n>...<me> t ha  t  <n>  <you>";

I want to eliminate:
1. All spaces and <n> codes between the <on> and <off> tags as before
2. All spaces and <n> codes  between the <me> and <you> tags

The code below is invalid, but it gives the idea of what I am trying to do:

$var =~ s/(<on>.*?<off>)(<me>.*?<you>)/     <----- 2 patterns to be matched
            my $s=$1;
            $s =~ s#(?: |<n>)##g;
            $s;
         /ge;

The desired result would be:
$var = "<on>this<off>...<n>...<me>that <you>";

** Note: The periods are meaningless, just there to take up space.

Thanks again,
Kevin




Tad McClellan wrote in message <8j1kc7.rb6.ln@magna.metronet.com>...
>Kevin Howe (khowe@performance-net.com) wrote:
>
>: The Variable:
>: $var = "<on>this  <off>..........<on>that  <n>  <off>..........<on>
>: more<off>";
>
>: What I want to do is eliminate all spaces(\s) and all "<n>" codes that
are
>: located between the <on><off> pairs in this string. Below is what I want
to
>: end up with
>
>: $var = "<on>this<off>...<on>that<off>...<on>more<off>";
>
>
>   Uhhh. Do you really also want all series of dots reduced to
>   three dots or something?
>
>   Because that result does not follow from what your word
>   description said...
>
>
>: I have tried many different pattern matches but I can't seem to get a
handle
>: on this one.
>
>
>$var =~ s/(<on>.*?<off>)/
>            my $s=$1;
>            $s =~ s#(?: |<n>)##g;
>            $s;
>         /ge;
>
>
>--
>    Tad McClellan                          SGML Consulting
>    tadmc@metronet.com                     Perl programming
>    Fort Worth, Texas




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

Date: Tue, 16 Mar 1999 16:24:04 GMT
From: Kid Kaboom <newsgroups@kidkaboom.frogspace.net>
Subject: Re: how to get system date?
Message-Id: <36EE855B.5843DA5A@kidkaboom.frogspace.net>

I thnk you need to add one the the month... its an array that starts at 0,
so you would need to add one.. :-)

Gleb Ekker wrote:

> Hi,
>
> I tried to get server system date and time using
>
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
>
> The time is correct but the date is always the same - the 15th of
> February!  Is it another variant to get the day and month?
>
> Thanks,
> Gleb.



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

Date: Tue, 16 Mar 1999 12:54:32 -0500
From: fisherm@tce.com (Mark Leighton Fisher)
Subject: Re: I want to run win32 program by running CGI under winNT
Message-Id: <MPG.115864e1851a9b2b9896b0@news-indy.indy.tce.com>

You need to look at what your PATH is in your CGI -- I've
learned to be very careful about setting my PATH in my
CGI.  The other problem you may run into is that your
CGI may be running under a different user ID when run
from the webserver than when you run it from the command
line. 
==========================================================
Mark Leighton Fisher          Thomson Consumer Electronics
fisherm@.tce.com              Indianapolis, IN
"Browser Torture Specialist, First Class"


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

Date: Tue, 16 Mar 1999 18:20:27 +0200
From: blade@leela.janton.fi (Sami Rosenblad)
Subject: Re: Incrementing several values in a hash
Message-Id: <blade-1603991820270001@durandal.janton.fi>

In article <w%uH2.11825$Ge3.46473337@news.itd.umich.edu>,
mcafee@waits.facilities.med.umich.edu (Sean McAfee) wrote:

[snipola]
> >How can I increment all the values in a slice? Must I do something like
> >     foreach my $key (@keys) { $hash{$key}++; }
> >, or is there a better way?
> 
> In versions of Perl before 5.005 you'd have to do that (or something
> similar), but now you can say:
> 
> $hash{$_}++ foreach @keys;

for (@keys) { $hash{$_}++ }  # isn't this equivalent?

foreach, modifier statements or not, still steps through the array,
doesn't it? How does it differ from:

map {$hash{$_}++} @keys;     # sorry, map in void context :)

> I'm of the opinion that the "foreach" statement modifier is the best new
> feature of 5.005.

I don't have 5.005 yet, but methinks it has another new feature to ensure
TIMTOWTDI. :)

-- 
Sami Rosenblad | blade@leela.janton.fi | running Linux since 1999


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

Date: Tue, 16 Mar 1999 10:10:36 -0500
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: Re: Interrupting "print FH"
Message-Id: <7clsb9$k9o@fidoii.cc.Lehigh.EDU>

> However, if I ctrl-C ... the test.log has nothing in it when I
>check it.


Fixed it!  Had to adjust $|.

    unless ( $whatever ) {
        open LOG, ">/u/path/test.log" or die;
        # Make LOG pipe hot!
        select( (select(LOG), $| = 1)[0] );
        $r->{private_Report_info}{logref} = \*LOG;
    }

>sub printlog {
>    my $self = shift;
>    my $log_fh = $self->{private_Report_info}{logref};

>    print $log_fh @_;
>}


Thanks,
Phil





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

Date: Tue, 16 Mar 1999 16:36:11 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Interrupting "print FH"
Message-Id: <F8p4sB.JpM@world.std.com>

prl2@lehigh.edu writes:

>In the following test, if I strike ENTER everything goes fine.	However, if I
>ctrl-C when it's waiting for input, the test.log has nothing in it when I
>check it.

In most configurations of perl, the print function uses the C
libraries underlying "stdio" library. (and the ones that don't use
something like sfio which must do something similar.) When the target
of a filehandle is not a terminal, the output is saved inside the
process and not actually sent to the file until a full "block" has
been written. This way, it can save of on expensive system calls. When
the output is a terminal, it writes its output either at the end of a
line, or before an read call is executed. (So the user can see any
prompts that are being written.)

Since you are writing to a file, and since you haven't written a full
block, the stuff you ment to print is being held inside the stdio
buffer. When you send an interrupt signal to the process via the
Control-C, the operating system kills the program and the data never
gets written. If you want to do your best to ensure that the data is
written, you might want to investigate the $| variable which sets
command buffering. See the $| entry in the perlvar man page for
details.

$oldfh = select(FH);
$|++;
select($oldfh);

>Questions: - Why? - What can I do to protect the log from ctrl-C's?  

Besides flushing the output to ensure that it is written to disk, you
can also trap control-C signals via the $SIG{INTR} handler instead of
leaving it to its default handling (killing the program.) See the
perlipc man page for details.
-- 
Andrew Langmead


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

Date: 16 Mar 1999 16:55:37 GMT
From: Frank 'Freddy' Altpeter <freddy@warmduscher.arnooo.de>
Subject: Re: Newbie question...
Message-Id: <7cm2e9$pa3$1@news.is-europe.net>

At Tue, 16 Mar 1999 15:37:11 GMT Seth Davis wrote:
> I have a var, say $temp which = abcd. I want to end up giving $temp1 = a
> $temp2 = b $temp3 = c $temp4 = d. How do I go about getting the first char
> of the item of $temp, second char of item of $temp, etc.

---cut here---
#!/usr/bin/perl

$temp = "abcd";				# this is what you want to split

@temp = split( '', $temp );		# split $temp with '', means to
					# cut every character out of it

print "\$temp[0] is $temp[0]\n";	# for each array var, print the
print "\$temp[1] is $temp[1]\n";	# result.
print "\$temp[2] is $temp[2]\n";
print "\$temp[3] is $temp[3]\n";

foreach $dummy (@temp) {		# Another way to print all the
	print "\$dummy is $dummy\n";	# variables
	}

---cut here-

Hope this helps and shows you how to solve your problem.

Regards
	Frank Altpeter

P.S. comp.lang.perl will be removed, use comp.lang.perl.misc instead.

--  
FA-RIPE  \  Fachbegriffe der Informatik einfach erklaert, Teil 7: "DOS" ==
Frank     \ "Denial Of Service"
"Freddy"   \                                         (Kristian Koehntopp)
Altpeter    \


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

Date: Tue, 16 Mar 1999 16:10:11 GMT
From: rolm@my-dejanews.com
Subject: perlcc error
Message-Id: <7clvoq$bch$1@nnrp1.dejanews.com>

hi.  i'm trying to use perlcc to create a standalone executable.  when i run
perlcc, i get the following :

#C:\PERL5\bin>perlcc c:\usr\dev\cnfg2hex.pl -o cnfg2hex.exe #
#----------------------------------------------------------------------------
-- #Compiling c:\usr\dev\cnfg2hex.pl:
#----------------------------------------------------------------------------
-- #Making C(c:\usr\dev\cnfg2hex.pl.c) for c:\usr\dev\cnfg2hex.pl!
#C:\PERL5\bin\perl.exe -IC:\PERL5\lib -IC:\PERL5\site\lib -I.
#-MO=CC,-oc:\usr\dev\cnfg2hex.pl.c c:\usr\dev\cnfg2h #ex.pl
#c:\usr\dev\cnfg2hex.pl syntax OK #XEvent has method DESTROY: -uXEvent
assumed #Compiling C(cnfg2hex.exe) for c:\usr\dev\cnfg2hex.pl! #Couldn't open
!

the perplexing part here is the "Couldn't open !".  i don't have any idea what
the compiler is unable to open.

any suggestions would be greatly appreciated.

rolm


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 16 Mar 1999 15:54:01 GMT
From: JAG <greenej@my-dejanews.com>
Subject: Re: Reading a file
Message-Id: <7cluqj$aaj$1@nnrp1.dejanews.com>

In article <36EE5994.1B3BAA8C@orades.nl>,
  s.filipowicz@orades.nl wrote:
> Hi Everyone,
>
> I've tried to make a small program that displays a file.
> This is what the program looks like :
>
> [-code snipped-]
>
> Only it doesn't work! :(
> It just has to read the file in line by line and print the line to the
> webbrowser.
>
> Any ideas??
>
> Thanks!
>

> #!/usr/local/bin/perl
>
>$target = '/usr/local/etc/httpd/logs/www.orades.nl.log';
>

If you are outputing text to a web browser, you have to tell it what you are
sending it, e.g.

print "Content-type: text/http\n\n";
print "<body><pre>\n";

>open FILE, "$target";

Never use open without checking the return value!!!
open(FILE, "<$target") || die "Can't open $target: $!";

> while ($line = <FILE> {
>        $line = split / / , $line ;
split returns a list, not a scalar. You should use
@foo = split / /, $line;

>        print $line if $line[1] ne "-";
>        }

Not sure what you're doing here - do you want to filter lines where the
second character is '-', or the second item in the list (aka $foo[1])?
Assuming the latter, I would use print $line if $foo[1] ne '-';

>        close FILE;
>
>print "DONE\n";

print "</pre></body>\n";

Hope this helps..

# James Greene - Informatics Consulting - D-79539 Loerrach, Germany
# Internet: www.gucc.org/greene/consult - greene@gucc.org
# PGP Fingerprint: CA88 9BE2 92B3 3162 DF6B  7080 2F9E A97E F25C 5972

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 16 Mar 1999 17:09:18 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Reading a file
Message-Id: <7cm37u$eh5$1@pegasus.csx.cam.ac.uk>

Tad McClellan <tadmc@metronet.com> wrote:
>
>   3) split() returns a list which you are assigning to a _scalar_.
>      you are losing all but one of the split out parts...

Not quite.    He's getting the number of parts split into, and *none*
of the parts.    And because he's failing to use -w, he's not even
getting

Use of implicit split to @_ is deprecated at ...


perldoc -f split, especially paragraph 2.


Mike Guy


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

Date: Tue, 16 Mar 1999 10:34:10 -0600
From: Burton Kent <burton.not.spam@lucent.com>
Subject: Regex limits for regex/function calls within subsitutions?
Message-Id: <36EE8802.CDDE808F@lucent.com>

What kind of limits does Perl have on substitutions?  
Is there anything I should watch out for in substitutions?
(e.g. $text =~ s/this/that/g;)

I get a segmentation fault at a consistent place in a 
substitution operation -- at the end of the replace.  I'm
able to print the value right before returning from the 
replace, but get the segmentation fault as the replace 
returns.

My workaround is to put the subsitution in a subroutine. 
I return the replacement from within the regex, instead of 
letting the replacement part of the expression finish.

The program involves recursively applying regular expression 
substitutions.  It seems to fail at about the 4th recursion 
of two nested (with subroutine calls) substitution operations.  
I'm also calling subroutines within the replacement part of 
the regex.  

Has anyone else had similar problems?  

Burton


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

Date: 16 Mar 1999 16:22:54 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Segmentation Fault
Message-Id: <7cm0gu$eoo$1@client2.news.psi.net>

Bill Moseley (moseley@best.com) wrote on MMXXIII September MCMXCIII in
<URL:news:MPG.115741ff1919b49b9896e1@206.184.139.132>:
 .. 
 .. Is Perl generating that message?


man perldiag



Abigail
-- 
perl -wleprint -eqq-@{[ -eqw\\\\- -eJust -eanother -ePerl -eHacker -e\\\\-]}-


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

Date: Tue, 16 Mar 1999 16:10:47 GMT
From: null@effierover.com (Effie Rover)
Subject: Re: Shopping Cart with Email Encryption?
Message-Id: <36ee8206.253043043@news.iinc.com>

On 15 Mar 1999 19:46:12 GMT, Mike West <westmj@esvax.dnet.dupont.com>
wrote:

>In article <36e88e48.12933846@news.vnet.net> Brantley Smith, 
> mtbdude1999@yahoo.com writes:
> 
>>Does anyone know of a PERL Shopping Cart program that encrypts order
>>data before sending to the merchant?
>
>  As usual, it appears the free program "MiniVend" has it.
>  http://www.minivend.com/iri/features.html
>  "PGP support for secure off-site mailing of orders"

This is the one we're using. PGP support does not = encryption
included. In fact, while Minivend supports encryption of all types, it
is still up to you to find, install, test, configure and plug in an
encryption method - PGP or other. We're still looking for a perl-based
free encryption method that can be plugged into minivend's
configuration.

  -- Loy

Loy Ellen Gross AKA Effie Rover
The email address above goes straight to /dev/null :-)
effie -at- effierover -dot- com * http://www.effierover.com
Effie Rover's Fantasy Role Playing Gamer's Library
---------------------------------------------------------------
Protect privacy, boycott Intel: http://www.bigbrotherinside.org
---------------------------------------------------------------


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

Date: 16 Mar 1999 17:08:31 GMT
From: eric@fruitcom.com (Eric Smith)
Subject: Slurping multiple files as input
Message-Id: <slrn7et4so.fqh.eric@plum.fruitcom.com>

Hi perl

Please can you suggest a way to add the contents of all files in a
specified dir to an array. 

In bash we go 
for file in `ls $DIR`;do ... $file ...

Thanx you very much.

-- 
Eric Smith
<eric@fruitcom.com>
Vodacom 082 780 7888


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

Date: 16 Mar 1999 17:07:46 GMT
From: kjetil.skotheim@usit.uio.no (Kjetil Skotheim)
Subject: Re: Sorting Problem
Message-Id: <7cm352$hkh$2@readme.uio.no>

In article <7clurd$enb$4@readme.uio.no>, kjetil.skotheim@usit.uio.no says...
>
>In article <36ED68D0.8D14D81D@xs4all.nl>, debot@xs4all.nl says...
>>
>>I have an array:
>>
>>$ar[0] = "14 || Some Text here";
>>$ar[1] = "4 || Lalalala";
>>$ar[2] = "7 || Hello World";
>>
>>How can I sort that the array is this:
>>
>>$ar[0] = "4 || Lalalala";
>>$ar[1] = "7 || Hello World";
>>$ar[2] = "14 || Some Text here";
>>
>>I've tried everything, but nothing worked.
>>
>

@ar = sort { getnumber($a) <=> getnumber($b) } @ar;

sub getnumber {
  shift()=~/([\d\.]+)/;
  return $1;
}



Or if @ar is big (several houndreds or thousands) this may run quicker:


@ar = map {$$_[1]}
      sort {$$a[0]<=>$$b[0]}
      map {[getnumber($_),$_]}
      @ar;


 ...that way the getnumber() dont get called so often. (n times,
vs n*log(n) above, or something like that)



--
KS




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

Date: Tue, 16 Mar 1999 17:24:26 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: traversing a directory tree
Message-Id: <7cm43s$fli$1@nnrp1.dejanews.com>

In article <oiIVtCAyFk72EwfN@beausys.demon.co.uk>,
  Andrew Fry <andrewf@beausys.demon.co.uk> wrote:
> I have been trying to write a little utility which
> goes down a directory tree and renames all directories
> and files which contain upper-case characters (...to
> lower case characters) ... eg FRED.TXT -> fred.txt
> I wrote the following, but it doesnt go right down
> the tree, only so far. Why is this ?
>

You're changing the directory structure as you traverse it.

You need to change it to work depth-first so that files are changed before the
directories containing them.

You can accomplish this by calling the function finddepth() instead of find().

--
Don Roby

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 16 Mar 1999 16:47:29 GMT
From: kjetil.skotheim@usit.uio.no (Kjetil Skotheim)
Subject: Re: Unpack question
Message-Id: <7cm1v1$hkh$1@readme.uio.no>

In article <36e949e7.99778814@proxy.reston.tnsi.com>, kkling@tnsi.com says...
>
>I have a shared memory segment on a unix box that I need to read.  It
>was created with the following C struct
>
>struct {
>        int numdnis;
>        unsigned char dnis[1000][4];
>        char cust[8];
>} dialed_numbers;
>
>
>
>shmread( $hdrid, $hdrdata, 0, $hdrsize )   
>        or die "Can't read from Header shared mem $! ";
>
>( $numdnis, @dnis, $cust ) = unpack( "I ?????? c8", $hdrdata );



($numdnis, $dnis,$cust)=unpack("I A4000 A8",$hdrdata);
@dnis = map {substr($dnis,$_*4,4)} (0..999);




>I am somewhat new to perl and I am not sure what template to use so
>that I can access the dnis.
>
>
>I want to be able to print out the dnis like:
>
>        print "Dnis 1 $dnis[0]\n"
>        print "Dnis 2 $dnis[1]\n"


--
KS



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

Date: 16 Mar 1999 17:58:17 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Which is better for Windows use: perl or python
Message-Id: <7cm63p$flr$1@client2.news.psi.net>

Franz Kaufmann (ws97-868@wsrz1.wiso.uni-erlangen.de) wrote on MMXXIII
September MCMXCIII in <URL:news:7clh3l$nro$1@rznews.rrze.uni-erlangen.de>:
?? 
?? I wonder what language is better suited for windows specific stuff (COM 
?? a.s.o) :Perl or Python


That's not something you want to ask in a group consisting of Perl users.

Which language is "better" mostly depends on the programmer. Take whatever
you prefer.



Abigail
-- 
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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