[15472] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2882 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 27 18:06:32 2000

Date: Thu, 27 Apr 2000 15:05:23 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <956873122-v9-i2882@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 27 Apr 2000     Volume: 9 Number: 2882

Today's topics:
    Re: A script to make the output of "perldoc -f ..." mor <do.not.mail.me@null.net>
    Re: AIX perl 5.6 compile <ccoving@uhc.com>
    Re: AIX perl 5.6 compile <rootbeer@redcat.com>
    Re: AIX perl 5.6 compile <ccoving@uhc.com>
    Re: Any electronic perl book to share (pdf will be a bo <red_orc@my-deja.com>
        Beginner Questions <mikes@escape.com>
    Re: Beginner Questions <rootbeer@redcat.com>
    Re: Beginner Questions nobull@mail.com
    Re: Best way to hide source <andrew.mcguire@walgreens.com>
    Re: executing sub in a module without calling it nobull@mail.com
    Re: Fast way to do nslookup? <rootbeer@redcat.com>
    Re: Fast way to do nslookup? <flavell@mail.cern.ch>
    Re: Fast way to do nslookup? <tony_curtis32@yahoo.com>
    Re: Fast way to do nslookup? <you.will.always.find.him.in.the.kitchen@parties>
    Re: File Parsing (Tad McClellan)
        Finding text in a file and renaming that file <bruceNObrSPAM@mccausland.com.invalid>
    Re: Finding text in a file and renaming that file <rootbeer@redcat.com>
    Re: Finding text in a file and renaming that file nobull@mail.com
    Re: Finding text in a file and renaming that file (Neil Kandalgaonkar)
    Re: Finding text in a file and renaming that file <lr@hpl.hp.com>
        form posting to a file on NT <ajlazo@hotmail.com>
    Re: form posting to a file on NT <lr@hpl.hp.com>
    Re: GPIB <jeffahill@lucent.com>
    Re: Hashes -- case insensitive keys? (J. B. Moreno)
    Re: Hashes -- case insensitive keys? <bmb@ginger.libs.uga.edu>
    Re: Hashes -- case insensitive keys? <aperrin@davis.DEMOG.Berkeley.EDU>
        help with large, complex data structure <janderso@ncbi.nlm.nih.gov>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 27 Apr 2000 13:22:08 -0700
From: Mike Ayers <do.not.mail.me@null.net>
Subject: Re: A script to make the output of "perldoc -f ..." more readable.
Message-Id: <3908A170.632FF4D5@null.net>


	Thank you!  THANK YOU!   Thank yoooooouuuuuuuuuu!!!!!!!

	:-)


/|/|ike

Francis Litterio wrote:
> 
> This script arranges to feed the output of "perldoc -f ..." through
> pod2man to make it more readable.
> 
> It is UNIX-centric because it depends on UNIX shell quoting semantics,
> nroff, and less.  If you don't have less installed, change "less" to
> "more".
> --
> Francis Litterio
> franl-removethis@world.std.omit-this.com
> PGP public keys available on keyservers.
> 
> #!/usr/bin/perl
> 
> use strict;
> use POSIX;
> 
> my $tmpdir = POSIX::tmpnam();
> my $tmpfile = "$tmpdir/$ARGV[0]";
> my $pager = "less";
> 
> mkdir($tmpdir, 0755) or die("mkdir failed: $!\n");
> 
> my $status = system("perldoc -f \"$ARGV[0]\" > \"$tmpfile\"");
> 
> system("pod2man --lax --center=\"Perl Function '$ARGV[0]'\" \"$tmpfile\" | nroff -man | $pager") unless $status;
> 
> unlink($tmpfile) or die("unlink $tmpfile failed: $!\n");
> rmdir($tmpdir) or die("rmdir $tmpdir failed: $!\n");


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

Date: Thu, 27 Apr 2000 14:10:35 -0500
From: Chris Covington <ccoving@uhc.com>
Subject: Re: AIX perl 5.6 compile
Message-Id: <390890AB.607135E@uhc.com>

