[16065] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3477 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 25 21:05:21 2000

Date: Sun, 25 Jun 2000 18:05:08 -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: <961981508-v9-i3477@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 25 Jun 2000     Volume: 9 Number: 3477

Today's topics:
        500 Internal Server Error? <omygod@my-deja.com>
    Re: 500 Internal Server Error? <tony_curtis32@yahoo.com>
    Re: 500 Internal Server Error? (Kragen Sitaker)
    Re: Can a regex pick out a domain name from a line of t <robert@chalmers.com.au>
    Re: defined() <sumus@aut.dk>
    Re: Get the matched position in regexp <godzilla@stomp.stomp.tokyo>
        HELP AGAIN PLEASE !!!! <lee.millard@ntlworld.com>
    Re: HELP AGAIN PLEASE !!!! <sumus@aut.dk>
        HELP ME PLEASE !!!! <lee.millard@ntlworld.com>
    Re: HELP ME PLEASE !!!! <sumus@aut.dk>
    Re: Is this a bug? <netnerds@bellsouth.net>
    Re: newbie perl question about file i/o <bwalton@rochester.rr.com>
    Re: newbie perl question about file i/o nobull@mail.com
    Re: newbie perl question about file i/o <tina@streetmail.com>
    Re: newbie perl question about file i/o <billy@arnis-bsl.com>
    Re: NT vs Unix detection <helderNOheSPAM@cesar.org.br.invalid>
    Re: NT vs Unix detection <helderNOheSPAM@cesar.org.br.invalid>
    Re: Reg Expression Question <DNess@Home.Com>
    Re: Sending data to a certain connection malverian@my-deja.com
    Re: test for membership in an array? <carvdawg@patriot.net>
        Thank you everyone for help!!! <kokopuff@cukezone.com>
    Re: zope, python vs apache, perl <smile773@bigfoot.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 25 Jun 2000 22:34:01 GMT
From: Ramya <omygod@my-deja.com>
Subject: 500 Internal Server Error?
Message-Id: <8j61cp$672$1@nnrp1.deja.com>

I am trying to install a cgi/pl script and everytime I click on the url
it gives me the following error message....could somebody have a look
and let me know where I am goofing up or is there a standard solution
for the following problem.

Thanks for the help,
Ramya.


Error Message:
----------------

Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, KATRAT@HOTMAIL.COM and inform
them of the time the error occurred, and anything you might have done
that may have caused the error.

Premature end of script headers: /home/usr101/cgi-
bin/dclinks/dcladmin.cgi



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

Apache/1.3.3 Server at www.etelugu.com Port 80




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


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

Date: 25 Jun 2000 18:01:00 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: 500 Internal Server Error?
Message-Id: <87vgyxz7pv.fsf@limey.hpcc.uh.edu>

>> On Sun, 25 Jun 2000 22:34:01 GMT,
>> Ramya <omygod@my-deja.com> said:

> I am trying to install a cgi/pl script and everytime I
> click on the url it gives me the following error
> message....could somebody have a look and let me know
> where I am goofing up or is there a standard solution
> for the following problem.

> Internal Server Error The server encountered an internal
> error or misconfiguration and was unable to complete
> your request.  Please contact the server administrator,
> KATRAT@HOTMAIL.COM and inform them of the time the error
> occurred, and anything you might have done that may have
> caused the error.

And what did katrat@hotmail.com say when you mailed them
the details of your error?

It sounds like your web server is not configured to do
CGI, or you are not using the web server in the way
intended at your site.

Either way, this isn't a perl problem.  You're likely to
get the best info in a newsgroup which deals with the
specific web server you are using.

hth
t
-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: Sun, 25 Jun 2000 23:45:56 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: 500 Internal Server Error?
Message-Id: <UQw55.3838$fB2.77801@news-east.usenetserver.com>

In article <87vgyxz7pv.fsf@limey.hpcc.uh.edu>,
Tony Curtis  <tony_curtis32@yahoo.com> wrote:
>>> On Sun, 25 Jun 2000 22:34:01 GMT,
>>> Ramya <omygod@my-deja.com> said:
>> I am trying to install a cgi/pl script . . .
>> Internal Server Error . . . 
>
>And what did katrat@hotmail.com say when you mailed them
>the details of your error?

