[24682] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6844 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 7 09:06:50 2004

Date: Sat, 7 Aug 2004 06:05:11 -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           Sat, 7 Aug 2004     Volume: 10 Number: 6844

Today's topics:
    Re: [OT] Perl Developers Needed for Open-Source ATC! (Peter Scott)
        Appending two arrays horizontally <ewijaya@singnet.com.sg.removethis>
    Re: Appending two arrays horizontally <gifford@umich.edu>
    Re: Appending two arrays horizontally <dave@dave.org.uk>
    Re: Breaking out of nested subroutine? (David Combs)
    Re: Creating Excel spreadsheet - Advanced question <null@example.net>
    Re: Dijkstra and Perl (was Re: Breaking out of nested s (David Combs)
    Re: How do I detect if I have incoming data in <STDIN>  <Joe.Smith@inwap.com>
    Re: How do I detect if I have incoming data in <STDIN>  <Joe.Smith@inwap.com>
        How to Delete File Contents (newzguy)
    Re: How to Delete File Contents <1usa@llenroc.ude.invalid>
    Re: How to Delete File Contents <gifford@umich.edu>
    Re: How to Delete File Contents <jurgenex@hotmail.com>
    Re: Input from subprocess called using open() buffered? 510046470588-0001@t-online.de
    Re: Input from subprocess called using open() buffered? <Joe.Smith@inwap.com>
    Re: join on space instead of comma (David Combs)
    Re: join on space instead of comma <tassilo.von.parseval@rwth-aachen.de>
    Re: Kqueue interface module implementation <troc@pobox.com>
    Re: modifying @ISA <Joe.Smith@inwap.com>
        Net::DNS-> About setting more than one nameserver to lo <eloelono1@sina.com>
    Re: Net::DNS-> About setting more than one nameserver t (Michael Fuhr)
    Re: NET::TELNET and displaying output on-screen (Charles DeRykus)
    Re: Perl 6: language has "local" variables (ie "dynamic (David Combs)
    Re: transforming german characters <Joe.Smith@inwap.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 07 Aug 2004 05:31:20 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: [OT] Perl Developers Needed for Open-Source ATC!
Message-Id: <IOZQc.30882$gE.13328@pd7tw3no>

In article <86d6242p5f.fsf@blue.stonehenge.com>,
 merlyn@stonehenge.com (Randal L. Schwartz) writes:
>>>>>> "Peter" == Peter Scott <peter@PSDT.com> writes:
>
>Peter> I've been assuming that this is a practical joke.  Anyone who thinks
>Peter> that Perl is a good choice for creating an *operational* air traffic
>Peter> control system needs their head examined.
>
>It's certainly better than the ancient stuff they're using now.
>
>Besides, if adequately tested, there's nothing with Perl for mission
>critical projects.  I know a lot of people who consider
>ticketmaster.com "mission critical"... especially the folks at
>Ticketmaster.  And that's all mod_perl from top to bottom... all Perl.
>
>So, an ATC system coded in Perl does not scare me in the slightest.

Er, if Ticketmaster makes a mistake people don't die.  The requirements 
that are placed by three-letter agencies on safety-of-life software are
mind-boggling.  Not sure where the full ones are but this looks like a
step in the right direction: 
http://www.fas.org/man/dod-101/sys/ac/equip/ord_nas.htm .

We *are* talking about a system for tracking aircraft through
radar and transponder data and updating multiple distributed
displays in real time plus handing off data between local and
regional centers, right?  I think I'd want real time interrupts
and interrupt priority levels, for a start.  Haven't seen a Perl
interface for those yet.  

It appears to me that the current system exceeds 2 million lines of
Ada, but I could be off; I'm having a hard time finding details.  
Coming up with a Perl equivalent sounds like... a lengthy project.
The government has budgeted several $billion for replacing it but
we can whack off one in our spare time that they'll agree to use?

Or are we talking about something else?  

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


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

Date: Sat, 07 Aug 2004 16:00:57 +0800
From: Edward wijaya <ewijaya@singnet.com.sg.removethis>
Subject: Appending two arrays horizontally
Message-Id: <opsccq7v1a074qab@news.singnet.com.sg>

Hi,

I have this two arrays:

@arr1 = qw(3 2 2 1);
@arr2 = qw(cc dd ff gg);

is there any way I can append this two arrays
so that it becomes

@arr3 = ["3 cc", "2 dd", "3 ff", "1 gg"];

Thanks before hand

Regards
Edward WIJAYA
SINGAPORE


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

Date: 07 Aug 2004 04:09:22 -0400
From: Scott W Gifford <gifford@umich.edu>
Subject: Re: Appending two arrays horizontally
Message-Id: <qszacx7bc99.fsf@asteroids.gpcc.itd.umich.edu>

Edward wijaya <ewijaya@singnet.com.sg.removethis> writes:

> Hi,
> 
> I have this two arrays:
> 
> @arr1 = qw(3 2 2 1);
> @arr2 = qw(cc dd ff gg);
> 
> is there any way I can append this two arrays
> so that it becomes
> 
> @arr3 = ["3 cc", "2 dd", "3 ff", "1 gg"];

Assuming you know in advance they're both the same size:

    my @arr3 = map { join(" ",$arr1[$_],$arr2[$_]) } (0..$#arr1);

This loops from 0 to the last element in @arr1, and for each number
joins the appropriate array elements together with a space.

----ScottG.


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

Date: Sat, 07 Aug 2004 09:51:36 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: Appending two arrays horizontally
Message-Id: <pan.2004.08.07.08.51.35.980098@dave.org.uk>

On Sat, 07 Aug 2004 16:00:57 +0800, Edward wijaya wrote:

> Hi,
> 
> I have this two arrays:
> 
> @arr1 = qw(3 2 2 1);
> @arr2 = qw(cc dd ff gg);
> 
> is there any way I can append this two arrays
> so that it becomes
> 
> @arr3 = ["3 cc", "2 dd", "3 ff", "1 gg"];

@arr3 = map { "$arr1[$_] $arr2[$_}" } 0 .. $#arr1

This assumes that you know the arrays are of equal length.

Dave...




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

Date: Sat, 7 Aug 2004 03:01:51 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: Breaking out of nested subroutine?
Message-Id: <cf1gmv$4hq$1@reader1.panix.com>

In article <bvhug05t5tlk96raii1n9ijnef0iq7d93j@4ax.com>,
Michele Dondi  <bik.mido@tiscalinet.it> wrote:
>On 02 Aug 2004 07:58:23 +0200, 510046470588-0001@t-online.de wrote:
>
>>Michele Dondi <bik.mido@tiscalinet.it> writes:
>>> More precisely it is true that perl has some flavours of C<goto> in
>>> disguise that blend nicely in the syntax of the language, but a "true"
>>> C<goto> disregarding matters of wether it is considered harmful or
>>> not, is first of all aesthetically unpleasant.
>>
>>I couldn't care any less what coding fascists consider as unpleasant.
>   ^^^^^^^^^^^^^^^^^^^^^^
>   ^^^^^^^^^^^^^^^^^^^^^^
>
>Idiot! Don't abuse words you don't have the slightest idea what they
>mean. Were you aware of what you wrote, you should feel as deeply
>humiliated by it as an arrogant beast like you can be.
>
>There's hardly nothing I hate more than fascism, so don't call me
>fascist. Do you know what fascism really is? Ignorance and arrogance,
>mostly. Two "virtues" that you seem to possess in a highly
>concentrated form...
>
>For one thing one of fascists' mottos used to be (and still is, for
>those motherfuckers who still are proud of calling themselves
>fascists) "me ne frego", i.e. "I don't care", just as you "don't
>care", disgusting dumbass: YOU ARE FASCIST!
>
>Fascists do NOT care, since they are both ignorant and arrogant enough
>to elect themselves ...

Oh, I get it -- you're talking about American politics!

David




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

Date: Sat, 07 Aug 2004 04:25:18 GMT
From: Rich Grise <null@example.net>
Subject: Re: Creating Excel spreadsheet - Advanced question
Message-Id: <OQYQc.691$Se2.531@nwrddc01.gnilink.net>

Lance Powers wrote:

> Hi folks,
> 
> I've got a project where I need to retrieve data from a database and
> insert that data into an Excel spreadsheet that can be downloaded or
> streamed to a browser.  I'm using Linux/Apache/Perl (I don't have the
> option of using Windows).
 ...
> 4) What would be ideal is if we could simply append a worksheet to the
> existing templated Excel file without disturbing the existing data
> (graphs, formulas, formatting, etc..).  From what I've seen, this is not
> possible with any of the current perl modules.
> 
> Anybody have any creative solutions?

