[19627] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1822 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 26 11:06:01 2001

Date: Wed, 26 Sep 2001 08:05:09 -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: <1001516709-v10-i1822@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 26 Sep 2001     Volume: 10 Number: 1822

Today's topics:
        add to: threads <mb@hgs.at>
    Re: Blank Lines (Ronald Blaschke)
    Re: Creating modules <bart.lateur@skynet.be>
    Re: Help: mail script (WIN) <bill02115@hotmail.com>
    Re: Is there a better way to do this?? <uri@sysarch.com>
        Managing Child Processes (Kevin J. Schmidt)
    Re: MIME::Lite problem (Villy Kruse)
    Re: Not sure what type of cgi script I need! (Snipes)
    Re: Peek and Poke on Perl? <bart.lateur@skynet.be>
    Re: Peek and Poke on Perl? <nospam-abuse@ilyaz.org>
    Re: Peek and Poke on Perl? <gamtci1@mpinet.net>
    Re: Peek and Poke on Perl? <gamtci1@mpinet.net>
    Re: Regular Expression Problem <bcaligari@fireforged.com>
    Re: Single line if Statement <whatever@nevermind.invalid>
    Re: Socket question (Paul Neubauer)
    Re: Socket question <bart.lateur@skynet.be>
    Re: Socket question (Randal L. Schwartz)
    Re: Transforming HTML <oneconcept@yahoo.co.uk>
    Re: Use of 'our' in older perl versions (Randal L. Schwartz)
        What does ||= do ? (Stan Brown)
    Re: What does ||= do ? <bart.lateur@skynet.be>
    Re: What's wrong with this code ? (David Wall)
    Re: who said this? (Kenny McCormack)
    Re: who said this? <miller5286@usenetserver.com>
    Re: Windows2000: CPAN.pm woes <bill02115@hotmail.com>
    Re: Windows2000: CPAN.pm woes <bill02115@hotmail.com>
        Works sometimes - tmadmin (Brian)
        XML::Writer question... how to write output to file? <julius_mong@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 26 Sep 2001 18:00:28 +0200
From: Buchleitner Martin <mb@hgs.at>
Subject: add to: threads
Message-Id: <20010926180028.03d3260b.mb@buntstift.at>

Hi Again !

I read very much about the use of fork.
But i always found examples with servers.

has somebody an example where fork is used
with sockets ?

thanks, martin


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

Date: 26 Sep 2001 15:02:59 GMT
From: TGVCDPVNTLMI@spammotel.com (Ronald Blaschke)
Subject: Re: Blank Lines
Message-Id: <9osqn2$f4igj$1@ID-57488.news.dfncis.de>

On Wed, 26 Sep 2001 22:56:58 +1000, Tintin <tintin@snowy.calculus> wrote:
> > Hi,
> >     I'm trying to read from a file and would like to skip if it's just
> blank
> > line... I've tried it in many different ways but would get me into
> infinite
> > loop.  Any ideas??
[snip]
> while (<>) {
>     next if (/^$/);
>     ...
> }

Maybe you want to skip lines that contain only whitespaces too.
Then try:

 while (<>) {
     next if /^\s*$/;
     ...
 }

-- 


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

Date: Wed, 26 Sep 2001 13:35:01 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Creating modules
Message-Id: <vuk3rtsjg68fjn02o5ltmu31t2evphepqn@4ax.com>

nobull@mail.com wrote:

>> > >+      *{"${callpkg}::EXPORT_OK"} = \@{$arg{EXPORT_OK} || []};
>> > 
>> > This does not do what you think it does.
>> 
>> It's possible that it simply does not do what *you think* he thinks it
>> does.
>> 
>> In particular, if the user passes a string or a glob, then \@$foo will
>> create an arrayref out of it.  I can't think of too many situations when
>> this would be useful, but I don't see a problem with doing it.
>> 
>> Oh, I can sorta think of one... if somebody passes in something other
>> than an arrayref as an argument, doing this will catch that mistake by
>> raising an error.
>
>Yep, Benjamin is bang on.  I often use \@$ref as an assertion to
>raise an error if $ref not an arrayref.


