[16064] in Perl-Users-Digest
Perl-Users Digest, Issue: 3476 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 25 18:05:31 2000
Date: Sun, 25 Jun 2000 15:05:10 -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: <961970710-v9-i3476@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 25 Jun 2000 Volume: 9 Number: 3476
Today's topics:
Re: Can a regex pick out a domain name from a line of t <renenyffenegger@my-deja.com>
filehandle <-> filename u_uuu@my-deja.com
Re: I need help to get headlines on my site, still not <phuket@phuket-guide.com>
Re: IO::Socket::INET forking server problem nawkboy@my-deja.com
Is this a bug? <netnerds@bellsouth.net>
matching question (http related) cavenewt@my-deja.com
Re: matching question (http related) purl_gurl@my-deja.com
Re: Need app to generate perl for windows (Bart Lateur)
Re: Need app to generate perl for windows (Eric Bohlman)
newbie perl question about file i/o (Will)
Re: newbie question from Learning Perl--help me debug t <rootbeer@redcat.com>
Re: newbie question from Learning Perl--help me debug t <bwalton@rochester.rr.com>
Re: newbie question from Learning Perl--help me debug t <wescott@eriadne.sc.rr.com>
Re: Newsgroup question <flavell@mail.cern.ch>
Re: Problem installing CPAN Date::Calc <sb@muccpu1.muc.sdm.de>
Stupid Perl 'if' Question <clarencehj@yahoo.com>
Re: Stupid Perl 'if' Question <bwalton@rochester.rr.com>
Re: Stupid Perl 'if' Question <billy@arnis-bsl.com>
Re: Stupid Perl 'if' Question <mdemello@pound.ruf.rice.edu>
Re: Stupid Perl 'if' Question <peter.sundstrom@eds.com>
User's details <raphaelp@nr1webresource.com>
Re: User's details (Abigail)
Re: User's details <billy@arnis-bsl.com>
Re: Using HTTP::Request::Form to get SELECT options <rootbeer@redcat.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 25 Jun 2000 20:48:31 GMT
From: Rene Nyffenegger <renenyffenegger@my-deja.com>
Subject: Re: Can a regex pick out a domain name from a line of text?
Message-Id: <8j5r6s$1rt$1@nnrp1.deja.com>
In article <5Uj55.2$I97.555@nsw.nnrp.telstra.net>,
"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.
>
> I can't work it out no matter how I try!!!
URI::URL might help.
Rene
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 25 Jun 2000 18:51:50 GMT
From: u_uuu@my-deja.com
Subject: filehandle <-> filename
Message-Id: <8j5kc1$tbm$1@nnrp1.deja.com>
Tom Phoenix <rootbeer@redcat.com> wrote:
> On Fri, 23 Jun 2000, andreyw wrote:
>
> > I have a filehandle (as a subroutine parameter).
> > Is there a way to know a filename or other disk file id.
>
> There may be no filename, or there may be more than one. But you can
> stat() the file to get a dev/ino pair, which (at least on Unix-like
> systems) will be a unique id for the item, in that truly different
files
> will have different dev/ino information, but two names for the same
file
> will give the same dev/ino information. Hope this helps!
>
> --
> Tom Phoenix Perl Training and Hacking Esperanto
> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
>
>
Thank you.
I look for WIN32 solution. A purpose is flock implementation (no
interface changing if it's possible)
Andrey
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 26 Jun 2000 00:23:57 +0200
From: Johan =?iso-8859-1?Q?B=FCnger?= <phuket@phuket-guide.com>
Subject: Re: I need help to get headlines on my site, still not working...
Message-Id: <3956867D.1EA6425@phuket-guide.com>
Hello All
I am sorry to say this do not help me out. But I think I am on the right
track
with my design right here. Their are some problems some one might be able
to solv. The scripts does not break up the headlines as it should. It
returns
the first headline and break it up. But then it is not breaking the script.
Can
any one help out with this??
#!/usr/local/bin/perl
$headlines = "10";
use LWP::Simple;
$newsURL="http://phuketgazette.net/feedme/index.asp";
$news=get($newsURL);
# All done
$headlines -= 1;
push @new, $news;
print "Content-type: text/html\n\n";
foreach $line (@new)
{
@news = split(/\<BR>/,$line);
foreach $i (@news)
{
($title,$url) = split(/\|/,$i);
print "<a href=\"$url\" target=\"_blank\">$title</a><br>\n";
}
}
exit;
# end main
take a look at it in action:
http://phuket-guide.com/cgi-bin/phuketgazette.cgi
Sincerely
Johan Bünger
PS. All other sugestions just give me error 500! So I am sorry to all of you
whom helped me, but I can get the scripts working (most likely I am the
cause of it)
Johan Bünger wrote:
> Hi
> I have been trying to get hold on a simple way to include headlines that
> is updated every day. I would like to collect the information from a
> site:
>
> http://www.phuketgazette.net/feedme/index.asp
>
> Then collect the data only and format it so I can use it on my first
> page. Now I have no idea about this and how to do it. If any one with a
> good hart out their would like to help out I would be most happy.
>
> The information from the link above look like this:
>
> <html>
> <body>
>
> Shortage of tour guides causes
> problems|http://www.phuketgazette.com/news/index.asp?id=943<br>15,000
> sign Luang Por Cham
> petition|http://www.phuketgazette.com/news/index.asp?id=942<br>Robbers
> stab German resident to
> death|http://www.phuketgazette.com/news/index.asp?id=941<br>Teens in
> ‘Romeo and Juliet’ double
> suicide|http://www.phuketgazette.com/news/index.asp?id=940<br>THAI to
> launch new Oz-Phuket
> service|http://www.phuketgazette.com/news/index.asp?id=939<br>Sweden
> pledges help for Cyber City
> plan|http://www.phuketgazette.com/news/index.asp?id=938<br>Angel Air
> suspends
> services|http://www.phuketgazette.com/news/index.asp?id=937<br>General
> coy about new job as
> minister|http://www.phuketgazette.com/news/index.asp?id=936<br>Pattana
> Kathu Party wins landslide
> victory|http://www.phuketgazette.com/news/index.asp?id=935<br>
> </body>
> </html>
>
> I think that the forst think is to remov the html, then list it up and
> make a small Perl script that I could call with SSI, I have tested
> several scripts and can not get it working. If you like you could at the
> same time explain the steps in the script, I hope learning some at the
> same time. I have tested doing this last 3-4 days no succes yet.
>
> My "playsite" this is where I play around to test every thing before I
> publish it.
>
> http://phuketadult.com
>
> My real site is:
>
> http://phuket-guide.com
>
> Sincerely
> Johan
------------------------------
Date: Sun, 25 Jun 2000 18:49:40 GMT
From: nawkboy@my-deja.com
Subject: Re: IO::Socket::INET forking server problem
Message-Id: <8j5k80$t2t$1@nnrp1.deja.com>
What about the extra processes that are hanging around as well? It was
obvious that I added extra processes everytime a client connected and
disconnected. Are these zombies? I had some <defunct> processes but
correcting some problems I had with the CHLD signal hander made those
go away. After those changes I noticed the extra perl processes and
the socket connections staying open.
I'm not worried about the socket connections now, but the extra perl
processes are still bothering me.
(See the results of the ps command.)
In article <3954f3e1.44874766@news.firstworld.net>,
efinley@efinley.com wrote:
> On Fri, 23 Jun 2000 22:13:00 GMT, nawkboy@my-deja.com wrote:
>
> >My forking perl server is configured to listen to port 2400.
Although
> >clients can successfully interact with the server, the socket
> >connections and forked processes are not being closed properly. This
> >is evidenced by the output from netstat and ps. Unfortunately, I do
> >not understand the problem well enough to diagnosis it. I have tried
> >to give enough information below that someone more familar with
> >writting servers in perl will be able to quickly see what is wrong.
>
> Your bound sockets will hang around for a while if you have reuse=1...
> Which you do. It's not a problem, it's more efficient that way.
>
> >
> >Any help will be greatly appreciated. I am intending to read "An
> >Advanced 4.4BSD Interprocess Communication Tutorial" this weekend in
> >the hopes of gaining greater insight into the problem.
> >
> >
> >-----Connection example------(ERROR is a valid response is this
context)
> >$ telnet nigel 2400
> >Trying 10.10.0.106...
> >Connected to nigel.
> >Escape character is '^]'.
> >hi
> >ERROR
> >quit
> >Connection closed by foreign host.
> >$
> >
> >------------netstat -a|grep 2400---------------
> >--After connecting and disconnecting several times------
> > *.2400 *.* 0 0 0 0
> >LISTEN
> >nigel.2400 nigel.33359 32768 0 32768 0
> >TIME_WAIT
> >nigel.2400 nigel.33361 32768 0 32768 0
> >TIME_WAIT
> >nigel.2400 nigel.33362 32768 0 32768 0
> >TIME_WAIT
> >
> >--While one client is connected--------
> > *.2400 *.* 0 0 0 0
> >LISTEN
> > *.2400 *.* 0 0 8576 0
> >BOUND
> >nigel.2400 nigel.33361 32768 0 32768 0
> >TIME_WAIT
> >nigel.2400 nigel.33362 32768 0 32768 0
> >TIME_WAIT
> >nigel.33368 nigel.2400 32768 0 32768 0
> >ESTABLISHED
> >nigel.2400 nigel.33368 32768 0 32768 0
> >ESTABLISHED
> >
> >-No one is connected and server has been running for a few minutes--
> >
> > *.2400 *.* 0 0 0 0
> >LISTEN
> > *.2400 *.* 0 0 8576 0
> >BOUND
> > *.2400 *.* 0 0 8576 0
> >BOUND
> > *.2400 *.* 0 0 8576 0
> >BOUND
> >nigel.2400 nigel.33368 32768 0 32768 0
> >TIME_WAIT
> >
> >----ps -ef|grep t22----------
> > sirsi 12110 4178 0 15:02:59 pts/2 0:00 perl -Mblib
> >t/t22_run_server
> > sirsi 12112 12110 0 15:03:07 pts/2 0:00 perl -Mblib
> >t/t22_run_server
> > sirsi 12414 11543 0 15:13:48 pts/5 0:00 grep t22
> > sirsi 12270 12143 0 15:08:51 pts/2 0:00 perl -Mblib
> >t/t22_run_server
> > sirsi 12135 12112 0 15:05:52 pts/2 0:00 perl -Mblib
> >t/t22_run_server
> > sirsi 12143 12135 0 15:06:04 pts/2 0:00 perl -Mblib
> >t/t22_run_server
> >
> >
> >-------------------Relevant Code Section-----------------------------
---
>
> --
> Elliot (efinley@efinley.com) Weird Science!
> ICQ# 77135295
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 25 Jun 2000 17:26:18 -0400
From: Paul Kunicki <netnerds@bellsouth.net>
Subject: Is this a bug?
Message-Id: <395678FA.7512A05A@bellsouth.net>
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 19:14:14 GMT
From: cavenewt@my-deja.com
Subject: matching question (http related)
Message-Id: <8j5lls$u6q$1@nnrp1.deja.com>
I'm trying to match the 'rightmost' pattern in a string
I'm trying to match the rightmost / character followed by everything
after it.
so if I have
http://www.nethole.com/bongo/junior.html it would match to
/junior.html
if I have
http://www.nethole.com/bongo/fred it would match to /fred
if I have
http://www.nethole.com/ it would match to /
the variants of \/$ seem to grab the left most / character. I want the
right most.
If you have suggestions, please e-mail a reply
--
http://www.nethole.com
With slashcode
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 25 Jun 2000 20:02:02 GMT
From: purl_gurl@my-deja.com
Subject: Re: matching question (http related)
Message-Id: <8j5ofi$6j$1@nnrp1.deja.com>
In article <8j5lls$u6q$1@nnrp1.deja.com>,
cavenewt@my-deja.com wrote:
> I'm trying to match the 'rightmost' pattern in a string
> so if I have
> http://www.nethole.com/bongo/junior.html it would match to
> /junior.html
> if I have
> http://www.nethole.com/bongo/fred it would match to /fred
> if I have
> http://www.nethole.com/ it would match to /
> the variants of \/$ seem to grab the left most / character.
> I want the right most.
> If you have suggestions, please e-mail a reply
Sure... as if..
* snaps her fingers *
Wallah! Piece of Marie Antoinette cake.
PRINTED RESULTS:
________________
Old String: http://www.nethole.com/bongo/junior.html
New String: /junior.html
Old String: http://www.nethole.com/bongo/fred
New String: /fred
Old String: http://www.nethole.com/
New String: /
Done! Godzilla Rocks!
TEST SCRIPT:
____________
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
$string = "http://www.nethole.com/bongo/junior.html";
&Right_Side;
$string = "http://www.nethole.com/bongo/fred";
&Right_Side;
$string = "http://www.nethole.com/";
&Right_Side;
sub Right_Side
{
print "Old String: $string\n";
$position = rindex ($string, "/");
$length = length ($string);
$fetch = ($length - $position);
$new_string = substr ($string, $position, $fetch);
print "New String: $new_string\n\n";
}
print "Done! Godzilla Rocks!";
exit;
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 25 Jun 2000 18:31:20 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Need app to generate perl for windows
Message-Id: <39564f77.3758133@news.skynet.be>
IQnegativeOne wrote:
> A
>language as cryptic as Perl should have a Win98 interface. Checkboxes, radio
>buttons and such.
Perl doesn't have check boxes or radio buttons.
If you're talking GUI: use any HTML editor you like, and incorporate the
resulting HTML into your program. Or use a template system, putting perl
variables into a prefab text file before sending it out. There are
several available at CPAN.
--
Bart.
------------------------------
Date: 25 Jun 2000 19:54:06 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Need app to generate perl for windows
Message-Id: <8j5o0u$knh$2@slb6.atl.mindspring.net>
IQnegativeOne (iqnegativeone@aol.com) wrote:
: I bought the Perl Black Book. Great book. However, I would like to take a
: shortcut. Perhaps there are perl apps, that will generate perl.pl files. A
: language as cryptic as Perl should have a Win98 interface. Checkboxes, radio
: buttons and such. Surely this question has been asked a thousand time. Any
: pointers would be a great help.
Are you talking about creating *applications* that have a GUI interface,
or are you talking about a GUI-based *development environment* for Perl?
If the former, check out Tk. If the latter, there are some commercial
offererings from ActiveState and others.
------------------------------
Date: Sun, 25 Jun 2000 21:45:41 GMT
From: willg@nospam.webmastermd.com (Will)
Subject: newbie perl question about file i/o
Message-Id: <39567c84.13320850@news.rdc1.bc.wave.home.com>
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.
------------------------------
Date: Sun, 25 Jun 2000 11:17:43 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: newbie question from Learning Perl--help me debug this
Message-Id: <Pine.GSO.4.10.10006251107440.23149-100000@user2.teleport.com>
On Sun, 25 Jun 2000, kokopuff wrote:
> #!/usr/bin/perl
Even though the current edition of Learning Perl doesn't encourage this,
you should use the -w option while debugging your code. It'll tell Perl to
warn you about any mistakes it can spot. There may be warnings about valid
code, too, but mostly you'll see important things to fix.
> while (defined ($input = <STDIN>)) {
> chomp;
You're chomping $_ (the default), not $input.
> push(@a, $input);
> #print "(" . @a . ")\n";
> }
>
> @b = @a;
>
> print @b; #why does this not print @[0]?
I don't know what you expect it to print. Do you mean $b[0]? It prints
that. Do you mean it should print a literal @-sign? Only if you've typed
one in. But on Windows, the terminal I/O routines (or something) will
gobble the first line of output under some circumstances, so that may be
what you're seeing. One solution is to print a throwaway line of output
after the while loop in your program.
> print @a;
Of course, that should print the same thing as @b, since they're the same.
Good thing you didn't really chomp that input. :-)
> foreach $_ (@_) {
>
> chomp ($_);
Not _wrong_ wrong, but unusual. You should be aware that you're modifying
your subroutine parameters, which is generally frowned upon.
> if ($_ < 10)
>
>
> if ($_ == 1) {
Okay; this is where I stop. You've got a syntax error there. If you're
going to post code to Usenet, you have to post code you're actually using.
Certainly you shouldn't lie about it:
> The subroutine is rather inefficient, but it seems to be working
> anyhow.
Tsk, tsk!
If you're still having problems with your code, cut it down to a small,
self-contained program which doesn't do what you think it should be doing,
and post that. Don't retype it, post the code you're actually using.
Good luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 25 Jun 2000 18:58:10 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: newbie question from Learning Perl--help me debug this
Message-Id: <3956568C.C6C363BB@rochester.rr.com>
kokopuff wrote:
>
> 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;
You are chomping $_, but using $input, so the stuff getting into @a is
not chomp'ed.
> push(@a, $input);
> #print "(" . @a . ")\n";
> }
>
> @b = @a;
>
> print @b; #why does this not print @[0]?
It prints $b[0] on my system just fine -- along with all the other
elements of @b that exist. What do you mean by @[0]? I assume that is
a typo for $b[0].
> print @a;
>
> print toString(@a);
>
> sub toString
> {
>
> $str = "";
>
> foreach $_ (@_) {
>
> chomp ($_);
>
> # if (/\d/) { $str .= $num2str[$_] . " ";}
>
> if ($_ < 10)
Won't compile -- you're missing a { on the above line -- did you paste
your code in, or retype it all for your note?
>
> 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?
On my system (Windoze 98 SE, ActiveState build 522), your program
(correctid with a trailing { on the if($_<10) line) prints $a[0] and
$b[0] just fine. I recommend you run your program with the -d switch
and observe what is happening using the debugger. I'm not sure what you
mean by "not printing @[0]". What is @[0]? Do you mean $b[0] and
$a[0]?
There are several other things to pick at in your program -- like the
method you use to transfer an array to a subroutine. What you have
works for transferring one array, but won't be so cool if you have more
than one array argument. You really want to pass array references, not
the array itself. And there is the question of whether you want to suck
all your input into an array, and the process the entire array, or
whether you would be better off reading and processing a line at a
time. In your case, it looks like a line at a time would be better. It
isn't an issue for a learning program like this, but when you get a
real-life program reading a file with a few million records, it will be
an issue then. Also, you use chomp on $_, rather than $input, which is
the variable you used for grabbing a line of input.
--
Bob Walton
------------------------------
Date: Sun, 25 Jun 2000 19:03:58 GMT
From: Michael Wescott <wescott@eriadne.sc.rr.com>
Subject: Re: newbie question from Learning Perl--help me debug this
Message-Id: <os1z1lr39o.fsf@eriadne.sc.rr.com>
"kokopuff" <kokopuff@cukezone.com> writes:
> 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"
[ rearranged ]
> 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?
Well, when I run the code the prints all work as I would expect. So I think
there's a misconception on your part on what perl should be doing and that's
rather hard to devine from this code.
> #!/usr/bin/perl
use -w it'll tell you about some things you're doing wrong.
> while (defined ($input = <STDIN>)) {
this reads a line at a time. Were you expecting character at a time input?
> chomp;
You've just chomp'd $_ which hasn't been assigned anything, why? $input
has the input line.
> push(@a, $input);
each element of @a is one line of input
> }
We get here at end of file (not end of line) so if the program is to work
reasonably, the input must be of the form
2
+
2
=
4
with each token on a separate line rather than all on one line. Is that what
you intended?
> @b = @a;
>
> print @b; #why does this not print @[0]?
> print @a;
Works as I expect. Were you perhaps confusing the echo of input with what
was to be printed?
> print toString(@a);
> sub toString
> {
Yes, the toString routine needs work. Perhaps you ought to consider how to
use a predefined hash to do the token-by-token conversion.
If I run your program (after fixing the syntax error) I get
$ perl ex8.2
2
+
2
=
4
2
+
2
=
4
2
+
2
=
4
two nine two nine four $
The first five lines being my input (followed by a ^D as end of file). The
next five are the output of
print @b; #why does this not print @[0]?
so @b is ("2\n", "+\n", "2\n", "=\n", "4\n"), a five element array (so is @a).
The next five lines are the output of
print @a;
and the last line is result of the conversion ("nine" being the result of
anything not understood). The last line has no "\n" so my shell prompt
appears there as well.
If I run it and put all input on one line it works like this:
$ perl ex8.2
2 + 2 = 4
2 + 2 = 4
2 + 2 = 4
two $
The first line is my input (plus a ^D). The second is @b. More specifically
it's $b[0] since the array has only one element, the string "2 + 2 = 4\n".
The next is $a[0] and the last is the conversion which only picks up the
first character for reasons having to do with the conversion of strings to
numbers.
--
Mike Wescott
wescott@conterra.com
------------------------------
Date: Sun, 25 Jun 2000 20:40:17 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Newsgroup question
Message-Id: <Pine.GHP.4.21.0006252038220.1593-100000@hpplus03.cern.ch>
On Sun, 25 Jun 2000, Tom Phoenix wrote:
> Follow-ups set, in case there's any Perl-related follow-up.
That's a neat bodyswerve! Can we all start doing that? ;-)
f'up overridden, and re-set "in case there's any Perl-related
follow-up".
cheers
------------------------------
Date: 25 Jun 2000 19:32:19 GMT
From: Steffen Beyer <sb@muccpu1.muc.sdm.de>
Subject: Re: Problem installing CPAN Date::Calc
Message-Id: <8j5mo3$dvd$1@solti3.sdm.de>
In article <8j4qhn$cm3$1@nnrp1.deja.com>, moomoo <mandersjones@my-deja.com> wrote:
> I too have the perl Makefile.pl producing the errors given below and it
> is driving me nuts! (on win98, ActivePerl)
> Using PPM is of course the thing to do if there is a package for the
> module you want. However there are loads of CPAN modules for which you
> cant use ppm (no ppd file). So this still leaves the problem of getting
> Perl Makefile.pl to work. I've looked and looked but no-one seems to
> have given an answer.
This has been answered before many times: The Win 98 command shell is too
dumb (to put it bluntly - politically correct I'd have to say it's not
POSIX-conform :-) ) to allow builds with Perl's build mechanism.
You need the Win NT shell or the 4DOS shell in order to do so.
Or you might try to compile under Win NT and copy the files to your
Win 98 machine.
Or use the plain Perl version of Date::Calc to avoid these problems
alltogether. (See my sig below for download URL)
> Installing Nmake15.exe with VC++ is not the
> solution for the perl Makefile.pl problem.
> I really hope someone out there can help us!
Good luck!
--
Steffen Beyer <sb@engelschall.com>
http://www.engelschall.com/u/sb/whoami/ (Who am I)
http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)
------------------------------
Date: Sun, 25 Jun 2000 20:44:58 GMT
From: Coolc <clarencehj@yahoo.com>
Subject: Stupid Perl 'if' Question
Message-Id: <8j5r07$1pg$1@nnrp1.deja.com>
How come the following is true?
#!/usr/bin/perl
if ( "g" == "a" ) {
print " they match \n";
}
--------
If you run this the words they match are printed..... Why...
They clearly dont match...
Even if you change the if line to look like this it does the same thing.
---> if ( "g" = "a" )
Clarence Hart
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 25 Jun 2000 21:02:49 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Stupid Perl 'if' Question
Message-Id: <395673C2.D420BCC0@rochester.rr.com>
Coolc wrote:
>
> How come the following is true?
>
> #!/usr/bin/perl
>
> if ( "g" == "a" ) {
They "match" because you are using the numeric equality comparison
operator ==. Try the string equality comparison operator eq. Note that
if you would include the -w switch when you run Perl, you would be
informed of this problem automatically.
> print " they match \n";
>
> }
>
> --------
>
> If you run this the words they match are printed..... Why...
> They clearly dont match...
Numerically, they *do* match -- they both have the numeric value 0.
> Even if you change the if line to look like this it does the same thing.
> ---> if ( "g" = "a" )
This doesn't compile. If it did, it would be even worse: = is the
value assignment operator, so you are attempting to assign the lvalue
"g" the value "a". Uncool. -w would give you a handy pointer about
this problem too.
>
> Clarence Hart
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
--
Bob Walton
------------------------------
Date: Sun, 25 Jun 2000 21:10:56 GMT
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: Stupid Perl 'if' Question
Message-Id: <8j5sgn$2uk$1@nnrp1.deja.com>
In article <8j5r07$1pg$1@nnrp1.deja.com>,
Coolc <clarencehj@yahoo.com> wrote:
> How come the following is true?
>
How come people do not read the docs ?
> #!/usr/bin/perl
>
> if ( "g" == "a" ) {
> print " they match \n";
>
> }
>
First, why you don't use -w switch (you don't use strict; also).
Therefore you missed perl's warnings:
Argument "a" isn't numeric in eq at ... line ...
Argument "g" isn't numeric in eq at ... line ...
Still confused ?
Please (re-)read 'perldoc perlop', section "Equality Operators"
(or http://www.cpan.org/doc/manual/html/pod/perlop.html).
Feel the difference:
"Binary == returns true if the left argument is numerically
equal to the right argument.
Binary ``eq'' returns true if the left argument is stringwise
equal to the right argument."
> If you run this the words they match are printed..... Why...
> They clearly dont match...
> Even if you change the if line to look like this it does the same
thing.
> ---> if ( "g" = "a" )
>
Oh, this is an assignment operator.
Ilja.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 25 Jun 2000 21:12:14 GMT
From: Martin Julian DeMello <mdemello@pound.ruf.rice.edu>
Subject: Re: Stupid Perl 'if' Question
Message-Id: <8j5sje$hbm$1@joe.rice.edu>
Coolc <clarencehj@yahoo.com> wrote:
> How come the following is true?
> #!/usr/bin/perl
Starting off with
#!/usr/bin/perl -w
use strict;
is always a good idea. On the following code
> if ( "g" == "a" ) {
> print " they match \n";
> }
it returns
Argument "a" isn't numeric in eq at match.pl line 3.
Argument "g" isn't numeric in eq at match.pl line 3.
they match
> --------
> If you run this the words they match are printed..... Why...
> They clearly dont match...
> Even if you change the if line to look like this it does the same thing.
> ---> if ( "g" = "a" )
This should not have worked at all
#!/usr/bin/perl
if ( "g" = "a" ) {
print " they match \n";
}
[~] perl match.pl
Can't modify constant item in scalar assignment at match.pl line 3, near ""a" )
"
Execution of match.pl aborted due to compilation errors.
In other words, you're trying to use a constant on the LHS of an assignment.
perldoc perlop, and search for 'Equality Operators'
--
Martin DeMello
------------------------------
Date: Mon, 26 Jun 2000 09:52:31 +1200
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: Stupid Perl 'if' Question
Message-Id: <8j5v2q$h0a$1@hermes.nz.eds.com>
Coolc wrote in message <8j5r07$1pg$1@nnrp1.deja.com>...
>How come the following is true?
>
>#!/usr/bin/perl
>
>if ( "g" == "a" ) {
> print " they match \n";
>
>}
== is for numeric comparisons. You need eq
>If you run this the words they match are printed..... Why...
>They clearly dont match...
>Even if you change the if line to look like this it does the same thing.
>---> if ( "g" = "a" )
The = is for assignment.
------------------------------
Date: Sun, 25 Jun 2000 21:13:04 +0200
From: "Raphael Pirker" <raphaelp@nr1webresource.com>
Subject: User's details
Message-Id: <8j5n7s$oap$12$1@news.t-online.com>
Hi,
I've heard that you can find out user's details using perl. In which array
or variable are they stored? I'm aiming at:
Browser
PC
OS
Can I find those anywhere?
Thanks in advance!
Raphael Pirker
raphaelp@nr1webresource.com
------------------------------
Date: 25 Jun 2000 15:57:11 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: User's details
Message-Id: <slrn8lcq2l.ka1.abigail@alexandra.delanet.com>
Raphael Pirker (raphaelp@nr1webresource.com) wrote on MMCDXC September
MCMXCIII in <URL:news:8j5n7s$oap$12$1@news.t-online.com>:
``
`` I've heard that you can find out user's details using perl. In which array
`` or variable are they stored? I'm aiming at:
Not in arrays or variables.
`` Browser
A user can use 0 to many browsers. Perl isn't aware of what's a browser.
There's no way to find this out.
`` PC
*shrug* Just look on the box...
`` OS
There are various methods to do this, but they are non-portable. For
Unix like systems, use `uname`. You could look in the configure script
to find out more general methods.
`` Can I find those anywhere?
Of course, it could be that you are actually asking a CGI question.
CGI questions are answered in a group dealing with, *drumroll*, CGI.
You can find such a group down the hall, to your left. Just follow the smell.
Abigail
--
package Z;use overload'""'=>sub{$b++?Hacker:Another};
sub TIESCALAR{bless\my$y=>Z}sub FETCH{$a++?Perl:Just}
$,=$";my$x=tie+my$y=>Z;print$y,$x,$y,$x,"\n";#Abigail
------------------------------
Date: Sun, 25 Jun 2000 20:33:21 GMT
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: User's details
Message-Id: <8j5qag$1d8$1@nnrp1.deja.com>
In article <8j5n7s$oap$12$1@news.t-online.com>,
"Raphael Pirker" <raphaelp@nr1webresource.com> wrote:
> Hi,
>
> I've heard that you can find out user's details using perl. In which
array
> or variable are they stored? I'm aiming at:
>
> Browser
> PC
> OS
>
> Can I find those anywhere?
>
What 'user' (or user of what) do you mean ?
There are plenty of entities which may be
described with that word.
Ok, as long as you included a keyword 'browser'
and making some assumptions I guess you mean the following:
"How can I get some details about HTTP client
in CGI environment using perl ?"
If so, you need a CGI.pm module (AFAIK part of
stardard perl distribution).
Consult your local 'perldoc CGI' or visit
http://www.cpan.org/doc/manual/html/lib/CGI.html
to learn more.
And do not trust any person who will say you
may parse environment variables by hand
instead of using CGI.pm.
Hope this helps.
Ilja.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 25 Jun 2000 11:06:37 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Using HTTP::Request::Form to get SELECT options
Message-Id: <Pine.GSO.4.10.10006251105290.23149-100000@user2.teleport.com>
On Sun, 25 Jun 2000, root wrote:
> @categories = $f->field_selection("desc");
> print "@categories";
>
> ##Here is what is printed out instead of the options: ARRAY(0x849e08)
Looks like you got an array reference where you wanted an array. If that's
not what that code was documented to do, that's a bug. But more likely,
you just need to see the perlref manpage. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
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 3476
**************************************