What about Open Office? It supposedly understands MICRO$~1 files.

Good Luck!
Rich



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

Date: Sat, 7 Aug 2004 02:57:04 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: Dijkstra and Perl (was Re: Breaking out of nested subroutine?)
Message-Id: <cf1ge0$4dn$1@reader1.panix.com>

In article <slrncgted8.i4t.abigail@alexandra.abigail.nl>,
Abigail  <abigail@abigail.nl> wrote:
>Greg Bacon (gbacon@hiwaay.net) wrote on MMMCMLXXXIX September MCMXCIII in
><URL:news:10gsekdbaqjrpa1@corp.supernews.com>:
>}}  In article <slrncgoacb.6hs.abigail@alexandra.abigail.nl>,
>}}      Abigail  <abigail@abigail.nl> wrote:
>}}  
>}} : [...]
>}} : BTW, I've no doubt that Mr. Dijkstra would have the same dim opinion
>}} : about Perl as a language as he had for 'goto' as a statement.
>}}  
>}}  I'm sure you're right, but I'd be interested in seeing more about why
>}}  you think so.
>
>
>That's mostly based on memories when I was still doing research at a
>university where a lot of the members of the staff were Dijkstra adepts,

  Cornell?  (David Gries et al were often part of his entourage,
   and I imagine that they also worshiped him as a god.)

