[24677] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 6839 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 6 00:06:04 2004

Date: Thu, 5 Aug 2004 21:05:08 -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           Thu, 5 Aug 2004     Volume: 10 Number: 6839

Today's topics:
    Re: [OT] Perl Developers Needed for Open-Source ATC! <matthew.garrish@sympatico.ca>
    Re: [OT] Perl Developers Needed for Open-Source ATC! <aquila_deus@yahoo.co.uk>
    Re: Breakpoint on a builtin? (Anno Siegel)
    Re: creating shell scripts using #!/usr/local/env perl <tzz@lifelogs.com>
    Re: creating shell scripts using #!/usr/local/env perl (Randal L. Schwartz)
    Re: Debugger angst (Peter Scott)
    Re: delimited data into nested array (Anno Siegel)
        Failing File Tests? (Jay Sun Ex)
    Re: Failing File Tests? <mritty@gmail.com>
    Re: Failing File Tests? (Randal L. Schwartz)
    Re: Failing File Tests? <junk@blackwater-pacific.com>
    Re: How do I detect if I have incoming data in <STDIN>  ctcgag@hotmail.com
    Re: How do I detect if I have incoming data in <STDIN>  <noreply@gunnar.cc>
        In search of grammars for parsing <newspost@coppit.org>
    Re: Lookuping IP address using four nameservers at the  <nospam@bigpond.com>
        modifying @ISA <a@a.a>
    Re: partially matching a regexp <andrewpalmer@email.com>
        Perl/regex Advice <michaeln@twentyten.org>
    Re: Perl/regex Advice <xx087@freenet.carleton.ca>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 5 Aug 2004 19:37:17 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: [OT] Perl Developers Needed for Open-Source ATC!
Message-Id: <LwzQc.43083$Vm1.959107@news20.bellglobal.com>


"Aquila Deus" <aquila_deus@yahoo.co.uk> wrote in message
news:c5cfac8f.0408050653.2cc054f2@posting.google.com...
> Hi all!
>
> The project MrATC (Air Traffic Control) needs more Perl developers.
> We've done some discussion and begin to code and write doc, but there
> are only 2 developers now (and one is a perl noob - me).
>
> WE NEED YOUR HELP TO BUILD THE WORLD'S NEXT GENERATION OF AIR TRAFFIC
> CONTROL SYSTEM IN PERL!
>

Not to be too discouraging, but have you identified a need for the new
system? (Or more to the point, your system?) Generally one would be working
in cooperation with the major players in the industry on a project of the
magnitude your undertaking (or at least some players). Announcing that no
one is working on your project but you hope some people will sign up is not
the most effective way to garner interest in your project. If you are
serious about this, I would suggest you start by making contacts within the
industry and looking for participation there. Anyone can write code, but
without a detailed and realistic plan you're not going to get off the ground
(sorry, bad joke!).

Matt




------------------------------

Date: Fri, 06 Aug 2004 09:31:28 +0800
From: Aquila Deus <aquila_deus@yahoo.co.uk>
Subject: Re: [OT] Perl Developers Needed for Open-Source ATC!
Message-Id: <r7qlnjbj.fsf@yahoo.co.uk>

**** Post for FREE via your newsreader at post.usenet.com ****

The chimp "Matt Garrish" <matthew.garrish@sympatico.ca> drew:

> "Aquila Deus" <aquila_deus@yahoo.co.uk> wrote in message
> news:c5cfac8f.0408050653.2cc054f2@posting.google.com...
>> Hi all!
>>
>> The project MrATC (Air Traffic Control) needs more Perl developers.
>> We've done some discussion and begin to code and write doc, but there
>> are only 2 developers now (and one is a perl noob - me).
>>
>> WE NEED YOUR HELP TO BUILD THE WORLD'S NEXT GENERATION OF AIR TRAFFIC
>> CONTROL SYSTEM IN PERL!
>>
>
> Not to be too discouraging, but have you identified a need for the new
> system? (Or more to the point, your system?) Generally one would be working
> in cooperation with the major players in the industry on a project of the
> magnitude your undertaking (or at least some players). Announcing that no
> one is working on your project but you hope some people will sign up is not
> the most effective way to garner interest in your project. If you are
> serious about this, I would suggest you start by making contacts within the
> industry and looking for participation there. Anyone can write code, but
> without a detailed and realistic plan you're not going to get off the ground
> (sorry, bad joke!).

Hmmmmm... I'll ask the project's admin (Michael Ross) for that.

