[7205] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 830 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 8 16:16:31 1997

Date: Fri, 8 Aug 97 13:00:26 -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           Fri, 8 Aug 1997     Volume: 8 Number: 830

Today's topics:
     21 Rules For Writing Secure CGI Programs  software@newapps.com
     Re: 21 Rules For Writing Secure CGI Programs (brian d foy)
     [BUG?] Perl 5.004_1 fails @ perl -nea 'print' (Nicholas J. Leon)
     Re: [BUG?] Perl 5.004_1 fails @ perl -nea 'print' <rootbeer@teleport.com>
     Can you use PerlScript or Perlis with windows95 PWS?? <designer@interpath.com>
     Re: Clearing browser screen before sending HTML code to <rootbeer@teleport.com>
     Re: Commandline arguments <mark@tstonramp.com>
     Re: Currency format <seay@absyss.fr>
     foo bar (Bart Lateur)
     Re: foo bar <rootbeer@teleport.com>
     Re: How to create more than object at once? (Chris Nandor)
     Re: How to make Perl Regular expressions "Rightmost is  (Bob Wilkinson)
     Re: How to make Perl Regular expressions "Rightmost is  <seay@absyss.fr>
     Re: if $FORM{r2} = problem (Mike Stok)
     Re: New To Perl/Prog.:Please Help (Ken Williams)
     Novice Newbie Perl CGI question <bruce@galileo.eng.wayne.edu>
     Re: Perl and Windows NT <thomas@fahle.de>
     Re: PERL direct hardware I/O dagcs@knuth.mtsu.edu
     Re: perl libraries <petri.backstrom@icl.fi>
     perl rpm ? <dvreijen@solair1.inter.nl.net>
     Re: perlIS information (Erik Y. Adams)
     Re: Problems with tie/DB_File/references (Paul Marquess)
     Re: Request help extracting acronyms (Tad McClellan)
     Sorting this file is killing me paries@advicom.net
     Re: SQL error message handling with sybPerl? <kevinl@ascend.com>
     Re: Still confused in flock() land <petri.backstrom@icl.fi>
     Re: What means --> Can't call method "xxxxxxx" on unble <seay@absyss.fr>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 8 Aug 1997 16:31:58 GMT
From: software@newapps.com
Subject: 21 Rules For Writing Secure CGI Programs 
Message-Id: <33eb49fa.131925327@nntp.iglou.com>

21 Rules For Writing Secure CGI Programs 
 .. http://www.newslinx.com

1. Carefully design the program before you start. 

Be certain that you understand what you are trying to build. Carefully
consider the environment in which it will run, the input and output
behavior, files used,arguments recognized, signals caught, and other
aspects of behavior. List all of the errors that might occur, and how
your program will deal with them. Write acode specification in English
(or your native language) before writing the code in the computer
language of your choice. 

2.Check all values provided by the user. 

An astonishing number of security-related bugs arise because an
attacker  sends an unexpected value or an unanticipated format to a
program or a function within a program. A simple way to avoid these
types of problems is by having your CGI programs always check all of
their arguments. Argument checking will not noticeably slow your CGI
scripts, but it will make them less susceptible to hostile users. As
an added benefit, argument checking and error reporting will make the
process of catching nonsecurity-related bugs easier. 

When you are checking arguments in your program, pay extra attention
to the following: 

 Filter your arguments, selecting the characters that are appropriate
for each application.   Check the length of every argument.   If you
use a selection list, make certain that the value provided by the user
was one of the legal values. 

3.Check arguments that you pass to operating system functions. 

 Even though your program is calling the system function, you should
check the arguments to be sure that they are what you expect them to
be. For example, if you think that your program is opening a file in
the current directory, you might want to use the index( ) function in
C or Perl to see if the filename contains a slash character (/). If
the file contains a slash, and it shouldn't, the program should not
open the file. 

4.Check all return codes from system calls. 

 The POSIX programming specification (which is followed by both C and
Perl) requires that every system call provide a return code. Even
system calls that you think cannot fail, such as write ( ), chdir ( ),
or chown ( ), can fail under exceptional circumstances and return
appropriate return codes. When a call fails, check the errno variable
to determine why it failed. Have your program log the unexpected value
and then cleanly terminate if the system call fails for an  unexpected
reason. This approach will be a great help in tracking down both
programming bugs and security problems later on. 

 If you think that a system call should not fail and it does, do