>and his (handwritten (!)) notes were faxed, copied and distributed among
>staff members, who were supposed to study them as if it was a gospel. I
>still think that there was a shrine dedicated to him in the small room
>that was always closed.

Years (eons) ago I attended two years of cs summer-schools 
at UC-Santa-Cruz,
4 weeks long, I think it was, and (just about ) *all* the "biggies" 
were there as guest lecturers or ran entire courses.

E.D. was there, complete with entire entourage from both
Amsterdam and Cornell (via Gries).

Dijkstra was of course an extremely smart guy, a genius, even,
and wanted everyone, it seemed, to know it.  

Once I recall him, before class, elaborating on how he rarely
made mistakes, and as an example told us how he developed
as a letter-writer.  

He decided that he was spending far too much time in rewriting,
and in correcting eg spelling errors, so he decided to
switch to indelible ink.  Any mistake, and he had to
rewrite the whole letter.  Soon, he said, he learned
to make *no* errors, *ever*, in letters he wrote --
saying that in much the same voice and with the same
body stance that maybe De Gaulle would have done.

(You get idea?)

Anyway, he was well known for his I-am-a-genius
perceived-by-us attitude.

Now, he had an unusual style of script he used,
quite recognizable, and apparently unique.  Also
well known and commented upon.

Anyway, once (also years ago) I was visiting someone
(maybe hanging-around better describes it), and
on the wall in someone's office, or maybe it was
on his door?, was a page of "Dijkstra-writing"
that was not only in his unique handwriting, but
in his also-unique way of speaking (often, about
himself).

It was a parody, but beautiful, really nailed him.

What was interesting to me was how they got the
handwriting.  Turns out, they had designed a
new postscript font, "Dijkstra", and then written
this parody using it.

Maybe it's still around someone, floating on the net...

Pretty funny stuff!

David




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

Date: Sat, 07 Aug 2004 10:39:52 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: How do I detect if I have incoming data in <STDIN> when I pipe something to my perl script ?
Message-Id: <Yj2Rc.103812$eM2.16983@attbi_s51>

Andreas Berg wrote:

> I do not want the script to wait for keyboard input.