But don't we just code for fun? :) 

-- 
me = d2004xx = d2003xx = d2002xx

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 *** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
                      http://www.usenet.com
Unlimited Download - 19 Seperate Servers - 90,000 groups - Uncensored
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


------------------------------

Date: 5 Aug 2004 22:12:45 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Breakpoint on a builtin?
Message-Id: <ceubct$9p9$1@mamenchi.zrz.TU-Berlin.DE>

Ilya Zakharevich  <nospam-abuse@ilyaz.org> wrote in comp.lang.perl.misc:
> [A complimentary Cc of this posting was sent to
> Anno Siegel
> <anno4000@lublin.zrz.tu-berlin.de>], who wrote in article
> <cespo4$5un$1@mamenchi.zrz.TU-Berlin.DE>:
> > Keith NoSpam Arner  <spam.keith.me.arner.not@marconi.com> wrote in
> comp.lang.perl.misc:
> >     # double braces indicate an un-indented block
> >     {{
> >     package CORE::GLOBAL;
> >     use subs 'unlink';
> >     sub unlink { CORE::unlink( @_) }
> >     }}
> 
> Not enough.  One needs to special-case the 0-arguments case.  [See
> Fatal for how to auto-implement this.]

Oh, CORE::unlink() doesn't unlink $_.  Whoda thunk.  Well,

    sub unlink { CORE::unlink( @_ ? @_ : $_) }

then.  Or am I still missing something?

Anno


------------------------------

Date: Thu, 05 Aug 2004 18:22:18 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <4nhdrhcjj9.fsf@lifelogs.com>

On 04 Aug 2004, merlyn@stonehenge.com wrote:

>>>>>> "Ted" == Ted Zlatanov <tzz@lifelogs.com> writes:
> 
> Ted> It should be noted that env will work in ANY shell, not just csh.
> Ted> That makes it a more useful tool than you imply.
> 
> Well, I think I'm trying to imply that it's not needed in *decent*
> shells.  It's needed only in *broken* shells.  Hence, merely
> a workaround for csh's dain-bramage (one of many).

`env -` has already been pointed out.  I also, as a matter of
personal choice, like a tool that works in ANY shell, and the env
syntax is clearer to me than prepending environment vars to the
command line.  TMTOWTDI.

Some of us use and like tcsh, as an example of 'any' shell as
mentioned above.  I would not consider tcsh broken, and neither would
most people.

Sorry for the off-topic posts.

Ted


------------------------------

Date: 05 Aug 2004 16:02:01 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <868yct42ae.fsf@blue.stonehenge.com>

>>>>> "Ted" == Ted Zlatanov <tzz@lifelogs.com> writes:

Ted> Some of us use and like tcsh, as an example of 'any' shell as
Ted> mentioned above.  I would not consider tcsh broken, and neither would
Ted> most people.

<http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/>

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Thu, 05 Aug 2004 22:17:35 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Debugger angst
Message-Id: <3myQc.19038$gE.344@pd7tw3no>

In article <slrnch3222.neh.clint@belle.0lsen.net>,
 Clint Olsen <clint@0lsen.net> writes:
>On 2004-07-30, Peter Scott <peter@PSDT.com> wrote:
>>
>> Which is why I developed the 'y' command which allows you to inspect
>> lexicals at higher stack frames.  perldoc perldebug.
>
>Ok, I managed to get this installed, and here are my thoughts on this:
>
>1) Since 'T' doesn't print out the numbers of the stack frames, I end up
>   using 'wc -l' to calculate my 'uplevel'.  This is really annoying.

Agreed.

>2) This command (and apparently 'X' and 'Y') don't take qualified type
>   names or references to such, just the literal text name.  Why?  So, if I
>   wanted to inspect a multi-level data structure (array, hash, or
>   whatever), I either get all or none of it.  In our case, that was about
>   1/4 mi. of text :)

'y' was intended as an analog to 'V' and 'X', which were already defined as
ways of scanning a package for particular variables.  For inspecting an
arbitrary expression, 'x' is your friend.  Unfortunately, 'x' can't jump
scoping levels.

>3) 'y' and friends don't have a depth limit so you don't get the reams of
>   data mentioned in #2.
>
>On another completely independent gripe:
>
>Why doesn't the perl debugger take File:line input as debug points?  Every
>time I have to type "f Package.pm" and "b lineno", it's very aggravating. 