Yuck. If there's an error, the error message will point to this line in
the module, not to the line of the script using the module, as it
should. You ought to be something along the lines of (which only accepts
unblessed array references):

    if(my $ref = $arg{EXPORT_OK}) {
        unless(ref $ref eq 'ARRAY') {
            require Carp;
            Carp::croak("Argument for EXPORT_OK is not an array ref");
        }
    }

Plus, it's not safe. See:

	package Bar;
	use vars '@EXPORT_OK';
	my @x;
	Foo::test(EXPORT_OK => \@x );
	push @x, 'A'..'F';
	print "@EXPORT_OK\n";
	package Foo;
	sub test {
	    my %arg = @_;
	    my($callpkg)= caller;
	    *{"${callpkg}::EXPORT_OK"} = \@{$arg{EXPORT_OK} || []} ;
	}

This prints:

	A B C D E F

So @EXPORT_OK has become an alias to @x! So manipulation of the original
array would result in changing @EXPORT_OK (or @EXPORT, or @ISA,
depending on which variable it's aliased to)!

And if you pass an object (based on an array ref), any reference to
@EXPORT_OK becomes this object!

	Foo::test(EXPORT_OK => bless [], 'Quux' );
	print \@EXPORT_OK;
-->
	Quux=ARRAY(0x1765770)

I fail to see why you want to be this lazy = unsafe.

-- 
	Bart.


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

Date: 26 Sep 2001 09:28:26 -0400
From: bill <bill02115@hotmail.com>
Subject: Re: Help: mail script (WIN)
Message-Id: <9osl5q$21e$1@panix3.panix.com>

In <3BB002BC.80F6B3D4@rochester.rr.com> Bob Walton <bwalton@rochester.rr.com> writes:


>bill wrote:
>> The mail must come from the "usual" SMTP server (i.e. the one used by
>> the usual mail program when mail is sent from the machine in
>> question).
>...
>> bill

>Well, when it comes to SMTP servers, there really isn't a "usual" SMTP
>server associated with a given machine.

For example, I use Emacs's RMAIL for all my mail from Unix.  I never
specify an SMTP server, even when I install Emacs for the first time
in a machine.  Emacs somehow finds out what SMTP server to use when
sending my mail, so I figured it must be able to get that information
from the OS somehow.

bill


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

Date: Wed, 26 Sep 2001 14:38:26 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Is there a better way to do this??
Message-Id: <x7zo7i9fus.fsf@home.sysarch.com>

>>>>> "MJD" == Mark Jason Dominus <mjd@plover.com> writes:

  MJD> In article <MPG.161af23bd6d5049c9897a8@news.edmonton.telusplanet.net>,
  MJD> Carlos C. Gonzalez  <aperlprogrammer@yahoo.com> wrote:
  >> David Hilsee at davidhilseenews@yahoo.com said...
  >>> 
  >>> If you don't like a lot of action in your if clauses, then take the action
  >>> out.
  >>> 
  >>> %data = found('jacky@ardvark.com');
  >>> if ( not %data )...
  >>> 
  >> 
  >> Thanks David.

  MJD> You can get rid of the 'not':
  MJD>         %data = found('jacky@ardvark.com');
  MJD>         if (%data) {
  MJD>           print $data{email_address};
  MJD>         } else {
  MJD>           print "Nothing there!\n";
  MJD>         }

  MJD> Under the circumstances, I think this is better than Uri's suggestion
  MJD> of 'unless'.

if i have both clauses of a condition, i would usually use if and change
the order to remove a 'not'. but the OP didn't show the clauses so i
assumed one and unless works best then IMO. in fact i was touting unless
in another thread and someone smacked himself saying that he keeps
forgetting about it. :)

so my rules are use if when you have both clauses which do real work and
order them so the test doesn't need 'not'.

if one clause is flow control, make the condition into a modified
statement (if/unless) and the main clause code loses its braces and
indents. 

i find the fewer braces and less indents, the clearer and easier to read
the code. of course that rule can be pushed too hard as well. balance is
key to good style.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


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