something appropriate. If you can't think of anything appropriate to
do, then have your program delete all of its temporary files and exit.


5.Have internal consistency-checking code. 

 If you think that a variable inside your program can only have the
values 1, 2, or3, check it to ensure that it does, and generate an
error condition if it does not. (You can do this easily using the
assert macro if you are programming in C.) 

 ...find more of the article via http://www.newslinx.com

NewsLinx, Daily Web News
Friday, August 8, 1997 


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

Date: Fri, 08 Aug 1997 15:48:52 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: 21 Rules For Writing Secure CGI Programs
Message-Id: <comdog-ya02408000R0808971548520001@alice.walrus.com>

In article <33eb49fa.131925327@nntp.iglou.com>, software@newapps.com wrote:

>21 Rules For Writing Secure CGI Programs 

>1. Carefully design the program before you start. 

>2.Check all values provided by the user. 

>3.Check arguments that you pass to operating system functions. 

>4.Check all return codes from system calls. 

>5.Have internal consistency-checking code. 

might as well have called it "21 Rules For Writing Programs".  are we
not supposed to do these things unless we want secure CGI scripts?  i
knew i was doing too much work :)

-- 
brian d foy                                   <comdog@computerdog.com>
please forgive any posting wierdness - i've recently changed providers and things are a bit wonky


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

Date: 8 Aug 1997 14:55:57 GMT
From: nicholas@neko.binary9.net (Nicholas J. Leon)
Subject: [BUG?] Perl 5.004_1 fails @ perl -nea 'print'
Message-Id: <slrn5umcrn.m9p.nicholas@neko.binary9.net>

I recently installed the new Perl 5.004_1. When I started playing with
it, I found this (potential) bug.

My only problem is that I can't see how this escaped the
beta-testers. So I'm willing to concede that either I'm missing
something blazingly obvious here, or my copy of perl is hosed (though
it passed all the tests via "make test").

The following log illustrates the issue, I believe:

> ls | ~/perl/bin/perl -nea 'print'
Can't open print: No such file or directory
> ~/perl/bin/perl -V
Summary of my perl5 (5.0 patchlevel 4 subversion 1) configuration:
  Platform:
    osname=linux, osvers=2.0.30, archname=i586-linux
    uname='linux neko 2.0.30 #16 sun jun 22 13:11:08 edt 1997 i586 '
    hint=recommended, useposix=true, d_sigaction=define
    bincompat3=n useperlio= d_sfio=
  Compiler:
    cc='cc', optimize='-O2', gccversion=2.7.2.1
    cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    stdchar='char', d_stdstdio=define, usevfork=true
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=4, usemymalloc=y, randbits=31
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lgdbm -ldb -ldl -lm -lc
    libc=/lib/libc.so.5.4.7, so=so
    useshrplib=true, libperl=libperl.so
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=, ccdlflags='-rdynamic
-Wl,-rpath,/usr/local/homes/nicholas/perl/lib/i586-linux/5.00401/CORE'

    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl): 
  Built under linux
  Compiled at Jul 21 1997 16:12:02
  %ENV:
    PERLLIB="/usr/local/homes/nicholas/lib"
  @INC:
    /usr/local/homes/nicholas/lib
    /usr/local/homes/nicholas/perl/lib/i586-linux/5.00401
    /usr/local/homes/nicholas/perl/lib
    /usr/local/homes/nicholas/perl/lib/site_perl/i586-linux
    /usr/local/homes/nicholas/perl/lib/site_perl
    .

> ls | /usr/bin/perl -nea 'print'
Mail/
News/
agents/
bin/
documents/
dos/
historical/
incoming@
indicies/
lib/
linux/
log/
madi/
mail@
misc/
mnt/
oldwww/
perl/
private/
src/
tao/
test/
tmp/
typescript
var/
what/
win95/
work/
www@
> /usr/bin/perl -V
Summary of my perl5 (5.0 patchlevel 3 subversion 0) configuration:
  Platform:
    osname=linux, osver=2.0.29-iss, archname=i586-linux
    uname='linux neko 2.0.29-iss #1 tue mar 11 16:43:47 est 1997 i586 '
    hint=recommended, useposix=true, d_sigaction=define
  Compiler:
    cc='cc', optimize='-O2', gccversion=2.7.2.1
    cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    stdchar='char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=4, usemymalloc=n, randbits=31
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lgdbm -ldb -ldl -lm -lc
    libc=/lib/libc.so.5.4.7, so=so
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

