[22473] in Perl-Users-Digest
Perl-Users Digest, Issue: 4694 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 11 14:07:41 2003
Date: Tue, 11 Mar 2003 11:05:11 -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: 4694
Today's topics:
Creating a variable with a file path/name in it (Sylvie)
Re: Creating a variable with a file path/name in it <john-s@moving-picture.com>
Re: Creating a variable with a file path/name in it <REMOVEsdnCAPS@comcast.net>
Re: Creating a variable with a file path/name in it <perl-dvd@darklaser.com>
DBI and MS Access Query problem <info@wienerlibrary.co.uk>
Re: DBI and MS Access Query problem <simon.oliver@umist.ac.uk>
Re: DBI and MS Access Query problem <tore@aursand.no>
dbm lock problem <ixanthi@ixan-remove this-hi.gr>
derive methods with OO <pilsl_use@goldfisch.at>
Re: derive methods with OO <me@verizon.invalid>
Re: derive methods with OO <REMOVEsdnCAPS@comcast.net>
Re: derive methods with OO <pilsl_use@goldfisch.at>
Dublin branch Perl Mongers <fergal@esatclear.ie>
Error redirection in subshell <pzerwetz@yaccom.com>
Re: Error redirection in subshell <thepoet@nexgo.de>
Re: Merging log files using hash - good idea/possible? <tore@aursand.no>
Re: Merging log files using hash - good idea/possible? (Thomas)
my $x = 100 for 1..3 why is $x undef <jihghong@yahoo.com.tw>
Re: my $x = 100 for 1..3 why is $x undef <REMOVEsdnCAPS@comcast.net>
Re: my $x = 100 for 1..3 why is $x undef (Quantum Mechanic)
Re: my $x = 100 for 1..3 why is $x undef (Stefan Adams)
Re: my $x = 100 for 1..3 why is $x undef <REMOVEsdnCAPS@comcast.net>
Re: Newbie: Extract info from MSI <pkrupa@redwood.rsc.raytheon.com>
Re: perl to strip high-end ASCII <flavell@mail.cern.ch>
perl, popfile & os/2 <sestini-antispam-@unisi.it>
Re: printing a file to a webpage <REMOVEsdnCAPS@comcast.net>
pstruct/c2ph on current Linux/gcc-3/glibc platforms? <anlauf@hep.tu-darmstadt.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 Mar 2003 08:48:18 -0800
From: eisfaerie@mad.scientist.com (Sylvie)
Subject: Creating a variable with a file path/name in it
Message-Id: <95401f60.0303110848.12c8e1b0@posting.google.com>
Hello. My programming knowledge is pretty basic, although I've been
doing Perl programming for some time now, so I really need help here.
I am trying to create a global variable which contains a particular
file's name (call it File for this example) and absolute path. My code
reads something like:
$MyFile = "/home/me/public_cgi/progXfolder/File";
I store this in a subroutine which I then call whenever I need to
open/read/write to this file. However, I am getting an error whenever
I try opening the file:
open (TheFile, "$MyFile") || &writeError($MyFile);
&writeError is a small script that lets me know when I'm having
trouble opening files. It writes down $MyFile in a text file, and
according to this, $MyFile is /home/me/public_cgi/progXfolder/File so
I know that the value of my variable is being passed correctly.
I've checked the read/write privileges for the file and folders, and
they're all correct.
I'm not sure what I'm doing wrong. Can I specify the absolute path
like this?
Any help would be appreciated. Please use as much detail as possible,
as I still consider myself a newbie at this :)
Sylvie
------------------------------
Date: Tue, 11 Mar 2003 17:01:52 +0000
From: John Strauss <john-s@moving-picture.com>
Subject: Re: Creating a variable with a file path/name in it
Message-Id: <20030311170152.3264fb9b.john-s@moving-picture.com>
open (TheFile, ">$MyFile") || &writeError($MyFile);
^
maybe.
On 11 Mar 2003 08:48:18 -0800
eisfaerie@mad.scientist.com (Sylvie) wrote:
>
> Hello. My programming knowledge is pretty basic, although I've been
> doing Perl programming for some time now, so I really need help here.
>
> I am trying to create a global variable which contains a particular
> file's name (call it File for this example) and absolute path. My code
> reads something like:
> $MyFile = "/home/me/public_cgi/progXfolder/File";
>
> I store this in a subroutine which I then call whenever I need to
> open/read/write to this file. However, I am getting an error whenever
> I try opening the file:
> open (TheFile, "$MyFile") || &writeError($MyFile);
>
> &writeError is a small script that lets me know when I'm having
> trouble opening files. It writes down $MyFile in a text file, and
> according to this, $MyFile is /home/me/public_cgi/progXfolder/File so
> I know that the value of my variable is being passed correctly.
>
> I've checked the read/write privileges for the file and folders, and
> they're all correct.
>
> I'm not sure what I'm doing wrong. Can I specify the absolute path
> like this?
>
> Any help would be appreciated. Please use as much detail as possible,
> as I still consider myself a newbie at this :)
>
> Sylvie
------------------------------
Date: Tue, 11 Mar 2003 11:26:29 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Creating a variable with a file path/name in it
Message-Id: <Xns933B7E8E4C18Dsdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
eisfaerie@mad.scientist.com (Sylvie) wrote in
news:95401f60.0303110848.12c8e1b0@posting.google.com:
> I store this in a subroutine which I then call whenever I need to
> open/read/write to this file. However, I am getting an error
whenever
> I try opening the file:
> open (TheFile, "$MyFile") || &writeError($MyFile);
>
> &writeError is a small script that lets me know when I'm having
> trouble opening files. It writes down $MyFile in a text file, and
> according to this, $MyFile is /home/me/public_cgi/progXfolder/File
so
> I know that the value of my variable is being passed correctly.
Why don't you ask perl what the problem is? Whenever a file open
fails, the reason is stored in $! -- check that variable.
- --
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+bhw8Y96i4h5M0egRAmQUAKDOaP4YfT8QTiPqXBzEllQY0nDcgACeMMxX
LssGHQAfE9+h0yXlipY+FgI=
=/A6w
-----END PGP SIGNATURE-----
------------------------------
Date: Tue, 11 Mar 2003 17:55:58 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: Creating a variable with a file path/name in it
Message-Id: <Oqpba.43$Ku2.11369@news-west.eli.net>
"Sylvie" <eisfaerie@mad.scientist.com> wrote in message
news:95401f60.0303110848.12c8e1b0@posting.google.com...
> Hello. My programming knowledge is pretty basic, although I've been
> doing Perl programming for some time now, so I really need help here.
>
> I am trying to create a global variable which contains a particular
> file's name (call it File for this example) and absolute path. My code
> reads something like:
> $MyFile = "/home/me/public_cgi/progXfolder/File";
>
> I store this in a subroutine which I then call whenever I need to
> open/read/write to this file. However, I am getting an error whenever
> I try opening the file:
> open (TheFile, "$MyFile") || &writeError($MyFile);
>
> &writeError is a small script that lets me know when I'm having
> trouble opening files. It writes down $MyFile in a text file, and
> according to this, $MyFile is /home/me/public_cgi/progXfolder/File so
> I know that the value of my variable is being passed correctly.
>
> I've checked the read/write privileges for the file and folders, and
> they're all correct.
>
> I'm not sure what I'm doing wrong. Can I specify the absolute path
> like this?
Yes you can
> Any help would be appreciated. Please use as much detail as possible,
> as I still consider myself a newbie at this :)
Try this:
open(TheFile, "$MyFile") || die "$MyFile not opened because $!\n";
$! should tell you why the system did not open the file for you (it will
be printed to STDERR, so it will probably show in your web server error
log)
Regards,
David
perl -e'print for map chr$_+1,"111100113107044099117099132"=~/(.{3})/g'
------------------------------
Date: Tue, 11 Mar 2003 12:24:13 +0000
From: Rod <info@wienerlibrary.co.uk>
Subject: DBI and MS Access Query problem
Message-Id: <v6lr6vgg91efueo755c2agpoirbtvo53sq@4ax.com>
Could anyone point out if I'm doing anything obviously wrong - this is
my first attempt to use the DBI module and I'm running into problems.
The code below attempts to pull data from an MS access 2000 DB on the
same machine (Win98) as an active state dist. of Perl 5.8.0 and
recently installed DBI/DBD modules.
The problem I'm having is in the inner while loop which only seems to
output the last row of any data found in the table for a given control
code i.e for a given control code I expect between 1 and 5 different
catalogue numbers but only the last of these is output to the
results.txt file.
I've run this on Perl Builder IDE and it suggests that
'while(@row=$sth->fetchrow_array)' only becomes defined for the last
row of data fetched - but I can't understand why this should be - any
help would be much appreciated.
code follows.............................
use DBI;
open RESULTS,"> results.txt" or die "can't open results: $!"; #opens
results file
open CONTROL,"< controlcodes3.txt" or die "can't get codes: $!";#opens
list of codes for query
$dbh = DBI->connect('dbi:ODBC:gentest'); #connects to database
while($control=<CONTROL>) #start while loop and read in first control
code
{
$subcontrol=chomp $control; #tidy up $control
$sqlstatement='SELECT CONTROL,CATALOGUE,LANGUAGE FROM CATALOGUES WHERE
CONTROL=?';
$sth = $dbh->prepare($sqlstatement)|| die "couldn't prepare
statement";
$sth->execute($subcontrol) || die "Could not execute SQL statement";
#output query results
while(@row=$sth->fetchrow_array)
{
print RESULTS "@row\n";}
}
#.....tidy up files and connections
personal replies to info@wienerlibrary.co.uk
------------------------------
Date: Tue, 11 Mar 2003 13:24:01 +0000
From: Simon Oliver <simon.oliver@umist.ac.uk>
To: Rod <info@wienerlibrary.co.uk>
Subject: Re: DBI and MS Access Query problem
Message-Id: <3E6DE371.8030200@umist.ac.uk>
Rod wrote:
> I've run this on Perl Builder IDE and it suggests that
> 'while(@row=$sth->fetchrow_array)' only becomes defined for the last
> row of data fetched
So for each $control there should be a number of rows? Then I can't see
what the problem is. Try using dump_results to see all the rows:
print RESULTS $sth->dump_results();
Here are a few points worth making which might help you solve your problem
and improve your DBI programming....
use strict and -w.
prepare() your SQL prior to the while($control=<CONTROL>) only execute()
within the loop - this is much more efficient.
> while(@row=$sth->fetchrow_array)
Use array references instead of copying array contents it's more efficient:
while(my $row=$sth->fetch)
{
print RESULTS join(',',@$row), "\n";
Also, don't keep testing for errors, use RaiseError instead:
$dbh->{RaiseError} = 1;
------------------------------
Date: Tue, 11 Mar 2003 17:24:01 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: DBI and MS Access Query problem
Message-Id: <pan.2003.03.11.14.29.58.535367@aursand.no>
On Tue, 11 Mar 2003 12:24:13 +0000, Rod wrote:
> $subcontrol=chomp $control; #tidy up $control
I don't think this does what you want it to do; 'chomp()' returns the
_number_ of removed characters from its argument(s).
You could actually forget about the '$subcontrol' variable and be happy
using only this code;
chomp( $control );
> $sth->execute($subcontrol) || die "Could not execute SQL statement";
...thus you have to change this into:
$sth->execute( $control );
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Tue, 11 Mar 2003 14:29:00 +0200
From: "Vassilis Tavoultsidis" <ixanthi@ixan-remove this-hi.gr>
Subject: dbm lock problem
Message-Id: <b4kkqi$amm$1@nic.grnet.gr>
I am trying to lock a dbm file using the following code
#!/usr/bin/perl
use CGI;
use Fcntl;
use DB_File;
my $q = new CGI;
$dbfile = $q->param("dbfile");
print "Content-type: text/html\n\n";
print $dbfile."<br>";
local *DBM;
my $db = tie %dbdata, "DB_File", $dbfile, O_CREAT | O_RDWR, 0755 or print
"could not tie to $dbfile: $!";
my $fd = $db->fd;
open DBM, "+<&=$fd" or print "Could not dub DBM for lock : $!";
flock DBM, LOCK_EX;
undef $db;
while (($k, $v) = each(%dbdata))
{
print $k."::".$v."<br>";
};
print "end.";
untie %dbdata;
exit;
I am not taking an error messages but it seems that nothing is being loaded
!
Should I use the dbmopen and dbmclose procedures everything works fine but I
have no locking capabilities
Could anybody help me with that ?
Thanks
Vassilis Tavoultsidis
ixanthi@ixanthi.gr
------------------------------
Date: Tue, 11 Mar 2003 15:52:11 +0100
From: peter pilsl <pilsl_use@goldfisch.at>
Subject: derive methods with OO
Message-Id: <3e6df866$1@e-post.inode.at>
I've a very basic question for object orientated perl. A given module has
the constructor and three methods. Now I want to replace one method with
another method in my programm. How can I do this ? (and maybe someone knows
if this works fine with mod_perl too). I tried (and guessed) many ways but
obviously I dont understand the underlying mechanisms and somehow I'm stuck
now.
the module:
==============================
package goldfisch::test::oo_test;
use strict;
sub new {
my $classname=shift;
my $ptr={};
bless($ptr,$classname);
$ptr->{color}='undef';
return $ptr;
}
sub get {
my $ptr=shift;
return $ptr->{color};
}
sub s1 {
my $ptr=shift;
$ptr->{color}='red';
return $ptr->get();
}
sub s2 {
my $ptr=shift;
$ptr->{color}='green';
return $ptr->get();
}
1;
=============================
the programm:
=============================
#!/usr/bin/perl -w
use strict;
use goldfisch::test::oo_test;
package Derived;
use vars qw(@ISA);
@ISA=qw(goldfisch::test::oo:test);
sub s1 {
my $ptr=shift;
$ptr->{color}='blue';
return $ptr->get();
}
package main;
my $obj=Derived->new();
print $obj->get(),"\n";
print $obj->s1(),"\n";
print $obj->s2(),"\n";
=============================
The output:
$ ./test.pl
Can't locate package goldfisch::test::oo:test for @Derived::ISA at
./test.pl line 20.
Can't locate package goldfisch::test::oo:test for @Derived::ISA at
./test.pl line 20.
Can't locate object method "new" via package "Derived" at ./test.pl line 20.
If I dont import the module with the use-command but just put the
module-code there things works perfect. But this is not what I want.
thnx,
peter
--
peter pilsl
pilsl_@goldfisch.at
http://www.goldfisch.at
------------------------------
Date: Tue, 11 Mar 2003 15:11:36 GMT
From: "dw" <me@verizon.invalid>
Subject: Re: derive methods with OO
Message-Id: <I0nba.9696$SX.6051@nwrdny03.gnilink.net>
"peter pilsl" <pilsl_use@goldfisch.at> wrote in message
news:3e6df866$1@e-post.inode.at...
>
> the module:
>
> package goldfisch::test::oo_test;
>
> =============================
> the programm:
>
> use goldfisch::test::oo_test;
>
> package Derived;
>
> use vars qw(@ISA);
> @ISA=qw(goldfisch::test::oo:test);
looks like this line should be (last colon should be an underscore)
@ISA=qw(goldfisch::test::oo_test);
Your 'use' is correct, but the @ISA is wrong.
------------------------------
Date: Tue, 11 Mar 2003 09:29:35 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: derive methods with OO
Message-Id: <Xns933B6ABCD2C14sdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
peter pilsl <pilsl_use@goldfisch.at> wrote in
news:3e6df866$1@e-post.inode.at:
> #!/usr/bin/perl -w
>
> use strict;
> use goldfisch::test::oo_test;
>
> package Derived;
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.
> use vars qw(@ISA);
> @ISA=qw(goldfisch::test::oo:test);
Shouldn't that be "oo_test"?
Looks to me like you're doing everything else right.
- --
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+bgDPY96i4h5M0egRAqt4AJ40Q6qBnGx8kllb1NUalh4LRTYx4QCgxs0k
IPl8ek8gma+3TMdE1tmAKy4=
=RkJc
-----END PGP SIGNATURE-----
------------------------------
Date: Tue, 11 Mar 2003 18:17:11 +0100
From: peter pilsl <pilsl_use@goldfisch.at>
Subject: Re: derive methods with OO
Message-Id: <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 ?
...
both ways work equal in this simple example.
my idea was that "first" I import the original package, then create the
"derived" package and then the main-package ...
I wonder why the statement
@ISA=qw(goldfisch::test::oo_test);
works without even "importing" these package first.
>
>> use vars qw(@ISA);
>> @ISA=qw(goldfisch::test::oo:test);
>
> Shouldn't that be "oo_test"?
>
thnx a lot. I dont want to tell in public how many hours I worked on this
and how many times I've read my book and the perldocs and wondering what I
was doing wrong. If I only hadnt read the errormessages a bit more
carefully ;)
thnx,
peter
--
peter pilsl
pilsl_@goldfisch.at
http://www.goldfisch.at
------------------------------
Date: Tue, 11 Mar 2003 15:31:19 +0000
From: Fergal Daly <fergal@esatclear.ie>
Subject: Dublin branch Perl Mongers
Message-Id: <b4kvag$eq0$1@dorito.esatclear.ie>
Howdy,
Anyone interested in setting up a Dublin branch of Perlmongers?
I know there are lots of Perl hackers around these parts and notice Mark
Jason Dominus is coming soon courtesy of TCD Netsoc and Doolin.com, it'd
be a shame not to have a Dublin.pm to welcome him.
The purpose would be to help each other on the mailing list, show each
other cool stuff at meeetings (stuff found and stuff you wrote) and
maybe every now then get drunk and tell that one about the time you got
$' and $` mixed up with hilarious consequences.
If you're interested, sign up to the mailing list by emailing
perl-request@sprucemoose.net with a subject line of
subscribe
and a blank message body or going here
http://frika.starflung.com/mailman/listinfo/perl
Fergal
------------------------------
Date: Tue, 11 Mar 2003 17:44:45 +0100
From: "Pascal Zerwetz" <pzerwetz@yaccom.com>
Subject: Error redirection in subshell
Message-Id: <b4l3pt$1bf3$1@biggoron.nerim.net>
Hello
I'm new in perl so this question may be silly.
I am using perl/Tk in Cygwin, on W2k.
I call a script and some info are edited in STDERR. (let's say grep for
example).
I hope to get all outputs and display them in a textbox during exec.
I've tried
open CMD_EXECUTION "grep .... |";
while (<CMD_EXECUTION>)
{
}
but the errors are let apart.
How can I do? Thanks a lot for answers.
Pascal.
------------------------------
Date: Tue, 11 Mar 2003 19:14:12 +0100
From: "Christian Winter" <thepoet@nexgo.de>
Subject: Re: Error redirection in subshell
Message-Id: <3e6e2667$0$6434$9b4e6d93@newsread2.arcor-online.net>
"Pascal Zerwetz" <pzerwetz@yaccom.com> schrieb:
> Hello
> I'm new in perl so this question may be silly.
> I am using perl/Tk in Cygwin, on W2k.
> I call a script and some info are edited in STDERR. (let's say grep for
> example).
> I hope to get all outputs and display them in a textbox during exec.
> I've tried
> open CMD_EXECUTION "grep .... |";
> while (<CMD_EXECUTION>)
> {
> }
> but the errors are let apart.
Hi,
you should have tried "perldoc -q stderr".
It would have shown you a working way, using
shell pipe redirection like
open( CMD, "$cmd 2>&1|" );
which works on a lot of shells, e.g. bash
or w2k's cmd.exe.
You may also have a look at "perldoc IPC::Open3"
on how to capture stderr independently of
stdout.
CPAN holds a module named "System2" that
provides even simpler access to stderr output
than open3 does. It's hit #3 if "stderr" is
fed to http://search.cpan.org/ as search term.
HTH
-Christian
------------------------------
Date: Tue, 11 Mar 2003 15:20:55 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Merging log files using hash - good idea/possible?
Message-Id: <pan.2003.03.11.10.57.04.158270@aursand.no>
On Tue, 11 Mar 2003 02:41:45 +0100, Tore Aursand wrote:
> The solution I ended up with was a great - and small - utility developed
> in C/C++ which was called 'something'. :) That's the problem; I don't
> remember the name of the program, but it wasn't something like 'log
> merge', 'merge log' or something.
Uhm. Correction: It _was_ something like that. :) It was also made
especially for working with Apache logfiles, and I guess that - if the
utility haven't been updated since I used it - it was intended for use
with Apache 1.x.
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: 11 Mar 2003 10:37:04 -0800
From: tornell@hotmail.com (Thomas)
Subject: Re: Merging log files using hash - good idea/possible?
Message-Id: <24ae4e25.0303111037.10a18156@posting.google.com>
Hi,
a year ago we also tried to merge our logfiles. The experience was
bad, since it was harder than expected to get a good merge that would
generate correct statistics in Webtrends. Also, the fact of having to
post-process the data every day, made us choose to buy the server
license from Webtrends. After doing this, the statistics have run
without problems. I would recommend to buy the extra licence, even
though the fee is pretty high.
Regards, Thomas
------------------------------
Date: Mon, 10 Mar 2003 10:17:04 +0800
From: "John Lin" <jihghong@yahoo.com.tw>
Subject: my $x = 100 for 1..3 why is $x undef
Message-Id: <b4gsiq$mph@netnews.hinet.net>
Dear all,
use strict;
my $x = 100 for 1..3;
print defined $x? $x: '<undef>';
__END__
<undef>
Eh? Shouldn't $x be 100? What is the trick here?
NOTE: I 'use strict', and $x is not a reserved (globally defined) variable.
So I think 'scoping' is not the problem.
Best regards.
John Lin
------------------------------
Date: Tue, 11 Mar 2003 06:22:27 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: my $x = 100 for 1..3 why is $x undef
Message-Id: <Xns933B4B04293CFsdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
"John Lin" <jihghong@yahoo.com.tw> wrote in
news:b4gsiq$mph@netnews.hinet.net:
> use strict;
> my $x = 100 for 1..3;
> print defined $x? $x: '<undef>';
> __END__
> <undef>
>
> Eh? Shouldn't $x be 100? What is the trick here?
>
> NOTE: I 'use strict', and $x is not a reserved (globally defined)
> variable. So I think 'scoping' is not the problem.
my $x = 100 for 1..3;
is functionally equivalent to
for (1..3) { my $x = 100; }
so scoping *is* the problem, as the scope of $x is just the for statement.
- --
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+bdUAY96i4h5M0egRApu7AJ9KEXzXXfyR033EoLohpsxWhTKZMACghg2K
7rW2lH0uHeZZq7KH6Ezqj6U=
=GYEx
-----END PGP SIGNATURE-----
------------------------------
Date: 11 Mar 2003 07:42:10 -0800
From: quantum_mechanic_1964@yahoo.com (Quantum Mechanic)
Subject: Re: my $x = 100 for 1..3 why is $x undef
Message-Id: <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.
-QM
[bored in training with no Perl]
------------------------------
Date: 11 Mar 2003 08:39:18 -0800
From: stefan@borgia.com (Stefan Adams)
Subject: Re: my $x = 100 for 1..3 why is $x undef
Message-Id: <dcc927de.0303110839.54bc4a66@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>
>
> Eh? Shouldn't $x be 100? What is the trick here?
>
> NOTE: I 'use strict', and $x is not a reserved (globally defined) variable.
> So I think 'scoping' is not the problem.
>
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.
Stefan
------------------------------
Date: Tue, 11 Mar 2003 11:23:32 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: my $x = 100 for 1..3 why is $x undef
Message-Id: <Xns933B7E0E06707sdn.comcast@216.166.71.239>
-----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.
- --
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+bhuPY96i4h5M0egRAj6GAKCJiO2xDDMYQmwvMKNqvtnvthUVrACfWFv9
nnUUIQbc2oD7nA3ZrogqkXo=
=11bc
-----END PGP SIGNATURE-----
------------------------------
Date: Tue, 11 Mar 2003 17:40:17 +0000
From: "Peter A. Krupa" <pkrupa@redwood.rsc.raytheon.com>
Subject: Re: Newbie: Extract info from MSI
Message-Id: <3E6E1F81.5040907@redwood.rsc.raytheon.com>
ActiveState has a module that may do what you want:
http://aspn.activestate.com/ASPN/Perl/Reference/Products/PDK/PerlMSI/PerlMSI.html
------------------------------
Date: Tue, 11 Mar 2003 11:19:17 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: perl to strip high-end ASCII
Message-Id: <Pine.LNX.4.53.0303111110320.10286@lxplus067.cern.ch>
On Tue, Mar 11, Jürgen Exner inscribed on the eternal scroll:
> Sean W. Ellis wrote:
> > Was wondering if there was a quick and dirty way to strip high-end
> > ASCII from a text file?
>
> Please define high-end ASCII.
This kind of loose terminology is, I suspect, rated to cause even more
confusion now that Perl natively supports Unicode. But I think we
might show a little more sympathy for folks who have picked-up this
inappropriate terminology from somewhere, possibly through no fault of
their own. I would translate the term in the question as 'some 8-bit
character code or other which has ASCII in its first 128 positions';
often it turns out to be Windows-1252 (bizzarely denoted 'ANSI'[1]
by its vendor, although there's no such ANSI specification), or
sometimes DOS CP-437.
I think workable practical answers have already been posted, so I'll
stop there.
best regards
[1] "the terms ANSI and USA are registered trademarks of the Microsoft
Corporation" -quoted without further comment from A.Prilop.
------------------------------
Date: Tue, 11 Mar 2003 16:49:38 GMT
From: "Piersante Sestini" <sestini-antispam-@unisi.it>
Subject: perl, popfile & os/2
Message-Id: <Csoba.40315$pG1.972204@news1.tin.it>
Is anybody successfully running the portable version of popfile 0.18.1 in
os/2?
Here, when retrieving mail through popfile, Netscape mail gives an
"error writing file", and the perl window get stuck in a
Watchcat-resistant mode (needs reboot to close), after showing these
errors:
Premature end of base64 data at Classifier/MailParse.pm line 1087, <MSG>
line 46.
Premature padding of base64 data at Classifier/MailParse.pm line 1087,
<MSG> line 46.
I am running perl 5.8.0. Testperl reports no problems except a bad
"locale" (it defaults to "C", which should work anyway).
It is not a mailserver problem, as popfile for windows works well with
the same server. Could be perl issue?
Thanks,
Piersante
------------------------------
Date: Tue, 11 Mar 2003 06:32:39 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: printing a file to a webpage
Message-Id: <Xns933B4CBE54FEDsdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Chris Lowth <please@no.spam> wrote in
news:Ywhba.60$KM4.37@newsfep3-gui.server.ntli.net:
> #! /usr/bin/perl
> print "Content-type: text/plain\n";
> print "\n";
> open(FILE, "< messages.txt");
> while (<FILE>) { print; }
> close(FILE);
> exit 0;
Or, slightly fancier and more efficient: (again, no err checking)
#!/usr/bin/perl
print "Content-type: text/plain\n\n";
{
open FILE, "< messages.txt";
local $/;
print <FILE>;
close FILE;
}
- --
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
iD4DBQE+bddXY96i4h5M0egRAsGOAJoDB0g0Elz5hhUr2vCvcbU4t5wUhACY+xRO
gjdFHe2mpWUJiDPpr9II4A==
=bwVo
-----END PGP SIGNATURE-----
------------------------------
Date: 11 Mar 2003 18:39:27 +0100
From: Harald Anlauf <anlauf@hep.tu-darmstadt.de>
Subject: pstruct/c2ph on current Linux/gcc-3/glibc platforms?
Message-Id: <ub3cltn6pc.fsf@heplix4.ikp.physik.tu-darmstadt.de>
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.
With gcc-3, I apparently need to specify CFLAGS='-g -S -gstabs' in order
to be able to get any results at all. However, there are still some
problems left.
Examples: on some header files, I receive messages of the type:
% pstruct CFLAGS='-g -S -gstabs' /usr/include/a.out.h
can't grok stab for nlist ((1,3)=u4n_name:(1,4)=*(0,2),0,32;n_next:(1,5)=*(1,2),0,32;n_strx:(0,3),0,32;;,0,32;n_type:(0,11),32,8;n_other:(0,2),40,8;n_desc:(0,8),48,16;n_value:(0,5),64,32;;) in line nlist:T(1,2)=s12n_un:(1,3)=u4n_name:(1,4)=*(0,2),0,32;n_next:(1,5)=*(1,2),0,32;n_strx:(0,3),0,32;;,0,32;n_type:(0,11),32,8;n_other:(0,2),40,8;n_desc:(0,8),48,16;n_value:(0,5),64,32;;
at /usr/bin/pstruct line 1077, <> line 33.
...
On other files, it apparently cannot extract appropriate types, as in:
% pstruct CFLAGS='-g -S -gstabs' /usr/include/dirent.h |tail -8
struct dirent {
_Bool dirent.d_ino 0 4
dirent.d_off 4 4
short unsigned int dirent.d_reclen 8 2
unsigned char dirent.d_type 10 1
char dirent.d_name[256][256] 11 256
}
If anyone has solved these problems, please let me know!
--
Ciao,
-ha
------------------------------
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 4694
***************************************