Agreed, but you can usually set a breakpoint for the subroutine in Package.pm,
or in some other way wait until you get to that file before setting the
breakpoint.  I have wanted the feature you suggest, but not very strongly.
As to 'why', see below.

>Don't get my wrong, 'y' is a big improvement over what I had before -
>zip/nada for peeking at the stack.  I just wanted to point out some usage
>model issues that could use some refinement.
>
>It would be interesting if you could interject on the effort involved on
>any of these points.  I'd even consider trying to add them with my fumble
>fingers if it was feasible.  I either need to do that or get the heck out
>of using Perl. :)

The reason the features you request aren't in the debugger is best explained
by the fact that it is a tortuous mess of incomprehensible code with a creaky
legacy user interface.  Only a few brave souls in recent years have had the
inclination and the courage to attempt to modify it.  I was responsible only
for minuscule modifications.  Most people these days are waiting for Mark
Jason Dominus' rewrite, schedule unknown to me.

If you wanted to attempt any of those changes, the one that might be doable
without encountering insanity in the process is qualifying line number
breakpoints with filenames.  No guarantee, though.

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/


------------------------------

Date: 5 Aug 2004 22:44:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: delimited data into nested array
Message-Id: <ceud89$9p9$2@mamenchi.zrz.TU-Berlin.DE>

Ben Morrow  <usenet@morrow.me.uk> wrote in comp.lang.perl.misc:

> my @lines = do {
>     open my $INFO, '<', $file or die "...";
>     chomp <$INFO>;
> };

Chomp() will tell you it can't "modify <HANDLE>...", and if it could,
it would return the number of characters chomped, not the chomped list.
One could wrap chomp() around the assignment, but I'd probably use an
extra statement.

Anno


------------------------------

Date: 5 Aug 2004 16:11:51 -0700
From: nefarious_6x3@yahoo.co.uk (Jay Sun Ex)
Subject: Failing File Tests?
Message-Id: <135fa1e0.0408051511.5b1abddf@posting.google.com>