Um, if Ramya is the one trying to install the script, Ramya is the one
who needs to deal with this.

>It sounds like your web server is not configured to do
>CGI, or you are not using the web server in the way
>intended at your site.

If it were not configured to do CGI, it would give Ramya a 403
Forbidden or just output the CGI script.  Most likely the script is
exiting with an error.  Ramya needs to look at the error_log to find
out what the error message is.

>Either way, this isn't a perl problem.

It probably is a Perl problem, but Ramya hasn't yet posted the
information necessary to determine which of the many possible Perl
problems it is :)
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
The power didn't go out on 2000-01-01 either.  :)


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

Date: Mon, 26 Jun 2000 09:29:08 +1000
From: "Robert Chalmers" <robert@chalmers.com.au>
Subject: Re: Can a regex pick out a domain name from a line of text?
Message-Id: <ezw55.14$7f7.1774@nsw.nnrp.telstra.net>

Hmmm,
no wonder I couldn't get it. :-)

That is a little on the complex side. However, it looks like just what I
need, so I'll use it.

All I need to do actuallyl is test a line of text to see if it has a string
in it that looks like a domain name.
What I'm doing is scanning an SOA record, and checking it for valid domain
names, and saving those, and leaving behind all the unnecessary stuf like
serial numbers, name servers and so on.  Like this,

                  2000062500 ;serial
                  1800 ;refresh every 30 min
                  900 ;retry every 15 min
                  604800 ;expire after a week
                  86400 ;minimum of a day
                  )
ORG. 518400 IN NS    blah blah blah

A.GTLD-SERVERS.NET. 518400 IN A 198.41.3.38
M.GTLD-SERVERS.NET. 518400 IN A 210.176.152.18
H.GTLD-SERVERS.NET. 518400 IN A 216.33.75.82
C.GTLD-SERVERS.NET. 518400 IN A 205.188.185.18
I.GTLD-SERVERS.NET. 518400 IN A 192.36.144.253
FITCITY.ORG. 172800 IN NS NSX.NTX.NET.
FITCITY.ORG. 172800 IN NS NSC.NTX.NET.


and just end up with the domain names at the start of the line. I know I
could just grab the start of the line, but I want to avoid all that early
serial number stuff as well.

Interesting exercise.

Thanks for your kind help,

cheers
Robert


"Keith Calvert Ivey" <kcivey@cpcug.org> wrote in message
news:39561874.87303736@nntp.idsonline.com...
> "Robert Chalmers" <robert@chalmers.com.au> wrote:
>
> >Does anyone have a regex that can pick out a domain name
> >from a line of text please.
>
> It depends on exactly what you mean by "domain name" and how
> strict you want to be.  If you mean a host name (as defined in
> RFC 952 updated by RFC 1123), then something like this might
> work, assuming the text is in $_:
>
>     my @names =
>         m{ \b              # a word boundary
>            (?:             # followed by one or more groups of
>              [a-z0-9]      # a letter or digit
>              (?:           # possibly followed by
>                [a-z0-9-]*  # letters, digits, and hyphens
>                [a-z0-9]    # ending with a letter or digit
>              )?
>              \.            # a period
>            )+
>            (?:             # and then one of
>              com |         # the 7 generic TLDs
>              edu |         # (top-level domains)
>              gov |
>              int |
>              mil |
>              net |
>              org |
>              [a-z]{2}      # or a country code
>            )
>            \b              # a word boundary
>          }gix;
>
> Note that you don't want to use \w, because (aside from the
> issue of locale) underscores aren't legal in domain names and
> hyphens are.  Also, there's a bit of complication to disallow
> hyphens at the beginning or end of any part of the name (Network
> Solutions had a problem with that a few months back and
> erroneously allowed people to register things like "e-.com").
>
> You could include the whole list of valid country codes, but
> then you'd have to keep updating it.  This regex has to be
> updated only whenever ICANN decides to define new generic TLDs,
> which is unlikely ever to happen because of the power of
> trademark holders.
>
> If you're trying to get just the second-level domain name (the
> thing registered with the Internic), then you're going to have
> to decide what to do about country-code TLDs, since different
> countries organize their DNS hierarchies differently -- some are
> deep and some are shallow.
> --
> Keith C. Ivey <kcivey@cpcug.org>
> Washington, DC
>
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----==  Over 80,000 Newsgroups - 16 Different Servers! =-----




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

