[15686] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3099 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 19 14:12:45 2000

Date: Fri, 19 May 2000 11:10:26 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <958759825-v9-i3099@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 19 May 2000     Volume: 9 Number: 3099

Today's topics:
    Re: HELP: how to compile (when necessary) a module down (Eric Liao)
    Re: HELP: how to compile (when necessary) a module down (Eric Liao)
    Re: matching question(s) nobull@mail.com
    Re: need starting point: manipulating graphics aaronp@removeme-shore.net
    Re: Newbie to hash. (HELP) <apage.net[remove]@usa.net>
    Re: Opening a file from another server (David Efflandt)
    Re: Parse::RecDescent problem, $::RD_TRACE showing some (Randal L. Schwartz)
    Re: Parsing a mail digest (Gwyn Judd)
    Re: Problem with classes and autoload <mark.anderson@libertymutual.com>
    Re: problems with compilation... (David Efflandt)
    Re: Q: children, signals, etc... (Elliot Finley)
    Re: Q: children, signals, etc... (Bart Lateur)
    Re: Q: children, signals, etc... (Bart Lateur)
    Re: Q: Reading from STDIN, pipe first, then keyboard nobull@mail.com
    Re: Q: Reading from STDIN, pipe first, then keyboard (Pascal Haakmat)
    Re: Q: Reading from STDIN, pipe first, then keyboard (David Efflandt)
    Re: Q: Reading from STDIN, pipe first, then keyboard (Pascal Haakmat)
    Re: Question on references... (David Combs)
    Re: re-evaluation (newbie) nobull@mail.com
    Re: re-evaluation (newbie) <uri@sysarch.com>
    Re: Return Codes <pheuvel@optusnet.com.au>
    Re: Return Codes <Luc-Etienne.Brachotte@wanadoo.fr>
    Re: rounding numbers <sariq@texas.net>
    Re: SNMP via Perl (brian moore)
        sorting a list of mixed numbers and text as in perldoc (Gwyn Judd)
    Re: split a list of number equally <iltzu@sci.invalid>
        Using several remote shell commands in print FILEHANDLE <m.abramowski@ic.ac.uk>
    Re: Using user-variables in external commands? II <flavell@mail.cern.ch>
        What is the CPAN module repository (url) name that can  (Eric Liao)
        Win32::OLE - Error message <a.tietje@flynet.de>
    Re: Windows on windows <lauren_smith13@hotmail.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 19 May 2000 10:07:55 -0500
From: ekliao@mediaone.net (Eric Liao)
Subject: Re: HELP: how to compile (when necessary) a module downloaded from CPAN
Message-Id: <3925580e.1929053@news1.newscene.com>

glauber:

this is what i did:

1. go to the dir where the makefile.pl for this module
(unicode-string) is.
2. perl Makefile.PL
results: a file called makefile is generated.
3. make
results: error message: Makefile:731: *** missing separator.  Stop.

My perl flavor is the standard perl for win32 from activestate.  build
522 (5.005).  

Any idea why the makefile failed?  Thanks.

eric

On Thu, 18 May 2000 15:10:10 -0700, glauber
<glauber.ribeiroNOglSPAM@experian.com.invalid> wrote:

>In article <3924650c.23742339@news1.newscene.com>,
>ekliao@mediaone.net (Eric Liao) wrote:
>>I need help on how to compile a CPAN module and put it under
>the right
>>place in local machine's (NT) win32 perl installation.
>[...]
>
>
>If you got it from CPAN, it should have a file called
>Makefile.PL. Run it, like this:
>perl Makefile.PL
>
>Now you should have a standard "makefile".
>make
>make test
>make install
>
>
>Problem is, unless you have compiled the Perl you are using
>(that is, you didn't download the binary from Activestate), then
>you will have trouble, since you won't have the include files,
>etc, you need.
>
>Many modules are pure perl (no C components). With those, you
>will have no problem.
>
>For users of the Activestate binary, it's often better to use
>the "ppm" utility to download and install precompiled modules
>(when available).
>
>glauber
>
>* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
>The fastest and easiest way to search and participate in Usenet - Free!
>



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

Date: 19 May 2000 10:09:36 -0500
From: ekliao@mediaone.net (Eric Liao)
Subject: Re: HELP: how to compile (when necessary) a module downloaded from CPAN
Message-Id: <392558d6.2128320@news1.newscene.com>

glauber,

btw, the 3 unicode modules i am installing are not available from
activestate.  otherwise life would be easier.  ppm is great.

eric

On Thu, 18 May 2000 15:10:10 -0700, glauber
<glauber.ribeiroNOglSPAM@experian.com.invalid> wrote:

>In article <3924650c.23742339@news1.newscene.com>,
>ekliao@mediaone.net (Eric Liao) wrote:
>>I need help on how to compile a CPAN module and put it under
>the right
>>place in local machine's (NT) win32 perl installation.
>[...]
>
>
>If you got it from CPAN, it should have a file called
>Makefile.PL. Run it, like this:
>perl Makefile.PL
>
>Now you should have a standard "makefile".
>make
>make test
>make install
>
>
>Problem is, unless you have compiled the Perl you are using
>(that is, you didn't download the binary from Activestate), then
>you will have trouble, since you won't have the include files,
>etc, you need.
>
>Many modules are pure perl (no C components). With those, you
>will have no problem.
>
>For users of the Activestate binary, it's often better to use
>the "ppm" utility to download and install precompiled modules
>(when available).
>
>glauber
>
>* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
>The fastest and easiest way to search and participate in Usenet - Free!
>



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

Date: 19 May 2000 17:42:47 +0100
From: nobull@mail.com
Subject: Re: matching question(s)
Message-Id: <u9n1lm1ofs.fsf@wcl-l.bham.ac.uk>

"W Kemp" <bill.kemp@wire2.com> writes:

> >   $_="@all_keys";
> 
> 
> I might be wrong, but isn't that an array being evaluated in a scalar
> context?

You are wrong. It is being evaluated in an interpolative context.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 19 May 2000 15:17:26 GMT
From: aaronp@removeme-shore.net
Subject: Re: need starting point: manipulating graphics
Message-Id: <aWcV4.23$Hw2.696@news.shore.net>


 Thanks, GD sounds like it will do the trick. I appreciate the help and
feedback here.


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

Date: Fri, 19 May 2000 11:17:12 -0400
From: "Zowwie" <apage.net[remove]@usa.net>
Subject: Re: Newbie to hash. (HELP)
Message-Id: <siamno6iius127@corp.supernews.com>

Never mind.... I found the solution to the below code.
:(
Stupid me.... Here is the fix:

Here are the two methods I have tried with no luck...
$new_size=$default_text_size {$box_memory_cells[3]}  (No go here...) :(
*If something similar to this would work... That would be great.

Here is the fix:
I forgot to 'chomp' my results before passing it to the above line. :(

chomp $box_memory_cells[3];
$new_size=$default_text_size {$box_memory_cells[3]}

Now... New scalar of $new_size will equal the VALUE of $default_text_size
for what ever KEY was specified in $box_memory_cells[3].

Thanks anyway folks....



Zowwie wrote in message ...
>Howdy all,
>
>I hope someone can assist me with this little problem here.... I have not
>worked with hashes much (as you can tell) and would love some assistance
>here.
>
>Here is my hash assignment:
>
>%default_text_size = (
>                tiny => '5X8',
>                small => '6X12',
>                medium => '7X13', #bold (default)
>                large => '8X16',
>                giant => '9X15', #bold
>                );
>
>Here is some inbound data that contains the word "large".
>$box_memory_cells[3]   (This contains the word "large")
>
>Now... This is what I need to do...
>I must look at $box_memory_cells[3] and determine what word they have tiny,
>small, etc.
>
>Then... I need to take that word, and compare it against the hash so I may
>assign the actual size of large (8X16) to another scalar.
>
>$new_size=$default_text_size {large}  (This one works... But its not what I
>need.
>
>Here are the two methods I have tried with no luck...
>$new_size=$default_text_size {$box_memory_cells[3]}  (No go here...) :(
>*If something similar to this would work... That would be great.
>
>I also tried.....
>foreach $default_box_size (keys %ENV){
>    if ($box_memory_cells[3] eq $key){
>    $new_size=$ENV{$key};
>    }
>}
>
>
>Please post any replies to both the group and my regular email. (remove the
>anti-spam).
>
>Thank you in advance for your time and assistance.
>
>Zowwie
>apage.net@[no_spam]usa.net
>
>
>
>
>
>
>
>--Thank you Mr. Wall!
>
>
>
>




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

Date: 19 May 2000 16:11:56 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Opening a file from another server
Message-Id: <slrn8iapu0.ibl.efflandt@efflandt.xnet.com>

On Fri, 19 May 2000 07:47:37 -0700, Jeff Zucker <jeff@vpservices.com> wrote:
>Franck Lalane wrote:
>> 
>> I have a search engine in perl running for an Intranet.
>> When I create the result list, I must open the files to get the title I will
>> display.
>> Everything works fine with all the files from the server running the script.
>> (I use the physical path related to the server)
>> 
>> The problem is that we have 3 servers, and I can't find the way to call them
>> in Perl.
>
>Look into the LWP (libnet) modules which allow you to access files on
>other servers.

Or if LWP is not on your server type 'perldoc perlipc' and look for the
webget example using IO::Socket.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: 19 May 2000 08:26:44 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Parse::RecDescent problem, $::RD_TRACE showing something very odd.
Message-Id: <m1bt228ssr.fsf@halfdome.holdit.com>

>>>>> "Omri" == Omri  <ocschwar@NOSPAM.mit.edu> writes:

Omri> It's only there because if it isn't I get this error message:

Omri> Can't find string terminator "}" anywhere before EOF at www/decss.pl
Omri> line 33.

That probably means that the "brace balancer" is confused for the q{}
string.  Try using a here-doc instead.  The odds of you having
\nYOUR_END_TAG\n in the midst of your string are a lot less than you
having unbalanced { and }, as you apparently have. :)

-- 
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: Fri, 19 May 2000 16:52:18 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Parsing a mail digest
Message-Id: <slrn8idgpu.tkm.tjla@thislove.dyndns.org>

I was shocked! How could Bernard El-Hagin <woofer@thenut.eti.pg.gda.pl>
say such a terrible thing:
>#!/blah/blah/blah/perl -w
>use strict;

<snip>

>-----------------
>What this does is create an array @headers of which each element is
>a seperate header and it creates the array @bodies which contains only
>one line (the first line of the first header). Could someone please tell
>me what I'm doing wrong?

Difficult to say since the script you provided wouldn't compile under
"use strict". This suggests that you typed it in rather than copy and
pasted it therefore any bugs I saw in that script were probably
unrelated to the actual program.

-- 
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
There's nothing like a good dose of another woman to make a man appreciate
his wife.
		-- Clare Booth Luce


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

Date: 19 May 2000 15:24:33 GMT
From: "Mark Anderson" <mark.anderson@libertymutual.com>
Subject: Re: Problem with classes and autoload
Message-Id: <01bfc1a6$d93c41c0$bc15b393@n0003171>

I tried the subroutine stubs with no luck. After playing around some more,
I determined that it was the Exporter that was getting in the way. I had
included my methods in the @EXPORT and that caused the different behaviour.
Once I removed that, everything worked fine.

Mark



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

Date: 19 May 2000 16:30:07 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: problems with compilation...
Message-Id: <slrn8iar03.ibl.efflandt@efflandt.xnet.com>

On Fri, 19 May 2000 10:56:25 GMT, Mat <matthebraveone@yahoo.com> wrote:
>
>I have traced a recent discussion regarding compiling perl scripts.
>However I don't see any alternative, cause the script has to be run at
>several different locations without perl installed and with no
>possibility to do it. I am using perlcc.exe on WinNT and what I get
>after
>running this program is:
>
>--------------------------------------------------------------------------------
>
>Compiling obs.pl:
>--------------------------------------------------------------------------------
>
>Making C(obs.pl.c) for obs.pl!
>C:\Perl\bin\Perl.exe -IC:/Perl/lib -IC:/Perl/site/lib -I. -MB::Stash -c
>obs.pl
>C:\Perl\bin\Perl.exe -IC:/Perl/lib -IC:/Perl/site/lib -I.
>-MO=C,-l2000,-umain,-uDB,-uWin32,-uattributes obs.pl
>Starting compile
>Walking tree
>Prescan
>Saving methods
>Bootstrap attributes obs.pl
>Writing output
>Loaded B
>Loaded IO
>Loaded Fcntl
>obs.pl syntax OK
>Compiling C(obs) for obs.pl!
>C:\Perl\bin\Perl.exe -IC:/Perl/lib -IC:/Perl/site/lib -I.
>C:\TEMP/obs.pl.tst
>Couldn't open C:TEMP/obs.pl.val

Does C:TEMP look like a correct path?  Maybe you forgot to properly quote
or escape a '\' somewhere.

>cl -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT
>-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX
>-IC:\Perl\lib/CORE -o obs obs.pl.c  /link -nologo -nodefaultlib
>-release  -libpath:"C:\Perl\lib\CORE"  -machine:x86
>-libpath:C:\Perl\lib/CORE C:\Perl\lib\CORE\perl56.lib   oldnames.lib
>kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib
>advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib
>wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib
>msvcrt.lib
>The name specified is not recognized as an
>internal or external command, operable program or batch file.
>ERROR: In compiling code for obs.pl.c !
>
>
>What do I do wrong? Is there any possibility to compile a script using
>other programs (free)?

Since compiling a perl script into .exe may make it rather bloated, I
could suggest using something native to the OS you are working with, but
I don't do Windows, and it wouldn't be a Perl answer anyway.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Fri, 19 May 2000 15:55:43 GMT
From: efinley@efinley.com (Elliot Finley)
Subject: Re: Q: children, signals, etc...
Message-Id: <39256359.40389564@news.firstworld.net>

On Fri, 19 May 2000 06:42:28 -0700, Tom Phoenix <rootbeer@redcat.com>
wrote:

>On Fri, 19 May 2000, Elliot Finley wrote:
>
>> are signals reliable in Perl 5.005_03?
>
>Sure, signals are reliable - it's the signal handlers written in Perl that
>are the problem! :-)
>
>Any signal handler written in Perl will, sooner or later, crash. Sometimes
>that's acceptable, sometimes it's a problem. 
>
>> Every time I fork and send an email, the parent process will
>> eventually receive a CHLD signal.
>
>On some systems, you can set $SIG{CHLD} to 'IGNORE' to get the system to
>automatically reap the child. Even if that doesn't happen automatically,
>you may be able to use waitpid() without a signal handler.

So if I set $SIG{CHLD} to 'IGNORE', the parent process will _never_ be
crashed by a CHLD signal?  Is this correct?  

If so, then I can just do a non-blocking waitpid in the mainloop of
the parent every so often to reap the children...
-- 
Elliot (efinley@efinley.com) Weird Science!


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

Date: Fri, 19 May 2000 17:06:26 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Q: children, signals, etc...
Message-Id: <392a7438.12553273@news.skynet.be>

Elliot Finley wrote:

>     I have a long running perl daemon that needs to send emails every
>so often.  I would like to be able to fork and have the child process
>send the email and then exit.
>
>     The first question is: are signals reliable in Perl 5.005_03?
>Every time I fork and send an email, the parent process will
>eventually receive a CHLD signal.

Can't you double-fork? Let the child fork again and exit. There is no
longer a relationship between parent and grandchild, so there shouldn't
be any zombies, withing waiting. 

I hope I got that right, I'm pretty green at this!   :-)

-- 
	Bart.


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

Date: Fri, 19 May 2000 17:09:41 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Q: children, signals, etc...
Message-Id: <392b74f0.12736613@news.skynet.be>

Tom Phoenix wrote:

>Well, it could fork a second child, then exit. The grandchild would be
>reaped by init, but the parent would still get a signal from the first
>child, normally. So, I don't think that's a solution.

Maybe it is. The lifetime of the child is very limited, so the parent
could do a wait() before doing anything else. Pretty safe, I hope.

-- 
	Bart.


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

Date: 19 May 2000 17:14:52 +0100
From: nobull@mail.com
Subject: Re: Q: Reading from STDIN, pipe first, then keyboard
Message-Id: <u9r9ay1pqb.fsf@wcl-l.bham.ac.uk>

p@awacs.dhs.org (Pascal Haakmat) writes:

> I want to write a program that reads data from a pipe on STDIN and then
> prompts for some data from the keyboard. I use 
> 
> undef $/;
> $data = <STDIN>;
> 
> to slurp the data from the pipe, and I use readline() to get input from the
> keyboard.

> I tried closing STDIN and reopening it...

That's should work.  Can you show us how you are doing it? 

> (in all sorts of funny ways, including redirection from and to
> /dev/null),

Where does /dev/null come in?  I thought you wanted to re-open STDIN
on /dev/tty?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 19 May 2000 16:52:40 GMT
From: p@awacs.dhs.org (Pascal Haakmat)
Subject: Re: Q: Reading from STDIN, pipe first, then keyboard
Message-Id: <slrn8iasam.211.p@awacs.dhs.org>

nobull@mail.com wrote:

>p@awacs.dhs.org (Pascal Haakmat) writes:
>
>> I want to write a program that reads data from a pipe on STDIN and then
>> prompts for some data from the keyboard. I use 
>> 
>> undef $/;
>> $data = <STDIN>;
>> 
>> to slurp the data from the pipe, and I use readline() to get input from the
>> keyboard.
>
>> I tried closing STDIN and reopening it...
>
>That's should work.  Can you show us how you are doing it? 

Something like

open(STDIN, "-");

But I realize now why that is wrong.

>> (in all sorts of funny ways, including redirection from and to
>> /dev/null),
>
>Where does /dev/null come in?  

Exasperation :)

>I thought you wanted to re-open STDIN
>on /dev/tty?

That's what I finally resorted to, and it works. I was just about to ask
whether it is actually supposed to work when I saw your reply, so I'll take
it that opening /dev/tty is reasonably well supported. The script isn't
meant to be very portable anyway.

Thanks for the reply!


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

Date: 19 May 2000 17:41:54 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Q: Reading from STDIN, pipe first, then keyboard
Message-Id: <slrn8iav6l.ibl.efflandt@efflandt.xnet.com>

On 19 May 2000 13:41:15 GMT, Pascal Haakmat <p@awacs.dhs.org> wrote:
>
>I want to write a program that reads data from a pipe on STDIN and then
>prompts for some data from the keyboard. I use 
>
>undef $/;
>$data = <STDIN>;
>
>to slurp the data from the pipe, and I use readline() to get input from the
>keyboard. The program is invoked from a shell somewhat like:
>
>echo 'test' | my-program
>
>The problem is that I can no longer read anything from the keyboard after I
>get the data from the pipe -- readline() just returns the undefined value.
>
>I tried closing STDIN and reopening it (in all sorts of funny ways,
>including redirection from and to /dev/null), tried creating two seperate
>scripts, one of them which reads the data from the pipe and then invokes the
>second script which does keyboard interaction, all to no avail.

I could not find a specific example reopening STDIN, but figured it out:


#!/usr/bin/perl
print "Type something, ^D on blank line to continue:\n";

* default STDIN
push @x,<STDIN>;
close STDIN;

# reopen STDIN for keyboard input
open(STDIN,"<&1")  || die "Can't reopen STDIN: $!";
push @x,<STDIN>;
print "\nInputs:\n",@x,"\n";


I just have not figured out how to tell IF you have piped input, so if
not, you have to hit ^D twice.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: 19 May 2000 17:52:22 GMT
From: p@awacs.dhs.org (Pascal Haakmat)
Subject: Re: Q: Reading from STDIN, pipe first, then keyboard
Message-Id: <slrn8iavre.k1.p@awacs.dhs.org>

David Efflandt wrote:

>>I want to write a program that reads data from a pipe on STDIN and then
>>prompts for some data from the keyboard. I use 
>>
>>undef $/;
>>$data = <STDIN>;
>>
>>to slurp the data from the pipe, and I use readline() to get input from the
>>keyboard. The program is invoked from a shell somewhat like:
>>
>>echo 'test' | my-program
>>
>>The problem is that I can no longer read anything from the keyboard after I
>>get the data from the pipe -- readline() just returns the undefined value.
>>
>>I tried closing STDIN and reopening it (in all sorts of funny ways,
>>including redirection from and to /dev/null), tried creating two seperate
>>scripts, one of them which reads the data from the pipe and then invokes the
>>second script which does keyboard interaction, all to no avail.
>
>I could not find a specific example reopening STDIN, but figured it out:
>
>
>#!/usr/bin/perl
>print "Type something, ^D on blank line to continue:\n";
>
>* default STDIN
>push @x,<STDIN>;
>close STDIN;
>
># reopen STDIN for keyboard input
>open(STDIN,"<&1")  || die "Can't reopen STDIN: $!";
>push @x,<STDIN>;
>print "\nInputs:\n",@x,"\n";
>
>
>I just have not figured out how to tell IF you have piped input, so if
>not, you have to hit ^D twice.

Thanks, I will try that. It seems to be a bit more portable than opening
/dev/tty to STDIN.



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

Date: 19 May 2000 16:59:50 GMT
From: dkcombs@netcom.com (David Combs)
Subject: Re: Question on references...
Message-Id: <8g3ru6$2fn$1@slb3.atl.mindspring.net>

In article <39140E4D.C5448EB@mediaone.net>,
PropART  <propart@mediaone.net> wrote:
>I was reading Perl In A Nutshell about creating a reference to an
>anonymous array and was suprised that it wasn't something like $ref =
>\(1,2,3);
>
>Then I did an experiment (below) and looked at perlref.
>
>snip

>Note that taking a reference to an enumerated list is not the same as
>using square brackets--instead it's the same as creating a list of
>references!
>
>    @list = (\$a, \@b, \%c);
>    @list = \($a, @b, %c);      # same thing!
>

Why don't they use (in the doc) the word "distributes",
eg "\ distributes over lists and hashes"?

David



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

Date: 19 May 2000 17:14:27 +0100
From: nobull@mail.com
Subject: Re: re-evaluation (newbie)
Message-Id: <u9snve1pr0.fsf@wcl-l.bham.ac.uk>

Ala Qumsieh <aqumsieh@hyperchip.com> writes:

> nobull@mail.com writes:
> 
> > Ala Qumsieh <aqumsieh@hyperchip.com> writes:
> > 
> > > 	my $number = 1;
> > > 
> > > 	sub mystring { return "test$number" }
> > > 
> > > 	print mystring;
> > > 
> > > 	$number = 2;
> > > 
> > > 	print mystring;
> > 
> > This advice should carry a health warning.  Never do this inside a
> > loop  or subroutine.  It will only work the first time.  Thereafter it
> > will print "test2" every time.
> 
> Not really.

To what are you referring here?  The fact that if you do this in a
loop or subroutine it will only work the first time?  This is real!

> It depends on what you want to do.

Huh?  The need for a product to carry health warning does not depend
on what _you_ do with it.  The _relvance_ to you may depend on what
you want to do.  The the _need_ for the health warning is dependant on
what anybody might think reasonable to do with a product.

> There is nothing wrong with closures, and I think they are a very
> valuable tool.

Pesticides are a valuable tool too - when used properly. They still
carry health warnings. Proper use of closures in Perl means (as a rule
of thumb) subroutine should be anonymous when you are thinking of them as
closures.  Named subroutines should only ever be defined at the
outermost lexical scope of a file unless you know what you are doing.

> Plus, I don't expect somebody to use closures unless they know
> exactly what they are.

Bogus expectaion!  Every subroutine declared in a module that uses
file-scoped lexical variables is acting as a closure.  It is
commonplace for someone to write a perfectly good Perl module
exploiting this fact without being conciously aware of it.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 19 May 2000 17:23:22 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: re-evaluation (newbie)
Message-Id: <x7r9ayfo8l.fsf@home.sysarch.com>

>>>>> "n" == nobull  <nobull@mail.com> writes:


  n> closures.  Named subroutines should only ever be defined at the
  n> outermost lexical scope of a file unless you know what you are
  n> doing.

and the best way to do that (used often in AUTOLOAD code) is to create
an anon sub closure and store its code ref into the typeglob with the
name you want (usually the one that triggered the AUTOLOAD) in the
desired package.

named closures don't seem too useful to me. closures are usually meant
for dynamically creating multiple instances of the same code with
private data in each one.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sat, 20 May 2000 01:25:11 +1000
From: Pat Heuvel <pheuvel@optusnet.com.au>
Subject: Re: Return Codes
Message-Id: <39255CD7.8EA9DF53@optusnet.com.au>

Gday Jeff,

Jeff Zucker wrote:
<...>
> 
> You're redundantly reduplicating your efforts multiple times in a row
> again.  Either use system to run a command or backtics, not both.
> 
Strewth mate, lucky I was sitting down - made me dizzy...

> --
> Jeff

Regards,
Pat


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

Date: Fri, 19 May 2000 19:16:42 +0200
From: Luc-Etienne Brachotte <Luc-Etienne.Brachotte@wanadoo.fr>
Subject: Re: Return Codes
Message-Id: <392576FA.FCAC80B3@wanadoo.fr>



Al Smith a écrit :

> Greetings folks,
>
>    I have what appears be a easy problem but it is complicated to me.
>    I am running a subroutine that runs a system command:
>
> system `/usr/bin/mt -t /dev/rmt/0m rew`
>
> basically it's doing a very basic drive test to see if a tape is in the
> drive. I am tring to figure out how to evaulate the return code then if
> the return code is anything but a 0 to get to a different subroutine.

I you just want to check if a tape is in the drive,
mt status
is quicker than
mt rew
because the second rewinds the tape. The first only "asks" the drive if a
tape is in it.
I choose the first solution in the Perl scripts I wrote on my UNIX servers.





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

Date: Fri, 19 May 2000 10:47:09 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: rounding numbers
Message-Id: <392561FD.63DB5990@texas.net>

Igor wrote:
> 
> Does anyone know how to round numbers to 2 deciaml places in perl?

perldoc -q round

But if you're dealing with currency, *always* use integers.  The decimal
point should only be used for display purposes.

- Tom


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

Date: 19 May 2000 17:18:20 GMT
From: bem@news.cmc.net (brian moore)
Subject: Re: SNMP via Perl
Message-Id: <slrn8iatqs.32i.bem@thorin.cmc.net>

On 19 May 2000 02:54:36 GMT, 
 mcnuttj@missouri.edu <mcnuttj@missouri.edu> wrote:
> Okay, guys, I think I've got a real winner here.
> 
> I'm trying to query a *specific* instance of a *specific* MIB using the
> UCD SNMP perl module (UCD SNMP 4.1.1).
> 
> If I do this:
> 
> ######## BEGIN CODE
> # Create a socket.
> $sess = new SNMP::Session(DestHost => $ip, Community => $comm);
> 
> # This is the MIB to query the layer 2 forwarding table of a switch.
> $mib = 'dot1dTpFdbPort';
> 
> # This is the object used for multi-instance queries.
> $vb = new SNMP::Varbind([$mib]);
> 
> # Set the instance to the decimal equivalent of the MAC address I'm
> # looking for (that's how they're stored in the forwarding table, in
> # numeric order).
> $vb->[$SNMP::Varbind::iid_f] = '8.0.32.47.24.108';
> 
> # Get the next instance of the MIB.
> $var = $sess->getnext($vb);
> ######## END CODE
> 
> If I do all that, what I get is the instance of the MIB that's immediately
> *after* the one I'm looking for.

Well, you did ask for the -next- one.

> Now, the intelligent person would say, "Okay, just subtract one and you'll
> get the one you're looking for."  Nay, not so, my friends.  I *still* get
> the one *after*.  Not until I reduced the *third* octet to less than *10*
> was I able to get the one I was looking for.

Sounds like a sparse table.

> The problem is, I can't make any sense of that.  Therefore, the only
> reliable algorithm I have for searching the forwarding table for an
> arbitrary MAC address is to begin at the beginning and just go until I hit
> the one I want.  This is pretty slow when the table is large.  The idea
> was to speed up this process (sometimes it will have to run over a modem
> link).
> 
> Any ideas?

Sure.

Use '$var = $sess->get($vb);'

-- 
Brian Moore                       | Of course vi is God's editor.
      Sysadmin, C/Perl Hacker     | If He used Emacs, He'd still be waiting
      Usenet Vandal               |  for it to load on the seventh day.
      Netscum, Bane of Elves.


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

Date: Fri, 19 May 2000 16:22:17 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: sorting a list of mixed numbers and text as in perldoc
Message-Id: <slrn8idf1j.tkm.tjla@thislove.dyndns.org>

No question to ask, just something I noticed when foolong round with
sort.

To sort an array called @old of numbers and text according to the perldoc
into an array called @new the epiphany is something along the lines of:

#!/usr/bin/perl
@old = qw(hi low 1 2 3 yo what's up dawg?);

@new = map { $_->[0] }
  sort { $b->[1] <=> $a->[1]
                  ||
         $a->[2] cmp $b->[2]
  } map { [$_, /=(\d+)/, uc($_)] } @old;


print join " ", @old;
print "\n";
print join " ", @new;
print "\n";

The only trouble with this is that it produces a whole bunch of warnings
about undefined variables when run under -w, so with a bit of hacking I
came up with this version which does plus it's (slightly) more
configurable I guess.

#!/usr/bin/perl -w

use POSIX qw(INT_MAX);

@old = qw(hi low 1 2 3 yo what's up dawg?);

# set this to INT_MAX to sort text before numbers or set to 0 to sort
# numbers before text
$text_first = INT_MAX;

@new = map { $_->[0] }
  sort { $b->[1] <=> $a->[1]
                 ||
         $a->[2] cmp $b->[2]
  } map { [$_, m/(\d+)/ ? $1 : $text_first, uc($_)] } @old;

print join " ", @old;
print "\n";
print join " ", @new;

-- 
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
You will lose an important tape file.


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

Date: 19 May 2000 17:53:12 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: split a list of number equally
Message-Id: <958757549.7217@itz.pp.sci.fi>

In article <39241C0D.C25A2EF5@synopsys.com>, Don Byington wrote:
>Does anyone have any Perl 5 code for spliltting a list of numbers into
>two or more lists, where the new lists have a sum that is as close as
>possible?

Is this what you're asking for:

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

  sub mean_idx {
      my ($l, $r, $ls, $rs) = (-1, $#_, 0, 0);
      $ls < $rs ? ($ls += $_[++$l]) : ($rs += $_[$r--]) while $l < $r;
      return $r;
  }

  while (<>) {
      next unless my @foo = split;
      my $idx = mean_idx(@foo);
      print join " " => @foo[0..$idx], "-", @foo[$idx+1..$#foo], "\n";
  }

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Fri, 19 May 2000 17:35:22 +0100
From: Michael Abramowski <m.abramowski@ic.ac.uk>
Subject: Using several remote shell commands in print FILEHANDLE "rsh..."
Message-Id: <39256D49.8DF917BE@ic.ac.uk>

Hi there!

 I have a problem with a current script. The local machine is using
tcsh, the remote machine bash, and I need to refine a script written by
a more experienced former colleague such that a qsub process uses not
the user's remote home directory /home/fred as working directory (as
mentioned in the qsub manual), but /home/fred/tmp (Ultimately, I'll
create a dir with tmp/$$/ as name, so that each job will run in its own
directory).
Although

    rsh -l username 192.168.0.2 'HOME=/home/username/tmp; env'

works fine from an interactive shell, I have trouble using a command
like that in my Perl script, because Perl interprets the ";" as line
end. Is there any way I can combine the three consecutive (print REQ
"rsh -l fred $ip...) lines into one? Because the way it currently works,
the new declaration of QSUB_WORKDIR only affects the line it is written
in. Later lines just assume the original home directory, so that my
output lands there (or not at all; in some versions of this script, it
doesn't even find the input file):

  open REQ, "|qsub -x -eo -rs -r _$jobname-$filename -q $que" or die
"Oops couldn't run qsub !";
  print  REQ "cd \$QSUB_WORKDIR\n";
  print  REQ "rcp $filename.$ext fred\@$ip:tmp/\n";
  print  REQ "rsh -l fred $ip \'export
QSUB_WORKDIR=/home/fred/tmp/\'\n";
  print  REQ "rsh -l fred $ip \"$path$code\" $input $output\n";
  print  REQ "rsh -l fred $ip rm $filename.$ext\n";
  print  REQ "rcp fred\@$ip:$filename.* ./\n";
  print  REQ "rsh -l fred $ip rm $filename.\"*\"\n";
  close REQ;

Is there any way to use multiple commands for an rsh at all? Even
writing \; won't work - it just gives a whole page of error messages.
Or should I post this to a Linux/UNIX newsgroup?
Thanks in advance,
    Michael





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

Date: Fri, 19 May 2000 15:14:14 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Using user-variables in external commands? II
Message-Id: <Pine.GHP.4.21.0005191506430.4238-100000@hpplus01.cern.ch>

On Wed, 17 May 2000, Bernard Cosell wrote:

> On Tue, 16 May 2000 15:30:56 -0700, Tom Phoenix <rootbeer@redcat.com>
> wrote:
> 
> } On Tue, 16 May 2000, Anonymous wrote:
> } 
> } > The question is can contain $body any character?
> } 
> } But I'll point out that a line containing a single dot is significant to
> } some mail-handling programs,...
> 
> Actually, the SMTP spec *forbids* a line with a single-period other
> than to terminate a DATA command.

But relatively few users of email talk raw SMTP protocol directly to a
server!  Any mail client or module should be taking care of such
details, so that the sender need not concern themselves with the
minutiae of the raw protocol.

So we would need to know more about the context of the original
question.  And, as Tom already rightly said (but has been unhelpfully
expunged from the f'up), this isn't a Perl programming issue (at least
not until the questioner comes up with a question about some specific
Perl module, in which case it's presumably ontopic on the
c.l.p.modules group).

  The spec requires that any line in
> the body of the message that begins with a dot must have the dot
> doubled [and the doubled-dot will be changed back to a single-dot by
> the receiving SMTP server].

All of which should be transparent to the end-user.  So, again, it's a
question of context.  From where did the questioner expect to get
$body, and to what software package are they intending to feed it?
It's only if they intend to feed it raw to the SMTP protocol that the
SMTP protocol specification sets the rules of play.

ttfn


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

Date: 19 May 2000 11:44:43 -0500
From: ekliao@mediaone.net (Eric Liao)
Subject: What is the CPAN module repository (url) name that can be used for PPM/VPM?
Message-Id: <392569e9.6500036@news2.newscene.com>

Does it exist?  THanks.

Eric



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

Date: Fri, 19 May 2000 18:26:12 +0100
From: "Axel Tietje" <a.tietje@flynet.de>
Subject: Win32::OLE - Error message
Message-Id: <8g3prk$5v8$1@news10.roka.net>

Hi,

is there anyone out there who knows more about
Win32::OLE than I do? I have some problems with
the objects, methods and properties that can be
used with MS Word. For example: What's wrong
with these lines:

my $s1 = $doc->Styles("Standard");
$word->Selection->({Style => $s1}); # this is line 43

I get the following Error:
'Not a CODE reference at word.pl line 43.'

Could anyone please tell me what's wrong?

TIA, Axel
--
"Way wrong answer!" - B. Willis in Armageddon

FLYnet - FLYer Kommunikationsgesellschaft mbH
Weender Landstr. 46           37073 Göttingen
http://www.flynet.de       a.tietje@flynet.de





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

Date: Fri, 19 May 2000 09:33:59 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Windows on windows
Message-Id: <8g3qej$87r$1@brokaw.wa.com>


Jonathan Stowe <gellyfish@gellyfish.com> wrote in message
news:8g1iom$qrp$1@orpheus.gellyfish.com...
> On Wed, 17 May 2000 12:00:16 -0700 Lauren Smith wrote:
> >
> > Luc-Etienne Brachotte <Luc-Etienne.Brachotte@wanadoo.fr> wrote in
message
> > news:3922E12D.28CFDB43@wanadoo.fr...
> >> I would like to know if it is possible in Perl for win32, to develop a
> >> graphic interface.
> >
> > Look into the Tk modules.
> >
>
> Or possibly the Win32::GUI module if a native look'n'feel is wanted.
>

Has anyone done any work with QT in Perl?  (A cow-orker was showing me some
documentation the other day and it got me curious.)

Lauren




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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3099
**************************************


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