Date: 26 Sep 2001 07:30:31 -0700
From: kschmidt@mindspring.com (Kevin J. Schmidt)
Subject: Managing Child Processes
Message-Id: <92541e99.0109260630.4fd24747@posting.google.com>

I have a Perl application that spawns multiple children at once
(anywhere from 1 to 100 or more). Each child exec's a binary
application, which in turn writes log data to several files, i.e. each
child writes to several log files via this binary application. The
parent then goes into an infinite loop and process the data the all
its children are logging to these log files. Now, my code works just
fine if each child gets to the point where it can exec the binary.
Each child does a check before it exec's to see if the device that it
needs to talk to is up. If the device isn't up, then it exits. If any
of the children exit, i.e. they never exec, the parent waits forever
and never makes it to the infinite loop for data processing.

I've been reading the newsgroups and have found some good information,
but am unable to get this hanging problem fixed with the right
combination of wait, waitpid, and $SIG{CHLD} code. The basic structure
of my code is as follows:

foreach $device (sort keys %devices) {
    unless($child = fork) {
        # child
        some_func();
        exit;
    }
}

# parent
while(1) {

    # Parent processes log files created by its children
}

Obviously I left out the calls to wait, waitpid, etc., mainly because
I'm not sure if I have them in the right places or not. To recap, I'm
trying to do the following:

1. fork many children from the parent (this works)
2. the parent doesn't care if any children die (exit). It should
continue processing as normal, i.e. make it to its infinite loop (this
doesn't work)
3. if a child does die, the parent needs to be made aware of that and
re-fork a new child. The parent needs to somehow get a hold of the PID
of the dead child, since a specific child is responsible for getting
log data from a single host. I create a hash of PID to host mappings,
and I need to make sure that the new child knows which host to talk
to.

If anyone can help me with numbers 2 and 3, I would greatly appreciate
it.

Thanks,
-Kevin

Summary of my perl5 (revision 5.0 version 6 subversion 0)
configuration:
  Platform:
    osname=linux, osvers=2.2.5-22smp, archname=i386-linux
    uname='linux porky.devel.redhat.com 2.2.5-22smp #1 smp wed jun 2
09:11:51 edt 1999 i686 unknown '
    config_args='-des -Doptimize=-O2 -march=i386 -mcpu=i686 -Dcc=gcc
-Dcccdlflags=-fPIC -Dinstallprefix=/usr -Dprefix=/usr
-Darchname=i386-linux -Dd_dosuid -Dd_semctl_semun -Di_db -Di_ndbm
-Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Uuselargefiles'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=undef 
    use64bitint=undef use64bitall=undef uselongdouble=undef
usesocks=undef
  Compiler:
    cc='gcc', optimize='-O2 -march=i386 -mcpu=i686', gccversion=2.96
20000731 (experimental)
    cppflags='-fno-strict-aliasing'
    ccflags ='-fno-strict-aliasing'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define,
longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=4
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldl -lm -lc -lcrypt
    libc=/lib/libc-2.1.92.so, so=so, useshrplib=false,
libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef,
ccdlflags='-rdynamic'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl): 
  Compile-time options:
  Built under linux
  Compiled at Aug  7 2000 10:59:51
  @INC:
    /usr/lib/perl5/5.6.0/i386-linux
    /usr/lib/perl5/5.6.0
    /usr/lib/perl5/site_perl/5.6.0/i386-linux
    /usr/lib/perl5/site_perl/5.6.0
    /usr/lib/perl5/site_perl


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

Date: 26 Sep 2001 13:44:02 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: MIME::Lite problem
Message-Id: <slrn9r3mt2.ecd.vek@pharmnl.ohout.pharmapartners.nl>

On 26 Sep 2001 09:00:08 -0400,
    bill <bill02115@hotmail.com> wrote:


>  < pdf attachment >
>
>Everything works fine, including the attachment, but, at the receiving
>end, the e-mail (as presented by Eudora) shows an unsightly header of
>directives, like this:
>
>  Content-Disposition: inline
>  Content-Length: 326
>  Content-Transfer-Encoding: binary
>  Content-Type: text/plain
>
>  Dear Dr. Foo:
>
>  < etc. >
>



What do you get if you ask MIME::Lite to print out the message instead
of mailing it?