I am working on a recursive program that prints out all directories
and files recursively starting from whatever directory is passed to
ARGV[0]. This version of my program is meant for use on windows 2000.
The problem is my program does not capture directories using the if
(-d $blah... file test. Below is my code. Any and all help would be
greatly appreciated.

$root = $ARGV[0];
&recurse($root);
sub recurse {
	opendir DIR, $_[0];
	foreach $file (readdir DIR) {
		if (($file eq ".") or ($file eq "..")) {
			#Do nothing
		} elsif (-d $file) {
			print "\n$file";
			$folder_path = $_[0] . "\\" . $file;
			push @directories, $folder_path;
		} else {
			print "\n$file is not a directory";
		}
	}
	close DIR;
	foreach $newpath (@directories) {
		shift @directories;
		&recurse($newpath);
	}
}


------------------------------

Date: Thu, 5 Aug 2004 19:41:44 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Failing File Tests?
Message-Id: <20040805194010.X4433@barbara.cs.rpi.edu>

On Thu, 5 Aug 2004, Jay Sun Ex wrote:

> I am working on a recursive program that prints out all directories
> and files recursively starting from whatever directory is passed to
> ARGV[0]. This version of my program is meant for use on windows 2000.
> The problem is my program does not capture directories using the if
> (-d $blah... file test. Below is my code. Any and all help would be
> greatly appreciated.
>
> $root = $ARGV[0];
> &recurse($root);
> sub recurse {
> 	opendir DIR, $_[0];
> 	foreach $file (readdir DIR) {
> 		if (($file eq ".") or ($file eq "..")) {
> 			#Do nothing
> 		} elsif (-d $file) {
> 			print "\n$file";
> 			$folder_path = $_[0] . "\\" . $file;
> 			push @directories, $folder_path;
> 		} else {
> 			print "\n$file is not a directory";
> 		}
> 	}
> 	close DIR;
> 	foreach $newpath (@directories) {
> 		shift @directories;
> 		&recurse($newpath);
> 	}
> }


Are you doing this as a learning experience?  If so, the answer is that
readdir returns the filename without the path.  That is, -d is looking for
a file named $file within the current working directory, not the directory
in which it was found.

If you're trying to do this for an actual practical purpose, stop wasting
effort.  It's already been done, in the standard module File::Find.

Paul Lalli


------------------------------

Date: 05 Aug 2004 17:02:17 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Failing File Tests?
Message-Id: <861xil3zhy.fsf@blue.stonehenge.com>

>>>>> "Paul" == Paul Lalli <mritty@gmail.com> writes:

Paul> If you're trying to do this for an actual practical purpose, stop wasting
Paul> effort.  It's already been done, in the standard module File::Find.

Or the bolt-on layers from the CPAN, the older File::Find::Rule,
and my own File::Finder.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Thu, 05 Aug 2004 18:50:18 -0700
From: Steve May <junk@blackwater-pacific.com>
Subject: Re: Failing File Tests?
Message-Id: <10h5otqrjd6uh64@corp.supernews.com>

Paul Lalli wrote:
> On Thu, 5 Aug 2004, Jay Sun Ex wrote:
> 
> 
>>I am working on a recursive program that prints out all directories
>>and files recursively starting from whatever directory is passed to
>>ARGV[0]. This version of my program is meant for use on windows 2000.
>>The problem is my program does not capture directories using the if
>>(-d $blah... file test. Below is my code. Any and all help would be
>>greatly appreciated.
>>
>>$root = $ARGV[0];
>>&recurse($root);
>>sub recurse {
>>	opendir DIR, $_[0];
>>	foreach $file (readdir DIR) {
>>		if (($file eq ".") or ($file eq "..")) {
>>			#Do nothing
>>		} elsif (-d $file) {
>>			print "\n$file";
>>			$folder_path = $_[0] . "\\" . $file;
>>			push @directories, $folder_path;
>>		} else {
>>			print "\n$file is not a directory";
>>		}
>>	}
>>	close DIR;
>>	foreach $newpath (@directories) {
>>		shift @directories;
>>		&recurse($newpath);
>>	}
>>}
> 
> 
> 
> Are you doing this as a learning experience?  If so, the answer is that
> readdir returns the filename without the path.  That is, -d is looking for
> a file named $file within the current working directory, not the directory
> in which it was found.
> 
> If you're trying to do this for an actual practical purpose, stop wasting
> effort.  It's already been done, in the standard module File::Find.
> 
> Paul Lalli

And if you knew about File::Find and just wanted to fiddle....

I tend to use something like the below, thought it might
be of interest to you.

Note that I have been accused of re-inventing the wheel
more than once, but quite often I really *do* want my
wheels to be square. :-)

(tested)

#! /usr/bin/perl -w
use strict;

my $dir = '/home/steve';
finddirs( $dir );

sub finddirs {
         my $dir = shift;
         $dir or return; # rampant paranoia
         $dir =~ m!/?\.{1,2}$! and return; # <- critical
         -d $dir or return;
         print "$dir\n";
         opendir DIR, $dir or die "Can't open $dir: $!\n";
         for( readdir DIR ){ finddirs( "$dir/$_" ); }
         closedir DIR;
}

1;

Comments, constructive or otherwise welcomed.
	
\s


------------------------------

Date: 05 Aug 2004 23:25:06 GMT
From: ctcgag@hotmail.com
Subject: Re: How do I detect if I have incoming data in <STDIN> when I pipe something   to my perl script ?
Message-Id: <20040805192506.702$d1@newsreader.com>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Andreas Berg wrote:
> > I'm writing a script that is supposed to fetch information from
> > <STDIN> that is piped to the script, something like this:
> > > cat file.txt | myscript.pl
> >
> > With this, I will get what I want into <STDIN> and I can read it.
> > But, this is the only case I want to read it. I do not want my
> > script to try to read from a file in case I do have any command
> > line paramters and I do not want the script to wait for keyboard
> > input. If something is piped to the script, I want that data, if
> > nothing is piped to the script, I dont want it to do anything with
> > <STDIN>, how do I accomplish this ?
>
>      unless (eof STDIN) {
>          my $data = do { local $/; <STDIN> };
>          # process data
>      }

On my computer, 'eof STDIN' will, when run without STDIN redirection, block
and wait for one line of user input on STDIN, so it doesn't do what the OP
wants.

In my hands, the file test "-p STDIN" works:

$ perl -le 'print -p STDIN ? "Read STDIN" : "Dont read STDIN";'
Dont read STDIN
$ echo blah | perl -le 'print -p STDIN ? "Read STDIN" : "Dont read STDIN";'
Read STDIN


Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Fri, 06 Aug 2004 02:38:05 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How do I detect if I have incoming data in <STDIN> when I pipe something   to my perl script ?
Message-Id: <2ng2l1FhhetU1@uni-berlin.de>

ctcgag@hotmail.com wrote:
> Gunnar Hjalmarsson wrote:
>> 
>>     unless (eof STDIN) {
>>         my $data = do { local $/; <STDIN> };
>>         # process data
>>     }
> 
> On my computer, 'eof STDIN' will, when run without STDIN
> redirection, block and wait for one line of user input on STDIN, so
> it doesn't do what the OP wants.

Hmm... So it seems.

I tested the code in a CGI context, calling the script with or without
POSTing data, and then it worked. Thought it would work from command
line as well. Obviously not. :(

Thanks!

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: Fri, 06 Aug 2004 00:32:35 GMT
From: David Coppit <newspost@coppit.org>
Subject: In search of grammars for parsing
Message-Id: <Pine.BSF.4.60.0408052030420.44572@www.provisio.net>

Hi all,

I'm writing a code generator that needs to parse a YACC-like input file
(including partially parsing the C/C++ parts of the head and tail
sections), as well as a LEX-like input file.

I figured I would start with existing YACC and LEX grammars, and modify
them to add my new features. Unfortunately, I'm having trouble finding
suitable Perl tools for parsing YACC, LEX, C, and C++. (I know the latter
two are hard--I only need a partial parsing.) Do anyone know where I can
find grammars for these languages?

Here's what my research has uncovered:

== Parsing a YACC file ==

- Parse::Yapp includes YappParse.yp, which partially parses most of a YACC
   grammar. I'd have to modify it to parse the tokens and union
   declaration.
- Parse::RecDescent shows a metagrammar in the POD, but I can't find the
   real thing in the distribution. I could use Parse::RecDescent::Deparse
   to recover it, but this isn't probably advisable and I'm not sure how
   close it is to recognizing a real YACC grammar anyway.

== Parsing a LEX file ==

- I can't find a suitable grammar anywhere. :(

== Parsing C/C++ ==

- I could try Inline::C::ParseRegExp or Inline::C::ParseRecDescent for C,
   and Inline::CPP::grammar for C++.
- PERCEPS (http://starship.python.net/crew/tbryan/PERCEPS/) is a Perl
   header file parser. Not sure how well it would work for the head section
   of a YACC or LEX input file.

In the worst case, both the bison and flex distributions have grammars,
which I could adapt to suitable input for Parse::RecDescent or
Parse::Yapp. But I can't help but think that someone has already done all
this work.

I need to fully parse the YACC and LEX input files, but for the C and C++
code I just need to locate any definitions so that I can move them to an
implementation file and replace them with "extern" declarations. (I'm
generating multiple source files from the YACC/LEX files, instead of the
normal one big implementation file.)

Thanks for the help!
David



------------------------------

Date: Fri, 06 Aug 2004 09:35:33 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Lookuping IP address using four nameservers at the same time.
Message-Id: <2nfui6FhbfbU1@uni-berlin.de>

Tom Regner wrote:

> David K. Wall wrote:
>> Gregory Toomey <nospam@bigpond.com> wrote in message
>> <news:2nefvmFvjjlsU2@uni-berlin.de>:
>> 
>>> Tom Regner wrote:
>>> 
>>>> Facco Eloelo wrote:
>>>> 
>>> 
>>>>> Is there a tool (or just a perl script) which can set four
>>>>> nameservers(or more) *at the same time* to query?
>>>>> 
>>> ....
>>>> foreach (@dnss) {
>>>>     my $res = qx/nslookup -type=A $host $_/;
>>>>     (print $res and exit(0)) if $res;
>>>> }
>>>> 
>>> 
>>> The OP wants the results in parallel. This does it sequentially.
>> 
>> OK, this has little to do with Perl, but can someone explain to me why
>> this makes a difference? Yes, I'm ignorant; that's why I asked. :-)
> 
> I guess because most of the time is spent waiting, that means
> sequentiell:
> 
> time = sum(each process);
> 
> parallel:
> time = max(time(processes));
> 
> so despite the overhead in organizing parallel execution, you might save a
> lot of time.
> 
> kind regards
> Tom

The other issue is that one of the programs may "hang" and not return
anything. This is especially try if you are working with DNS & trying to
diagnose problems.

gtoomey


------------------------------

Date: Fri, 06 Aug 2004 03:09:21 GMT
From: "Gibbering Poster" <a@a.a>
Subject: modifying @ISA
Message-Id: <BDCQc.887$m83.261@newssvr29.news.prodigy.com>

Hey .. i'm playing around with the silly idea (yah I know) of writing a
roguelike in Perl, and had a quick question about dynamic multiple
inheritance.

I have a main IO Handler object called Handler.   When the game is started,
it checks your OS, and returns you an object of class Handler::Win or
Handler::Linux depending on what $^O contains.   So far, so good.

The main Handler super-object contains methods to return objects like
player, map, etc for the child handler, so he can know how to paint the
screen and such.

I've decided that I'd like to be able to subclass the handler on levels
other than the OS.   I'd like to have:

Handler::DungeonMovement
Handler::PlayerCreation
Handler::Inventory
Handler::Prompt
etc....

What I was thinking I would do is morph the object as I needed to change the
handler object.  For instance, When the game starts, the win32 handler adds
Handler::PlayerCreation to its @ISA list so that one can choose
name/class/etc ...  Once that's complete, I was hoping I could remove
Handler::PlayerCreation from the @ISA list, and push on
Handler::DungeonMovement so that the process_key method would know how to
properly interprate the keystrokes to move the player around the dungeon.

I'm having a tough time dynamically modifying the Handler::Win32's @ISA list
for a blessed object instance...

Here's some code that demonstrates a constuctor for the main super Handler
class that will create the proper OS handler, then TRY to immediatly throw
them into 'movement' mode, by trying to twiddle @ISA:

sub new ($$) {
 my ($handler, $mode) = @_;

 if ($^O =~ /win/i) {
  $handler = Handler::Win -> new;
 } else {
  $handler = Handler::Unix -> new;
 }
 if ($mode eq 'movement') {
  push @$handler::ISA => 'Movement';
 }
 return $handler;
}

I KNOW that push line is ridiculously wrong syntactically, but I wanted to
give you an idea of what I was trying to do...
What's the proper syntax to do this, and is the whole architecture lame?

Thanks VERY much in advance for help :)






------------------------------

Date: Thu, 5 Aug 2004 21:57:22 -0500
From: "Andrew Palmer" <andrewpalmer@email.com>
Subject: Re: partially matching a regexp
Message-Id: <HpCQc.3093$zc1.2205@fe40.usenetserver.com>


"Thomas Koenig" <Thomas.Koenig@online.de> wrote in message
news:cettfn$4o9$1@meiner.onlinehome.de...
> Assume I have a regexp, /^(hello)|(goodbye)$/ for example.
>
> I want to see wether a particular string matches part of that
> particular regexp, so "", "h", "he", "hel", "hell", "hello", "g",
> "go", "goo" "good", "goodb", "goodby" and "goodbye" would be ok,
> and anything else wouldn't.
>
> I could hand-craft this example easily enough, but it grows
> tedious and error-prone for more general regular expressions,
> and automation would be much preferred.
>
> Ideas?

Something like:

if(test($input,"hello") || test($input,"goodbye"))
{
 # stuff
}

sub test
{
 my($s1,$s2)=@_;
 for my $len(0..length($s2))
 {
  return 1 if(substr($s2,0,$len) eq $s1);
 }
 return 0;
}





------------------------------

Date: Thu, 5 Aug 2004 15:42:27 -0700
From: "Michael" <michaeln@twentyten.org>
Subject: Perl/regex Advice
Message-Id: <10h5durae1fnn66@corp.supernews.com>

I'm attempting to yank a number out of a web interface and I'm running into
an issue.  I have a solution that works, but it feels so sloppy.  Basically
the output is like this:

 ..HTML..
(value 1 of value 2)
 ..HTML..
(value 3 of value 4)
 ..HTML..
(value 5 of value 6)
 ..HTML..

What I want is "value 6" so what I currently do is split on "(" then I take
the fourth section from the split and split on ")", then I split on " of "
and magically there's my number.

It feels sloppy.  Any ideas on how to do it better?


Michael




------------------------------

Date: 6 Aug 2004 01:15:52 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: Perl/regex Advice
Message-Id: <slrnch5mu8.4bu.xx087@smeagol.ncf.ca>

At 2004-08-05 06:42PM, Michael <michaeln@twentyten.org> wrote:
>  the output is like this:
>  
>  ..HTML..
>  (value 1 of value 2)
>  ..HTML..
>  (value 3 of value 4)
>  ..HTML..
>  (value 5 of value 6)
>  ..HTML..
>  
>  What I want is "value 6" so what I currently do is split on "(" then I take
>  the fourth section from the split and split on ")", then I split on " of "
>  and magically there's my number.

    my @values = $output =~ /\(value (\d+) of value (\d+)\)/sg;
    my $sixth = $values[5];


-- 
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca


------------------------------

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 6839
***************************************


home help back first fref pref prev next nref lref last post