That's different than what you asked the the subject line.

   Q: How can I tell when data becomes available on STDIN?
   A: Use select() checking for input available on file handle 0.
      This is recommended when reading from a TCP/IP socket.

   Q: How can I tell when STDIN is associated with a pipe (or
      redirected from an input file) and not coming from the terminal?
   A: Use the -t() function.

   if (-t) {
      print "Input appears to be from a tty; not reading from it\n";
      @lines = ();
   } else {
      print "Reading from input file or pipe\n"
      @lines = <STDIN>;
   }
   print "Read ",scalar(@lines)," lines\n";

	-Joe


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

Date: Sat, 07 Aug 2004 10:42:09 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: How do I detect if I have incoming data in <STDIN> when I pipe something   to my perl script ?
Message-Id: <5m2Rc.242159$JR4.64066@attbi_s54>

ctcgag@hotmail.com wrote:

> 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

That works for input from a pipe, but not when redirecting input from a file.
The file test "-t STDIN" handles both.
	-Joe


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

Date: 6 Aug 2004 20:38:29 -0700
From: newzguy@ziplip.com (newzguy)
Subject: How to Delete File Contents
Message-Id: <6d7814d4.0408061938.3856e8a4@posting.google.com>

How do I delete a file's content? I don't want it to
append, I want the contents overwritten, how do I
do it?  What I have is:

# Append the fetched data to the local file.

open out, ">>$localfile";
print out $result->content;
close out;

Does the >> have something to do with appending?


thanks


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

Date: 7 Aug 2004 04:13:05 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: How to Delete File Contents
Message-Id: <Xns953E2381C5CAasu1cornelledu@132.236.56.8>

newzguy@ziplip.com (newzguy) wrote in news:6d7814d4.0408061938.3856e8a4
@posting.google.com:

> How do I delete a file's content? I don't want it to
> append, I want the contents overwritten, how do I
> do it?  What I have is:
> 
> # Append the fetched data to the local file.
> 
> open out, ">>$localfile";

open my $out, '>', $localfile or die "Cannot open $localfile: $!";

> print out $result->content;
> close out;
> 
> Does the >> have something to do with appending?

perldoc -f open


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

Date: 07 Aug 2004 00:15:47 -0400
From: Scott W Gifford <gifford@umich.edu>
Subject: Re: How to Delete File Contents
Message-Id: <qszfz6zbn2k.fsf@asteroids.gpcc.itd.umich.edu>

newzguy@ziplip.com (newzguy) writes:

> How do I delete a file's content? I don't want it to
> append, I want the contents overwritten, how do I
> do it?  What I have is:
> 
> # Append the fetched data to the local file.
> 
> open out, ">>$localfile";

Instead use

    open out, ">$localfile";

See the documentation for open for more information.

----ScottG.


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

Date: Sat, 07 Aug 2004 04:59:48 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to Delete File Contents
Message-Id: <8lZQc.749$Se2.101@nwrddc01.gnilink.net>

newzguy wrote:
> How do I delete a file's content?

Many different ways.
- you could delete the file and then recreate it; however coming to think of
it this would create new file although with the same file name.
- you could open the file for writing and immediately close it again
- ...

>  I don't want it to
> append, I want the contents overwritten, how do I
> do it?  What I have is:
>
> # Append the fetched data to the local file.

You don't want to append but you append?
Mind to explain?

> open out, ">>$localfile";

Ok, you code comforms with the comment, but both of those conflict with your
spec.

> print out $result->content;
> close out;
>
> Does the >> have something to do with appending?

What happened when you read the documentation for the open() function?

jue




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

Date: 06 Aug 2004 23:41:28 +0200
From: 510046470588-0001@t-online.de
Subject: Re: Input from subprocess called using open() buffered?
Message-Id: <87r7qkaqrb.fsf@debian.i-did-not-set--mail-host-address--so-shoot-me>

Brian McCauley <nobull@mail.com> writes:
> 
> Failing that, I Expect (hint, hint) there's something on CPAN you
> could use to allow Perl to fool the other process into thinking its
> output was going to a terminal.


IO::Pty, which comes with IO::Tty