It worked well using the extra cost IBM compiler instead of gcc. 
Fortunately we are a big enough shop to have one laying around.  Thanks
for the info.  It's working now.

Still, too bad perl doesn't compile with gcc on AIX.
--
Chris Covington, UnitedHealth Group, ccoving@uhc.com


Elaine Ashton wrote:
> 
> in article 390756FF.B78971AA@uhc.com, Chris Covington at ccoving@uhc.com
> quoth:
> 
> > I am trying to compile perl5.6 on AIX 4.3 using gcc.  I get an error
> > after configuration, a while into the "make":
> 
> Use your native compiler.
> 
> e.


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

Date: Thu, 27 Apr 2000 12:25:37 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: AIX perl 5.6 compile
Message-Id: <Pine.GSO.4.10.10004271225080.21722-100000@user2.teleport.com>

On Thu, 27 Apr 2000, Chris Covington wrote:

> Still, too bad perl doesn't compile with gcc on AIX.

So, have you filed a bug report with the gcc team? :-)

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



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

Date: Thu, 27 Apr 2000 14:35:37 -0500
From: Chris Covington <ccoving@uhc.com>
To: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: AIX perl 5.6 compile
Message-Id: <39089689.C7D89B93@uhc.com>

If I was given any reasonable length of time to try to debug it, it
would probably be sent to the perl team rather than the gcc team, since
only that program doesn't compile on gcc (even tried with the latest
gcc).

Tom Phoenix wrote:
> 
> On Thu, 27 Apr 2000, Chris Covington wrote:
> 
> > Still, too bad perl doesn't compile with gcc on AIX.
> 
> So, have you filed a bug report with the gcc team? :-)
> 
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/

--
Chris Covington, UnitedHealth Group, ccoving@uhc.com


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

Date: Thu, 27 Apr 2000 18:28:15 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: Any electronic perl book to share (pdf will be a bonus)
Message-Id: <8ea0ra$ghg$1@nnrp1.deja.com>

In article <3907C4D0.31CFE058@ti.com>,
  norazman@ti.com wrote:
> Hi,
>
> I was currently in a stage of studying perl. Unfortunately, as a
student I
> don't have
> much money to invest on buying lots of book.
>

O'Reilly has 'The Perl CD Bookshelf', which includes a CD and hardcopy
'Perl In A Nutshell'.  Costs about $54.00 at amazon

CD includes:

Perl in a Nutshell, Advanced Perl Programming, Learning Perl (2nd),
Programming Perl (2nd), Perl Cookbook, Learning Perl on Win32 Systems,
all in HTML format with a search engine and a global index.

ISBN 1565924622


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 27 Apr 2000 15:05:10 -0400
From: mike <mikes@escape.com>
Subject: Beginner Questions
Message-Id: <39088F66.C97B5578@escape.com>

Hi,
        I can't execute a Perl script unless I do at the bash prompt:
perl scriptname. I though that if the first line of the script
has:
#!/usr/bin/perl

that it would execute by just typing the name of the script at the
bash prompt with out using the prefix "perl". I am using Redhat 5.1

One other question. Can Perl go into an interactive mode like
Basic so as to be in a Perl shell and try to execute some simple
commands or scripts. I have tried it and it didn't work. Could
my system be set up improperly?

                                                Mike




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

Date: Thu, 27 Apr 2000 12:23:43 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Beginner Questions
Message-Id: <Pine.GSO.4.10.10004271218500.21722-100000@user2.teleport.com>

On Thu, 27 Apr 2000, mike wrote:

> Subject: Beginner Questions

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> I can't execute a Perl script unless I do at the bash prompt:
> perl scriptname. I though that if the first line of the script
> has:
> #!/usr/bin/perl
> 
> that it would execute by just typing the name of the script at the
> bash prompt with out using the prefix "perl". 

I have the feeling I've seen this question already today. Let's see: Are
the #! characters the very first two characters on the very first line? Is
/usr/bin/perl a valid path to perl on your system? Is your script's
execute bit set? Does your $PATH include the script's directory? Is your
script's name the same as a shell built-in or something else found along
your $PATH? Of course, this doesn't really have anything to do with bash.