Date: 26 Jun 2000 02:23:25 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: defined()
Message-Id: <vgyxb88y.fsf@macforce.sumus.dk>

SPAM+indigo@dimensional.com (Tim) writes:

> In your example, defined is superfluous, because all values will have
> a newline,...

 ... provided of course that $/ hasn't been tampered with. If $/ is set to
'0' for some weird reason, you will actually assign '0' which is false
to $_ if the input stream contains two zeros in a row. And in the more likely
case where $/ is set to \1 (ref. to integer 1) you'll read one char at a
time - so you'll get '0' if it occurs in the input.

Now this whole thing got me curious so I went and tested it. And it appears
that the while test is smarter than we dared to assume: Apparantly it
tests for definedness (as opposed to trueness) when the predicate involves
the <HANDLE> operator:

$/ = '0';
while ( <DATA> ) { print "->$_" }
__DATA__
pnu00oda
gnu
0
1 2 3 0 0 000 gryttt

produces:
->pnu0->0->oda
gnu
0->
1 2 3 0-> 0-> 0->0->0-> gryttt

and

$/ = \1;
while ( <DATA> ) { print "->$_" }
__DATA__
pnu00oda
gnu
0
1 2 3 0 0 000 gryttt

produces:
->p->n->u->0->0->o->d->a->
->g->n->u->
->0->
->1-> ->2-> ->3-> ->0-> ->0-> ->0->0->0-> ->g->r->y->t->t->t->

And it's not only when you use the while ( <DATA> ) special syntax. It
also works with while ( $_ = <DATA> ) or even while ( $x = <DATA> ).

So calling defined() in the test is superfluous eventhough <> actually
may return false before EOF.

-- 
Jakob


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

Date: Sun, 25 Jun 2000 15:38:16 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Get the matched position in regexp
Message-Id: <395689D8.FCC25CD@stomp.stomp.tokyo>

multiplexor wrote:

> Is it possible to get the position of the matched part in a string?
> For example:
 
> $_ = 'ABCDE';
> if (/C/) {
>     print "C is at the 3rd character".
> }
 
> How do I get the position of C in $_ ?


An alternative method. Position is
given from a human perspective.

Godzilla!


PRINTED RESULTS:
________________

x is character number 1
x is character number 11
x is character number 20

     Done! Godzilla Rocks!

n is character number 3
n is character number 13
n is character number 22
n is character number 24

     Done! Godzilla Rocks!

Oh Mule Manure. I did not find z.

     Done! Godzilla Rocks!



TEST SCRIPT:
____________

#!/usr/local/bin/perl

print "Content-Type: text/plain\n\n";

$string = "xenophilicxenophobexenon";

$godzilla = "     Done! Godzilla Rocks!";

$request = "x";

&Find_It;

$request = "n";

&Find_It;

$request = "z";

&Find_It;

sub Find_It
 {
  $mule_manure = index ($string, $request);
  if ($mule_manure eq -1)
   { 
    print "Oh Mule Manure. I did not find $request.\n\n",
          "$godzilla\n\n"; last;
   }
  else
   {
    $found = 0;
    for ($iterate = 1; $iterate <= (length ($string)); $iterate++)
     {
      $found = index ($string, $request, $found);
      if ($found gt -1)
       { $found++; print "$request is character number $found\n"; }
      else
       { print "\n$godzilla\n\n"; last; }
     }
   }
 }

exit;


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

Date: Mon, 26 Jun 2000 01:08:02 +0100
From: "Lee Millard" <lee.millard@ntlworld.com>
Subject: HELP AGAIN PLEASE !!!!
Message-Id: <fax55.2500$NE5.57476@news2-win.server.ntlworld.com>

Please can some one help me edit this script so that it says the accessors
IP address where I have put ~@~@~@~@~@~@


Please help me ASAP

Cheers

Lee