Klaus Schilling


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

Date: Sat, 07 Aug 2004 09:53:07 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Input from subprocess called using open() buffered?
Message-Id: <7E1Rc.259664$Oq2.66162@attbi_s52>

g r a e m e b [at] c a d e n c e [dot] c o m wrote:

open(COMMAND, "$cmd 2>&1 |") || die "Couldn't run command";
> while (<COMMAND>) {
>   print;
> }
> 
> The problem is that the output from the command appears to arrive in 
> chunks (a bit like watching 'tail' on a file which is constantly 
> updating).  It looks as though it's getting buffered until it exceeds a 
> certain threshold, then all coming out at once.

You will see the same symptoms if when running it from the command line.
   bash% cmd 2>&1 | cat

> Is there some way I can read from COMMAND and actually get the output 
> when it appears, rather than when there is a sizable chunk?

Most implementations of stdio buffer output whenever it is directed
to anything other than a tty (or a pty).  Using a pty instead of a pipe
will avoid this behavior.
	-Joe


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

Date: Sat, 7 Aug 2004 04:43:19 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: join on space instead of comma
Message-Id: <cf1ml7$64d$1@reader1.panix.com>

In article <cer6vn$8is$1@mamenchi.zrz.TU-Berlin.DE>,
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:

SNIP


>If you have to extract fields of fixed length at fixed positions,
>the unpack() function is the right tool.  It can extract multiple
>substrings in one step.
>
>"pack" and "unpack" and their formats are a sub-language of its own.
>No-one memorizes all of it, but a few idioms are worth memorizing.
>One is, to extract a substring of length $length at position $pos,
>the unpack template is "@${pos}a$length".  Putting it all together,
>your solution becomes
>
>    chomp( my @lines = <DATA>);
>    for ( @lines ) {
>        my @fields = unpack( '@7a7 @39a10 @63a*', $_);
>        print join( ', ', @fields), "\n";
>    }
>
>Anno


Anno -- what are the *other* pack-unpack idioms you think worth
memorizing?  

I bet lots of people here would like to see what you've got!

Thanks,

David




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

Date: Sat, 7 Aug 2004 11:14:43 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: join on space instead of comma
Message-Id: <2njks4F1ieeaU1@uni-berlin.de>

Also sprach David Combs:

> In article <cer6vn$8is$1@mamenchi.zrz.TU-Berlin.DE>,
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:

>>If you have to extract fields of fixed length at fixed positions,
>>the unpack() function is the right tool.  It can extract multiple
>>substrings in one step.
>>
>>"pack" and "unpack" and their formats are a sub-language of its own.
>>No-one memorizes all of it, but a few idioms are worth memorizing.
>>One is, to extract a substring of length $length at position $pos,
>>the unpack template is "@${pos}a$length".  Putting it all together,
>>your solution becomes
>>
>>    chomp( my @lines = <DATA>);
>>    for ( @lines ) {
>>        my @fields = unpack( '@7a7 @39a10 @63a*', $_);
>>        print join( ', ', @fields), "\n";
>>    }
>>
>>Anno
> 
> 
> Anno -- what are the *other* pack-unpack idioms you think worth
> memorizing?  

Not that I'm Anno, but here's one that I find useful, namely the '/'
construct. The template preceeding the slash is used as a count argument
for the template following the slash:

    # look at the first byte and extract that many
    # bytes after that (3 in this case) 
    # as unsigned characters
    
    my @x = unpack "c/C", "\x03\x00\x01\xff\x03";
    print "@x\n";
    
    __END__
    0 1 255

Note how this can be combined with @:

    my @x = unpack '@2c/C', "\x03\x00\x01\xff\x03";
    print "@x\n",
    __END__
    255

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Sat, 07 Aug 2004 07:07:10 GMT
From: Rocco Caputo <troc@pobox.com>
Subject: Re: Kqueue interface module implementation
Message-Id: <slrnch8vtc.hdf.troc@eyrie.homenet>