> One other question. Can Perl go into an interactive mode like Basic so
> as to be in a Perl shell and try to execute some simple commands or
> scripts.

Have you seen the FAQ's entry on "Is there a Perl shell?"

Cheers!

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



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

Date: 27 Apr 2000 20:34:36 +0100
From: nobull@mail.com
Subject: Re: Beginner Questions
Message-Id: <u9og6v1goj.fsf@wcl-l.bham.ac.uk>

mike <mikes@escape.com> writes:

>         I can't execute a Perl script unless I do at the bash prompt:
> perl scriptname. I though that if the first line of the script
> has:
> #!/usr/bin/perl
> 
> that it would execute by just typing the name of the script at the
> bash prompt with out using the prefix "perl". I am using Redhat 5.1

No, to make a script executable you need to do chmod +x 

This has nothing to do with Perl - it applies to all scripting
languages under Unix.

> One other question. Can Perl go into an interactive mode like
> Basic so as to be in a Perl shell and try to execute some simple
> commands or scripts.

See FAQ: "How can I use Perl interactively?"

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 27 Apr 2000 16:20:36 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: Best way to hide source
Message-Id: <3908AF24.382554F0@walgreens.com>

System Administrator wrote:

[ snip of entire post ]

Please set your word wrap to 72 charachters before posting again,
otherwise you will likely be ignored here.  Also as Tad said,
you may want to reconsider posting as Super-user.

Now, to your problem, keeping the open source parts as modules
sounds like your best bet.   The encryption method that you suggested
would mean that at some point in time, the data would have to be
unencrpyted before being ran.  At that point in time you will
have violated your NDA. There is a potential for a race condition
there, depending on how you go about it.

Regards,

anm
-- 
Andrew N. McGuire
andrew.mcguire@walgreens.com


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

Date: 27 Apr 2000 19:13:11 +0100
From: nobull@mail.com
Subject: Re: executing sub in a module without calling it
Message-Id: <u9wvlj1kg8.fsf@wcl-l.bham.ac.uk>

Uri Guttman <uri@sysarch.com> writes:

> >>>>> "n" == nobull  <nobull@mail.com> writes:
> 
>   n> Tony Curtis <tony_curtis32@yahoo.com> writes:
>   >> perldoc perlmod would be a good place to look for some
>   >> info, especially about BEGIN, or possibly INIT, blocks (if
>   >> I interpret your situation correctly).
> 
>   n> I'd suggested BEGIN, I'd never heard of INIT.  Is INIT a new 5.6
>   n> feature?  There's no mention of it in the 5.5 (pl3) perlmod page.
> 
> grep -w INIT *.pod
> perldelta.pod:have very little impact on compatibility.  See L<New C<INIT> keyword>,
> perldelta.pod:=head2 New C<INIT> keyword
> perldelta.pod:C<INIT> subs are like C<BEGIN> and C<END>, but they get run just before
> perldelta.pod:C<INIT> blocks to initialize and resolve pointers to XSUBs.
> perlfunc.pod:the C<eval ''>, C<BEGIN {}>, C<END {}>, and C<INIT {}> constructs.
> perlsub.pod:functions mentioned in L<perltie>.  The 5.005 release adds C<INIT>
>                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
> <more snipped>

So this is just another case of a cry-woolf RTFM.  The INIT function
in 5.005 is not documented anywhere but perldelta.  There are mentions
of it in other pages but they do not explain it, and there is no
mention at all in perlmod which is where the asker was directed.  This
is likely to cause unecessary frustration.

Please folks, we love to beat people up for not taking due care in
posing their questions - we should take some care in telling them to
RTFM.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 27 Apr 2000 11:05:36 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Fast way to do nslookup?
Message-Id: <Pine.GSO.4.10.10004271103290.21722-100000@user2.teleport.com>

On 27 Apr 2000, Tony Curtis wrote:

> > Hi, can anyone tell me how I can do an nslookup in perl
> > without exec-ing the built-in nslookup in unix? The
> > reason is that I'm working on a slow machine and
> > launching the nslookup program seem to be slowing the
> > whole process down so I'd like to do it natively in
> > perl.
> 
> perldoc Net::DNS

Alas, the slowness is probably DNS itself, and not the sub-process. Which
doesn't mean that the OP shouldn't consider using Net::DNS, though!

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



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

Date: Thu, 27 Apr 2000 19:53:16 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Fast way to do nslookup?
Message-Id: <Pine.GHP.4.21.0004271944160.28438-100000@hpplus01.cern.ch>

On 27 Apr 2000, Bala wrote:

> Hi, can anyone tell me how I can do an nslookup in perl without exec-ing the
> built-in nslookup in unix? 

Curiously, trawling the FAQs with 'perldoc -q name' or 'perldoc -q
address' tells one how to deduce one's _own_ address, but does not
seem to deal with the gethostby* functions for other host
name/addresses.  I don't know whether this calls for an FAQ upgrade -
what do the regulars think?

Anyway, you're looking for the gethostbyname/gethostbyaddress
functions, along with the inet_ntoa/aton functions for converting
between dotted-decimal and packed IP-address formats.
perldoc -f gethostbyname  should get you started.



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

Date: 27 Apr 2000 13:16:17 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Fast way to do nslookup?
Message-Id: <874s8nflzi.fsf@shleppie.uh.edu>

>> On Thu, 27 Apr 2000 11:05:36 -0700,
>> Tom Phoenix <rootbeer@redcat.com> said:

> On 27 Apr 2000, Tony Curtis wrote:
>> > Hi, can anyone tell me how I can do an nslookup in
>> perl > without exec-ing the built-in nslookup in unix?
>> The > reason is that I'm working on a slow machine and
>> > launching the nslookup program seem to be slowing the
>> > whole process down so I'd like to do it natively in >
>> perl.
>> 
>> perldoc Net::DNS

> Alas, the slowness is probably DNS itself, and not the
> sub-process. Which doesn't mean that the OP shouldn't
> consider using Net::DNS, though!

This is true, perhaps I should have thought about it when
I posted my reply (however, forking nslookup all over the
shop is certainly going to make things even slower).  In
this vein, perhaps pointers to

    perldoc Memoize

or the use of a hash to cache already seen addresses would
help this program?

hth
t


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

Date: Fri, 28 Apr 2000 08:03:52 +1200
From: "Tintin" <you.will.always.find.him.in.the.kitchen@parties>
Subject: Re: Fast way to do nslookup?
Message-Id: <956865761.395527@shelley.paradise.net.nz>


"Bala" <engbpa@liquidinformation.com> wrote in message
news:8e9tj5$5an$1@bignews.shef.ac.uk...
> Hi, can anyone tell me how I can do an nslookup in perl without exec-ing
the
> built-in nslookup in unix? The reason is that I'm working on a slow
machine
> and launching the nslookup program seem to be slowing the whole process
down
> so I'd like to do it natively in perl.

Apart from the other answers, if you really want to speed up DNS lookups,
keep a local DBM cache.  There is a slight trade off on the accuracy of the
data depending on the expiry times you set, but the speed increase is
significant for addresses that come from the cache (particularly if you have
a slow DNS).




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

Date: Thu, 27 Apr 2000 16:13:04 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: File Parsing
Message-Id: <slrn8gh7qg.rn.tadmc@magna.metronet.com>

On Thu, 27 Apr 2000 10:14:25 GMT, scarey_man@my-deja.com <scarey_man@my-deja.com> wrote:
>If I have a file with the following line:
>aaaa    bbbb  cccc       dddd
>how can I read the line into an array using split, even though the
>field separators are different lengths each time e.g. 4 spaces, and
>then 2 spaces?


If the "line" is in the $_ variable, then:

   my @array = split;


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


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

Date: Thu, 27 Apr 2000 11:21:02 -0700
From: fortbruce <bruceNObrSPAM@mccausland.com.invalid>
Subject: Finding text in a file and renaming that file
Message-Id: <0bf0fd7e.04c584a0@usw-ex0104-028.remarq.com>