Villy


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

Date: 26 Sep 2001 07:38:02 -0700
From: pilotsnipes@yahoo.com (Snipes)
Subject: Re: Not sure what type of cgi script I need!
Message-Id: <ae7dfa3b.0109260638.6c2dc7bf@posting.google.com>

marc@oscar.eng.cv.net (Marc Spitzer) wrote in message news:<slrn9r203i.1671.marc@oscar.eng.cv.net>...

> > Anyone with any suggestions? Thank you for your time and I appreciate
> > your help!
> > 
> 
> gnu mailman might fit the bill, with a little work.
> 

Marc, thanks for the suggestion, looking into it.


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

Date: Wed, 26 Sep 2001 13:09:00 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Peek and Poke on Perl?
Message-Id: <4kk3rt0n100lg2h3lfngkm789uqcjvscns@4ax.com>

Gary wrote:

>Why would this be a "surefire" way to get it to crash?  In order
>for the OS to communicate with the monitor card (A000 thru B000),
>the hard drive (often in C000), many ethernet boards (C000 or D000
>or E000), and even the BIOS (F000), it would have to have mapped 
>addresses within these spaces and it must use them constantly.

The OS can be trusted. It should be well debugged, and therefore safe to
use. A peek/poke interface cannot be trusted. So you allow joe random to
mess with the low level hardware of your harddisk?!? He can reach, and
destroy, ANY data that way. I'm not even saying it's on purpose.


And I don't trust the levels of protection much, if they even exist. If
you're allowed access to the hardware, say, the video card, you might as
well be able to overwrite the interrupt vectors, for example (by
accident, of course). You'll likely get a crash within a fraction of a
second.

-- 
	Bart.


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

Date: Wed, 26 Sep 2001 13:26:28 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Peek and Poke on Perl?
Message-Id: <9osl24$1uo2$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Gary 
<gamtci1@mpinet.net>], who wrote in article <3BB1C485.5465@mpinet.net>:
> Why would this be a "surefire" way to get it to crash?  In order
> for the OS to communicate with the monitor card (A000 thru B000),
> the hard drive (often in C000), many ethernet boards (C000 or D000
> or E000), and even the BIOS (F000), it would have to have mapped 
> addresses within these spaces and it must use them constantly.

LOL!  How/why an OS (thus protected mode code) would use something as
C000 which works only in a real mode?

Ilya

P.S.  If all you want is not reading/writing at addresses, but
      reading/writing from/to a port, then most CRTL provide necessary
      functions (usually named as in8(), out8(), etc).  5min with h2xs
      would give you a module which interfaces to these functions.


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

Date: Wed, 26 Sep 2001 13:42:13 GMT
From: Gary <gamtci1@mpinet.net>
Subject: Re: Peek and Poke on Perl?
Message-Id: <3BB1DAFF.111A@mpinet.net>

C000 whether protected mode or not is still a valid real-world 
address.  According to your thinking, segment 0000 non-protected 
mode would be an invalid address in protected mode, but, of course, 
it isn't. If a board in the system expects to be addressed at C000, 
then the OS must put this address onto the bus. The card doesn't 
care what mode the CPU is operating in.  

To be clear: the physical address lines would have to produce 
1100 0000 0000 0000 0000 (on a 20-bit (SA19 thru SA0) PC ISA slot) 
regardless of the CPU's operating mode in order for the card to
decode (C000:0000) and respond to this address.


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

Date: Wed, 26 Sep 2001 13:44:21 GMT
From: Gary <gamtci1@mpinet.net>
Subject: Re: Peek and Poke on Perl?
Message-Id: <3BB1DB80.5EA1@mpinet.net>

I wasn't thinking of a "random-anywhere-you-want" read/write.
I'm not even sure you could convince the kernel to let you 
map anywhere-anytime. I was thinking registering with the 
kernel to map a certain space to this "driver", such as the 
space allotted to add-in boards.


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

Date: Wed, 26 Sep 2001 16:10:20 +0200
From: "B. Caligari" <bcaligari@fireforged.com>
Subject: Re: Regular Expression Problem
Message-Id: <9osn6501jt2@enews3.newsguy.com>


