[22475] in Perl-Users-Digest
Perl-Users Digest, Issue: 4696 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 11 18:06:03 2003
Date: Tue, 11 Mar 2003 15:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 11 Mar 2003 Volume: 10 Number: 4696
Today's topics:
Re: A Good Perl Developing Environment <jlomas@tcta.org>
Alternatives to FormMail (Steph)
Re: Alternatives to FormMail <REMOVEsdnCAPS@comcast.net>
Re: binary template for OMF? (Lars Unrotin)
Re: derive methods with OO <REMOVEsdnCAPS@comcast.net>
ever-growing value <systemunix@mpthrill.com>
Re: ever-growing value <skuo@mtwhitney.nsc.com>
Re: ever-growing value <tassilo.parseval@post.rwth-aachen.de>
Re: ever-growing value <systemunix@mpthrill.com>
Re: ever-growing value (Jay Tilton)
Forcing format to print top of page (gavs)
Like to distribute a game. <mail@annuna.com>
Re: my $x = 100 for 1..3 why is $x undef (Anno Siegel)
Re: my $x = 100 for 1..3 why is $x undef <abigail@abigail.nl>
Re: my $x = 100 for 1..3 why is $x undef <rgarciasuarez@free.fr>
Re: my $x = 100 for 1..3 why is $x undef <s_grazzini@hotmail.com>
Re: my $x = 100 for 1..3 why is $x undef (Anno Siegel)
Re: my $x = 100 for 1..3; why is $x undef <abigail@abigail.nl>
Re: my $x = 100 for 1..3; why is $x undef <abigail@abigail.nl>
Re: my $x = 100 for 1..3; why is $x undef <wuerz@yahoo.com>
Re: new Perl feature request: call into shared libs <nospam-abuse@ilyaz.org>
Object Oriente with Perl. <mail@annuna.com>
Posting more than 1 string from a file <matt307@carolina.rr.com>
Re: Posting more than 1 string from a file <noreply@gunnar.cc>
Re: Posting more than 1 string from a file (Jay Tilton)
Problem matching a value in hash (Steph)
Re: Problem matching a value in hash (Anno Siegel)
Re: Problem matching a value in hash <thepoet@nexgo.de>
Re: pstruct/c2ph on current Linux/gcc-3/glibc platforms <tassilo.parseval@post.rwth-aachen.de>
Re: Re to all <cwilbur@mithril.chromatico.net>
Remote File <johnthompson1@hotmail.com>
Re: select ip-adress out of pipe delimited file <abigail@abigail.nl>
XS, SWIG? Accessing C API easily (Kelly Blakeland)
Re: XS, SWIG? Accessing C API easily <tassilo.parseval@post.rwth-aachen.de>
Re: XS, SWIG? Accessing C API easily <abigail@abigail.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 11 Mar 2003 22:28:37 GMT
From: Jeremy Lomas <jlomas@tcta.org>
Subject: Re: A Good Perl Developing Environment
Message-Id: <BA93BA22.2EF8%jlomas@tcta.org>
This may be even later, but a _great_ IDE for Windoze OR (I believe) Linux
is Komodo, by ActiveState -- great development tool
www.activestate.com
On 3/10/03 11:10 AM, in article 4tgp6vsrvrrmcahqmp352p3g3pge06gguk@4ax.com,
"info@wienerlibrary.co.uk" <info@wienerlibrary.co.uk> wrote:
> On Sat, 18 Jan 2003 04:17:18 GMT, "A. Fuentes" <alvarof2@hotmail.com>
> wrote:
>
>>
> This might be a bit late but:
>
> If you're developing on PC or Linux then the only IDE that I've heard
> of is Perl Builder from Soution soft.
>
> check out www.solutionsoft.com
------------------------------
Date: 11 Mar 2003 11:43:28 -0800
From: sbour@niaid.nih.gov (Steph)
Subject: Alternatives to FormMail
Message-Id: <79e85d7d.0303111143.148232ea@posting.google.com>
Hi,
I am using FormMail.pl and sendmail (/usr/sbin/sendmail) on my OS X
Server to email web form data. However, I'd like to inactivate
sendmail on the server because it's overkill for my needs and I'd
don't know enough about it to ensure security. I just came accross the
SendMail.pl script <http://www.tneoh.zoneit.com/perl/SendMail/2.0/>.
Am I correct that the script could replace sendmail? What would be an
alternative for FormMail.pl that would work with SendMail.pl then?
Thanks,
Stephan.
------------------------------
Date: Tue, 11 Mar 2003 16:07:39 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Alternatives to FormMail
Message-Id: <Xns933BAE37F294Bsdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
sbour@niaid.nih.gov (Steph) wrote in
news:79e85d7d.0303111143.148232ea@posting.google.com:
> Hi,
> I am using FormMail.pl and sendmail (/usr/sbin/sendmail) on my OS
X
> Server to email web form data. However, I'd like to inactivate
> sendmail on the server because it's overkill for my needs and I'd
> don't know enough about it to ensure security. I just came accross
the
> SendMail.pl script
<http://www.tneoh.zoneit.com/perl/SendMail/2.0/>.
> Am I correct that the script could replace sendmail? What would be
an
> alternative for FormMail.pl that would work with SendMail.pl then?
You ask this as though there's only one FormMail.pl out there. :-)
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13
iD8DBQE+bl4hY96i4h5M0egRAuNLAKC+ttQNhbjVxk6mwP9/zeRbLKDOvQCfSTLp
5bLNvDys6rb+/daFRAGs+Io=
=AopQ
-----END PGP SIGNATURE-----
------------------------------
Date: 11 Mar 2003 12:06:49 -0800
From: spammy@ridiculopathy.com (Lars Unrotin)
Subject: Re: binary template for OMF?
Message-Id: <903e0b6b.0303111206.76e27d6f@posting.google.com>
I'm currently using unpack to get at the data and I can read some of
it. I can see some recognizable strings, but they're offset in a
pattern I can't figure out.
open (OMF, $file_url);
binmode(OMF);
print "<table border=\"1\">";
while ($len=sysread(OMF, $buf, 64))
{
@raw=unpack("A5 a*",$buf);
print "<tr><td>".@raw[0]."</td><td>".@raw[1].";
print "</td></tr>\n";
}close (OMF);
print "</table>";
I've played with different sysread line lengths and different
templates, but I can't seem to figure it out. Is there a trick to
this? Is there a script for detecting how a binary file is laid out?
------------------------------
Date: Tue, 11 Mar 2003 16:14:26 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: derive methods with OO
Message-Id: <Xns933BAF5E2C511sdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
peter pilsl <pilsl_use@goldfisch.at> wrote in
news:3e6e1a63$1@e-post.inode.at:
> Eric J. Roode wrote:
>
>>
>> It's good practice to put your "use" statements *after* the
module's
>> "package" statement, in case it imports symbols. In your case,
>> however, it makes no difference. Just for your future reference.
>>
>
> Where exactely do you mean ?
>
> package Derived;
>
> -> here ?
>
> .....
>
> package main;
>
> -> or here ?
Right where I told you:
>> #!/usr/bin/perl -w
>>
>> use strict;
>> use goldfisch::test::oo_test;
>>
>> package Derived;
Your 'Derived' package makes use of goldfisch::test::oo_test, but the
relevant 'use' statement is outside of package Derived.
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13
iD8DBQE+bl81Y96i4h5M0egRAp3qAKDjIkiKms1f/t7yC+0V+d5uQg+EkQCgm07L
JXkKuixP0FPQS5mrDDpFJZA=
=pEm6
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 12 Mar 2003 22:42:06 +0200
From: "Shay Hugi" <systemunix@mpthrill.com>
Subject: ever-growing value
Message-Id: <3e6e4cc9@news.012.net.il>
Hi, is there any way i can define an ever growing variable in a perl
script?, when each time the value will appear in the script it will increase
to be +1 than what was before (without using perl arithmetic)
for example...
$i=10 ;
........ $i
....
..
.... $i
the first one will be 11
the second will be 12 and so on (it would also be better if i'll be able to
define the values and the growing steps)
I don't want to use $i = $i+1 ; ($i++)
or read the data from an (external) array
I just want to use it as a global variable (using a module/library)
or even a loop within a function where i can return the value to, and read
the increased value to the variable once again.
is this possible?
--
Shay Hugi
http://www.mpthrill.com
call(phone); +927.52.771855, +972.392.72967
------------------------------
Date: Tue, 11 Mar 2003 13:21:03 -0800
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: ever-growing value
Message-Id: <Pine.GSO.4.21.0303111315151.29972-100000@mtwhitney.nsc.com>
On Wed, 12 Mar 2003, Shay Hugi wrote:
> Hi, is there any way i can define an ever growing variable in a perl
> script?, when each time the value will appear in the script it will increase
> to be +1 than what was before (without using perl arithmetic)
>
> for example...
> $i=10 ;
>
> ........ $i
> ....
> ..
> .... $i
>
> the first one will be 11
> the second will be 12 and so on (it would also be better if i'll be able to
> define the values and the growing steps)
>
> I don't want to use $i = $i+1 ; ($i++)
> or read the data from an (external) array
>
> I just want to use it as a global variable (using a module/library)
> or even a loop within a function where i can return the value to, and read
> the increased value to the variable once again.
>
> is this possible?
>
Yes. You could use the Tie::Scalar module. For example:
% cat -n tie_example
1 #! /usr/local/bin/perl
2
3 package Together;
4
5 require Tie::Scalar;
6 @ISA = (Tie::StdScalar);
7
8 sub FETCH {
9 my $self = shift;
10 return $$self++;
11 }
12
13 1;
14
15 package main;
16
17 tie our $hands, 'Together', 10;
18
19 print <<"_bondage_";
20 $hands tied together. Can you free your $hands? Nothing up my sleeve,
21 nothing in my $hands. Presto, change-o, watch what appears in my
22 $hands.
23
24 _bondage_
25
26 print tied $hands, "\n";
--
Hope this helps,
Steven
------------------------------
Date: 11 Mar 2003 21:38:23 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: ever-growing value
Message-Id: <b4ll0f$n1t$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Shay Hugi:
> Hi, is there any way i can define an ever growing variable in a perl
> script?, when each time the value will appear in the script it will increase
> to be +1 than what was before (without using perl arithmetic)
>
> for example...
> $i=10 ;
>
> ........ $i
> ....
> ..
> .... $i
>
> the first one will be 11
> the second will be 12 and so on (it would also be better if i'll be able to
> define the values and the growing steps)
You can achieve that by tying the scalar to your own class.
use strict;
package Tie::Increment;
{ my $step;
sub TIESCALAR {
my ($class, %args) = @_;
$step = $args{ step } || 1;
my $self = -$step; # so that first FETCH is 0
bless \$self => $class;
}
sub FETCH { my $self = shift; $$self += $step }
sub STORE { my $self = shift; $$self = shift };
}
package main;
tie my $var, "Tie::Increment", step => 2;
print $var, "\n", for 1 .. 5;
__END__
0
2
4
6
8
With a minimum of effort you can add some means to set a initial value
etc.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Wed, 12 Mar 2003 23:35:59 +0200
From: "Shay Hugi" <systemunix@mpthrill.com>
Subject: Re: ever-growing value
Message-Id: <3e6e596a$1@news.012.net.il>
Thank you very much for the quick answers!
also (Ethan Brown) who replied to me personally.
-Shay.
"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in
message news:b4ll0f$n1t$1@nets3.rz.RWTH-Aachen.DE...
> Also sprach Shay Hugi:
>
> > Hi, is there any way i can define an ever growing variable in a perl
> > script?, when each time the value will appear in the script it will
increase
> > to be +1 than what was before (without using perl arithmetic)
> >
> > for example...
> > $i=10 ;
> >
> > ........ $i
> > ....
> > ..
> > .... $i
> >
> > the first one will be 11
> > the second will be 12 and so on (it would also be better if i'll be able
to
> > define the values and the growing steps)
>
> You can achieve that by tying the scalar to your own class.
>
> use strict;
>
> package Tie::Increment;
> { my $step;
> sub TIESCALAR {
> my ($class, %args) = @_;
> $step = $args{ step } || 1;
> my $self = -$step; # so that first FETCH is 0
> bless \$self => $class;
> }
> sub FETCH { my $self = shift; $$self += $step }
> sub STORE { my $self = shift; $$self = shift };
> }
>
> package main;
>
> tie my $var, "Tie::Increment", step => 2;
>
> print $var, "\n", for 1 .. 5;
> __END__
> 0
> 2
> 4
> 6
> 8
>
> With a minimum of effort you can add some means to set a initial value
> etc.
>
> Tassilo
> --
>
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
>
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
>
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Tue, 11 Mar 2003 22:35:31 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: ever-growing value
Message-Id: <3e6e64ac.7174786@news.erols.com>
"Shay Hugi" <systemunix@mpthrill.com> wrote:
: Hi, is there any way i can define an ever growing variable in a perl
: script?, when each time the value will appear in the script it will increase
: to be +1 than what was before
Tie::Counter;
: (without using perl arithmetic)
Mmmkay. Whose arithmetic would you like to use instead?
------------------------------
Date: 11 Mar 2003 13:16:30 -0800
From: gavspp@yahoo.com (gavs)
Subject: Forcing format to print top of page
Message-Id: <54dc4b2a.0303111316.9e21605@posting.google.com>
Hello:
I am creating a report which should print the top of page every time
the id changes, regardless of the number of lines used.
Here is the code. Can you please point out my mistake? Thanks for
your help!
gavs.
#!/usr/bin/perl
$= = 45;
while (fetching results from db) {
if ($new_id != $cur_id) {
$new_id = $cur_id;
##$% = 46;
$- = 0;
}
write(OUTFILE);
}
format OUTFILE_TOP=
.
.
.
format OUTFILE=
.
.
.
close OUTFILE;
------------------------------
Date: Tue, 11 Mar 2003 16:46:15 -0600
From: Joe Creaney <mail@annuna.com>
Subject: Like to distribute a game.
Message-Id: <3E6E6737.4040402@annuna.com>
I have learning perl and programming and devloped a simple proto-role
playing game. Check out my perl page at www.annuna.com/perl5 The game
is completly free and distributable.
------------------------------
Date: 11 Mar 2003 19:23:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: my $x = 100 for 1..3 why is $x undef
Message-Id: <b4ld3h$3kf$1@mamenchi.zrz.TU-Berlin.DE>
Eric J. Roode <REMOVEsdnCAPS@comcast.net> wrote in comp.lang.perl.misc:
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> stefan@borgia.com (Stefan Adams) wrote in
> news:dcc927de.0303110839.54bc4a66@posting.google.com:
>
> > I think scoping is the problem. If I'm not mistaken, your code is
> the
> > same as:
> >
> > use strict;
> > for ( 1..3 ) {
> > my $x = 100;
> > }
> > print defined $x? $x: '<undef>';
> >
> > Therefore $x is lexically scoped to the 'for' loop and your print
> > statement is out side of that block and $x is therefore not
> defined.
>
> Perhaps, but your example doesn't even compile. Perhaps the OP's
> code should have a similar compile-time error.
I don't think so. The my() declaration of $x is in the lexical scope of
print() in the original code, which was:
my $x = 100 for 1 .. 3;
print defined $x? $x: '<undef>';
In the replacement code that is not so, so they are not equivalent.
I believe John Lin (the OP) was right in his expectation to find 100
in $x after the loop.
Interestingly, even Deparse thinks the statement-modifying "for" and
the full-blown loop (with its own body block) are equivalent. When
you add "use strict", which would make it a syntax error, it cheats
and changes it to "use strict 'refs'".
Anno
------------------------------
Date: 11 Mar 2003 19:48:01 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: my $x = 100 for 1..3 why is $x undef
Message-Id: <slrnb6sfbg.kfn.abigail@alexandra.abigail.nl>
Quantum Mechanic (quantum_mechanic_1964@yahoo.com) wrote on MMMCDLXXIX
September MCMXCIII in <URL:news:f233f2f0.0303110742.72735589@posting.google.com>:
{} "John Lin" <jihghong@yahoo.com.tw> wrote in message news:<b4gsiq$mph@netnews.hinet.net>...
{} > Dear all,
{} >
{} > use strict;
{} > my $x = 100 for 1..3;
{} > print defined $x? $x: '<undef>';
{} > __END__
{} > <undef>
{}
{} Is "my $x" considered inside the "for" block? If so, once outside the
{} "for" block, "my $x" goes away, and the "print" never sees it.
What for block? There's no for statement in the above program.
There's a for *statement modifier* though, but that doesn't
create a block.
After all, if there was indeed a block, the code above would not
compile - it would complain the $x used in the print didn't exist.
I think this is a bug.
Abigail
--
perl -wle 'sub _ "Just another Perl Hacker"; print prototype \&_'
------------------------------
Date: 11 Mar 2003 20:43:13 GMT
From: Rafael Garcia-Suarez <rgarciasuarez@free.fr>
Subject: Re: my $x = 100 for 1..3 why is $x undef
Message-Id: <slrnb6silq.bq0.rgarciasuarez@dat.local>
Anno Siegel wrote in comp.lang.perl.misc :
>
> my $x = 100 for 1 .. 3;
> print defined $x? $x: '<undef>';
>
<...>
>
> Interestingly, even Deparse thinks the statement-modifying "for" and
> the full-blown loop (with its own body block) are equivalent. When
> you add "use strict", which would make it a syntax error, it cheats
> and changes it to "use strict 'refs'".
B::Deparse can't deparse the strict pragma correctly, it only recognizes
the strict-refs subpragma. The result you get is not surprising.
(B::Deparse is no more than a collection of hacks around the weird
stuff perl does with its source code input. It can't be trusted in every
case.)
Concerning the original topic :
May I quote the relevant part of perlsub ?
B<NOTE:> The behaviour of a C<my> statement modified with a statement
modifier conditional or loop construct (e.g. C<my $x if ...>) is
B<undefined>. The value of the C<my> variable may be C<undef>, any
previously assigned value, or possibly anything else. Don't rely on
it. Future versions of perl might do something different from the
version of perl you try it out on. Here be dragons.
--
It's not a can of worms, it's a tank of shai-hulud.
-- Jarkko Hietaniemi
------------------------------
Date: Tue, 11 Mar 2003 20:47:46 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: my $x = 100 for 1..3 why is $x undef
Message-Id: <SXrba.79723$Mh3.24408936@twister.nyc.rr.com>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
> Eric J. Roode <REMOVEsdnCAPS@comcast.net> writes:
>> stefan@borgia.com (Stefan Adams) writes:
>>
>> > I think scoping is the problem. If I'm not mistaken, your code
>> > is the same as:
>> >
>> > use strict;
>> > for ( 1..3 ) {
>> > my $x = 100;
>> > }
>> > print defined $x? $x: '<undef>';
>> >
>> > Therefore $x is lexically scoped to the 'for' loop and your
>> > print statement is out side of that block and $x is therefore
>> > not defined.
>>
>> Perhaps, but your example doesn't even compile. Perhaps the OP's
>> code should have a similar compile-time error.
>
> I don't think so. The my() declaration of $x is in the lexical
> scope of print() in the original code, which was:
>
> my $x = 100 for 1 .. 3;
> print defined $x? $x: '<undef>';
>
> In the replacement code that is not so, so they are not equivalent.
> I believe John Lin (the OP) was right in his expectation to find
> 100 in $x after the loop.
The scope is there to protect $_.
$ perl -le '$_=1; $x=$_ for 1..3; print "$_ : $x"'
So the question is: *why* is there only one lexical scope, if the
foreach modifier is going to create a second (physical?) scope.
Still looks like a bug. :)
> Interestingly, even Deparse thinks the statement-modifying "for"
> and the full-blown loop (with its own body block) are equivalent.
>
> When you add "use strict", which would make it a syntax error,
> it cheats and changes it to "use strict 'refs'".
strict "subs" and "vars" don't go in the opcode tree.
$ perl -Mstrict -MO=Deparse -e 'my $x'
use strict 'refs';
my $x;
-e syntax OK
--
Steve
------------------------------
Date: 11 Mar 2003 21:53:38 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: my $x = 100 for 1..3 why is $x undef
Message-Id: <b4llt2$a3e$2@mamenchi.zrz.TU-Berlin.DE>
Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote in comp.lang.perl.misc:
> Anno Siegel wrote in comp.lang.perl.misc :
> >
> > my $x = 100 for 1 .. 3;
> > print defined $x? $x: '<undef>';
> >
> <...>
> >
> > Interestingly, even Deparse thinks the statement-modifying "for" and
> > the full-blown loop (with its own body block) are equivalent. When
> > you add "use strict", which would make it a syntax error, it cheats
> > and changes it to "use strict 'refs'".
>
> B::Deparse can't deparse the strict pragma correctly, it only recognizes
> the strict-refs subpragma. The result you get is not surprising.
Ah, it always does that. It certainly looked like deliberate cheating
in context :)
> (B::Deparse is no more than a collection of hacks around the weird
> stuff perl does with its source code input. It can't be trusted in every
> case.)
>
> Concerning the original topic :
> May I quote the relevant part of perlsub ?
>
> B<NOTE:> The behaviour of a C<my> statement modified with a statement
> modifier conditional or loop construct (e.g. C<my $x if ...>) is
> B<undefined>. The value of the C<my> variable may be C<undef>, any
> previously assigned value, or possibly anything else. Don't rely on
> it. Future versions of perl might do something different from the
> version of perl you try it out on. Here be dragons.
Oh, there it is. Thanks for the pointer. So it falls into the same
class as the once-popular "my $x if 0".
Anno
------------------------------
Date: 11 Mar 2003 20:21:27 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: my $x = 100 for 1..3; why is $x undef
Message-Id: <slrnb6sha7.kfn.abigail@alexandra.abigail.nl>
Mona Wuerz (wuerz@yahoo.com) wrote on MMMCDLXXIX September MCMXCIII in
<URL:news:m3vfyqof2j.fsf@karrooite.njitdm.campus.njit.edu>:
\\ johnlin@chttl.com.tw (John Lin) writes:
\\
\\ > use strict;
\\ > my $x = 100 for 1..3;
\\
\\ that's equivalent to
\\
\\ for (1..3) {
\\ my $x = 100
\\ }
\\
\\ so $x is scoped to the for loop.
But it's not. There's no block, and hence no scope, in 'my $x = 100 for 1 .. 3'.
Otherwise, the following wouldn't print 'foo':
$ perl -wle 'my $x = "foo" if 1; print $x'
foo
Furthermore, the given code wouldn't even compile if your statement was true.
\\
\\ > print defined $x? $x: '<undef>';
\\ > __END__
\\ > <undef>
\\ >
\\ > Eh? Shouldn't $x be 100? What is the trick here?
\\
\\ If, hypothetically, the statement
\\
\\ my $x = 100 for 1..3;
\\
\\ was equivalent to
\\
\\ my $x = 100;
\\ my $x = 100;
\\ my $x = 100;
But it's not. It's roughly equivalent to:
my $x;
$x = 100;
$x = 100;
$x = 100;
\\ then, with warnings enabled you'd get a warning
\\
\\ "my" variable $x masks earlier declaration in same scope at...
Really? Shall we do something daring, and actually run the code with
warnings enable?
use strict;
use warnings;
my $x = 100 for 1 .. 3;
print defined $x ? "$x\n" : "<undef>\n";
__END__
<undef>
Hmmm, no warnings....
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: 11 Mar 2003 20:24:17 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: my $x = 100 for 1..3; why is $x undef
Message-Id: <slrnb6shfh.kfn.abigail@alexandra.abigail.nl>
Charles DeRykus (ced@bcstec.ca.boeing.com) wrote on MMMCDLXXIX September
MCMXCIII in <URL:news:HBKKMv.23D@news.boeing.com>:
[]
[] But doesn't perlsyn imply a scope ... ("The foreach modifier
[] evaluates once for each element in its LIST, with $_ aliased
[] to the current element") ?
Where do you read the word 'scope' or anything related to that in the
part you quote?
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s};;;
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)}; # Perl 5.6.0 broke this...
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: 11 Mar 2003 16:13:06 -0500
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: my $x = 100 for 1..3; why is $x undef
Message-Id: <m3n0k18v4t.fsf@karrooite.njitdm.campus.njit.edu>
Abigail <abigail@abigail.nl> writes:
> Mona Wuerz (wuerz@yahoo.com) wrote on MMMCDLXXIX September MCMXCIII in
> <URL:news:m3vfyqof2j.fsf@karrooite.njitdm.campus.njit.edu>:
>
> Otherwise, the following wouldn't print 'foo':
>
> $ perl -wle 'my $x = "foo" if 1; print $x'
> foo
Ok, the reference to the documentation re my() and statement modifiers
has been given meanwhile.
but then, I'll have to add some emphasis, if only for the record:
> \\
> \\ If, hypothetically, the statement
~~ ~~~~~~~~~~~~~~
> \\
> \\ my $x = 100 for 1..3;
> \\
> \\ was equivalent to
~~~
> \\
> \\ my $x = 100;
> \\ my $x = 100;
> \\ my $x = 100;
>
> But it's not. It's roughly equivalent to:
isn't that what I just said?
> my $x;
> $x = 100;
> $x = 100;
> $x = 100;
>
> \\ then, with warnings enabled you'd get a warning
~~
> \\
> \\ "my" variable $x masks earlier declaration in same scope at...
Then I went on: "- but you don't, so - [...] - it's scoping after all."
~~~~~~~~~~~~~
> Really? Shall we do something daring, and actually run the code with
> warnings enable?
>
> use strict;
> use warnings;
>
> my $x = 100 for 1 .. 3;
>
> print defined $x ? "$x\n" : "<undef>\n";
> __END__
> <undef>
>
>
> Hmmm, no warnings....
You don't say. My conclusion was obviously too hasty, but don't put
words in my mouth either.
--
$_="\n,rekcah egnufeB rehtona tsuJ";#v1<?>g\:pv-<5<
s s\S+(?:B)sunpack'u',q q$;')E4qsee;#>60#^<(v!<)g6<
print scalar reverse,$@ unless m,[+;#]55,;m:_,:#^1<
------------------------------
Date: Tue, 11 Mar 2003 22:30:10 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: new Perl feature request: call into shared libs
Message-Id: <b4lo1i$p8c$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Matt Taylor
<para@tampabay.rr.com>], who wrote in article <vacba.19122$Xu4.533273@twister.tampabay.rr.com>:
> Default convention (__cdecl) is the same. Windows system libraries are
> compiled with __stdcall convention which is different. The following code
> should suffice for any convention except a register-parameter scheme:
Thanks! Unfortunately, VAC (IBM's compiler) uses the
register-parameter call by default (e.g., in its CRT library). Also,
now that in gcc 3.1 __regparam__(3) finally works, a lot of libraries
on Unix may also start using it [I saw that linux kernel is now
__regparam__(3)].
Ilya
------------------------------
Date: Tue, 11 Mar 2003 16:48:03 -0600
From: Joe Creaney <mail@annuna.com>
Subject: Object Oriente with Perl.
Message-Id: <3E6E67A3.9030106@annuna.com>
I have been reading a about Object oriented programming in C++. Is perl
suitable or OO programming. If so what is the real advante of OO
programming.
------------------------------
Date: Tue, 11 Mar 2003 22:27:01 GMT
From: matt307 <matt307@carolina.rr.com>
Subject: Posting more than 1 string from a file
Message-Id: <3E6E62AF.ED3333B2@carolina.rr.com>
Hey all, its me again. I have finally got my script working, well
somewhat. It is now reading from messages.txt but it is only reading the
first message. How do i get it to read more messages? thx
------------------------------
Date: Tue, 11 Mar 2003 23:37:04 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Posting more than 1 string from a file
Message-Id: <b4lodn$20g8qi$1@ID-184292.news.dfncis.de>
matt307 wrote:
> Hey all, its me again. I have finally got my script working, well
> somewhat. It is now reading from messages.txt but it is only reading the
> first message. How do i get it to read more messages? thx
If it isn't too much trouble, it would be nice to see the actual script
you are using, together with a description of how the messages.txt file
is structured.
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 11 Mar 2003 22:44:49 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Posting more than 1 string from a file
Message-Id: <3e6e64f4.7246961@news.erols.com>
matt307 <matt307@carolina.rr.com> wrote:
: Hey all, its me again. I have finally got my script working,
What are you talking about? If this is in reference to an earlier
thread, why did you not followup within that thead?
: well somewhat. It is now reading from messages.txt but it is only reading the
: first message. How do i get it to read more messages? thx
Take whatever you did before and do it some more.
Really now. How can you expect good help with such a paucity of
details?
Posting the relevant section of the code (*NOT* the entire program)
that opens, reads, and closes the file would be just the thing.
------------------------------
Date: 11 Mar 2003 11:33:21 -0800
From: sbour@niaid.nih.gov (Steph)
Subject: Problem matching a value in hash
Message-Id: <79e85d7d.0303111133.71b03a96@posting.google.com>
I'm trying to parse an html file to send an email reminder (please
disregard the various print commands, there are there to make sure
things behave as they should).
#!/usr/bin/perl -w
open (d0, "d0.html");
while (<d0>)
{
if (/\b\+\b/)
{
@roughname = split (/>/);
print "The array is @roughname\n";
print "$roughname[6]\n";
@name = split (/</, $roughname[6]);
print "The name is $name[0]\n";
{
%email = qw (Yoshi ynishimura@someplace.com Steph
sbour@someplace.com);
$match = $name[0];
print "The hash key is $match\n"
print "The email is $email{$match}\n";
}
}
}
When I run that I get:
syntax error at splithtml line 21, near "print"
syntax error at splithtml line 28, near "}"
Execution of splithtml aborted due to compilation errors.
The error is in the last print command.
However, this variation works:
#!/usr/bin/perl -w
open (d0, "d0.html");
while (<d0>)
{
if (/\b\+\b/)
{
@roughname = split (/>/);
print "The array is @roughname\n";
print "$roughname[6]\n";
@name = split (/</, $roughname[6]);
print "The name is $name[0]\n";
{
%email = qw (Yoshi ynishimura@someplace.com Steph
sbour@someplace.com);
print "Enter a name: ";
chomp ($entry = <STDIN>);
print "The email is $email{$entry}\n";
}
}
}
OUTPUT:
The array is <td NOWRAP </td <td NOWRAP </td <td <A HREF="d0+1.html"
Yoshi</A </td <td
Yoshi</A
The name is Yoshi
Enter a name: Yoshi
The email is ynishimura@niaid.nih.gov
So, the script can extract the proper hash value when the key is in
STDIN but not when in the $match variable. Do you know why?
Thanks for your help,
Stephan.
------------------------------
Date: 11 Mar 2003 19:52:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Problem matching a value in hash
Message-Id: <b4leq5$3kf$2@mamenchi.zrz.TU-Berlin.DE>
Steph <sbour@niaid.nih.gov> wrote in comp.lang.perl.misc:
> I'm trying to parse an html file to send an email reminder (please
> disregard the various print commands, there are there to make sure
> things behave as they should).
>
> #!/usr/bin/perl -w
>
> open (d0, "d0.html");
> while (<d0>)
> {
> if (/\b\+\b/)
> {
> @roughname = split (/>/);
>
> print "The array is @roughname\n";
> print "$roughname[6]\n";
> @name = split (/</, $roughname[6]);
> print "The name is $name[0]\n";
> {
> %email = qw (Yoshi ynishimura@someplace.com Steph
> sbour@someplace.com);
> $match = $name[0];
> print "The hash key is $match\n"
^
Missing semicolon. There's your syntax error.
> print "The email is $email{$match}\n";
> }
> }
> }
>
> When I run that I get:
> syntax error at splithtml line 21, near "print"
[...]
Anno
------------------------------
Date: Tue, 11 Mar 2003 21:05:13 +0100
From: "Christian Winter" <thepoet@nexgo.de>
Subject: Re: Problem matching a value in hash
Message-Id: <3e6e406b$0$6437$9b4e6d93@newsread2.arcor-online.net>
"Steph" <sbour@niaid.nih.gov> schrieb:
[...]
> print "The hash key is $match\n"
> print "The email is $email{$match}\n";
[...]
You should end each line with a ";"
:-)
HTH
-Christian
------------------------------
Date: 11 Mar 2003 19:15:04 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: pstruct/c2ph on current Linux/gcc-3/glibc platforms?
Message-Id: <b4lcjo$ed6$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Harald Anlauf:
> Since I couldn't find anything useful after some googling, I am asking
> here:
>
> Is pstruct/c2ph still being maintained? I am having problems extracting
> C structures from header files on current Linux platforms with gcc-3.
> It is not clear to me whether this is either due to changes in gcc's
> debugging format, or peculiarities of the header files, or something
> missing in pstruct/c2ph.
I never used pstruct myself but from its manpage I assume that
Convert::Binary::C can do the same with ease. This module comes with a
complete yacc grammar for C and an ANSI99 compliant preprocessor. Also,
it has a little tool called 'ccconfig' that determines the
characteristics of almost any C compiler so that you don't have to do
the mapping of the module to your compiler yourself.
Looking at its manpage, there is also an offsetof() method that will do
what you need.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Tue, 11 Mar 2003 20:00:27 GMT
From: Charlton Wilbur <cwilbur@mithril.chromatico.net>
Subject: Re: Re to all
Message-Id: <87vfypbrpf.fsf@mithril.chromatico.net>
>>>>> "TA" == Tore Aursand <tore@aursand.no> writes:
TA> But! Why don't people better - or more often - check out
TA> their options when it comes to working with - or inside a -
TA> development environment?
TA> Don't they understand that we live in 2003 and every decent
TA> language, Perl is one of them of course, have a debugging
TA> method of some sort? It's quite frustrating to answer
TA> questions which the questionnaire easily could have found the
TA> answer himself/herself if he/she just had taken a few minutes
TA> to read some documentation.
Debugging is the hardest part of programming, especially for novice
programmers. Even if they know of the existence of the debugger
(which can't be assumed), they still don't know how to isolate the bug
and fix it.
In particular I recall my days in college, learning C, working in a
computer lab with other students. I had established a reputation as a
C expert (at least by undergraduate standards), largely by my
debugging skills. A few of my fellow students would come to me on a
regular basis for help debugging, and the first question I would
always ask was "Have you run it under the debugger?" It amazed me
that there were a large number of them who would answer "no" to that
-- even after they'd asked for help more than once, even after I had
pointed out that I *always* asked that question first.
Charlton
------------------------------
Date: Tue, 11 Mar 2003 15:23:02 -0500
From: "Johnny" <johnthompson1@hotmail.com>
Subject: Remote File
Message-Id: <3e6e459e$1@news.xetron.com>
Hello,
I'm trying to read a file on the proc file system. I figured I would use
the File-Remote-1.16 module. However, I can't find an example anywhere that
shows how to send your username and password to the server.
Can anybody help me?
Thanks,
John
------------------------------
Date: 11 Mar 2003 19:56:28 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: select ip-adress out of pipe delimited file
Message-Id: <slrnb6sfrc.kfn.abigail@alexandra.abigail.nl>
Pynex (pynex@gmx.de) wrote on MMMCDLXXIX September MCMXCIII in
<URL:news:d57585e5.0303102348.3516b74b@posting.google.com>:
^^ Hello !
^^
^^ I've got a pipe delimited file like this:
^^
^^ 456|blob|06-20-2001|ping|09-15-2002|192.168.1.1|ABC-1-01|||Hub|Yes|mid|tel
^^ 457|blub|06-20-2000|pang|09-21-2002|192.168.1.2|ABG-1-134|||Hub|Yes|mid|tel
^^ 458|bleb|06-20-1999|pung|09-23-2002|192.168.1.3|BGF-1-03|||Hub|Yes|mid|tel
^^ 459|blib|06-20-2002|peng|09-25-2002|192.168.1.6|L67-1-87|||Hub|Yes|mid|tel
^^
^^ I want to get the IP-Adresses.
^^
^^ At the moment i'm doing it in this way (it not very beautiful, but it works):
^^
^^ $line=<FILE>;
^^ ($one,$two,$three,$four,$five,$sic,$seven)=split /[|]/, $line,7;
^^ print "$six\n";
^^
^^ Anybody a better idea ?
That's a fine way of doing it (after fixing the typo). You could do
my ($ip) = (split /[|]/ => $line, 7) [5];
as well, saving on the number of variables used.
Alternatively, if you don't know where the IP address is in the line,
you could use the Regexp::Common module:
use Regexp::Common;
while (<>) {
print $1, "\n" if /$RE{net}{IPv4}{-keep}/;
}
Abigail
--
sub _ {$_ = shift and y/b-yB-Y/a-yB-Y/ xor !@ _?
exit print :
print and push @_ => shift and goto &{(caller (0)) [3]}}
split // => "KsvQtbuf fbsodpmu\ni flsI " xor & _
------------------------------
Date: Mon, 10 Mar 2003 21:37:17 +1000
From: kblang4-spam@spamgoawayar.com.au (Kelly Blakeland)
Subject: XS, SWIG? Accessing C API easily
Message-Id: <3e6c6944$1_1@bn.ar.com.au>
I knew C quite well a while back, but have been completely spoiled
by Perl. I find that my C is now extremely hopeless.
I don't want to write any C functions, but wish to use the C API
of various commercial products. Should I take the effort to
learn about SWIG, or try to learn XS?
Does it work flawlessly, or am I going to find some C code which
simply can't be called from Perl? I know that most of the API calls
I'll need use pointers to various things, and maybe even more
complex things.
I'd hate to have to learn to write 40 separate interface declarations
for 40 C functions that I need, only to find that I can't call most
of these functions from Perl.
------------------------------
Date: 11 Mar 2003 21:19:57 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: XS, SWIG? Accessing C API easily
Message-Id: <b4ljtt$m7l$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Kelly Blakeland:
> I knew C quite well a while back, but have been completely spoiled
> by Perl. I find that my C is now extremely hopeless.
>
> I don't want to write any C functions, but wish to use the C API
> of various commercial products. Should I take the effort to
> learn about SWIG, or try to learn XS?
SWIG is not Perl specific and should work with other languages such as
Python as well. Other than that, my only contact with SWIG has been
brief only to convince me that I don't like it.
XS might be harder to learn. It's not because it is overly complicated
but rather because the documentation is a little unorganized. But once
you have understood only the most basic concepts behind it, it looks
suddenly quite nice.
> Does it work flawlessly, or am I going to find some C code which
> simply can't be called from Perl? I know that most of the API calls
> I'll need use pointers to various things, and maybe even more
> complex things.
Since XS is only a thin wrapper around C, anything in C should be
possible in XS as well. And yes, you will need pointers. The Perl API
even contains some macros and functions that require to use pointers to
pointers. Hoooo. ;-)
> I'd hate to have to learn to write 40 separate interface declarations
> for 40 C functions that I need, only to find that I can't call most
> of these functions from Perl.
Only after you have written a wrapper for them. Some people think that
Inline::C is the easier approach. While I think that there is next to no
difference in complexity, you might prefer that.
If you decide to learn XS, have a look for CookbookA and CookbookB on
the CPAN. It contains some useful examples how to turn C structures into
Perl objects. This is going to save you a lot of typing and time on the
long run.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 11 Mar 2003 21:20:01 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: XS, SWIG? Accessing C API easily
Message-Id: <slrnb6sko1.kpb.abigail@alexandra.abigail.nl>
Kelly Blakeland (kblang4-spam@spamgoawayar.com.au) wrote on MMMCDLXXVIII
September MCMXCIII in <URL:news:3e6c6944$1_1@bn.ar.com.au>:
()
() I knew C quite well a while back, but have been completely spoiled
() by Perl. I find that my C is now extremely hopeless.
()
() I don't want to write any C functions, but wish to use the C API
() of various commercial products. Should I take the effort to
() learn about SWIG, or try to learn XS?
()
() Does it work flawlessly, or am I going to find some C code which
() simply can't be called from Perl? I know that most of the API calls
() I'll need use pointers to various things, and maybe even more
() complex things.
()
() I'd hate to have to learn to write 40 separate interface declarations
() for 40 C functions that I need, only to find that I can't call most
() of these functions from Perl.
You might want to consider Inline::C.
Abigail
--
#!/opt/perl/bin/perl -- # No trailing newline after the last line!
BEGIN{$|=$SIG{__WARN__}=sub{$_=$_[0];y-_- -;print/(.)"$/;seek _,-open(_
,"+<$0"),2;truncate _,tell _;close _;exec$0}}//rekcaH_lreP_rehtona_tsuJ
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.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 4696
***************************************