I'm pretty new to Perl and require some assistance with a Perl
script.  I have some dynamic text files which I need to be able
to first: find the first occurance of text which begins with a
tilda character and ends with a comma, I then need to change the
name of that file to match the characters between that string
and move that file to a different directory. This script will be
run on an NT machine and the input files are FTP'd to a
directory on that machine.

Thanks for any help!

Bruce

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: Thu, 27 Apr 2000 11:45:53 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Finding text in a file and renaming that file
Message-Id: <Pine.GSO.4.10.10004271143550.21722-100000@user2.teleport.com>

On Thu, 27 Apr 2000, fortbruce wrote:

> I'm pretty new to Perl and require some assistance with a Perl
> script.  

How far have you gotten?

> to first: find the first occurance of text which begins with a
> tilda character and ends with a comma, 

Could do that with a pattern match.

> I then need to change the name of that file

Have you seen the rename() function in the perlfunc manpage?

> and move that file to a different directory. 

You may be able to do that with rename(), or you can use File::Copy to do
it.

Good luck with it!

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



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

Date: 27 Apr 2000 19:49:03 +0100
From: nobull@mail.com
Subject: Re: Finding text in a file and renaming that file
Message-Id: <u9u2gn1isg.fsf@wcl-l.bham.ac.uk>

fortbruce <bruceNObrSPAM@mccausland.com.invalid> writes:

> I'm pretty new to Perl and require some assistance with a Perl
> script.

Could you be more precise about where you are having difficulties
please? I trust you are not simply expecting us to do it for you?

Where is you problem:

  reading directories?
  reading files?
  searching for a pattern?
  saving the value matched by a pattern?
  renaming files?

>  I have some dynamic text files which I need to be able
> to first: find the first occurance of text which begins with a
> tilda character and ends with a comma,

my $found;
while (<FILE>) {
  last if ($found) =~ /~(.*?),/;
}

> I then need to change the
> name of that file to match the characters between that string
> and move that file to a different directory.

Use rename() (assuming directories on same device).

> This script will be run on an NT machine

I believe that rename() on NT still works as it should.


> and the input files are FTP'd to a directory on that machine.

You probably want the make the (.*?) a bit more restrictive then,
perhaps (\w+?)

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 27 Apr 2000 19:19:47 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: Finding text in a file and renaming that file
Message-Id: <8ea3sj$b60$1@newsflash.concordia.ca>

In article <0bf0fd7e.04c584a0@usw-ex0104-028.remarq.com>,
fortbruce  <bruceNObrSPAM@mccausland.com.invalid> wrote:
>I'm pretty new to Perl and require some assistance with a Perl
>script.  I have some dynamic text files which I need to be able
>to first: find the first occurance of text which begins with a
>tilda character and ends with a comma, I then need to change the
>name of that file to match the characters between that string
>and move that file to a different directory. This script will be
>run on an NT machine and the input files are FTP'd to a
>directory on that machine.
>
>Thanks for any help!

Is there any specific part you have more trouble with?

basic overview in pseudocode 

scan directory with opendir, readdir, grep for interesting files 
(see perldoc -tf readdir)

for my $f (@file) {
  
  local *FILE;  # make a local filehandle. 
  my $new_filename;

  open FILE, $f or die $!;
  while (<FILE>) {
    ($new_filename) = (/~([^,]+),/);
    last if defined $new_filename;
  }
  close FILE;

  if (defined $new_filename) {
    rename $f, $new_filename or die $! # with appropriate paths.
  } else {
    # no name to rename to.
  }
}
-- 
Neil Kandalgaonkar
neil@brevity.org


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

Date: Thu, 27 Apr 2000 12:56:51 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Finding text in a file and renaming that file
Message-Id: <MPG.13723b5939e3206198a998@nntp.hpl.hp.com>

In article <u9u2gn1isg.fsf@wcl-l.bham.ac.uk> on 27 Apr 2000 19:49:03 
+0100, nobull@mail.com <nobull@mail.com> says...

 ...