@INC: /usr/local/homes/nicholas/lib /usr/lib/perl5/i586-linux/5.003
/usr/lib/perl5 /usr/lib/perl5/site_perl/i586-linux
/usr/lib/perl5/site_perl .


Anymore information that would be helpful I will provide upon request.




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

Date: Fri, 8 Aug 1997 12:31:34 -0700
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: [BUG?] Perl 5.004_1 fails @ perl -nea 'print'
Message-Id: <Pine.GSO.3.96.970808122957.15673C-100000@kelly.teleport.com>

On 8 Aug 1997, Nicholas J. Leon wrote:

> Subject: [BUG?] Perl 5.004_1 fails @ perl -nea 'print'

No options can follow -e within the same argument. So, if I'm not
mistaken, that command is the same as this one.

    perl -ne a print

So it's no surprise that it doesn't work. :-)  I think you want this.

    perl -nae print

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, 8 Aug 1997 10:49:30 -0400
From: "martin" <designer@interpath.com>
Subject: Can you use PerlScript or Perlis with windows95 PWS??
Message-Id: <5sfbj0$30u@redstone.interpath.net>

Hi I'm using Internet studio and the included PWS under
windows 95 to develop web applications and then transfer them to my web
site.

Ive installed Perl for win32 build 306 as well as perlis and perlscript from
the package.

Id like to do some development in PerlScript (ASP) but from what I can tell
it
doesn't work (crashes server).  Has anyone gotten this to work correctly?

I'd also like to get Perlis to work as well but get the following error when
running perlis: HTTP/1.0 500 Server Error (87).

Yes I do have the registry entry installed:

    HKEY_LOCAL_MACHINE\System\CurrentControlSet
               \Services\W3Svc\Parameters\Script Map

      .plx     c:\perl\bin\perlis.dll

PerlScript on the other hand, really doesn't give an error.  It just hangs
the
 server.. you eventually get a windows error from the server.



        (*)\||/(*)
         | ~  ~ |               Marty Poulin
        (  @  @  )
+-----oOOo-(<>)-oOOo------+-------------------------------------------+
|                         | There is an art, or rather a knack to     |
| Marty@capehatteras.net  | flying. The knack lies in learning how    |
| http://capehatteras.net | to throw yourself at the ground and miss. |
|               Oooo.     |                                           |
+----.oooO------(  )------|-------------------------------------------+
      (  )      (_/
       \_)







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

Date: Thu, 7 Aug 1997 07:05:35 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Holly Henry-Pilkington <hollyhp@nospam.one.net>
Subject: Re: Clearing browser screen before sending HTML code to browser.
Message-Id: <Pine.GSO.3.96.970807065506.18326H-100000@kelly.teleport.com>

On Wed, 6 Aug 1997, Holly Henry-Pilkington wrote:

> Tom Phoenix wrote:
> > 
> > On Mon, 4 Aug 1997, Steve Schmitz wrote:
> > 
> > > The problem is that when my PERL script sends the output to the browser,
> > > instead of the output starting at the top of the screen, it follows the
> > > "please wait" message that I already have on the screen.  I would like
> > > for the "please wait" message to be overwritten at this point.
> > 
> > If this is possible, you need to print something different to the browser.
> > Since what you print won't be Perl, I can't help you any more here. You
> > should check with a browser newsgroup (or its FAQ) to find out what to
> > print, if it's even possible. Good luck!
> 
> How would you accomplish thi task if the "something different" WERE
> Perl? 

Unless you have a browser which understands Perl code, you won't usually
send Perl code to the browser.

> For example, if you had a routine that might take some time to run
> before displaying, how would you send first a "please wait" type
> message, then print the resullts on a "fresh" on the fly html screen? 

I don't know. :-)  But I know that _if_ such a thing can be done, it would
almost certainly be html/http that you'd be sending to the browser. (It
wouldn't be Perl, since Perl has no provisions for such things as creating
new windows or clearing old ones, even if a browser would understand Perl.
So this turns out not to be a Perl topic.) You may find an answer in the
FAQs, docs, and newsgroups about HTML and HTTP.

If you have questions about Perl which aren't answered in the docs and
FAQs, please post those here. Thanks!

-- 
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: Wed, 06 Aug 1997 14:33:58 -0700
From: "Mark J. Schaal" <mark@tstonramp.com>
Subject: Re: Commandline arguments
Message-Id: <33E8EDC6.4E6B@tstonramp.com>