"Ilmari Karonen" <iltzu@sci.invalid> wrote in message
news:1001499936.6639@itz.pp.sci.fi...

<snip>

> Not unless he also adds a few dollar signs, and makes the comments start
> with #, and adds semicolons..  (Wait, doesn't Java need semicolons too?)
>
> Anyway, the code given by the original poster isn't Perl.  It's Java,
> and he's using a "Perl-compatible" regex library for Java.  We really
> need a newsgroup or a mailing list for these questions, so that we can
> shove them out of clpm where they're just confusing.
>
> --
> Ilmari Karonen -- http://www.sci.fi/~iltzu/

hmmm

comp.lang.perl.misc - converts welcome

Brendon
++++




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

Date: Wed, 26 Sep 2001 09:28:33 -0400
From: asif <whatever@nevermind.invalid>
Subject: Re: Single line if Statement
Message-Id: <3BB1D801.8080505@nevermind.invalid>

Victor Menendez wrote:

> I would like to print an item based on an expression that is true.
> print OUT  if expression returns TRUE other wise skip goto next line."
> Content "\n";
> Is there a way to do this using just a single line command?
> Thanks
> 


I've used:

while(<>){ EXPRESSION && print; }

/whatever

 




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

Date: 26 Sep 2001 06:34:34 -0700
From: Paul.Neubauer@bsu.edu (Paul Neubauer)
Subject: Re: Socket question
Message-Id: <3711e117.0109260534.5bdfca8d@posting.google.com>

merlyn@stonehenge.com (Randal L. Schwartz) wrote in message news:<m18zf3npwh.fsf@halfdome.holdit.com>...
> >>>>> "Paul" == Paul Neubauer <Paul.Neubauer@bsu.edu> writes:
> Paul> I seem to be having a problem connecting to a socket on a remote
> Paul> machine. I've boiled it down to a minimal program, which I include
> Paul> here:
> <snipped>
> I'll shorten it down much tighter:
> 
> use IO::Socket;
> my $host  = 'foo.bsu.edu';
> my $port  = 22;
> my $socket = IO::Socket::INET->new("$host:$port") or die "$!";
> 
> Stop using hard-to-use interfaces!

OK. Thanks, Randall. And thanks for the e-mail copy too. :-) I was
trying to use the form from the 2nd ed of the Camel book, but it looks
like it's time to buy the 3rd ed.

As Joe Schaefer pointed out, my mistake was using $iaddr instead of
$paddr in the connect line. But you're both right, I have no doubt.
Too many hoops. So here's what seems to work for the test:

#---------- Cut here -------------#
#! /bin/perl -w
use strict;
use IO::Socket;
my $host  = 'foo.bsu.edu';
my $port  = 1521;
my $socket = IO::Socket::INET->new("$host:$port");
if ($socket) {
    print "Connection made.\n";
    close ($socket);
}else{
    print "Connection failed: $!\n";
    print "Exit now!\n";
    exit;
}
print "We got the connection, so do something useful here\n";
exit;
#---------- Cut here -------------#

This successfully tests when the connection can be made and notes when
the connection fails. I'll put in a loop to wait for the oracle server
to come up and all should be copacetic. :-) Thanks much, guys! I'll
check out the 3rd ed.

-- 
Paul
Paul.Neubauer@bsu.edu


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

Date: Wed, 26 Sep 2001 13:44:13 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Socket question
Message-Id: <kpm3rtoa24iriar80lcor8q3nu7k5ohpc3@4ax.com>

Paul Neubauer wrote:

>merlyn@stonehenge.com (Randal L. Schwartz) wrote

>> I'll shorten it down much tighter:
>> 
>> use IO::Socket;
>> my $host  = 'foo.bsu.edu';
>> my $port  = 22;
>> my $socket = IO::Socket::INET->new("$host:$port") or die "$!";
>> 
>> Stop using hard-to-use interfaces!
>
>OK. Thanks, Randall. And thanks for the e-mail copy too. :-) I was
>trying to use the form from the 2nd ed of the Camel book, but it looks
>like it's time to buy the 3rd ed.