#!/usr/bin/perl
#the next 4 lines have to be edited before running the script
$mailprog = '/usr/lib/sendmail'; #make sure this is set to the location of
sendmail on the web server
$outputpage = 'https://64.176.8.216/secure/thank_you.html'; #this is the
html page that is displayed after a visitor has submitted the form
$subject = 'Form Orders Cards'; #The subject of email that the forms sends
out to the address below
$recipient
='modifications@gadgetfantastic.com,modifications@x-stream.co.uk'; #the
email address that script will send to *****MAKE SURE THIS IS VALID*****

&parse_form; #gather all to the form information sent to the script
print "Location: $outputpage\n\n"; #print the redirectional location header,
so the html response page is displayed after the email has been sent
&send_mail; #Send E-Mail
############################################################################
############################################################################
########
sub parse_form
{
   if($ENV{'REQUEST_METHOD'} eq 'POST') #the form must send this script it's
information using the "POST" method
 {
    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); #get all the form
information
   @pairs = split(/&/, $buffer); #split the info into name and value pairs
   }
   else{&error;} #run the error sub

   foreach $pair (@pairs) #For each field and data received from the form
 {
      local($name, $value) = split(/=/, $pair); # Split the pair up into
individual variables.
      #Decode the form's URL encoding on the name and value variables.
      $name =~ tr/+/ /;
      $name =~ 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 they try to include server side
includes, erase them.

  push(@Field_Order,$name); #add the field name to an array to keep the same
order the fields appear in the form
      $Form{$name} = $value; #store the current field name and value
 }
}
############################################################################
############################################################################
##########
sub send_mail
{
 my($field);

   open(MAIL,"|$mailprog -t"); # Open the sendmail program on the web server

 #print the email headers
   print MAIL "To: $recipient\n";
   print MAIL "From: $Form{'email'} ($Form{'realname'})\n";
 print MAIL "Subject: $subject\n\n";

 #print the email body
 print MAIL "Below is the result of your feedback form.  It was submitted
by\n~@~@~@~@~@~@";
   print MAIL "$Form{'realname'} ($Form{'email'})\n";
   print MAIL "-" x 75 . "\n\n";

   foreach $field (@Field_Order){print MAIL "$field: $Form{$field}\n\n";}
#print each form field and value

 close (MAIL); #finished email so close sendmail, so the email is sent
}
############################################################################
############################################################################
#
sub error
{
 print <<"(END ERROR HTML)"; #display error message to user by using the
html below. (any html can go between the <html> tags)
Content-type: text/html

<html>
<head>
 <title>Error - Reqest Method</title>
</head>
<body bgcolor=#FFFFFF text=#000000>
 <center>
  <h1>Error - Request Method</h1>
  The request method of the form attempting to use this cgi script must be
set to:<br>
  <i>POST</i>
 </center>
</body>
</html>
(END ERROR HTML)
   exit; #script
}




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

Date: 26 Jun 2000 02:53:47 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: HELP AGAIN PLEASE !!!!
Message-Id: <snu1b6uc.fsf@macforce.sumus.dk>

"Lee Millard" <lee.millard@ntlworld.com> writes:

> Please can some one help me edit this script so that it says the accessors
> IP address where I have put ~@~@~@~@~@~@

Please don't put so much code in for no reason. The IP is in the environment
variable REMOTE_ADDR which is accessible as

$ENV{ REMOTE_ADDR }

in perl. It's up to you to enter it at the right place in your script.

So I even made your request look almost like a perl question for you there,
didn't I? ;-)

-- 
Jakob


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

Date: Mon, 26 Jun 2000 01:04:57 +0100
From: "Lee Millard" <lee.millard@ntlworld.com>
Subject: HELP ME PLEASE !!!!
Message-Id: <m7x55.2495$NE5.57465@news2-win.server.ntlworld.com>

Hi,

I am a newbie to Perl and I am trying to get my perl script to do a simple
thing......

How do I get my script to display a list of directories that are in the same
directory as the script ???


Please help me ASAP


Cheers

Lee




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

Date: 26 Jun 2000 02:45:42 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: HELP ME PLEASE !!!!
Message-Id: <u2ehb77t.fsf@macforce.sumus.dk>