Note:  comp.lang.perl has not existed for quite some time.


Ulf Knoblich wrote:
> 
> I'm just doing some Perl programming and have the task to compare two
> files and write the output to another file. the problem is that the
> script may get wildcards in the commandline like
> 
> dif *.d *.d2
> 
> (that means it should compare all files with the suffix .d to the
> equivalent ones with the suffix .d2)
> 
> how can i parse this?
> when i do it as one might think, i get as arguments teh first two
> matching files for the first expression.
> 

(HINT: Did you try adding 'print "@ARGV \n";' at the top of
 your script to see the actual arguments Perl is receiving?)

Your shell parses the commandline and expands the filename 
wildcards automatically before it sends them to perl. You will
need to escape the wildcards with a backslash to avoid this.
	dif \*.d \*.d2
Oh, wait, you probably aren't working in Unix so that might not
be the way to do it.  If it isn't, ask whoever is locally 
responsible for your OS.

If you are just concerned with suffixes, then you could create
a special mode to deal with this, e.g.
	dif -suffix d d2

hope this helps,

mark
--
Mark J. Schaal		TST On Ramp Sysadmin	mark@tstonramp.com


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

Date: Fri, 08 Aug 1997 20:45:24 +0200
From: Doug Seay <seay@absyss.fr>
To: Khemarath Choke-Mangmi <mike@hq.npc.co.th>
Subject: Re: Currency format
Message-Id: <33EB6944.6197023@absyss.fr>

[posted and mailed]


Khemarath Choke-Mangmi wrote:
> 
> It might be a stupid question? But I cannot found the solution anywhere
> else. How can I format a number to currency form (eg. "###,###,##9.9").  By
> s/// or sprintf() or format()???
> Any help would be appreciated.

This, sir, is a FAQ.

How about "perldoc perlfaq5" and read down until you find your answer.

- doug


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

Date: Fri, 08 Aug 1997 16:28:43 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: foo bar
Message-Id: <33eb4865.29547617@news.tornado.be>

What is all this "foo bar" stuff that is sprinkled all over the
documentation?

I think it's pure nonsense, but not being a native English speaker, I'm
curious where these words came from.

	Bart Lateur
	bart.mediamind@tornado.be


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

Date: Fri, 8 Aug 1997 12:37:23 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Bart Lateur <bart.mediamind@tornado.be>
Subject: Re: foo bar
Message-Id: <Pine.GSO.3.96.970808123435.15673D-100000@kelly.teleport.com>

On Fri, 8 Aug 1997, Bart Lateur wrote:

> What is all this "foo bar" stuff that is sprinkled all over the
> documentation?

Those are metasyntactic variables. This site will lead you to more
information. Hope this helps!

    http://www.cnam.fr/Jargon/?%5Efoo%24
    http://www.cnam.fr/Jargon/?%5Emetasyntactic+variable%24

-- 
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, 08 Aug 1997 15:35:37 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: How to create more than object at once?
Message-Id: <pudge-ya02408000R0808971535370001@news.idt.net>

In article <33ea360b.8986057@newshost.rz.hu-berlin.de>,
oliver.hellberg@fernuni-hagen.de (Oliver Hellberg) wrote:

# I'm not able to create two objects within the same class.
#         $self{inhalt} = shift;
#         print "$self:   $self->{inhalt}     \n";


Change to:

          $self->{inhalt} = shift;
          print "$self:   $self->{inhalt}     \n";

--
Chris Nandor             pudge@pobox.com             http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])


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

Date: Fri, 08 Aug 1997 13:58:32 +0100
From: b.wilkinson@pindar.co.uk (Bob Wilkinson)
Subject: Re: How to make Perl Regular expressions "Rightmost is greediest"?
Message-Id: <b.wilkinson-0808971358320001@ip57-york.pindar.co.uk>

In article <33E8D3BE.A662B42@nrc.ca>, Patrice Boissonneault
<Patrice.Boissonneault@nrc.ca> wrote:

> In Regular expressions with Perl, when there are two mutipliers in a
> single expresseon, the greedy rule is augmented with "leftmost is
> greediest".  For example:
> 
> $_ = "a xxx c xxxxxxxx c xxx d";
> /a.*c.*d/;
> 
> In this case, the first ".*" in the regular expression matches all off
> the caracters up to the second c, even though matching only the
> caracters up to the first c would still allow the entire regular
> expression to match.
> 
> How to tell Perl to match the caracters up to the first c.  "Rigthmost
> is greediest".
> 
> Please, help me.
> 
> Thanks
> 
> Patrice Boissonneault
> -----------------------------
> Patrice.Boissonneault@nrc.ca