Perhaps check out Lincoln Stein's book, "Netwoking Programming with
Perl" as well. This goes much deeper into this and related subjects than
any other Perl related book I've seen. And than most other books as
well. <http://www.modperl.com/perl_networking/>

-- 
	Bart.


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

Date: 26 Sep 2001 07:02:01 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Socket question
Message-Id: <m14rpqgiee.fsf@halfdome.holdit.com>

>>>>> "Bart" == Bart Lateur <bart.lateur@skynet.be> writes:

Bart> Perhaps check out Lincoln Stein's book, "Netwoking Programming with
Bart> Perl" as well. This goes much deeper into this and related subjects than
Bart> any other Perl related book I've seen. And than most other books as
Bart> well. <http://www.modperl.com/perl_networking/>

I'll second, third, and fourth that.  That book inspired me to take on
some tasks in Perl that I hadn't formerly attempted.

print "Just another Perl hacker,"

-- 
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: Wed, 26 Sep 2001 15:45:48 +0100
From: "Raj" <oneconcept@yahoo.co.uk>
Subject: Re: Transforming HTML
Message-Id: <1001515548.1252.0.nnrp-12.c2d95a2c@news.demon.co.uk>

<nobull@mail.com> wrote in message news:u97kunw3sg.fsf@wcl-l.bham.ac.uk...
> "Raj" <oneconcept@yahoo.co.uk> writes:
> >
> > Basically, I would like to turn:
> >
> > <INPUT TYPE="text" NAME="xFname">
> >
> > into:
> >
> > <INPUT TYPE=text" NAME="xFname" VALUE="Raj">
> >
> > I'm sure its quite simple
>
> That would be your error.  As we point out in this newsgroup several
> times a week trasforming HTML is not simple.  That's why we have
> modules to do it.

I'm sorry.  I'm quite new to Perl and I was hoping that this could be done
without the need for modules.  Do they not carry any sort of overhead?
Also, I'd like to learn exactly how I would do this rather than let a module
cover up the detail (which I know is their function!).

If anyone can think of a way to acheive what I want without the use of a
module, and has the time for me, please feel free to contact me.

Thank you.

Regards,
Raj




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

Date: 26 Sep 2001 06:27:40 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Use of 'our' in older perl versions
Message-Id: <m1wv2mgjzn.fsf@halfdome.holdit.com>

>>>>> "Bart" == Bart Lateur <bart.lateur@skynet.be> writes:

Bart> Leo Hemmings wrote:
>> I am using 'strict' and have decalred many of my variables as 'our
>> $varname'. Using 'our' only seems to work with perl v5.6. No older version
>> 5's like the use of 'our'. Is this correct? I find it hard to believe that
>> perl did not encorporate decalaration of global variables before version
>> 5.6! Is there any other way apart from using 'our', one can declare a global
>> variable?

Bart> use vars qw/$varname/;

Bart> our() was added because the above was a bit, er, verbose.

More than that.  "use vars" is a package-wide permission to use a
package var without colons.  As such, it's still useful and valid,
because "our" is a lexical-scoped permission to use a package var
without colons.

Witness:

    use strict;

    {
      package bedrock;

      use vars qw($fred);
      our $barney;
      my $dino;

      $fred; # $bedrock::fred
      $barney; # $bedrock::barney
      $dino; # lexical $dino

      package slatetown;

      $fred; # NOT PERMITTED
      $barney; # still $bedrock::barney !
      $dino; # still lexical $dino
    }

    {
      package bedrock;
      $fred; # still $bedrock::fred !
      $barney; # NOT PERMITTED
      $dino; # NOT PERMITTED
    }

The "our" declaration stays alive in a scope.  The "use vars" declaration
is alive whenever we are in that package.

See, not interchangable, and sometimes you want one, and sometimes
you want the other.

Of course, if you wanna be able to run on many boxes, stick
with the 5.5.3 compatible version.

print "Just another Perl hacker,"