"Lee Millard" <lee.millard@ntlworld.com> writes:

> How do I get my script to display a list of directories that are in the same
> directory as the script ???

opendir DIR, '.';
while ( $_ = readdir DIR ) { -d $_ and print $_, "\n" }

This works if '.' gives you the directory of the script. I'm not sure if it
does that in all CGI environments - if that's where you need it - but it does
in mine.

look up
perldoc -f opendir
perldoc -f readdir
perldoc -f -d

you might also want to know
perldoc -f rewinddir

-- 
Jakob


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

Date: Sun, 25 Jun 2000 18:22:39 -0400
From: Paul Kunicki <netnerds@bellsouth.net>
Subject: Re: Is this a bug?
Message-Id: <3956862F.64999BA0@bellsouth.net>

Well I answered my own question. This isn't a bug. In fact it's just
another case of foot in mouth syndrome.

#Here is the line at fault:
my @categories = $f->field_selection("desc");

Here is what it SHOULD look like:
my @categories = @{$f->field_selection("desc")};

Although I will say that perlref man page can get pretty scary :-)

Thanks for your time and Patience,

Paul Kunicki

Paul Kunicki wrote:

> Hello,
>
>     I'm trying to utilize  HTTP::Request::Form to learn about about some
> forms on remote sites and the code seems to be acting contary to the
> authors documentation but I am not sure if I have found a bug or not.
> If this is not a bug please give me an example of how to correctly
> access the form options I am trying to retrieve.
>
> This is off an Intel Linux box running Perl5:
>
> ##First I retrieve a page with numerous input fiels which include a
> select box. I assign the names of the fields to an array without any
> difficulty.
>
> my $f = HTTP::Request::Form->new($forms[0][1], $url);
> @names = $f -> fields;
> print "These are the field names --->@names";
>
> ##Here is what I think might be a bug or an oversight on my part. The
> code should assign all the select options of a an input field named
> 'desc' but instead it prints: Array(852xYUn)
>
> my @categories = $f->field_selection("desc");
> print "@categories";
>
> The author says that field_selection should return an array, not a
> reference to one.
>
> Thanks for your time and patience,
>
> Paul Kunicki



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

Date: Sun, 25 Jun 2000 22:27:16 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: newbie perl question about file i/o
Message-Id: <3956878E.1EE4CA93@rochester.rr.com>