Hello,

/a[^c]*c.*d/; rather than /a.*c.*d/;

Bob

-- 
 .sig file on holiday


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

Date: Fri, 08 Aug 1997 19:52:02 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: How to make Perl Regular expressions "Rightmost is greediest"?
Message-Id: <33EB5CC2.6E2622D@absyss.fr>

A lot of people have commented on this topic, mostly saying to use
non-greedy REs.  That seems to be a valid approach for this particular
problem, but is it a general solution?  As I understand the RE engine,
it matches left to right (leftmost is greediest).  What he asked
(perhaps not what he needed) is more of a right to left matching.  Does
Perl support anything like this?  I've never needed it, so this is just
a Deep Thought type question.

My solution was to reverse the string, build the search pattern
backwards and see if that matches.  If so, reverse each of the matched
fields and you're done.  I think that this is "rightmost is greediest",
but my formal theory isn't strong enough.  Does anyone care to comment?

- doug


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

Date: 8 Aug 1997 19:29:13 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: if $FORM{r2} = problem
Message-Id: <5sfs29$l8r@news-central.tiac.net>

In article <33EA4668.6982@hilding.com>, Eric Hilding  <eric@hilding.com> wrote:
>Gosh...I'm stuck...apparently with a syntax problem in the perl scrip
>that parses some html input via a radio button.  I've used
>them before but a unique twist has me baffled.
>
>The form input is: (need to use brief codes like r2a, r2b, etc. due 
>to large number of entry items)

>Here's what I'm trying to do, but am stuck on the syntax: (clipped
>from the perl script) ... just for info, what I want to do is shown 
>in [ ]'s ... which line to print if the value of r2 = (the options)
>
>print MAIL "  Timetable: NOW\n" if $FORM{'r2'} [=r2a];  
>print MAIL "  Timetable: Within 3 Months\n" if $FORM{'r2'} [=r2b];
>print MAIL "  Timetable: Within 6 months\n" if $FORM{'r2'} [=r2c];
>
>I've tried if ($FORM{'r2'} UMPTEEN COMBINATIONS OF STUFF)

If you want to do it that way then you can say

  print MAIL "  Timetable: NOW\n" if $FORM{'r2'} eq 'r2a';

but you might want to say:

  %r2 = (r2a => 'NOW',
         r2b => 'Within 3 Months',
         r2c => 'Within 6 Months',
        );

And later in the script say

  print MAIL "  Timetable: $r2{$FORM{'r2'}}\n";

or

  $r2 = $r2{$FORM{'r2'}} || '* UNEXPECTED *';
  print MAIL "  Timetable: $r2\n";