On 4 Aug 2004 09:46:25 -0700, U. A. R. Ruirarchzatrea wrote:
> Uri Guttman <uri@stemsystems.com> wrote in message news:<x73c33bigg.fsf@mail.sysarch.com>...
>
>> check out using libevent (at http://monkey.org/~provos/libevent/)
>> instead and wrapping that in perl via xs/swig/inline. that will be more
>> effective in that it gives you /dev/poll, kqueue(2), select(2), poll(2)
>> and epoll(4) support already and with one api wrapper you get all in
>> perl. i would be willing to help out with this as i have written and
>> wrapped event loops and done some (small) xs work (actually in swig).
>> 
>
> Thank you for the advice. I think doing a libevent interface i an
> excellent idea. But I also think that there is still is a need for a
> interface to kqueue, and that is on my list of things to study doing.
> There are actually many event engines written in Perl that could
> benefit from it, such as POE. Doing an engine in Perl has its
> advantages, as it is eisier to understand the code and to improve upon
> it, and there is less chance of memory buffer overflows.

Have a look at the POE::Loop documentation if you're considering
interfacing POE to BSD's kqueue.  For portability's sake, all it really
requires is I/O events and a timeout.

-- 
Rocco Caputo - http://poe.perl.org/


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

Date: Sat, 07 Aug 2004 11:34:37 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: modifying @ISA
Message-Id: <h73Rc.217727$a24.129466@attbi_s03>

Gibbering Poster wrote:

> 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.

That does not make sense, unless you are using code like:
   $key = get_keystroke();
   $handle->a() if $key eq 'a';
   $handle->b() if $key eq 'b';
   $handle->c() if $key eq 'c';

Diddling with @ISA is not the way to handle dispatch tables.

Create a hash with coderefs for each legal letter in PlayerCreation mode.
This will be used to map letters to subroutines.
Create another hash with coderefs for DungeonMovement mode.
Set your command loop to use one or the other depending on which mode
you're in.  The selected hash can be used to determine which command
letters are legal in this mode, and which subroutine to invoke when
a legal letter is seen.

You could push and pop hash references onto an array to have stacked
dictionaries (like Postscript uses).

   @dispatch = \%Help;		# These commands are legal everywhere
   push @dispatch, \%Create;
       ...	# acceptable commands = union of Create + Help;
   pop @dispatch;
   push @dispatch, \%Movement;
	...			# Move around
	push @dispatch, \%Inventory
	   ...	# acceptable commands = union of Inventory + Movement + Help
	pop @dispatch;
	   ...  # acceptable commands = union of Movement + Help
   pop @dispatch;

   sub process_keystroke {
     my $self = shift;
     my $key = shift;
     for my $n (1 .. @dispatch) {
       my $href = $dispatch[-$n];	# Traverse from end to front
       if (defined $href->{$key}) {
         return $href->{$key}($self);	# Invoke appropriate function
       }
     }
     return unknown_command($self,$key);
   }

	-Joe


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

Date: Sat, 07 Aug 2004 20:05:57 +0800
From: eloelo <eloelono1@sina.com>
Subject: Net::DNS-> About setting more than one nameserver to lookup.
Message-Id: <2njuutF1j0v5U1@uni-berlin.de>

I want to use four nameserver to look up a domain's IP.
But why the code below can lookup domain's IP only using one nameserver. 


  #!/usr/bin/perl
  use Net::DNS;
  @ns=('222.33.11.2','223.55.4.3','223.55.4.2','223.55.4.7');

for($i=0;$i<4;$i++)
{
        my $res   = Net::DNS::Resolver->new;
        $res->nameservers($ns[i]);
        my $query = $res->search("www.bdchina.com");

        if ($query)
        {
                foreach my $rr ($query->answer)
                {
                next unless $rr->type eq "A";
                print "$ns[i]---->",$rr->address, "\n";
                }
        }
        else
        {
        warn "$ns[i]---->query failed: ", $res->errorstring, "\n";
        }
}
                                                                              



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

Date: 7 Aug 2004 06:57:30 -0600
From: mfuhr@fuhr.org (Michael Fuhr)
Subject: Re: Net::DNS-> About setting more than one nameserver to lookup.
Message-Id: <4114d1ba$1_2@omega.dimensional.com>

eloelo <eloelono1@sina.com> writes:

> I want to use four nameserver to look up a domain's IP.
> But why the code below can lookup domain's IP only using one nameserver. 

Add "use warnings" to your script and let Perl tell you.  Many
programmers consider "use strict" to be good practice as well.

>   #!/usr/bin/perl
>   use Net::DNS;
>   @ns=('222.33.11.2','223.55.4.3','223.55.4.2','223.55.4.7');
>
> for($i=0;$i<4;$i++)
> {
>         my $res   = Net::DNS::Resolver->new;
>         $res->nameservers($ns[i]);
>         my $query = $res->search("www.bdchina.com");
>
>         if ($query)
>         {
>                 foreach my $rr ($query->answer)
>                 {
>                 next unless $rr->type eq "A";
>                 print "$ns[i]---->",$rr->address, "\n";
>                 }
>         }
>         else
>         {
>         warn "$ns[i]---->query failed: ", $res->errorstring, "\n";
>         }
> }

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/


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

Date: Sat, 7 Aug 2004 03:03:52 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: NET::TELNET and displaying output on-screen
Message-Id: <I2236G.1px@news.boeing.com>

In article <d4376e99.0408061140.1978c947@posting.google.com>,
ZoloftGuy <zoloftguy@myrealbox.com> wrote:
>I'm a newbie to Perl and I am writing a script to telnet in an shut
>off one of our Nortel Contivity VPNs. It works but, I'd like some of
>the activity to display on the screen rather then just in the logs.
>
>Is there anyway to do this? Here is the script. Please tell me if
>there is anything back-asswords about it. Thanks:
>
>$t = new Net::Telnet (Timeout => 30, Prompt => '/[\$]/');
>

$t = new Net::Telnet ( ... , input_log =>\*STDOUT);

(dump_log provides even more detail)

--
Charles DeRykus


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

Date: Sat, 7 Aug 2004 04:26:52 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: Perl 6: language has "local" variables (ie "dynamic" vars)?
Message-Id: <cf1lmc$5s2$1@reader1.panix.com>

In article <fvnqg05gmjpa2aphv60kvor2n0o2bk55fl@4ax.com>,
Michele Dondi  <bik.mido@tiscalinet.it> wrote:
>On 31 Jul 2004 20:42:47 -0400, dkcombs@panix.com (David Combs) wrote:
>
>>Saw dynamic vars in the interpreter-language, but
>>no mention in the perl-6 language.
>>
>>Is it there?  Better, does perl-6 have such a dcl?
>>
>>For when it's needed, is very nice indeed;
>>saves having to write lots of exceptions-code.
>
>I'm not sure if I understand what you mean. AIUI Perl6 will finally
>get rid of the two current mostly orthogonal sets of variables
>(pacakge and lexical). What is now C<local> will be C<temp>. 

Great!   So it'll now be called  "temp".

(I would have preferred "dynamic", which is what common-lisp
calls it, the pre lexical-concept of variable binding used
in pre-common lisps, and still used in emacs-lisp.)

Thanks!

David




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

Date: Sat, 07 Aug 2004 10:04:45 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: transforming german characters
Message-Id: <1P1Rc.103679$eM2.2830@attbi_s51>

Gunnar Hjalmarsson wrote:

> steve_f wrote:
> 
>> I want to transform special German characters to obtain the
>> following variations:
>>
>> groß bräu
>> gross bräu
>> gross braeu

>>     for my $string (@input) {
>>         push @output, $string;
> 
> Here you copy the whole original text to @output ...
> 
>>         if ($string =~ /\xDF/) {
>>             $string =~ s/\xDF/ss/g;
>>             push @output, $string;
> 
> 
> ... and here you *add* the converted string. In the suggestion below, 
> I'm assuming that was a mistake.

As I read it, steve_f wants to output three separate lines for each
line of input that has both sets of characters.
   line 1 = original string.
   line 2 = string after doing just the ss substitution
   line 3 = string after doing ss and all the other substitutions.
If so, adding the converted string with a second and third push is correct.
	-Joe


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

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


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