Will wrote:
> 
> Hi folks, I am new to perl and have a question.
> 
> I am trying to read data from a file until the '=' character is found.
> It works, except if the number 0 is in the string it replaces it with
> a newline character.
> 
> .
> .
> .
> 
>        while($ch) {
>           last if $ch eq "=";
>           $key .= $ch;
>           $ch = getc(HANDLE);
>        }
>        print "$key\n";
> 
> when the data might read:
> 
> Testing054=something
> 
> the program would output
> 
> Testing
> 54
> 
> Any help will be very much appreciated.
The character "0" is being interpreted as a false in the while test. 
You need to replace the while test with:

     while(defined $ch) {

Then it'll work fine.  That tests for $ch containing undef or not, with
undef being the value returned by getc when end-of-file is reached.  You
might consider using Perl's normal I/O facilities, which will be much
faster and less hassle than getc.
-- 
Bob Walton


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

Date: 25 Jun 2000 23:11:58 +0100
From: nobull@mail.com
Subject: Re: newbie perl question about file i/o
Message-Id: <u966qxz9zl.fsf@wcl-l.bham.ac.uk>

willg@nospam.webmastermd.com (Will) writes:

> Subject: newbie perl question about file i/o

"newbie" doesn't help us to understand your problem.

"perl question about ..." can be assumed this this is the hierachy
comp.lang.perl

Your problem has nothing to do with "file i/o".

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


> It works, except if the number 0 is in the string...

If you use a scalar in a boolean context then it is true unless it is:
  Undefined
  The null string
  The string '0'
  A reference to a blessed thingy with overload 

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


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

Date: 25 Jun 2000 23:06:53 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: newbie perl question about file i/o
Message-Id: <8j63ad$617lh$1@fu-berlin.de>

hi,
Will <willg@nospam.webmastermd.com> wrote:

> I am trying to read data from a file until the '=' character is found.
> It works, except if the number 0 is in the string it replaces it with
> a newline character.

>        while($ch) {

you're testing if $ch is true. if $ch is
"0" it is not true.
so replace it with
   while (defined $ch) {

>           last if $ch eq "=";
>           $key .= $ch;
>           $ch = getc(HANDLE);
>        }
>        print "$key\n";   

but maybe you would like to use regular expressions?
getting everything before  "=" in a $string:
($match) = ($string =~m/(.*?)\=/);


tina

-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \ _,_\ __/\ __/_| /__/ perception
"The Software required Win98 or better, so I installed Linux."


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

Date: Sun, 25 Jun 2000 22:58:56 GMT
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: newbie perl question about file i/o
Message-Id: <8j62ra$72p$1@nnrp1.deja.com>

In article <39567c84.13320850@news.rdc1.bc.wave.home.com>,
  willg@nospam.webmastermd.com (Will) wrote:
> Hi folks, I am new to perl and have a question.
>
> I am trying to read data from a file until the '=' character is found.
> It works, except if the number 0 is in the string it replaces it with
> a newline character.
>
> .
> .
> .
>
>        while($ch) {
>           last if $ch eq "=";
>           $key .= $ch;
>           $ch = getc(HANDLE);
>        }
>        print "$key\n";
>
> when the data might read:
>
> Testing054=something
>
> the program would output
>
> Testing
> 54
>

As perldoc -f getc says, getc() return undef on EOF.
When you read '0' into $ch, your while($ch)
evaluates to false (what isn't what you mean)
and your loop breaks.
Use while(defined $ch).

Maybe a more compact way:

my ($ch, $key) = ('', '');

$key .= $ch   while (defined ($ch=getc HANDLE) && $ch ne '=');

print $key, "\n";

You may also consider another way
for reading key-value pairs
(if there is only one pair per line):

1. Read the whole line;
2. Split it into key-value pair.

Example (untested):

$_ = <HANDLE>;
($key, $value) = split /=/;

Hope this helps.
Ilja.


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


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

Date: Sun, 25 Jun 2000 14:47:45 -0700
From: Helder <helderNOheSPAM@cesar.org.br.invalid>
Subject: Re: NT vs Unix detection
Message-Id: <2164be04.1dfbcbcb@usw-ex0102-014.remarq.com>

Try this:

$OS=`uname`;

if ($OS =~ /SunOS/)
{
        print "Sistema SunOS.";
}
else
{
        print "Outro Sistema.";
}

I am not so good in Perl. You make your improvements.
:)


Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



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

Date: Sun, 25 Jun 2000 15:01:26 -0700
From: Helder <helderNOheSPAM@cesar.org.br.invalid>
Subject: Re: NT vs Unix detection
Message-Id: <0991de68.218de5af@usw-ex0102-014.remarq.com>

Sorry, you have to find uname for NT. If you want, I can send
you by email.

Helder.

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



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

Date: Sun, 25 Jun 2000 22:36:43 GMT
From: David Ness <DNess@Home.Com>
Subject: Re: Reg Expression Question
Message-Id: <39568980.14AFE538@Home.Com>

Bernard El-Hagin wrote:
> 
> Tina Mueller wrote:
> >
> > hi,
> >
> > Tad McClellan <tadmc@metronet.com> wrote:
> > > On Tue, 20 Jun 2000 02:37:40 GMT, tony_123@my-deja.com <tony_123@my-deja.com> wrote:
> >
> > >>I have the string
> > >>
> > >>$MyString='<img src="http://www.myhouse.com.au/house.gif">';
> > >>
> > >>Can someone please tell me how I can extract the house.gif part of this
> > >>string.
> >
> > > Here's one way:
> > >    my $img_name = substr($MyString, 36, 9);
> >
> > i like that one, but how about that:
> > ($gif) = ($MyString =~ m/(house\.gif)/);
> 
> Let the anti-golf begin:
> 
> ($gif) = ($MyString =~
> m/....\s...........\....\........\....\....(house\.gif)../);
> 
> :-)
> 
> --
> Cheers,
> Bernard

I thought anti-golf was `flog'...

(Let the `flog'-ing begin!)


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

Date: Sun, 25 Jun 2000 22:38:58 GMT
From: malverian@my-deja.com
Subject: Re: Sending data to a certain connection
Message-Id: <8j61m0$69n$1@nnrp1.deja.com>

Hello =)
Bringing this to the front again..


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


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