> my $found;
> while (<FILE>) {
>   last if ($found) =~ /~(.*?),/;
> }

I'm quite sure that you intended to capture the result of the match 
against $_ in $found.  Unfortunately, that's not what the code you 
posted does.

You can make it correct and save one keystroke at the same time.

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


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

Date: Thu, 27 Apr 2000 15:56:31 -0400
From: Alberto <ajlazo@hotmail.com>
Subject: form posting to a file on NT
Message-Id: <B52E13AE.4E9%ajlazo@hotmail.com>

Hi all, if anyone can help it would be greatly appreciated.  The cgi below
for some reason will only output to screen and when I look inside the log
file its empty.  Am I doing/not doing something wrong?

Thanks
Alberto




#!/usr/local/bin/perl


&Parse_Form;

$checkbox = $formdata{'checkbox'};
$checkbox2 = $formdata{'checkbox2'};
$checkbox3 = $formdata{'checkbox3'};
$checkbox4 = $formdata{'checkbox4'};
$firstname = $formdata{'firstname'};

$lastname = $formdata{'lastname'};
$middlename = $formdata{'middlename'};

$company = $formdata{'company'};

$contactphone = $formdata{'contactphone'};


$email = $formdata{'email'};

$comments = $formdata{'comments'};

open(LOG,">>/logfile.txt") || &ErrorMessage;
print LOG "$firstname $middlename
$lastname\n$company\n$contactphone\n$email\n$comments\n---------------------
---\n";
close (LOG);



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

print "<html><title>Thank You</title><body bgcolor=\"#FFFFFF\">";
print "<p><p><font face=\"Arial, Helvetica, sans-serif\">";
print "Thank you for entering your contact information.";
print "<br>The following information was entered:</center><p>";
print "<blockquote><blockquote><blockquote>";
print "I'm interested in: $checkbox $checkbox2 $checkbox3 $checkbox4<br>";
print "First Name: $firstname<br>";
print "Last Name: $lastname<br>";
print "Middle Name: $middlename<br>";
print "Company: $company<br>";
print "Contact Number: $contactphone<br>";
print "E-mail: $email<br>";
print "Comments: $comments";
print "</blockquote></blockquote></blockquote></font>";
print "<p><p><br><br>";
print "<p align=\"center\">";
print "</body></html>";

sub ErrorMessage {
print "Content-type:text/html\n\n";
print "The server can't open the file.\n";
exit;
}

sub Parse_Form {
    if ($ENV{'REQUEST_METHOD'} eq 'GET') {
        @pairs = split(/&/, $ENV{'QUERY_STRING'});
    } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
        read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
        @pairs = split(/&/, $buffer);
        
        if ($ENV{'QUERY_STRING'}) {
            @getpairs =split(/&/, $ENV{'QUERY_STRING'});
            push(@pairs,@getpairs);
            }
    } else {
        print "Content-type: text/html\n\n";
        print "<P>Use Post or Get";
    }

    foreach $pair (@pairs) {
        ($key, $value) = split (/=/, $pair);
        $key =~ tr/+/ /;
        $key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
        $value =~ tr/+/ /;
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    
        $value =~s/<!--(.|\n)*-->//g;
    
        if ($formdata{$key}) {
            $formdata{$key} .= ", $value";
        } else {
            $formdata{$key} = $value;
        }
    }
}    
1;




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

Date: Thu, 27 Apr 2000 13:52:31 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: form posting to a file on NT
Message-Id: <MPG.1372485c376e6cd598a99a@nntp.hpl.hp.com>

In article <B52E13AE.4E9%ajlazo@hotmail.com> on Thu, 27 Apr 2000 
15:56:31 -0400, Alberto <ajlazo@hotmail.com> says...
> Hi all, if anyone can help it would be greatly appreciated.  The cgi below
> for some reason will only output to screen and when I look inside the log
> file its empty.  Am I doing/not doing something wrong?

Oh, yes.  You are doing several things wrong.