-- 
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: 26 Sep 2001 10:10:20 -0400
From: stanb@panix.com (Stan Brown)
Subject: What does ||= do ?
Message-Id: <9osnkc$cvi$1@panix2.panix.com>

 I ran across the ||= construct in some examle code, and I can't figure out
 what it does. I'm familiar wiht += & -=, etc for C, but this ones got me
 stumped. I looked in the O'rielly "Programing Perl" book, and found it
 listed in a table, but no explabation as to what it does.


-- 
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
						-- Benjamin Franklin


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

Date: Wed, 26 Sep 2001 14:34:41 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: What does ||= do ?
Message-Id: <cpp3rtslntm9ofv61ph5nk0pecq1dc1duk@4ax.com>

Stan Brown wrote:

> I ran across the ||= construct in some examle code, and I can't figure out
> what it does. I'm familiar wiht += & -=, etc for C, but this ones got me
> stumped. I looked in the O'rielly "Programing Perl" book, and found it
> listed in a table, but no explabation as to what it does.

It makes the following equivalence:

	$a ||= expr();

	$a = $a || expr();

expr() is only evaluated, and assigned to $a, if $a was false before
(zero, empty string, undef).

-- 
	Bart.


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

Date: Wed, 26 Sep 2001 14:07:34 -0000
From: darkon@one.net (David Wall)
Subject: Re: What's wrong with this code ?
Message-Id: <Xns912866E43F203darkononenet@207.126.101.97>

Uri Guttman <uri@sysarch.com> wrote on 25 Sep 2001:

> [...] a style trick i like is when you have a conditional clause
> with next/last is to make a statement modifier instead. it saves those
> precious braces and indents:
> 
>      next unless my @names = m/(name-\S+)/g ;
> 
>      for my $name (@names) {
> 
>           next unless /^service\s+(\S+)/ ;
>           print "name    = $name\nservice = $1\n";
>      }

Well, crap.  :-)  That's much cleaner and easier to read than what I wrote.  
I always forget about 'unless'.  (Makes mental note to self)

-- 
David Wall
darkon@one.net


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

Date: 26 Sep 2001 08:41:52 -0500
From: gazelle@yin.interaccess.com (Kenny McCormack)
Subject: Re: who said this?
Message-Id: <9oslv0$4md$1@yin.interaccess.com>

In article <9or4j1025db@enews3.newsguy.com>,
Dann Corbit <dcorbit@connx.com> wrote:
>With a PC, I always felt limited by the software available.
>On Unix, I am limited only by my knowledge.

The fact is that, for most people, being limited by their own knowledge
(wisdom) would be (and is) a serious limitation indeed.

But, of course, the real question is, what does this quote actually mean?
Since it was posted in a Unix group, we tend to assume it is the typical
"Unix good - Windoze bad" sort of thing, but OTOH, being attributed to
Leader Bill, one ought to assume the contrary.  And, in fact, it could
easily be interpreted in just that way.  I.e., that the whole point of the
PC/DOS/Windoze is to remove the limitation of being limited by one's own
wisdom (which is, let's be honest, a rare commodity in the general
population) and instead, to allow everyone to benefit from the efforts of
the few.

I don't think this later interpretation is at all unreasonable.  Mind you,
I haven't said anything about what my own view is (*).

(*) Although I am, in fact, as much of a "Unix good, Windoze bad"
person as you are likley to find.


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

Date: Wed, 26 Sep 2001 10:56:15 -0400
From: "Mike Miller" <miller5286@usenetserver.com>
Subject: Re: who said this?
Message-Id: <3bb1cff9_2@Usenet.com>

I run Unix on my PC.  ;o)

"Dann Corbit" <dcorbit@connx.com> wrote in message
news:9or4j1025db@enews3.newsguy.com...
> With a PC, I always felt limited by the software available.
> On Unix, I am limited only by my knowledge.
>
> --Peter J. Schoenster
> --
> C-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
>  "The C-FAQ Book" ISBN 0-201-84519-9
> C.A.P. FAQ: ftp://cap.connx.com/pub/Chess%20Analysis%20Project%20FAQ.htm
>
>



 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: 26 Sep 2001 09:21:36 -0400
From: bill <bill02115@hotmail.com>
Subject: Re: Windows2000: CPAN.pm woes
Message-Id: <9oskp0$17h$1@panix3.panix.com>

