[21777] in Perl-Users-Digest
Perl-Users Digest, Issue: 3981 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 16 14:05:53 2002
Date: Wed, 16 Oct 2002 11:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 16 Oct 2002 Volume: 10 Number: 3981
Today's topics:
Re: [cgi] How to read user file (edvjacek)
Re: [cgi] How to read user file (edvjacek)
Re: [cgi] How to read user file (Helgi Briem)
Re: array of array? <goldbb2@earthlink.net>
Re: attr proposition: function call performed at compil <goldbb2@earthlink.net>
Re: attr proposition: function call performed at compil <occitan@esperanto.org>
Re: attr proposition: function call performed at compil <occitan@esperanto.org>
CGI-related error (Colby)
Controlling recursion depth with File::Find <bik.mido@tiscalinet.it>
Re: defining subroutines on the fly in a module <nobull@mail.com>
Help Reading data in text files <kashmirnospam@bellnet.ca>
Re: Help Reading data in text files <nobull@mail.com>
Re: Installing Modules <invalid@pinnock.com>
Re: New JAPH <ubl@schaffhausen.de>
Re: Perl Memory Management <goldbb2@earthlink.net>
Re: Perl Modules news@roaima.freeserve.co.uk
Re: Read a single character from STDIN (W98) <goldbb2@earthlink.net>
ref() on hash keys <alecler@sympatico.ca>
Regular expressions and newlines <mdudley@execonn.com>
Re: Regular expressions and newlines <nobull@mail.com>
Re: Regular expressions and newlines (Tad McClellan)
Sleeping until another process finishes? (D. Alvarado)
Re: Switching from Python to Perl <nospam1002@joesbox.cjb.net>
Re: Switching from Python to Perl <goldbb2@earthlink.net>
Two questions about File::Find "preprocess" coderef <bik.mido@tiscalinet.it>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Oct 2002 08:17:25 -0700
From: jacek@pc1.ips.lodz.pl (edvjacek)
Subject: Re: [cgi] How to read user file
Message-Id: <2abb9911.0210160717.11155fce@posting.google.com>
Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in message news:<slrnaqqcil.12b.bernard.el-hagin@gdndev25.lido-tech>...
> In article <2abb9911.0210160129.48f22d8d@posting.google.com>, edvjacek
> wrote:
> > Hallo,
> >
> > I have to read normal user file in my cgi script. The directory has
> > 0700 and the file 0600. How can I make?
>
>
> What is your Perl question?
>
>
> Cheers,
> Bernard
This script I write in Perl.
Jacek
------------------------------
Date: 16 Oct 2002 08:19:42 -0700
From: jacek@pc1.ips.lodz.pl (edvjacek)
Subject: Re: [cgi] How to read user file
Message-Id: <2abb9911.0210160719.339e697c@posting.google.com>
"Gregory Toomey" <nobody@nowhere.com> wrote in message news:<Iuar9.54206$g9.156703@newsfeeds.bigpond.com>...
> edvjacek wrote in message
> <2abb9911.0210160129.48f22d8d@posting.google.com>...
> >Hallo,
> >
> >I have to read normal user file in my cgi script. The directory has
> >0700 and the file 0600. How can I make?
> >
> Change to permissions that allow you to read them?
>
> gtoomey
I can't. Another program makes this file one time pro minute.
Jacek
------------------------------
Date: Wed, 16 Oct 2002 16:01:58 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: [cgi] How to read user file
Message-Id: <3dad8cc2.45987286@news.cis.dfn.de>
On 16 Oct 2002 08:19:42 -0700, jacek@pc1.ips.lodz.pl
(edvjacek) wrote:
>"Gregory Toomey" <nobody@nowhere.com> wrote in message news:<Iuar9.54206$g9.156703@newsfeeds.bigpond.com>...
>> edvjacek wrote in message
>> <2abb9911.0210160129.48f22d8d@posting.google.com>...
>> >Hallo,
>> >
>> >I have to read normal user file in my cgi script. The directory has
>> >0700 and the file 0600. How can I make?
>> >
>> Change to permissions that allow you to read them?
>>
>> gtoomey
>
>I can't. Another program makes this file one time pro minute.
Then make the other program or its owner change the
permissions. Presumably, if the owner wants it to be
inaccessible to others, that's what it's supposed to
be. There still is no Perl content here.
If you have control over how the other program is being run,
and you can't to a chmod within it, you can run it via a
batch file that does:
other_program
chmod 755 directory
chmod 644 file
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: Wed, 16 Oct 2002 12:58:44 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: array of array?
Message-Id: <3DAD9AC4.4440489E@earthlink.net>
jackkon wrote:
>
> "Benjamin Goldberg" <goldbb2@earthlink.net> ?????
> news:3DAC4D05.61AC210C@earthlink.net...
> > jackkon wrote:
> > > ========text file
> > > 01 AAAA-F.
> > > 03 AA-ERR PIC S9(05).
> > > 03 AA-FNAME PIC X(10).
> > > 03 AA-COUNT-K PIC 9(10).
> > > 01 AAAA-R.
> > > 03 AA-REC-KEY.
> > > 05 AA-DEPT-NO PIC X(02).
> > > 05 AA-DEPT-MAX PIC X(02).
> > > 03 AA-DEPT-NAME PIC X(12).
> > > 03 AA-BED-NO PIC 9(05).
> > > 03 AA-TOT-BED-NO PIC 9(05).
> > This solution was inspired by both tassilo's and david's solutions,
> > but I believe it to be simpler and more elegant.
> >
> > my @data;
> > while( <DATA> ) {
> > chomp;
> > my ($depth, $hasinfo) = /(\d+) \S+(\s?)/;
>
> I change the line to
> my ($depth, $hasinfo) = /(\d+)(.*)/;
But that would be wrong.
For a line like "01 AAAA-R.", $hasinfo should be false, and for a line
like "05 AA-DEPT-NO PIC X(02).", $hasinfo should be true.
I'm trying to detect whether or not there is a space (and thus, whether
there's extra information on this line, like "PIC ...").
If you change the regex to /(\d+)(.*)/, then $hasinfo will always be
true... which isn't what I want.
> > my $dref = \@data;
>
> What the three lines below mean and do?
> I can't understand it -.-"
> May I ask for you to explain it. Thanks a lot ^^
>
> > $dref = $dref->[-1] for 1 .. ($depth - 1) / 2;
First get the depth ("01", "03", "05"), subtract one and divide by two,
which makes it (0, 1, or 2).
Walk through the data structure to whatever depth is necessary to find
the location to insert the next piece of data.
> > push @$dref, $_;
Push the current line.
> > push @$dref, [] if !$hasinfo;
Make space for the next nested structure, if there is a nested
structure.
> > }
> > [untested]
>
> I test the code, and it works but not what I expect.
What did it produce? What did you expect?
> If I could, I will modify the code to fit my need.
We could help you, if you tell how the results differ from what you
want.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Wed, 16 Oct 2002 13:10:15 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: attr proposition: function call performed at compile time
Message-Id: <3DAD9D77.D674DD85@earthlink.net>
Jay Tilton wrote:
>
> Daniel Pfeiffer <occitan@esperanto.org> wrote:
>
> | sub mysub : begin { ... }
>
> [snip]
>
> | But he can't use
> | it normally, unless calling my function within a BEGIN { ... }.
>
> If the purpose is to make the sub inaccessible after compile-time,
> what would the new attribute buy that couldn't be accomplished with
>
> CHECK{ undef &mysub }
I think that what the OP wants is a property which will magically change
all calls to mysub($x) into things of the form BEGIN{ mysub($x) }.
This could probably be accomplished with a source filter.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Wed, 16 Oct 2002 19:42:51 +0200
From: Daniel Pfeiffer <occitan@esperanto.org>
Subject: Re: attr proposition: function call performed at compile time
Message-Id: <20021016194251.64d97df3.occitan@esperanto.org>
tiltonj@erols.com (Jay Tilton) skribis:
> Daniel Pfeiffer <occitan@esperanto.org> wrote:
> | sub mysub : begin { ... }
> [snip]
> | But he can't use
> | it normally, unless calling my function within a BEGIN { ... }.
> If the purpose is to make the sub inaccessible after compile-time,
> what would the new attribute buy that couldn't be accomplished with
> CHECK{ undef &mysub }
No, no, no! I want it to be accessible. What I want is that any call to mysub implicitly be in a BEGIN { }. This is to be more like sub, which is performed at compile time. And also to save the startlement, when (as I do time and again) the user forgets to call mysub within a BEGIN { }.
Maybe for consistency it should be
sub mysub : BEGIN { ... }
coralament / best Grötens / liebe Grüße / best regards / elkorajn salutojn
Daniel Pfeiffer
--
-- http://dapfy.bei.t-online.de/sawfish/
--
------------------------------
Date: Wed, 16 Oct 2002 19:55:40 +0200
From: Daniel Pfeiffer <occitan@esperanto.org>
Subject: Re: attr proposition: function call performed at compile time
Message-Id: <20021016195540.04c58696.occitan@esperanto.org>
Benjamin Goldberg <goldbb2@earthlink.net> skribis:
> This could probably be accomplished with a source filter.
Haven't come across those (only got 5.8 with SuSE 8.1 last week :-). How do they work?
coralament / best Grötens / liebe Grüße / best regards / elkorajn salutojn
Daniel Pfeiffer
--
-- http://dapfy.bei.t-online.de/sawfish/
--
------------------------------
Date: 16 Oct 2002 10:49:57 -0700
From: yorokobi@sisna.com (Colby)
Subject: CGI-related error
Message-Id: <ef094b21.0210160949.54f463ba@posting.google.com>
I have a CGI script accessing a MySQL DB via DBI, the script executes
almost flawlessly on my home Linux box running Apache 1.3.26 and Perl
5.8.0 (with the usual modules installed and then some :) (The warning
my Linux box gives me is related to the concatenation operator '.')
However, the web host that I've just signed up with (running RH Linux
with Apache 1.3.? and Perl 5.6.1) won't execute my script and returns
the following errors when run from the command line:
_________________________________________
Global symbol "" requires explicit package name at ./myscript.cgi line
60, 70, 90, 108
_________________________________________
I understand that that error usually means that when using '-w' and
'use strict;' that I haven't declared a variable using 'my $varname;'
I don't have a variable that has no name or is "" and so the above
error has really stumped me.
I've gone over the code with a fine-tooth comb as it were, checked for
the usual (missing semi-colons, right parenthesis/curly braces, etc
...) and found nothing amiss. I haven't run the script through the
Perl debugger yet and I am not able to do so on the web hosting
company's server because they don't allow telnet/SSH.
Any ideas folks?
Thanks in advance.
------------------------------
Date: Wed, 16 Oct 2002 17:40:59 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Controlling recursion depth with File::Find
Message-Id: <heuqquccvp7brd877leli9ugd6hru3s8ni@4ax.com>
Is there any easy/preferred way to impose limits to recursion depth
for File::Find::find, as for the -mindepth, -maxdepth parameteres of
the find command?
Have I to count the number of directory separators?
Note: I tried the above parameters with find2perl, but they were not
recognized.
Michele
--
Liberta' va cercando, ch'e' si' cara,
Come sa chi per lei vita rifiuta.
[Dante Alighieri, Purg. I, 71-72]
I am my own country - United States Confederate of Me!
[Pennywise, "My own country"]
------------------------------
Date: 16 Oct 2002 17:50:26 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: defining subroutines on the fly in a module
Message-Id: <u97kginx9p.fsf@wcl-l.bham.ac.uk>
"Keith A. Clay" <novalid@email.oops> writes:
> I have a list of variables separated by a semicolon and are defined in
> the module object ($self->{'USER_VARS'}). Is there a way in a
> subroutine to define each of these with a subroutine that can be called
> like $self->set_user_name.
Its probably better to forget about defining subroutines and just use
the AUTOLOAD mechanism. Anyhow since you ask...
> sub define_sub {
> my ($self)=@_;
> foreach my $tk ( split(':',$self->{'USER_VARS'}) ) {
> my $sname = "set_" . lc($tk);
> my $gname = "get_" . lc($tk);
> <now what I need to do is define subroutines for get and set that are
> object methods (i.e., $self->set_user_name)>
my $set = sub {
# Don't just use the $self from the enclosing scope or else
# set_foo() will always act on the
my $self = shift;
# Do what needs to be done to set attribute $tk
};
{
no strict 'refs';
no warnings 'redefine';
*$sname = $set;
}
Then the same again for $get.
Note: Because methods are properties of the class if any object of
YourClass has ever had a set_wibble() method then the method now
exists for all objects of YourClass.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 16 Oct 2002 12:06:12 -0400
From: "Kashmir" <kashmirnospam@bellnet.ca>
Subject: Help Reading data in text files
Message-Id: <U7gr9.5849$q83.886226@news20.bellglobal.com>
Hi everyone,
I'm unfortunately new to the Perl world. I would like to have your help
in order to read certain values contained in a text file. I am
interested in reading some values like, the time and date contained in
the file (not the time&date of the file generated by the O/S)
I give you an example of the text file:
Start of text file
Header1: doremi
Date: 2002/04/17 12:45:19hrs
Output value: 117
Details // from that point I don't care
Blabla, blabla,blabla,blabla,blabla,blabla,blabla,blabla,blabla,
End of text file
I want to read header1 "doremi", time "12:45:19hrs" and date
"2002/04/17" and the output value "117". If you can give me hints or
module to use, I would appreciate very much. BTW, how can one know when
to use a module and where can I find in plain english explanations of
these modules. Again, I have interest in text strings, date formats,
report generation in a win32 environment.
Thanks,
Kashmir
------------------------------
Date: 16 Oct 2002 18:08:24 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Help Reading data in text files
Message-Id: <u94rbmnwfr.fsf@wcl-l.bham.ac.uk>
"Kashmir" <kashmirnospam@bellnet.ca> writes:
> I'm unfortunately new to the Perl world.
Try a tutorial.
> I would like to have your help
> in order to read certain values contained in a text file. I am
> interested in reading some values like, the time and date contained in
> the file (not the time&date of the file generated by the O/S)
>
> I give you an example of the text file:
> Start of text file
>
> Header1: doremi
> Date: 2002/04/17 12:45:19hrs
> Output value: 117
>
> Details // from that point I don't care
> Blabla, blabla,blabla,blabla,blabla,blabla,blabla,blabla,blabla,
>
> End of text file
>
> I want to read header1 "doremi", time "12:45:19hrs" and date
> "2002/04/17" and the output value "117". If you can give me hints
First you must work out what you want to do is some absolute sense.
Not just an example but an absolute unambigous mental model of what you
want to do.
Then you have to code it.
This has nothing to do with Perl - it is the same in any programming
language.
E.g. from your example I could guess you want to read the bit after
the the last space on the 2nd,3rd and 4th lines of the file.
I could guess you want to read the bit that appears after the string
"Header1: " on the first line to start with that sequence (and so on).
I could guess you want to read the bit that appears after the string
"Header1: " on the _last_ line to start with that sequence (and so on).
my ($header,$time,$output);
while (<>) {
$header = $1 if /^Header1: (.*)/;
$time = $2 if /^Date: (\S+) (.*)/;
$output = $1 if /^Output value: (.*)/;
}
I could guess many things.
Until you can express what you want in unambigously _some_ form you
cannot hope to express it is a specific form (e.g. a Perl script).
> BTW, how can one know when
> to use a module and where can I find in plain english explanations of
> these modules.
That sounds very like FAQ: "What modules and extensions are available
for Perl? What is CPAN? What does CPAN/src/... mean?"
> Again, I have interest in text strings, date formats,
> report generation
What do you mean "again". This is the first time you've mentioned
date formats or report generation.
> in a win32 environment.
If using ActiveState then many CPAN modules are also avialable using
ActiveState's PPM tool.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 16 Oct 2002 16:25:34 +0100
From: "Graeme" <invalid@pinnock.com>
Subject: Re: Installing Modules
Message-Id: <Pxfr9.3042$v_5.224966@newsfep2-win.server.ntli.net>
"Bart Lateur" <bart.lateur@pandora.be> wrote in message
news:3npqqu4ojanetqoibht7bclpf1kn517tjt@4ax.com...
> Graeme wrote:
>
> >I successfully installed the above module but have discovered that
it
> >relies on win32::api which I don't have.
> >I tried to install it but I can't find a precompiled version that
> >works with w2000. I don't have a C compiler so can't use a source
> >version so I'm stuck.
>
> Heh, what? I think I've used Win32::API on W2K before.
>
> You should be able to find a copy on Activestate's repository,
> <http://www.activestate.com/PPMpackages/>, either under "5.6" or
under
> "5.6plus" or from
> <http://www.activestate.com/PPMPackages/zips/6xx-builds-only/>, all
if
> you're using 5.6.x.
>
Thanks Bart.
Having read up on PPM I now have succesfully installed win32-api and
it seems to work fine. No I just got to work out why most of the
SerialPort tests fail!
D:\SerialPort-0.19>test.pl
t/test1.............defined(@array) is deprecated at t/test1.t line
445.
(Maybe you should just omit the defined()?)
t/test1.............NOK 6could not open port com2
t/test1.............dubious
Test returned status 2 (wstat 512, 0x200)
DIED. FAILED tests 6-275
Failed 270/275 tests, 1.82% okay
t/test2.............ok 1/145can't open file: com2_test.cfg at
t/test2.t line 93
t/test2.............dubious
Test returned status 1 (wstat 256, 0x100)
DIED. FAILED tests 2-145
Failed 144/145 tests, 0.69% okay
t/test3.............defined(@array) is deprecated at t/test3.t line
444.
(Maybe you should just omit the defined()?)
t/test3.............NOK 3could not open port com2
t/test3.............dubious
Test returned status 2 (wstat 512, 0x200)
DIED. FAILED tests 3-244
Failed 242/244 tests, 0.82% okay
t/test4.............ok 1/516can't open file: com2_test.cfg at
t/test4.t line 95
t/test4.............dubious
Test returned status 1 (wstat 256, 0x100)
DIED. FAILED tests 2-516
Failed 515/516 tests, 0.19% okay
t/test5.............ok
t/test6.............ok 1/315can't open file: com2_test.cfg at
t/test6.t line 94
t/test6.............dubious
Test returned status 1 (wstat 256, 0x100)
DIED. FAILED tests 2-315
Failed 314/315 tests, 0.32% okay
t/test7.............ok 1/88can't open file: com2_test.cfg at t/test7.t
line 98
t/test7.............dubious
Test returned status 1 (wstat 256, 0x100)
DIED. FAILED tests 2-88
Failed 87/88 tests, 1.14% okay
Failed Test Status Wstat Total Fail Failed List of Failed
----------------------------------------------------------------------
----------
t/test1.t 2 512 275 270 98.18% 6-275
t/test2.t 1 256 145 144 99.31% 2-145
t/test3.t 2 512 244 242 99.18% 3-244
t/test4.t 1 256 516 515 99.81% 2-516
t/test6.t 1 256 315 314 99.68% 2-315
t/test7.t 1 256 88 87 98.86% 2-88
Failed 6/7 test scripts, 14.29% okay. 1572/1749 subtests failed,
10.12% okay.
D:\SerialPort-0.19>
------------------------------
Date: Wed, 16 Oct 2002 17:06:14 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: New JAPH
Message-Id: <aok2jv$gmc$1@news.dtag.de>
Jeff 'japhy' Pinyan wrote:
> Why all that work? You're not changing anything if you get a miss. I'd
> say:
>
> if ("@cur" eq "@list") { print "ok! $i\n" }
Because I only wanted to pay the price of uppercasing $cur[1..3] if I
had to. I know it could have been prettier, but it works.
--
srand 108641088; print chr int rand 256 for qw<J A P H>
------------------------------
Date: Wed, 16 Oct 2002 13:07:29 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Perl Memory Management
Message-Id: <3DAD9CD1.B7D749D6@earthlink.net>
MMichalow wrote:
> Benjamin Goldberg wrote:
> > Michael Carman wrote:
> > [snip]
> > > > Is it sufficient to restart single thread?
> > >
> > > Hmm... dunno. I've never really played with threads.
> >
> > Each thread has it's own malloc arena, created with mmap.
> >
> > When the thread finishes, the entire arena is freed.
>
> That sounds good...
>
> > So yes, letting the thread die and starting a new one in it's place
> > *should* be sufficient. *However*, when you start a new thread, it
> > gets a copy of it's *entire* parent thread's perl interpreter. So,
> > you should have your 'main' thread (the original one which starts
> > with perl in it) really minimal, and load as few modules as it can,
> > and only have the threads it starts load modules, so that if you
> > want to have a thread get restarted, it can tell the main thread to
> > do that (rather than doing it itself, which copies too much info,
> > defeating the purpose).
>
> O.k. I will take account of this. What's about shared variables of the
> main thread? Are they 'copied' to the child threats? I think, they are
> not, are they?
If they are not visible through the main thread, nor are part of the
data that's sent to the main thread from the thread which is trying to
restart itself, then no.
If they are visible through the main thread, then, they are copied,
sortof.
Perl implements sharing through tieing. The object that shared
structures are tied to is in it's own arena -- this doesn't get copied
to the new thread. But the other part of the shared variable -- yes,
this gets copied. Usually that front end part is empty though.
> > PS: Shared arrays leak memory -- I'm not sure whether restarting a
> > thread will decrease this leak. Re-execing perl will clean up
> > leaked data, though :)
>
> Yes, I tripped over this at the beginning. But I found some Thread::*
> Modules, which compensate these behaviour.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Wed, 16 Oct 2002 16:25:10 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: Perl Modules
Message-Id: <mc0koa.oti.ln@moldev.cmagroup.co.uk>
Benling <benlingcai@hotmail.com> wrote:
> I need to port some perl scripts to AS/400. These are the modules
> needed for the scripts. Could someone please let me know where I can
> find the AS/400 downloans for them?
> 1. http://www.perl.com/CPAN-local/modules/by-module/LWP/ (click on
> libwww-perl-5.10.tar.gz module)
> 2. http://www.perl.com/CPAN-local/modules/by-module/MD5/ (click
> on MD5-1.7.tar.gz module)
> 3. http://www.perl.com/CPAN-local/modules/by-module/MIME/ (click
> on MIME-Base64-2.12.tar.gz module)
> 4. http://www.perl.com/CPAN-local/modules/by-module/Net/ (click on
> libnet-1.0704.tar.gz module)
What's wrong with these locations you've provided?
Chris
--
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
------------------------------
Date: Wed, 16 Oct 2002 13:15:27 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Read a single character from STDIN (W98)
Message-Id: <3DAD9EAF.1A14EB8E@earthlink.net>
Nemo Oudeheis wrote:
>
> Thanks for the tip. There are many interesting functions in this
> module, including InputChar.
>
> However, as far as I can discern, it is intended to work in the
> windowing subsystem, not with the "dosbox" STDIN. At least, I don't
> seem to be able to set it up to do this. I tried:
>
> require Win32::Console;
> $CONSOLE = Win32::Console->new();
> $CONSOLE->Select(STD_INPUT_HANDLE);
Try:
use strict;
use warnings;
use Win32::Console;
my $console = Win32::Console->new(STD_INPUT_HANDLE);
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Wed, 16 Oct 2002 13:44:02 -0400
From: Andre <alecler@sympatico.ca>
Subject: ref() on hash keys
Message-Id: <alecler-7F851F.13440216102002@news1.qc.sympatico.ca>
Hiyall, I found this unexpected behavior when attempting to test whether
the keys of a hash are references (5.6.1):
#!perl -w
use strict;
my %h = ('foo', 'bar', [0,1], 0);
for (keys %h) {
print "$_ : ", ref(), "\n";
}
The result is
foo :
ARRAY(0x6649010) :
I would have expected the second line to read,
ARRAY(0x6649010) : ARRAY
OTOH, this works as expected:
my %h = ('foo', 'bar', 0, [0,1]);
for (values %h) {
print "$_ : ", ref(), "\n";
}
Result:
ARRAY(0x6649010) : ARRAY
bar :
Did I miss something? Just curious.
Andre
------------------------------
Date: Wed, 16 Oct 2002 09:46:20 -0400
From: Marshall Dudley <mdudley@execonn.com>
Subject: Regular expressions and newlines
Message-Id: <3DAD6DAC.87C21142@execonn.com>
If you have a line with a \n in it, there seems to be no way to search
the entire line. IE.
$test = "%Line one\nLine two%";
$test =~ /\%(.*)\%/;
print "$1\n";
This will print nothing except the newline in the print statement.
Now according to the documentation the "." does not match with a
newline, so that makes sense.
So I try
$test = "%Line one\nLine two%";
$test =~ /\%([.\n]*)\%/;
print "$1\n";
And that doesn't work either. If I take the \n out of the string, the
first one works, but the second one still does not. To get the second
one to work with that string requires me to replace the [.\n] with a
[\w\s\n]. But I cannot do that because it will still not work if there
is any punctuation in the line.
Is there any way to do a match for all characters, including the \n?
Also, why does the "." not work inside of []?
Thanks,
Marshall
------------------------------
Date: 16 Oct 2002 17:39:21 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Regular expressions and newlines
Message-Id: <u9adlenxs6.fsf@wcl-l.bham.ac.uk>
Marshall Dudley <mdudley@execonn.com> writes:
> If you have a line with a \n in it, there seems to be no way to search
> the entire line.
That is untrue.
> Is there any way to do a match for all characters, including the \n?
There are many
[\S\s]
Or, of course, the . with the /s switch in effect.
> Also, why does the "." not work inside of []?
Because it wouldn't be very useful.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 16 Oct 2002 11:54:01 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Regular expressions and newlines
Message-Id: <slrnaqr6d9.3fm.tadmc@magna.augustmail.com>
Marshall Dudley <mdudley@execonn.com> wrote:
[snip: dot does not match newline]
> So I try
>
> $test = "%Line one\nLine two%";
> $test =~ /\%([.\n]*)\%/;
> print "$1\n";
( I hope this is just an artifact of your test case, and not
in your "real" code. You should never use the dollar-digit
variables unless you have first ensured that the match
succeeded.
)
> And that doesn't work either.
> Is there any way to do a match for all characters, including the \n?
Yes, the s///s option:
if ( $test =~ /\%(.*)\%/s ) {
print "$1\n";
}
Or even without that option:
if ( $test =~ /\%([\w\W]*)\%/ ) {
> Also, why does the "." not work inside of []?
dot is not "meta" in a [character class], it has no special meaning.
In a char class dot means (literal) dot.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 16 Oct 2002 10:36:39 -0700
From: laredotornado@zipmail.com (D. Alvarado)
Subject: Sleeping until another process finishes?
Message-Id: <9fe1f2ad.0210160936.1e3be1cc@posting.google.com>
I know the $pid of another process, and I want my perl script to sleep
until the other process (denoted by $pid) is done. Any ideas?
Thanks, Dave
------------------------------
Date: 16 Oct 2002 17:18:20 GMT
From: Josef Drexler <nospam1002@joesbox.cjb.net>
Subject: Re: Switching from Python to Perl
Message-Id: <aok70s$j43$1@panther.uwo.ca>
Derek Thomson wrote:
> I thought of one other major advantage in favor of Jython. You can
> actually produce Java bytecode from your Python code, or your
> Python/Java hybrid, and then ship it as you would any other Java
> application.
>
> Which means that the end user doesn't even need to know it was written
> in Python in the first place, and they *definitely* do not have to link
> in libperl.so to make it run (which also means *obtaining* a libperl.so
> from somewhere). It just runs exactly as any other Java bytecode would
> on a plain, ordinary JVM. They don't even need Jython! When you
> "package" a Jython application, it automatically works out what Python
> libraries you need and puts the bytecode for those in the Java "jar" file.
>
> It's great stuff, indeed - http://jython.org. I wish there was something
> like it for Perl, but that seems unlikely, given the amount of effort
> involved in implementing Perl entirely in Java.
Would Parrot be able to output Java bytecode? Is Perl5 going to be ported
to Parrot?
My guesses are "yes" and "maybe", so that could be a way of linking Perl
and Java more closely if you need to.
--
Josef Drexler | http://publish.uwo.ca/~jdrexler/
---------------------------------+----------------------------------------
Please help Conserve Gravity | Email address is *valid*.
Stop flipping pancakes. | Don't remove the "nospam" part.
------------------------------
Date: Wed, 16 Oct 2002 13:56:27 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Switching from Python to Perl
Message-Id: <3DADA84B.F61D4A19@earthlink.net>
Derek Thomson wrote:
>
> Derek Thomson wrote:
> > Benjamin Goldberg wrote:
> >
> >> Derek Thomson wrote:
> >> [snip]
> >>
> >>> So, Java. Perl really can't win here, as Python has the amazing
> >>> Jython.
> >>
> >> How does Jython compare to JPL, "Java Perl Lingo"?
>
> [snip list of ways Jython beats out JPL]
>
> I thought of one other major advantage in favor of Jython. You can
> actually produce Java bytecode from your Python code, or your
> Python/Java hybrid, and then ship it as you would any other Java
> application.
Hmm...
Currently, there exists a java->perl6 translator. (Well, it actually
runs javap on a .class file to get java assembler, then turns it into
parrot assembler.)
Perhaps in the future, a perl6->java translator will come to be?
Or rather, a parrot bytecode->java bytecode translator :)
> Which means that the end user doesn't even need to know it was written
> in Python in the first place, and they *definitely* do not have to
> link in libperl.so to make it run (which also means *obtaining* a
> libperl.so from somewhere). It just runs exactly as any other Java
> bytecode would on a plain, ordinary JVM. They don't even need Jython!
Does python have any kind of "eval" operator, which takes a string and
parses and executes it as python code?
If so, I don't see how you could omit Jython from any code which uses
eval.
> When you "package" a Jython application, it automatically works out
> what Python libraries you need and puts the bytecode for those in the
> Java "jar" file.
>
> It's great stuff, indeed - http://jython.org. I wish there was
> something like it for Perl, but that seems unlikely, given the amount
> of effort involved in implementing Perl entirely in Java.
It's unlikely for perl5, yes. But perl6 will probably be able to be
compiled down to java bytecode.
And even for perl5, someone with sufficient tuits might decide to try
and write a B::Java class.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Wed, 16 Oct 2002 17:40:58 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Two questions about File::Find "preprocess" coderef
Message-Id: <gduqqukcv1drmc4pma3up74u8d129c2v4g@4ax.com>
perldoc File::Find yields the following piece of information:
"preprocess"
The value should be a code reference. This code reference is used to
preprocess a directory; it is called after readdir() but before the
loop that calls the wanted() function. It is called with a list of
strings and is expected to return a list of strings. The code can be
used to sort the strings alphabetically, numerically, or to filter
out directory entries based on their name alone.
Now I have two questions:
(1) How does one really use arguments and return values of the
"preprocess" coderef? Can I have an example?
(2) Can there be any issues if I create a subdir (and possibly some
files in it) with "preprocess"? That is would that directory entry
(and the files contained therein) be encountered in subsequent
"wanted" coderefs?
<comment>
FWIM the question originally arised when I had to process all of the
files (of a certain kind) in a directory tree and wanted to make .bak
copies of the original ones.
The problem was that I had some huge directories (500..1000 files
each) and creating bak copies of their files in the same directories
was inefficient (working on W98 fs), no matter which method I used.
I thought of partially increasing the speed by creating a bak subdir
and put copies of the original files in there. BTW: actually I ended
up modifying the files "directly".
</comment>
Michele
--
Liberta' va cercando, ch'e' si' cara,
Come sa chi per lei vita rifiuta.
[Dante Alighieri, Purg. I, 71-72]
I am my own country - United States Confederate of Me!
[Pennywise, "My own country"]
------------------------------
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 3981
***************************************