Date: Sun, 25 Jun 2000 19:39:46 -0400
From: H C <carvdawg@patriot.net>
Subject: Re: test for membership in an array?
Message-Id: <39569842.14AEF495@patriot.net>

I don't know but I've been told....grep() works

iwelch@my-deja.com wrote:

> what is the recommended way to test repeatedly for existence
> of different scalars in an array?  (I know I can write a loop or turn
> the array into a hash, but that seems somewhat inelegant for an
> operation that is probably very standard.)
>
> /iaw
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.



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

Date: Sun, 25 Jun 2000 20:03:31 -0400
From: "kokopuff" <kokopuff@cukezone.com>
Subject: Thank you everyone for help!!!
Message-Id: <sld7brqojev88@corp.supernews.com>

Thank you everyone!!!


kokopuff <kokopuff@cukezone.com> wrote in message
news:slccnksfjev131@corp.supernews.com...
> I am going through the exercises in "Learning Perl" from O'Reilly.
>
> I was working on 8.2, which (i slightly misunderstood...) asks you to
write
> a subroutine that takes in an arithmetic operation, such as 2 + 2 = 4 and
> return it as a string, like "Two plus two equals four"
>
> Here is my code so far:
>
>
> #!/usr/bin/perl
>
> while (defined ($input = <STDIN>)) {
>  chomp;
>  push(@a, $input);
>  #print "(" . @a . ")\n";
> }
>
> @b = @a;
>
> print @b; #why does this not print @[0]?
> print @a;
>
> print toString(@a);
>
>
>
> sub toString
> {
>
> $str = "";
>
>  foreach $_ (@_) {
>
>   chomp ($_);
>
> # if (/\d/) { $str .= $num2str[$_] . " ";}
>
>
>  if ($_ < 10)
>
>
>   if ($_ == 1) {
>    $str .= "one ";
>   }
>   elsif ($_ == 2) {
>    $str .= "two ";
>   }
>   elsif ($_ ==3) {
>    $str .= "three ";
>   }
>   elsif ($_ == 4) {
>    $str .= "four ";
>   }
>   elsif ($_ == 5) {
>    $str .= "five ";
>   }
>   elsif ($_ == 6) {
>    $str .= "six ";
>   }
>   elsif ($_ == 7) {
>    $str .= "seven ";
>   }
>   elsif ($_ == 8) {
>    $str .= "eight ";
>   }
>   else {
>    $str .= "nine ";
>   }
>  }
>
>  else { $str .= $_ . " ";  }
>
>   } #foreach
>
>   return $str;
> }
>
>
>
> The subroutine is rather inefficient, but it seems to be working anyhow.
My
> problem is, as I commented above, with the lines
>
> print @b; #why does this not print @[0]?
> print @a;
> print toString(@a);
>
> For reasons beyond my knowledge, @b does not print out @b[0]. When I
comment
> out that line, @a does not print out @[0] any more.
> When I comment out both of these lines, print toString(@a) no longer
works.
>
> Anybody have any idea what is going on?
>
>
>



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

Date: Sun, 25 Jun 2000 23:50:21 GMT
From: "smile773" <smile773@bigfoot.com>
Subject: Re: zope, python vs apache, perl
Message-Id: <1Vw55.1584$AM4.94995@bgtnsc04-news.ops.worldnet.att.net>


> I want to evaluate serverA, script_typeA vs ServerB, Script_typeB.
These values are strickly wild guesses and meant to help you
find some of your own priorities.

quick and dirty 9:6
stable and secure ?:9
amount of help and resourses  3:9
server perfomance ?:7
modifies easily ?:?
reliable and dependable ?:7
future enhancement ?:?
development 9:8
workhorse ?:9
specialized 7:5
mutipurpose 5:7

pick your poison





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

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


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