In <9oqhdt$6u2$1@canopus.cc.umanitoba.ca> Randy Kobes <randy@theoryx5.uwinnipeg.ca> writes:

>> I'm at a loss.  Never heard of ls6.informatik.uni-dortmund.de, and I
>> really don't have a "favourite WAIT server", whatever that is.

>CPAN::WAIT is used for looking up stuff in the documentation within 
>the CPAN.pm shell (it uses the 'WAIT server' being referred to), but 
>this is an optional plug-in. The error message resulted
>from not being able to connect to this server - that could mean
>the server itself is down, or perhaps your machine wasn't connected
>at the time.

I know for sure that my machine was connected at the time, as it is
now.  How can I determine if the WAIT server is indeed down?  I tried
pinging it, and I got:

  $ ping ls6.informatik.uni-dortmund.de
  PING lothlorien.informatik.uni-dortmund.de (129.217.19.67) from 134.174.168.180 :
  56(84) bytes of data.
  From gb5-gw-hrz.cs.Uni-Dortmund.DE (129.217.129.227): Packet filtered
  From gb5-gw-hrz.cs.Uni-Dortmund.DE (129.217.129.227): Packet filtered
  From gb5-gw-hrz.cs.Uni-Dortmund.DE (129.217.129.227): Packet filtered
  
  --- lothlorien.informatik.uni-dortmund.de ping statistics ---
  16 packets transmitted, 0 packets received, +3 errors, 100% packet loss

(But maybe ping is not the best way to check the status of a WAIT
server.)

Thanks,

ali


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

Date: 26 Sep 2001 09:23:03 -0400
From: bill <bill02115@hotmail.com>
Subject: Re: Windows2000: CPAN.pm woes
Message-Id: <9oskrn$1cq$1@panix3.panix.com>

In <1001443133.812871@newsmaster-04.atnet.at> "Stefan Weiss" <weiss@kung.foo.at> writes:

><OT>
>"Alicia" <alicia090677@hotmail.com> wrote:
>> (whew!  That was a lot of typing!  The blasted cmd.exe window doesn't
>> seem to have cut and paste!)

>Yes it does: highlight the text with your mouse, then press the right
>mouse button. The highlighted part should be in the clipboard now.
>Similarly, you can paste into the console window with a right mouse
>click.

(Thanks!  That's very useful to know.)

></OT>

ali






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

Date: 26 Sep 2001 07:47:59 -0700
From: redace1919@yahoo.com (Brian)
Subject: Works sometimes - tmadmin
Message-Id: <d550bb5.0109260647.6a824159@posting.google.com>

Hello, 

I have a script that runs the tmadmin command (This is a program used
to configure/monitor BEA Tuxedo/WLE servers).

These are the three lines that have a problem.. sometimes.  Usually
this works.

open(TUX,"tmadmin <<EOF\nv\npsr\nEOF\n|")  ||
         die "Unable to open TUXEDO\n";
@tux = <TUX>;
close TUX;

Every once in a while, @tux will contain only 2 lines.  This happens
over a period of time. So I can run this over and over for 5-10
minutes and I'll get this incorrect info.  @tux will show this:

DB<2> x @tux
0  '
'
1  '> 
'

But usually, when it's working, it is a large array with info about
the running servers.

The reason I believe it is something in my script is that while this
is happening, if I simply type :
tmamdin
v
psr
from unix, I get the info that I expect.

So, is my script wrong?  Any ideas?  I'm pretty lost right now.

Regards,
Brian


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

Date: Wed, 26 Sep 2001 15:34:02 +0100
From: "Dr Joolz" <julius_mong@hotmail.com>
Subject: XML::Writer question... how to write output to file?
Message-Id: <9osp14$ige$1@oyez.ccc.nottingham.ac.uk>

Dear all, I'm a newbie to the XML modules. I'm trying to write the xml
output code to a file instead of stdout, please tell me how to
declare/define $output below...

my $writer = new XML::Writer(OUTPUT => $output, NEWLINES => 1);

Thanx,
        Jules

***24 hours in a day...24 beers in a case...coincidence?***





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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 1822
***************************************


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