[22456] in Perl-Users-Digest
Perl-Users Digest, Issue: 4677 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 6 18:10:48 2003
Date: Thu, 6 Mar 2003 15:10:14 -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 Thu, 6 Mar 2003 Volume: 10 Number: 4677
Today's topics:
Re: Moving on a grd. <mail@annuna.com>
perlcc error (cl and link) (Krusty)
Re: perlcc error (cl and link) <ian@WINDOZEdigiserv.net>
Re: printing hash values (david)
Re: Problem Implementing Sleep() Function - Need Help <usenet@dwall.fastmail.fm>
Re: Problem Implementing Sleep() Function <s_grazzini@hotmail.com>
Question about Forking & Win32 <extendedpartition@nospam.yahoo.com>
Regular Expressions <bach@nospamworld.com>
Re: Regular Expressions <nobull@mail.com>
Re: Regular Expressions <goldbb2@earthlink.net>
Re: Regular Expressions (Tad McClellan)
Re: Regular Expressions <bach@nospamworld.com>
Re: Regular Expressions <jurgenex@hotmail.com>
Substitution and regex question (Domenico Discepola)
Re: Substitution and regex question <nobull@mail.com>
Re: Substitution and regex question <mpapec@yahoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 06 Mar 2003 16:38:25 -0600
From: Joe Creaney <mail@annuna.com>
Subject: Re: Moving on a grd.
Message-Id: <3E67CDE1.1030804@annuna.com>
I didn't think this file was encoded. But here is the part I am having
trouble with. Can I use nested foreach loops to print out a 2 dim grid.
sub pgrid {
my ($xp,$yp) = @_;
my $l;
my $l1;
my @grd=(
[ qw( . . . . . )],
[ qw( . . . . . )],
[ qw( . . . . . )],
[ qw( . . . . . )],
[ qw( . . . . . )],
);
print "Printing Grid \n";
foreach $l (@grd) {
for ( $l1=0; $l1 >4; $l1++) {
if (($l == $xp) and ($l1 == $yp)) {
print "*"; } else {
print "$grd[$l] [$l1]"; }
print "$l $l1";
}
print "\n";
print "$grd[$l][$l1]";
}
}
Joe Creaney wrote:
> Thanks so much for your help.
>
> ctcgag@hotmail.com wrote:
>
>> Joe Creaney <mail@annuna.com> wrote:
>>
>>
>> You appear to be posting in some MIME or html format (although my
>> reader protects me from it until I try reply. Please don't
>> do that.
>>
>>
>>> I did some work on my idea. My problem is that I want to use a foreach
>>> loop to print out the values of the array @grid. I immagine that I
>>> could get the program to work if I use nested for i = 1 to 5 to print
>>> out the arrays.
>>>
>>> I have been playing with the program and it is realy buggs. I am still
>>> working on it.
>>>
>>> Here is the code:
>>
>>
>>
>> You really, really, should 'use strict;' It would point many of your
>> errors.
>>
>> <snip>
>>
>>
>>> while ($l < 5) {
>>
>>
>>
>> foreach my $l (0..4) {
>>
>>
>>> while ($l1 < 5 ) {
>>
>>
>>
>> foreach my $l1 (0..4) {
>>
>>
>>> if (($l == $xp) and ($l1 == $yp)) {
>>> print "*"; } else {
>>> print "$grd[$l],[$l1]"; }
>>> $l1++;
>>> }
>>
>>
>>
>> Your formatting is weird. The else is more than cuddled, it's coddled!
>> No commas are used between the brackets to access arrays. It's
>> either $grd[$l][$l1] or $grd[$l]->[$l1]. (But in this case, you could
>> just hard code in the ".", since it will never change. Unless of course
>> you plan to add obstacles to grd in the future)
>>
>>
> I am self taught and I often forget or overlook some detailes.
>
>>
>>> print "\n";
>>> $l++;
>>
>>
>>
>> $l1=0;
>>
>> You need to reset $l1 also. (if you used the foreach, you wouldn't
>> need to
>> worry about that.)
>
>
> Is that the case when the program re=accesses the subroutine, the
> variables keep ther values one the function is exited. Can I use a
> foreach loop with both dimentions of an array?
>
>>
>> <snip>
>>
>>> sub move {
>>> my ($mi, $xm, $ym) = @_;
>>> my %mov = (n => [ 0, -1], s => [ 0, 1], e => [1, 0], w => [-1,
>>> 0]); $xm += $mov{$mi[0]};
>>
>>
>> $xm += $mov{$mi}[0];
>>
>> This is the kind of thing strict tells you about.
>>
>> There are more problems (is it $xm or is it $mx?), but I'm
>> bored now. use strict.
>>
> You have been much help. I often get distracted when writing programs
> and loose my train of thought.
>
------------------------------
Date: 6 Mar 2003 13:55:03 -0800
From: danparker276@yahoo.com (Krusty)
Subject: perlcc error (cl and link)
Message-Id: <f4a9a3fc.0303061355.20855837@posting.google.com>
this is the error I get, I'm using active perl for windows.
'cl' is not recognized as an internal or external command,
operable program or batch file.
'link' is not recognized as an internal or external command,
operable program or batch file.
anyone know what's going on?
------------------------------
Date: Thu, 06 Mar 2003 22:57:04 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: perlcc error (cl and link)
Message-Id: <uekf6v002qvav611f99cob1nrsujp6vguu@4ax.com>
Keywords: Remove WINDOZE to reply
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
In a fit of excitement on 6 Mar 2003 13:55:03 -0800,
danparker276@yahoo.com (Krusty) managed to scribble:
> this is the error I get, I'm using active perl for windows.
>
> 'cl' is not recognized as an internal or external command,
> operable program or batch file.
> 'link' is not recognized as an internal or external command,
> operable program or batch file.
>
>
> anyone know what's going on?
cl is the cmdline version of M$VC++ AFAIK. I assume 'link' has
something to do with that too. Either they're not installed, or not
in your %PATH%.
HTH.
Regards,
Ian
-----BEGIN xxx SIGNATURE-----
Version: PGP 8.0
iQA/AwUBPmfSPmfqtj251CDhEQI3kwCfTTgqZowoAFIKbFZRl6Cbqmg0aOEAmgJg
D5F0aL5DPkayVZ09Y/q7vCBL
=6Miq
-----END PGP SIGNATURE-----
--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Scripting, Web design, development & hosting.
------------------------------
Date: 6 Mar 2003 12:51:34 -0800
From: dwlepage@yahoo.com (david)
Subject: Re: printing hash values
Message-Id: <b09a22ae.0303061251.68fe9415@posting.google.com>
Andrew Lee <spamtrap@nowhere.com> wrote in message news:<srme6vko3ai0t4db9vf1u5tj9un583cfft@4ax.com>...
> On 5 Mar 2003 19:22:43 -0800, dwlepage@yahoo.com (david) wrote:
>
> >If I have lexical values:
> >my ($keyname, $keyvalue, $search, $replace);
> >my %uid ();
> >
> >What would be the best way to print the contents of my hash once it
> >has been populated? I am new to perl and am having a hard time
> >visualizing the whole hash concept. Any suggestions?
>
> In addition to the suggestions posted, read the "Data: Hashes
> (Associative Arrays)" section of perlfaq4. perldoc perlfaq4 -- it is a
> 3/4 down the page.
>
> HTH
Great thanks all. Mission accomplished. I think it will take time, but
it does make more sense to be able to visualize this.. At least for
dense folks like myself..
Dave
------------------------------
Date: Thu, 06 Mar 2003 19:07:38 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Problem Implementing Sleep() Function - Need Help
Message-Id: <Xns93368FB5C681Fdkwwashere@216.168.3.30>
DannyBoy <dan4606@hotmail.com> wrote on 06 Mar 2003:
> I'm trying to write a small script that will run another script
> that performs a certain function. I want it to run and then sleep
> for about 120 seconds. so far I've been having problems
> implementing this. I'm using ActivePerl 5.8.0.805. My code looks
> like this:
Why not use the OS to schedule this? WinNT has a "scheduled tasks"
function that is similar to unix cron.
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: Thu, 06 Mar 2003 22:49:32 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: Problem Implementing Sleep() Function
Message-Id: <0gQ9a.76410$ma2.19475092@twister.nyc.rr.com>
DannyBoy <dan4606@hotmail.com> writes:
>
> do `$file`;
do `echo $file`;
(Or just get rid of the backticks.)
--
Steve
------------------------------
Date: Thu, 6 Mar 2003 15:07:22 -0600
From: "Extended Partition" <extendedpartition@nospam.yahoo.com>
Subject: Question about Forking & Win32
Message-Id: <3e67b8cc_1@nntp2.nac.net>
In Linux there are certain programs I can start that fork into the
background and return me to the command prompt. I can then close the console
and the program keeps running. In Windows NT this is probably the same as a
service. But is there anyway to do this under Win32? I am talking about
forking a Perl program into the background in this manner.
Thanks,
Anthony
---
Sick of Spam?
Stop it NOW!!
http://www.safferconsulting.com/spamviper
------------------------------
Date: Thu, 06 Mar 2003 19:37:40 GMT
From: "bach" <bach@nospamworld.com>
Subject: Regular Expressions
Message-Id: <8sN9a.183482$Zr%.73881@news01.bloor.is.net.cable.rogers.com>
Perl noob here.
Can anyone tell me what the following lines do?
<something> = ~s/(\s)+(·)(\s)+/;/g;}
<something2> = split(/\;\s*/, <something>);
<something3> = ~s/\0/\ \&\#183\;\ /g;}
I know that · is a dot '.', but I can't figure out what they're doing
to it.
Thx,
b@
------------------------------
Date: 06 Mar 2003 20:06:01 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Regular Expressions
Message-Id: <u93cm06yxi.fsf@wcl-l.bham.ac.uk>
"bach" <bach@nospamworld.com> writes:
> Can anyone tell me what the following lines do?
Generate compiler errors.
Please show actual code.
Please do not treat the newsgroups as an alternative to reading the
manual.
Read about split and s/// in the manual. If having done so you have
questions then come back and post your questions with real examples to
illustrate them.
No quickly scribbled response will help you as much as RTFM.
> I know that · is a dot '.', but I can't figure out what they're doing
> to it.
No it is not. As far as Perl is concerned it is an ampersand,
followed by a hash, followed by a one, followed by an eight, followed
by...
These characters are not meta in Perl string or regex. They are
special in HTML.
I suspect you have a problem partitioning problem here. You are
confusing the semantics of the data being processed by the Perl code
(an XML or HTML data) with the semantics of the Perl code itself.
Newsgroup comp.lang.perl does not exist (see FAQ). Please do not
start threads there.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 06 Mar 2003 15:25:42 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Regular Expressions
Message-Id: <3E67AEC6.16DD3BC2@earthlink.net>
bach wrote:
>
> Perl noob here.
>
> Can anyone tell me what the following lines do?
> <something> = ~s/(\s)+(·)(\s)+/;/g;}
I doubt that the code was "foo = ~ s/bar/baz/g"
It was much more likely to have been "foo =~ s/bar/baz/g".
That is, it was the =~ operator, not the = operator followed by the ~
operator. Space is important!
That said, your <something> is an l-value (something which is
assignable-to), and the =~ s/// has the effect of altering that l-value
so as to replace all sequences of {one or more whitespace, followed by
"·" followed by one or more whitespace} with ";".
> <something2> = split(/\;\s*/, <something>);
This takes the <something> on the right, and splits it on semicolons
(also discarding any whitespace which happens to be after the
semicolons), and then assigns the list to the <something> on the left.
> <something3> = ~s/\0/\ \&\#183\;\ /g;}
>
> I know that · is a dot '.', but I can't figure out what they're
> doing to it.
The backslashes are just there to confuse you (or because the person who
wrote the code was confused).
Assuming that the code had "=~", not "= ~", then:
This takes <something3>, finds any "\0" chars, and replaces them with
the string " &183; ".
PS:
If the original code really did have "= ~", then...
<something> = ~s/(\s)+(·)(\s)+/;/g;
Takes the $_ variable, performs a substitution on it, then performs a
bitwise negation of the number of substitutions performed, and assigns
to <something> this bitwise negated integer.
Similarly with the other s/// expression.
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: Thu, 6 Mar 2003 14:13:35 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Regular Expressions
Message-Id: <slrnb6favf.7jp.tadmc@magna.augustmail.com>
[ comp.lang.perl is a non-group. Please don't post there. ]
bach <bach@nospamworld.com> wrote:
> Can anyone tell me what the following lines do?
><something> = ~s/(\s)+(·)(\s)+/;/g;}
^
^
><something3> = ~s/\0/\ \&\#183\;\ /g;}
^
^
> I know that · is a dot '.', but I can't figure out what they're doing
> to it.
With those spaces in such a strange place, I don't know either.
Are those spaces there in the real code?
Are the <angle brackets> in the real code?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 06 Mar 2003 22:12:43 GMT
From: "bach" <bach@nospamworld.com>
Subject: Re: Regular Expressions
Message-Id: <vJP9a.185194$Zr%.154617@news01.bloor.is.net.cable.rogers.com>
Dear Brian:
I hope your ego feels a little better after showing off your
holier-than-thou attitude. A "wrong newsgroup for this post" would have
been just fine. "No quickly scribbled response will help you as much as
RTFM." And so won't your feather fluffling.
I think I'll settle for Mr. Golberg's response instead, which is way more
useful than your reply.
P.S. Next time someone makes a mistake, try to be candid in showing them the
right way instead of evangilizing. Trust me, you'll feel better, and people
will want to pay more attention to your gibberish.
b@
"Brian McCauley" <nobull@mail.com> wrote in message
news:u93cm06yxi.fsf@wcl-l.bham.ac.uk...
> "bach" <bach@nospamworld.com> writes:
>
> > Can anyone tell me what the following lines do?
>
> Generate compiler errors.
>
> Please show actual code.
>
> Please do not treat the newsgroups as an alternative to reading the
> manual.
>
> Read about split and s/// in the manual. If having done so you have
> questions then come back and post your questions with real examples to
> illustrate them.
>
> No quickly scribbled response will help you as much as RTFM.
>
> > I know that · is a dot '.', but I can't figure out what they're
doing
> > to it.
>
> No it is not. As far as Perl is concerned it is an ampersand,
> followed by a hash, followed by a one, followed by an eight, followed
> by...
>
> These characters are not meta in Perl string or regex. They are
> special in HTML.
>
> I suspect you have a problem partitioning problem here. You are
> confusing the semantics of the data being processed by the Perl code
> (an XML or HTML data) with the semantics of the Perl code itself.
>
> Newsgroup comp.lang.perl does not exist (see FAQ). Please do not
> start threads there.
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
------------------------------
Date: Thu, 06 Mar 2003 22:32:23 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Regular Expressions
Message-Id: <X%P9a.38963$V42.9348@nwrddc03.gnilink.net>
bach wrote:
> Perl noob here.
>
> Can anyone tell me what the following lines do?
> <something> = ~s/(\s)+(·)(\s)+/;/g;}
>
> <something2> = split(/\;\s*/, <something>);
>
> <something3> = ~s/\0/\ \&\#183\;\ /g;}
They generate several syntax error:
Can't modify <HANDLE> in scalar assignment at C:\tmp\t.pl line 3, near
"s/(\s)+(
·)(\s)+/;/g;"
Unmatched right curly bracket at C:\tmp\t.pl line 3, at end of line
syntax error at C:\tmp\t.pl line 3, near ";}"
Execution of C:\tmp\t.pl aborted due to compilation errors.
> I know that · is a dot '.', but I can't figure out what they're
> doing to it.
They do nothing to it because they cannot be run because the program has
syntax errors.
If you want us to explain something then please post real code, not some
mock-up pseudo-code.
If you use mock-up code then nobody can tell if the problem lies with your
mock-up or with your code.
Besides, interpreting pseudo-code is like reading a crystal ball or coffee
grinds unless you formally define what the file handle <something2> (and all
the other meta notation or not meta notation; who can tell?) means in your
pseudo-code.
jue
------------------------------
Date: 6 Mar 2003 12:40:41 -0800
From: joeminga@yahoo.com (Domenico Discepola)
Subject: Substitution and regex question
Message-Id: <698c67f.0303061240.78ce0edf@posting.google.com>
I'm reading a text file (windows)
Whenever I see four pipes in $_, I want to replace the 4 pipes with a
single \r\n
here's my substitution command:
$_ =~ s/||||/\r\n/g;
Why doesn't this work (I'm using perl for cygwin)? It does not find
the match and my $_ still contains 4 pipes
sample line:
field1|field2||field3||||field1b|field2b
the output should be :
field1|field2||field3
field1b|field2b
but it's not...
Any thoughts?
------------------------------
Date: 06 Mar 2003 20:45:20 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Substitution and regex question
Message-Id: <u9u1eg5in3.fsf@wcl-l.bham.ac.uk>
joeminga@yahoo.com (Domenico Discepola) writes:
> Whenever I see four pipes in $_, I want to replace the 4 pipes with a
> single \r\n
>
> here's my substitution command:
>
> $_ =~ s/||||/\r\n/g;
BTW: why do you tell Perl: "don't act on $_, act on $_ instead"?
> Why doesn't this work (I'm using perl for cygwin)? It does not find
> the match and my $_ still contains 4 pipes
The character | is special in regex. You musescape it as \|
> Any thoughts?
Well as you ask...
I think newsgroups should not be used as an alternative to reference
manuals.
Since you say in your subject line "Substitution and regex question" I
think you should have considered reading the sections of the Perl
manual that explain the Perl substitution operator and the Perl regex
syntax before posting to Usenet.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 06 Mar 2003 21:48:01 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: Substitution and regex question
Message-Id: <mncf6vsgn7vu49t66tmdtreo40u9sms5fu@4ax.com>
X-Ftn-To: Domenico Discepola
joeminga@yahoo.com (Domenico Discepola) wrote:
>I'm reading a text file (windows)
>
>Whenever I see four pipes in $_, I want to replace the 4 pipes with a
>single \r\n
>
>here's my substitution command:
>
>$_ =~ s/||||/\r\n/g;
pipe is metachar in regex so you have to escape it:
s!\|\|\|\|!\r\n!g;
or
s!\Q||||\E!\r\n!g;
or just
s!\Q||||!\r\n!g;
--
$_=$2.$1,s sg s sgmx,$/.=$_,while q mnagdaLrrgysiHgsihgca
ek r=m=~m m(. ) (. ) mmxg;print"There is only one God,$/"
------------------------------
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 4677
***************************************