> #!/usr/local/bin/perl

You are not using the '-w' flag (some would say the '-T' flag also) and 
you need:

  use strict;

> &Parse_Form;

You are using home-grown input parsing instead of CGI.pm, which is much 
more likely to do it right than you are.

  use CGI ':standard';

> $checkbox = $formdata{'checkbox'};

These would all become

  my $checkbox = param('checkbox');

etc.

 ...

> open(LOG,">>/logfile.txt") || &ErrorMessage;

Are you really trying to write a file in the root directory of the 
server?  I am amazed that you have permission to do that.  The program 
should produce an error message.  See below.

 ...

> print "Content-type: text/html\n\n";
> 
> print "<html><title>Thank You</title><body bgcolor=\"#FFFFFF\">";

You should use a here-doc to avoid all those print statements with the 
ugly escapes.

You have no <head> and </head> tags, though perhaps some browsers 
tolerate that.

You could do:

    print header, start_html('Thank You');

to get it all right with less typing.

 ...

> sub ErrorMessage {
> print "Content-type:text/html\n\n";

That is incorrect, as it needs a space after the colon, though some 
browsers may tolerate that.  Also, you are printing plain text, not 
HTML.

This is probably where your error message is going astray.  Replace this 
all by:

  use CGI::Carp 'fatalsToBrowser';

and just die() after the open() above.

> print "The server can't open the file.\n";

And don't forget to include $! in the diagnostic.

> exit;
> }
> 
> sub Parse_Form {

And can all the rest of this stuff.

HTH.  HAND!

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


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

Date: Thu, 27 Apr 2000 16:11:38 -0500
From: Jeff H <jeffahill@lucent.com>
Subject: Re: GPIB
Message-Id: <3908AD0A.D6C7408E@lucent.com>

I've had quite a bit of experience with GPIB in Visual Basic.  Usually, I set a
variable as a handle to the device. ex:

	dim i as integer
	i = iopen("718")
	iwrite i, "*RST"

I would imagine that the library you are using has a similar ability.  You may
want to try something along those lines.

Dave Zempel wrote:
> 
> I'm attempting to communicate with a GPIB device (HP8594E).  I've just
> recently realized that my problem is in specifying the HPIB device
> address.  This is not /dev/gpib0.  I open /dev/gpib0 and then print to
> that IO channel.  The problem is that since many devices can be
> connected to /dev/gpib0, I also need to specify an address (718).  All
> of the example programs provided with the GPIB interface card come with
> IO libraries that hide this addressing issue.
> 
> Has anyone done this before in PERL or any other scripting language.
> And can you tell me how to handle the addressing issue?
> 
> thanks, Dave Zempel.


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

Date: Thu, 27 Apr 2000 14:39:04 -0400
From: planb@newsreaders.com (J. B. Moreno)
Subject: Re: Hashes -- case insensitive keys?
Message-Id: <1e9r4a7.zahheen32597N%planb@newsreaders.com>

Brad Baxter <bmb@ginger.libs.uga.edu> wrote:

> On Thu, 27 Apr 2000, J. B. Moreno wrote:
> 
> > Is it possible to have case insensitive hash keys without storing the
> > keys in either uc or lc?
> > 
> > I.e. some way to make $hash{'John'} and $hash{'john'} refer to the same
> > thing, but keys %hash return whatever was first used?
> > 
> 
> The short answer is, "No."
> 
> If you don't mind my asking, why don't you want to use uc or lc?  Is it
> because you want to keep the original case?

Basically yes.

> If so, you might try an aggregate structure
> 
> my %hash = (
> 
>   john => [ 'John', "John's data" ],
>   mary => [ 'Mary', "Mary's data" ],
> 
> );
> 
> In this case, $hash{john}[0] contains the name in it's original case,
> and $hash{john}[1] contains the data you want. You could hide this by
> making the hash an object and possibly implementing a tie.

That'll work well enough.

> By the way, "keys %hash" returns something, but it's not "whatever was
> first used", unless I'm mistaken.

If there's no "whatever was used first", then if it's not unique it's
the same as whatever was used first.

$hash{'john'}=1; $hash{'JOHN'}++;
and then keys %hash returns (john, JOHN) and both have a value of 1.
What I was asking for was for keys %hash to return (john) and for
$hash('john'} to have a value of 2.


-- 
John B. Moreno


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

Date: Thu, 27 Apr 2000 16:26:36 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Hashes -- case insensitive keys?
Message-Id: <Pine.A41.4.10.10004271621560.14050-100000@ginger.libs.uga.edu>

On Thu, 27 Apr 2000, J. B. Moreno wrote:
> Brad Baxter <bmb@ginger.libs.uga.edu> wrote:

> > By the way, "keys %hash" returns something, but it's not "whatever was
> > first used", unless I'm mistaken.
> 
> If there's no "whatever was used first", then if it's not unique it's
> the same as whatever was used first.
> 
> $hash{'john'}=1; $hash{'JOHN'}++;
> and then keys %hash returns (john, JOHN) and both have a value of 1.
> What I was asking for was for keys %hash to return (john) and for
> $hash('john'} to have a value of 2.

I probably just misunderstood.  The point I was making is that "keys" does
not return the keys of a hash in any particulary order (assuming the hash
isn't tied to some class for which that statement is false).

You may not have meant to imply otherwise, but I just wanted to clarify
in case you were expecting otherwise.

Regards,

--
Brad



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

Date: 27 Apr 2000 14:31:02 -0700
From: Andrew Perrin - Demography <aperrin@davis.DEMOG.Berkeley.EDU>
Subject: Re: Hashes -- case insensitive keys?
Message-Id: <u5kr9brfcyx.fsf@davis.DEMOG.Berkeley.EDU>


There's a CPAN module that purports to use tie() to do this - haven't
tried it, but it's not a particularly hard problem so I'd expect it to
behave well.

http://www.cpan.org/modules/by-module/Tie/Tie-CPHash-1.001.tar.gz

ap


-- 
---------------------------------------------------------------------
Andrew J. Perrin - aperrin@demog.berkeley.edu - NT/Unix Admin/Support
Department of Demography    -    University of California at Berkeley
2232 Piedmont Avenue #2120  -    Berkeley, California, 94720-2120 USA
http://demog.berkeley.edu/~aperrin --------------------------SEIU1199


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

Date: 27 Apr 2000 16:58:37 -0400
From: "John S. J. Anderson" <janderso@ncbi.nlm.nih.gov>
Subject: help with large, complex data structure
Message-Id: <wenhfcn45xe.fsf@ncbi.nlm.nih.gov>

Greetings.

I'm struggling with implementing a large two level data
structure, and would like to get some input from the mass mind.

Conceptually the structure is a hash of arrays -- about 7000 different
arrays, each with 65536 (4**8) elements. Figuring 1 byte per element
[1] gives a total size of 458,752,700 bytes -- so that's not going 
to work. (And, yes, I do need random access at the upper level of the
structure, so working on this one hash at a time isn't going to cut
it.)

The arrays are pretty sparsely populated, maybe ~25% filled on
average, and actually map to strings rather than numbers[3], so I
considered using a hash of hashes...but I also need this to be
persistent (i.e., written out to disk), and from the *DBM_File docs,
multi-level structures are a no-op.

So, at this point, I'm looking at using pack to scrunch the second
level hashes into blobs, which can then be unpacked on the fly as they
are accessed. Of course, that means I've got to have a second
structure, telling me how many key/value pairs I have in each packed
hash (because each will differ)...

And I find myself saying, there must be a Better Way. Any one have any
ideas?

Thanks,
john.

Footnotes: 
[1]  Which is an under-estimination, in all likelihood.
[2]  I was using one global look-up array to map the strings back onto
     multiple data arrays.

-- 
------------------------------------------------------------------------
John S J Anderson                                           NCBI,NLM,NIH
IRTA Fellow                                              Bldg 38A, B2N14  
janderso@ncbi.nlm.nih.gov                                    301.594.608



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 2882
**************************************


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