(assuming %r2 doesn't have any logically false values like "0" in it...)

Hope this helps,

Mike (now in NYC)

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


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

Date: Fri, 08 Aug 1997 11:35:23 -0400
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: Re: New To Perl/Prog.:Please Help
Message-Id: <ken-0808971135230001@news.swarthmore.edu>

In article <33eb0615.82065@netnews.mis.net>, blueboyd@mis.net wrote:
[snip]

>each week. If a line has a duplicate (some will, some won't), the last
>entry will be the most current.  I want to process the file and write
>each line to a new file that will not have any duplicates and will
>have the most recent info (the last submission for a particular ss#). 

This should make the "hash alarm" go off in your head (hash is the new
word for associative array), since hashes have the nice feature of only
allowing one value for each key.  Their speed of lookup makes them a great
choice for eliminating duplicates in a list.  So I might do something like
this:


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

open(IN,"list") or die $!;  # Check the return value
while(<IN>) {
   /(\d*):(.*)/;  # Now $1 contains the SSN, and $2 contains the rest

   $records{$1} = $2;
}
close IN;

open (OUT, ">list_out") or die $!;
foreach $key (sort keys %records) {
   print OUT ("$key:$records{$key}\n");
}
close OUT;
___________

Here's another way to use hashes to eliminate duplicates.  It's taken from
the Camel book, I believe:

@list3 = &union(@list1, @list2); 
@list5 = &union(@list4); # @list5 is @list4 without duplicates, but 
                         # order is _not_ preserved.

sub union {
   my %hash;
   foreach $item (@_) {
      $hash{$item} = 1;
   }

   return keys %hash;
}

If you're not using Perl 5, I strongly recommend it for its more
sophistocated data structures (among other reasons) - they will make more
advanced parsing of your data file cleaner.  Check out the man page on
perl data structures for more info.

-Ken Williams
 The Math Forum
 ken@forum.swarthmore.edu


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

Date: Thu, 07 Aug 1997 11:15:20 -0400
From: Bruce Hopkins <bruce@galileo.eng.wayne.edu>
Subject: Novice Newbie Perl CGI question
Message-Id: <33E9E688.59E2@galileo.eng.wayne.edu>

How do I redirect someone to a different web page dependind upon thier
IP address? For instance, if their IP address is not 111.111.1.x domain,
they will be served a different page.

Thanks


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

Date: Fri, 08 Aug 1997 17:47:46 -0700
From: Thomas Fahle <thomas@fahle.de>
To: Barry Andre <bandre@xs4all.nl>
Subject: Re: Perl and Windows NT
Message-Id: <33EBBE32.6360@fahle.de>

Barry Andre wrote:
> 

> Where can I get ready to use CGI-scripts for my server ?
Try
http://www.cgi-resources.com 
http://selena.mcp.com/scripts/
http://www.4images.com/ntperl/


Thomas Fahle


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

Date: Fri, 08 Aug 1997 19:49:04 GMT
From: dagcs@knuth.mtsu.edu
Subject: Re: PERL direct hardware I/O
Message-Id: <33eb767a.30480851@rtpnews.raleigh.ibm.com>

On Tue, 22 Jul 1997 11:18:38 +0100, Roberto Turco <roberto@atr-it.com>
wrote:

>Is there a way to directly control the hardware I/O ports? 
>
>I have a standard I/O board and wish to use it to turn on some LED's
>have not found how to control the port in perl...
>
>can anyone help?
>
>My linux box is running PERL5.003
>on an intel based pc 
>
>I guess i could also use the parallel port at 278H
>
>Thanks...

	If you know the system commands to access the ports try using
the backwards single quote mark to enclose the system commands.  This
allows you to run system commands via a perl script.

Example:
# run nbtstat -n command and store in variable then strip out IP
#address
$nbt = `nbtstat -n`;

@nbt = split (/ /,$nbt);
$tmpip = @nbt[2];
chop($tmpip);
@ip = split (//,$tmpip);
$trash = shift(@ip);
$ip = join ("",@ip);


	Reference from:  "teach yourself Perl 5 for Windows NT in 21
days" by Zhang & Till.  I picked it up at the local Media Play.

Good Luck!





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

Date: Tue, 05 Aug 1997 10:30:02 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: perl libraries
Message-Id: <33E6D67A.12F9@icl.fi>

Suzan wrote:
> 
> I am novice with perl. I got a cgi script and wanted to test it on my
> system. Nothing happens. I presume I have not the required libraries.
> How is it possible to get them?
> 
> My system: win 95.
> 
> Thank you for your answer.

Please state how you installed Perl? Did you get it to work?
How you tested your CGI script? What, exactly, did you try
to do? What, exactly, happenes? "Nothing happens" is not
a valid answer! What's in the script?

For starters you should probably read the Perl for Win32
Frequently Asked Questions (FAQ) list:

  http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html

See also:

  http://www.perl.com/FAQ/
  http://www.perl.com/CPAN/
  http://www.perl.com/perl/
  http://www.activeware.com
  http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.htm

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: 7 Aug 1997 10:13:10 GMT
From: "Daan" <dvreijen@solair1.inter.nl.net>
Subject: perl rpm ?
Message-Id: <01bca31a$960ddf60$ce9e4ec1@wolga.emswitch.net>

I'm looking for the perl 5.004 rpm. I tried compiling the perl sources but
for some reason it can't locate gcc on my machine.
I'm running redhat 4.0 on a pentium and for several resons do not want to
upgrade to RH4.2

Greetz,

Daan
DvReijen@solair1.inter.NL.net


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

Date: Fri, 08 Aug 1997 12:04:12 -0800
From: erik@earthlink.net (Erik Y. Adams)
Subject: Re: perlIS information
Message-Id: <erik-ya023180000808971204120001@news.earthlink.net>

In article <33EB4E11.89A796C2@dotshop.com>, Carine Boneh
<qeren@dotshop.com> wrote:

> <HTML>
> Does somebody know were it is possible to find the source code of perlIS,
> and if a new version: 5.004, is available?
> 
> <P>Thank you!
> 
> <P>Qeren</HTML>

The source code is not now, nor has it ever been, available.  Hell, there
isn't even any documentation on it.

Erik


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

Date: 8 Aug 1997 08:08:43 GMT
From: pmarquess@bfsec.bt.co.uk (Paul Marquess)
Subject: Re: Problems with tie/DB_File/references
Message-Id: <5sek6b$6hp$2@pheidippides.axion.bt.co.uk>

[ Posted & Mailed ]

robert (robert@ICK.il.fontys.nl) wrote:
: Hey all,

: For a program I've been working on I'm tieing a bunch of hash arrays to
: Berkeley DB files. Now I figured I'd get smart and make my own subroutine
: in which the tie() takes place, and I pass a hash-reference and filename
: to this routine.

: However, I'm getting the distinct feeling that I'm missing some sort of
: clue on how this should work.

: I've tried all sorts of methods, but it seems the untie'ing of the
: hash-variable doesn't gets propagated to the backend properly, since I
: keep ending up with 0-size db files.

: Consider this code snippet:
: --
: #!/usr/local/bin/perl5

: use DB_File;
: use Fcntl;

: sub	mytie
: {
: 	my ($ref, $filename) = @_;

: 	my $db = tie %{$ref}, DB_File, $filename, O_TRUNC|O_CREAT|O_RDWR, 0644;
: 	$db || die "tie on $filename: $!";
: }

: mytie(\%hash, "testdb");
: for (0..100)
: {
: 	$hash{$_} = "test $_";
: };
: untie %hash;
: system "ls -al";
: --

: So my question is...what am I doing wrong?? :) Thanks alot in advance.

Nothing. What you are doing should work.

If you do the "ls -l" after the script has terminated is it still empty?

Paul


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

Date: Wed, 6 Aug 1997 06:30:29 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Request help extracting acronyms
Message-Id: <l8n9s5.fl.ln@localhost>

Marjorie Roswell (roswell@umbc.edu) wrote:
: Thank you very much, Daniel and Mike! 

: Now there is a special case that I want to consider. 

: If the acronym is used at the end of the sentence, my addition will
: remove the final period if there is only one period. Thus, it will
: return "UNICEF" instead of "UNICEF." in the sentence 
: "Please support UNICEF."

: Now, wouldn't it be nice if U.S.A. sorted  *after* UNICEF? Suggestions
: are welcome! Once we get this last piece ironed out, (or even if we
: don't) may I submit it to the FAQ? (email:
: perlfaq-suggestions@perl.com). 


If you don't like how sort sorts, then you can write a sort routine
that does it the way you want:

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

%ac = qw( U.S.A 1 UNICEF 1);

foreach (sort by_acronym keys %ac) {
   print "$_\n";
}

sub by_acronym {              # not very efficient, but you get the idea
   (my $aa = $a) =~ tr/.//d;  # see "Schwartzian Transform" under sort
   (my $bb = $b) =~ tr/.//d;  # entry in the perlfunc man page if it is
                              # too slow
   return $aa cmp $bb;
}
-----------------------------


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Fri, 08 Aug 1997 13:35:17 -0600
From: paries@advicom.net
Subject: Sorting this file is killing me
Message-Id: <871064323.30737@dejanews.com>

Hello,
THis should be easy and I have seen many sorting example, but can't seem
to get the handle on this !%$# sorting thing...

anyways , I have a file that looks like this

Marge Simpson|100.00
bart Simpson|1000.00
joe simth|300.00

I need to read in this file and the sort the pairs by field 2 and then
load into either an array of arrays or hash.

I have been banging my head for a couple hours(i know this should be
simple)

Thanks for any help

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


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

Date: 08 Aug 1997 08:00:14 -0400
From: Kevin Lambright <kevinl@ascend.com>
Subject: Re: SQL error message handling with sybPerl?
Message-Id: <yhfyb6cnaup.fsf@ascend.com>

Your Name <id@aom.ericsson.se> writes:

> 
> I wonder if someone can help me
> with how to handle SQL error
> messages or error-codes in SybPerl.
> 
> Any help would be appreciated.
> 
> Patrik

I just went through this a few weeks ago.  If you have sybperl installed,
there should be a file under your site_perl directory 
(/usr/local/lib/perl5/site_perl on my Solaris machine) called 'sybutil.pl'.
If you look at this file, it gives you an example of how to set up both
error and message handlers for Sybase to use.  You can defined your
own routines and set them up as the error routines to use before you
do any Sybase processing.

You need to call &dbmsghandle and &dberrhandle somewhere in your 
initialization routine.

Hope this helps.

Kevin

-- 
------------------------------------------------------------------------------
Kevin Lambright                                    email: kevinl@casc.com
Ascend Communications                              voice: 508-952-7407
1 Robbins Road                                     fax:   508-692-1510
Westord, Ma. 01886


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

Date: Tue, 05 Aug 1997 11:53:05 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Still confused in flock() land
Message-Id: <33E6E9F1.15E1@icl.fi>

J. Paul Reed wrote:
> 
> Hey perl people!
> 
> I'm still confused about one thing about the flock() function call.
> 
> If I do this:
> 
> 1. Open file
> 2. Issue flock(FH, LOCK_EX);
> 3. Continue with the script
> 4. Close the FH,
> 
> what will happen if the exact same script (with a different PID, of
> course) tries to do number 2 above if the first process is at step 3.
> 
> Will the second script calling for a flock() die, wait until number 4 and
> then issue it's own flock(), or what?!
> 
> I never understood this one (pretty important) part.
> 
> Thanks for the help!
> 
> Later,
> Paul

If you run your script twice (changing number 3 so that it
waits for a while - by, for example, adding a line with 
'sleep( 100 );' -, if it'd otherwise be too quick) in 
separate windows, you'll see the effect in split second.

If you have a system/environment where you can only run a 
single program in a single window, I suggest you consider 
a multitasking environment/operating system. ;-)

Anyway, the second instance of your script will wait at 
the flock() until the first instance closes the file. At
least that's what happens on my machine. :-)

Try these as a simplified example:

hold.pl:

   open( FH, ">test.dat" ) or die "open failed ($!)\n";
   flock( FH, 2 ) or die "flock failed ($!)\n";
   print "sleeping...\n";
   sleep( 100 );
   close( FH ) or die "close failed ($!)\n";

try.pl:

   open( FH, ">>test.dat" ) or die "open failed ($!)\n";
   print "trying to lock...\n";
   flock( FH, 2 ) or die "flock failed ($!)\n";
   print "trying to write...\n";
   print FH "testline\n";
   close( FH ) or die "close failed ($!)\n";


regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: Thu, 07 Aug 1997 11:27:29 +0200
From: Doug Seay <seay@absyss.fr>
To: ITCG <itcg@com.latnet.lv>
Subject: Re: What means --> Can't call method "xxxxxxx" on unblessed reference ...?
Message-Id: <33E99501.4F3ABF6A@absyss.fr>

[posted and mailed]

ITCG wrote:
> 
> Hello big brothers,
> 
> Can anybody explain what does this message mean:
> 
> -------
> Can't call method "AddHeader" on unblessed reference at pop4.pl line 88,
> <SOCK2> line 29.
> -------

add "use diagnostics;" at the top of your source.  This give more
details about messages.  That is the third trick for all beginner Perl
programmers (-w and "use strict" are more important).


> {Who can bless it?}

You can.  "perldoc -f bless" for the details.  The question is: why
wasn't it blessed.

As for "why" have a blessed reference, You seem to be calling code in
the

	$object->method()

style of invocation.  $object has to be the name of a class (ie
MyClass->new()) or a blessed reference.  This "blessing" says where to
look to find "method".  This is all covered in the man pages, but it can
be a bit complicated for beginners.


> The goal is to check as frequently possible the mailbox, parse the
> contents and the send the HTTP request to WEB server.
> 
> My program does it very nicely but after 3rd or 4th time it shows this
> message and dies.(Or dies and then shows the message...?) I have placed
> everything in while(1){...} loop.
> 
> I thought - maybe requests are being sent very fast one after another
> (about 2,3 seconds) and tried to add sleep(). Doesn't help.
> 
> I can send a source if somebody is interested to help...


It looks like you've done

	my $var = \SOCK2;
	$var->AddHeader();

Since you say it works well for the first few iterations, I'd guess that
$var (or whatever your variable is called) was well defined at first,
but the value is changed.  At first it was a blessed reference and later
it becomes a reference to a filedescriptor.  Could this be the problem?

- doug

PS - "pop4.pl" is a bad name.  Since you seem to be using OO stuff, the
suffix should be ".pm".  This isn't fundamentally important, but it is
the convention.


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

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

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