[18302] in Perl-Users-Digest
Perl-Users Digest, Issue: 470 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 12 09:10:33 2001
Date: Mon, 12 Mar 2001 06:10:16 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <984406216-v10-i470@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 12 Mar 2001 Volume: 10 Number: 470
Today's topics:
Re: How to reverse a loop ? <wyzelli@yahoo.com>
Re: How to reverse a loop ? (Gwyn Judd)
Re: How to reverse a loop ? (Martien Verbruggen)
How to run a Perlscript? <lasarosm@ec.se>
Re: How to run a Perlscript? <josef.moellers@fujitsu-siemens.com>
LWP::Simple Error <ncmncm@MailAndNews.com>
Re: number (Philip Lees)
Re: Pass in variables to web page (Abigail)
Typeglob assignment confusion <james@NOSPAM.demon.co.uk>
Re: Typeglob assignment confusion <peb@bms.umist.ac.uk>
Re: Typeglob assignment confusion <tinamue@zedat.fu-berlin.de>
Re: Typeglob assignment confusion <james@NOSPAM.demon.co.uk>
Re: Typeglob assignment confusion <james@NOSPAM.demon.co.uk>
Re: Typeglob assignment confusion <tom@power.net.uk>
Re: Typeglob assignment confusion (Anno Siegel)
Re: Typeglob assignment confusion (Anno Siegel)
Re: using Perl for B2B? robert.groenewegen@removetomailme.zonnet.nl
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 12 Mar 2001 18:59:44 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: How to reverse a loop ?
Message-Id: <YF0r6.6$NX2.837@vic.nntp.telstra.net>
<euterpe21@yahoo.com> wrote in message
news:ctvoatcdd23qr6cs4qunl8rue2p98j35sa@4ax.com...
> for (my $i=1; $i<scalar(@bids); $i++) {
for (my $i=@bids; $i>0; $i--) {
Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';
------------------------------
Date: Mon, 12 Mar 2001 09:35:12 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: How to reverse a loop ?
Message-Id: <slrn9ap62f.hv8.tjla@thislove.dyndns.org>
I was shocked! How could Wyzelli <wyzelli@yahoo.com>
say such a terrible thing:
><euterpe21@yahoo.com> wrote in message
>news:ctvoatcdd23qr6cs4qunl8rue2p98j35sa@4ax.com...
>> for (my $i=1; $i<scalar(@bids); $i++) {
>
>for (my $i=@bids; $i>0; $i--) {
Not quite.
for (my $i = $#bids; $i >= 0; $i--) {
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Ship it.
------------------------------
Date: Mon, 12 Mar 2001 21:02:31 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: How to reverse a loop ?
Message-Id: <slrn9ap7ln.uuk.mgjv@martien.heliotrope.home>
On Mon, 12 Mar 2001 08:51:26 +0100,
euterpe21@yahoo.com <euterpe21@yahoo.com> wrote:
> for (my $i=1; $i<scalar(@bids); $i++) {
> my ($alias, $email, $bid, $time, $add1, $add2, $add3) = &read_bid
> ($bids[$i]);
> my $bidtime = gmtime($time);
> print "<FONT SIZE=-1>$alias \($bidtime\) - \GBP $bid</FONT><BR>";
for (my $i = $#bids; $i >= 0; $i--) { }
But unless oyu really need the $i (and you don't seem to), and depending
on how large @bids is, it's probably nicer to do:
for my $bid_el (@bids)
{
my ($alias, $email, $bid, $time, $add1, $add2, $add3) =
read_bid($bid_el);
}
and for the reverse
for my $bid_el (reverse @bids)
{
}
And yes, drop the & from the function call. Read perlsub to understand
why it's unnecessary.
Martien
--
Martien Verbruggen |
Interactive Media Division | Freudian slip: when you say one thing
Commercial Dynamics Pty. Ltd. | but mean your mother.
NSW, Australia |
------------------------------
Date: Mon, 12 Mar 2001 08:24:38 GMT
From: "Lasse" <lasarosm@ec.se>
Subject: How to run a Perlscript?
Message-Id: <aJ%q6.17808$Qb7.3090172@newsb.telia.net>
Is there a way to make a Perl-script start before you start windows ?
Thankful for all answers
regards
/Lasse
------------------------------
Date: Mon, 12 Mar 2001 09:29:59 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: How to run a Perlscript?
Message-Id: <3AAC8907.194065E2@fujitsu-siemens.com>
Lasse wrote:
> =
> Is there a way to make a Perl-script start before you start windows ?
> Thankful for all answers
Of course there is! Check your /etc/inittab for the sequence of rc
scripts run at boot time. Depending on the OS you use (flavours of
Linux, FreeBSD, S*laris, ...), scripts like /etc/rc.d/rc.sysinit or some
runlevel-specific rc-script (in /etc/rc.d/rc?.d) will be appropriate.
Unless ... you are referring to MS-Windows, rather than X-Windows. But
then ... you should have said that in the first place.
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Mon, 12 Mar 2001 07:34:09 -0500
From: Chandramohan Neelakantan <ncmncm@MailAndNews.com>
Subject: LWP::Simple Error
Message-Id: <3AB71E10@MailAndNews.com>
Hi
I tried the following program :
use LWP::Simple;
use LWP::Debug qw(+ -conns);
$content=get("http://www.rediff.com/index.html");
print $content;
and got the following:
Your vendor has not defined Socket macro AF_INET, used at
/usr/lib/perl5/5.00503
/i386-linux/IO/Socket.pm line 385
My Questions are:
1.Is there a compatibility problem with the Module(LWP) and my Perl
version(version 5.005_03 built for i386-linux)
2.Is the problem specific to my machine?
Please help.
Thanx in advance
regards
CM
------------------------------------------------------------
Get your FREE web-based e-mail and newsgroup access at:
http://MailAndNews.com
Create a new mailbox, or access your existing IMAP4 or
POP3 mailbox from anywhere with just a web browser.
------------------------------------------------------------
------------------------------
Date: Mon, 12 Mar 2001 08:42:43 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: number
Message-Id: <3aac8b7e.4054159@news.grnet.gr>
On Fri, 09 Mar 2001 12:34:55 GMT, "Waarddebon" <Waarddebon@chello.nl>
wrote:
>In my script i've got some variables with .00 behind it.
>for example $xx="55.00"
>
>Which line do i need so that $xx will contain 55 (so without the .00)
>Thanks in advance
Notwithstanding the other helpful suggestions, my PSI:ESP module tells
me that you want to trim trailing zeroes attached to integer values
read from a database.
$xx =~ s/^(\d+)\.0+$/$1/;
Phil
--
@x=split//,'Just another Perl decoder,';split//,'*'x@x;%i=split/=/,
'AA=a=aa= =1=,';for$i(0..$#x){$_[$i]=chr($=+5);while($_[$i]ne$x[$i])
{$_[$i]=$i{$_[$i]}if$i{++$_[$i]};print@_,"\r";while(rand!=rand){}}}
Ignore coming events if you wish to send me e-mail
------------------------------
Date: 12 Mar 2001 10:17:51 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Pass in variables to web page
Message-Id: <slrn9ap8if.db9.abigail@tsathoggua.rlyeh.net>
uNcONvEntiOnaL (tomcat@visi.com) wrote on MMDCCL September MCMXCIII in
<URL:news:ugYq6.916$Tg.111250@ruti.visi.com>:
?? I have a perl script which is invoked from a html form:
??
?? $body = $in{"body"};
?? print "<a HREF='http://www.aol.com/contact.html?body=$bod
?? y'>Return\n";
??
??
?? The page that comes up in the browser is:
??
?? http://www.aol.com/contact.html?body=This is a test message
??
?? in this page that comes up I have a textarea named body
?? <TEXTAREA COLS=60 ROWS=14 NAME="body" value=""></TEXTAREA>
??
?? Question: Can I make this page that comes up display
?? "This is a test message" in the textarea named "body" ???
?? - will the html page accept me stuffing something into "value"
?? for textarea ??
And your Perl question is?
HTLM issues are discussed elsewhere.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'
------------------------------
Date: Mon, 12 Mar 2001 11:44:04 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Typeglob assignment confusion
Message-Id: <ant1211041cbfNdQ@oakseed.demon.co.uk>
Am I going completely mad?! I'm sure this used to work but I can't now
remember how. For the sake of clarity I want to be able to create an
alias to an array that is passed by reference to a subroutine and then
treat the alias as if it were an ordinary array. For example:
__________________________________
#!/usr/bin/perl -w
use strict;
sub testsub (\@) {
local *array = shift;
foreach my $item (@array) {
print $item, "\n";
}
}
my @testarray = qw(One Two Three);
testsub @testarray;
__________________________________
The output is:
Variable "@array" is not imported at testprog line 8.
Global symbol "@array" requires explicit package name at testprog line 8.
Execution of testprog aborted due to compilation errors.
I feel quite sure that this kind of think is supposed to work, but
I've obviously forgotten how or gone mad or something. Please could
someone kindly put me right. Thanks.
--
James Taylor <james (at) oakseed demon co uk>
Based in Hammersmith, London, UK.
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Mon, 12 Mar 2001 12:44:55 +0000
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: Typeglob assignment confusion
Message-Id: <3AACC4C7.50387AA0@bms.umist.ac.uk>
> Am I going completely mad?! I'm sure this used to work but I can't now
> remember how. For the sake of clarity I want to be able to create an
> alias to an array that is passed by reference to a subroutine and then
> treat the alias as if it were an ordinary array. For example:
>
> __________________________________
>
> #!/usr/bin/perl -w
>
> use strict;
>
> sub testsub (\@) {
> local *array = shift;
>
> foreach my $item (@array) {
> print $item, "\n";
> }
> }
>
> my @testarray = qw(One Two Three);
> testsub @testarray;
> __________________________________
>
> The output is:
> Variable "@array" is not imported at testprog line 8.
> Global symbol "@array" requires explicit package name at testprog line 8.
> Execution of testprog aborted due to compilation errors.
no you're not going mad. If you remove the 'use strict' from your code
it works as you expect.
Paul
------------------------------
Date: 12 Mar 2001 12:56:22 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: Typeglob assignment confusion
Message-Id: <98ih1m$249hj$3@fu-berlin.de>
hi,
James Taylor <james@nospam.demon.co.uk> wrote:
> Am I going completely mad?! I'm sure this used to work but I can't now
> remember how. For the sake of clarity I want to be able to create an
> alias to an array that is passed by reference to a subroutine and then
> treat the alias as if it were an ordinary array. For example:
> local *array = shift;
> foreach my $item (@array) {
> print $item, "\n";
> The output is:
> Variable "@array" is not imported at testprog line 8.
> Global symbol "@array" requires explicit package name at testprog line 8.
> Execution of testprog aborted due to compilation errors.
put
use vars qw(@array);
at the beginning.
hth,
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
please don't email unless offtopic or followup is set. thanx
------------------------------
Date: Mon, 12 Mar 2001 13:02:13 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Typeglob assignment confusion
Message-Id: <ant121313b49fNdQ@oakseed.demon.co.uk>
In article <3AACC4C7.50387AA0@bms.umist.ac.uk>, Paul Boardman
<URL:mailto:peb@bms.umist.ac.uk> wrote:
>
> no you're not going mad.
Thanks. :-)
> If you remove the 'use strict' from your code
> it works as you expect.
But I don't want to do that, use strict is a good thing.
--
James Taylor <james (at) oakseed demon co uk>
Based in Hammersmith, London, UK.
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Mon, 12 Mar 2001 13:28:56 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Typeglob assignment confusion
Message-Id: <ant121356868fNdQ@oakseed.demon.co.uk>
In article <98ih1m$249hj$3@fu-berlin.de>, Tina Mueller
<URL:mailto:tinamue@zedat.fu-berlin.de> wrote:
>
> put
> use vars qw(@array);
>
> at the beginning.
Do you mean at the beginning of the whole program? If so then I would
prefer to avoid creating what is in effect a global variable just for
the sake of clarity within one subroutine. That seems rather like
cutting off my nose to spite my face.
Is it possible to say:
sub testsub (\@) {
use vars qw(@array);
local *array = shift;
...etc
and would this scope the @array variable to the inside of the
subroutine?
--
James Taylor <james (at) oakseed demon co uk>
Based in Hammersmith, London, UK.
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Mon, 12 Mar 2001 13:36:48 +0000
From: Tom Scheper <tom@power.net.uk>
Subject: Re: Typeglob assignment confusion
Message-Id: <56kpat8o31uoq8lh4ls3qvr8kict395n6j@4ax.com>
On Mon, 12 Mar 2001 13:28:56 +0000, James Taylor
<james@NOSPAM.demon.co.uk> shed a beam of light on us:
>In article <98ih1m$249hj$3@fu-berlin.de>, Tina Mueller
><URL:mailto:tinamue@zedat.fu-berlin.de> wrote:
>>
>> put
>> use vars qw(@array);
>>
>> at the beginning.
>
>Do you mean at the beginning of the whole program? If so then I would
>prefer to avoid creating what is in effect a global variable just for
>the sake of clarity within one subroutine. That seems rather like
>cutting off my nose to spite my face.
>
>Is it possible to say:
>
>sub testsub (\@) {
> use vars qw(@array);
> local *array = shift;
> ...etc
>
>and would this scope the @array variable to the inside of the
>subroutine?
Just out of ignorance and curiosity, why can you't you say my
@array=shift ? Or even my @array; @array=@_; ?
-=Cornelis
------------------------------
Date: 12 Mar 2001 13:39:47 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Typeglob assignment confusion
Message-Id: <98ijj3$3e4$1@mamenchi.zrz.TU-Berlin.DE>
According to James Taylor <james@NOSPAM.demon.co.uk>:
> In article <98ih1m$249hj$3@fu-berlin.de>, Tina Mueller
> <URL:mailto:tinamue@zedat.fu-berlin.de> wrote:
> >
> > put
> > use vars qw(@array);
> >
> > at the beginning.
>
> Do you mean at the beginning of the whole program? If so then I would
Not necessarily.
> prefer to avoid creating what is in effect a global variable just for
> the sake of clarity within one subroutine. That seems rather like
> cutting off my nose to spite my face.
>
> Is it possible to say:
>
> sub testsub (\@) {
> use vars qw(@array);
> local *array = shift;
> ...etc
Quite possible.
> and would this scope the @array variable to the inside of the
> subroutine?
This would allow unqualified use of @array from the point of the
"use vars" to the end of the file.
Using "our @array;" in the subroutine would restrict unqualified
access to the sub (or, in general, the block it appears in).
Mind you, you're still using a global variable which is visible
throughout the package is is declared in. It's only access via
the default package that is restricted.
Anno
------------------------------
Date: 12 Mar 2001 13:48:33 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Typeglob assignment confusion
Message-Id: <98ik3h$3e4$2@mamenchi.zrz.TU-Berlin.DE>
According to Tom Scheper <tom@power.net.uk>:
> On Mon, 12 Mar 2001 13:28:56 +0000, James Taylor
> <james@NOSPAM.demon.co.uk> shed a beam of light on us:
>
> >In article <98ih1m$249hj$3@fu-berlin.de>, Tina Mueller
> ><URL:mailto:tinamue@zedat.fu-berlin.de> wrote:
> >>
> >> put
> >> use vars qw(@array);
> >>
> >> at the beginning.
> >
> >Do you mean at the beginning of the whole program? If so then I would
> >prefer to avoid creating what is in effect a global variable just for
> >the sake of clarity within one subroutine. That seems rather like
> >cutting off my nose to spite my face.
> >
> >Is it possible to say:
> >
> >sub testsub (\@) {
> > use vars qw(@array);
> > local *array = shift;
> > ...etc
> >
> >and would this scope the @array variable to the inside of the
> >subroutine?
>
> Just out of ignorance and curiosity, why can you't you say my
> @array=shift ? Or even my @array; @array=@_; ?
Both would deposit a reference to the original array in $array[ 0].
This is not what the poster wants. Of course, the desired effect
can be achieved with "my @array = @{ shift()}", but that copies the
array, which is probably what the prototype (\@) is there to avoid.
If you want aliasing, there's no way around a package variable.
Anno
------------------------------
Date: 12 Mar 2001 12:28:51 GMT
From: robert.groenewegen@removetomailme.zonnet.nl
Subject: Re: using Perl for B2B?
Message-Id: <984400131.453060@newsreader1.wirehub.nl>
Working as software engineer with several junior collegues I would say:
both (Java and Perl that is)
Jave is a system (kind of) programming language like C, C++, Cobol and so
on. Learning such a language is a must for your knowledge, skills and (as
said before) your career. Java is very convenient for B2B applications.
But: The biggest problem that I notice with the newbies is that they want
to solve everything with the tool they know. Working with both languages
(and reading a lot about design, methods and project management ofcourse)
helps to work from a high level (Perl) to a lower level (Java). The other
advantages are that you can look in different levels to your problems,
choose which tool is the appropriate and so on.
Also personally I have noticed that I only feel comfortable with system
programming languages when I have a tool (like scripting) for testing and
glueing the part together
Good luck, Robert
------------------------------
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 V10 Issue 470
**************************************