[24538] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6716 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 22 14:05:56 2004

Date: Tue, 22 Jun 2004 11:05:07 -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           Tue, 22 Jun 2004     Volume: 10 Number: 6716

Today's topics:
        2 queries- first day of month and  reading zipped files (Shalini Joshi)
    Re: 2 queries- first day of month and  reading zipped f <postmaster@castleamber.com>
    Re: alternative to cwd() <me@privacy.net>
    Re: alternative to cwd() <josef.moellers@fujitsu-siemens.com>
    Re: alternative to cwd() <tore@aursand.no>
    Re: alternative to cwd() <josef.moellers@fujitsu-siemens.com>
    Re: alternative to cwd() ctcgag@hotmail.com
        Anyone seen Exegesis 12 ? (K. L. Estes)
    Re: Anyone seen Exegesis 12 ? <uri@stemsystems.com>
    Re: Embedding perl in Java <junkto@tm.net.my>
    Re: Formatting numbers to currency format <noreply@gunnar.cc>
        globbing files with extension (justme)
    Re: globbing files with extension <noreply@gunnar.cc>
    Re: globbing files with extension <ittyspam@yahoo.com>
    Re: globbing files with extension (Greg Bacon)
    Re: Help required <tadmc@augustmail.com>
        How can both be true: $! == 10 && $! eq 'No child proce (Peter Valdemar Morch)
    Re: How can both be true: $! == 10 && $! eq 'No child p <pinyaj@rpi.edu>
    Re: if statement w/hash and subroutines (Anno Siegel)
    Re: if statement w/hash and subroutines (Mark Connell)
    Re: if statement w/hash and subroutines <pinyaj@rpi.edu>
    Re: join (@a, @b, @c) (Sam Holden)
    Re: Perl DNS reverse lookups -- multiple IP addresses p <Petri_member@newsguy.com>
    Re: perl, mysql fetchrow_arrayref without package ctcgag@hotmail.com
    Re: Question on Perl printing <raisin@delete-this-trash.mts.net>
    Re: running multiple versions of perl heitkamp@ameritech.net
    Re: Signals interrupt accept() - bug in perldoc perlipc <vek@station02.ohout.pharmapartners.nl>
        Style [Q]: the placement of 'use' <socyl@987jk.com>
    Re: Style [Q]: the placement of 'use' <pinyaj@rpi.edu>
    Re: Style [Q]: the placement of 'use' <nobull@mail.com>
    Re: Why won't this split file script work? <remorse@partners.org>
    Re: Why won't this split file script work? (Anno Siegel)
    Re: WMI and boolean values from Win32_Processor (Daniel Berger)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 22 Jun 2004 10:34:52 -0700
From: shalinij1@yahoo.com (Shalini Joshi)
Subject: 2 queries- first day of month and  reading zipped files directly off server
Message-Id: <283d6b7e.0406220934.4efef7cf@posting.google.com>

Hi!

I am supposed to be writing perl code which , opens and reads a
particular file only if it's the first day of the month; otherwise it
reads another file always. I'd really appreciate any comments on how
to proceed with this one.

Also, I would be reading the files off of a remote server, which
stores these files in zipped format. The server allows us to download
these files and then read them(parse them too), but I was wondering if
to save on the download time(the files are financial  price
files....huge and updated daily) we could read the zipped files
directly from the server???

Can I accomplish all this in perl? Any help would be welcome, and as
always, thanks a bunch for the help and tips in advance.

Regards,

Shalini


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

Date: Tue, 22 Jun 2004 12:48:54 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: 2 queries- first day of month and  reading zipped files directly off server
Message-Id: <40d87108$0$199$58c7af7e@news.kabelfoon.nl>

Shalini Joshi wrote:

> Hi!
> 
> I am supposed to be writing perl code which , opens and reads a
> particular file only if it's the first day of the month; otherwise it
> reads another file always. I'd really appreciate any comments on how
> to proceed with this one.
> 
> Also, I would be reading the files off of a remote server, which
> stores these files in zipped format. The server allows us to download
> these files and then read them(parse them too), but I was wondering if
> to save on the download time(the files are financial  price
> files....huge and updated daily) we could read the zipped files
> directly from the server???
> 
> Can I accomplish all this in perl?

Yes

> Any help would be welcome, and as

How much are you paying ;-)

> always, thanks a bunch for the help and tips in advance.

Net::FTP or better use Net::SFTP, the first day of the month is trivial.

-- 
John                               MexIT: http://johnbokma.com/mexit/
                            personal page:       http://johnbokma.com/
    Experienced Perl programmer available:     http://castleamber.com/
             Happy Customers: http://castleamber.com/testimonials.html


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

Date: Tue, 22 Jun 2004 22:36:14 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: alternative to cwd()
Message-Id: <2jqgcmF14bmv7U1@uni-berlin.de>


"Sunil" <sunil_franklin@hotmail.com> wrote in message
news:CaPBc.55$pW6.383@news.oracle.com...
> Hi All,
>     I need to find the current working directory, Is there any alternative
> to
>             use Cwd;
>             $pwd = cwd();
>
>         I am looking for a solution other than using system() or backtics

For solution see above.

Seriously, why not cwd?




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

Date: Tue, 22 Jun 2004 15:17:36 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: alternative to cwd()
Message-Id: <cb9b9f$j9i$1@nntp.fujitsu-siemens.com>

Tintin wrote:
> "Sunil" <sunil_franklin@hotmail.com> wrote in message
> news:CaPBc.55$pW6.383@news.oracle.com...
>=20
>>Hi All,
>>    I need to find the current working directory, Is there any alternat=
ive
>>to
>>            use Cwd;
>>            $pwd =3D cwd();
>>
>>        I am looking for a solution other than using system() or backti=
cs
>=20
>=20
> For solution see above.
>=20
> Seriously, why not cwd?

Probably
"Assignment 3: "Find the current working directory. Do NOT
use Cwd; $pwd =3D cwd();
"

The wording of the OP suggests this.

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Tue, 22 Jun 2004 16:14:40 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: alternative to cwd()
Message-Id: <pan.2004.06.22.14.14.27.642036@aursand.no>

On Tue, 22 Jun 2004 15:17:36 +0200, Josef Moellers wrote:
>> Seriously, why not cwd?

> Probably
> "Assignment 3: "Find the current working directory. Do NOT
> use Cwd; $pwd = cwd();
> "
> 
> The wording of the OP suggests this.

Still:  Why not use cwd?  It comes with the standard Perl distribution,
and it's portable.


-- 
Tore Aursand <tore@aursand.no>
"The science of today is the technology of tomorrow." (Edward Teller)


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

Date: Tue, 22 Jun 2004 16:49:55 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: alternative to cwd()
Message-Id: <cb9glq$i08$1@nntp.fujitsu-siemens.com>

Tore Aursand wrote:
> On Tue, 22 Jun 2004 15:17:36 +0200, Josef Moellers wrote:
>=20
>>>Seriously, why not cwd?
>=20
>=20
>>Probably
>>"Assignment 3: "Find the current working directory. Do NOT
>>use Cwd; $pwd =3D cwd();
>>"
>>
>>The wording of the OP suggests this.
>=20
>=20
> Still:  Why not use cwd?  It comes with the standard Perl distribution,=

> and it's portable.

Because his homework assignment strictly forbids to do that.

Besides: It is sometimes extremely instructive NOT to use some canned=20
function. But for the sake of portability, I'd use Cwd, too.

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: 22 Jun 2004 17:21:06 GMT
From: ctcgag@hotmail.com
Subject: Re: alternative to cwd()
Message-Id: <20040622132106.578$6a@newsreader.com>

"Sunil" <sunil_franklin@hotmail.com> wrote:
> Hi All,
>     I need to find the current working directory, Is there any
> alternative to
>             use Cwd;
>             $pwd = cwd();
>
>         I am looking for a solution other than using system() or backtics
> (``).

Ask Cwd how it does it.

vi `perldoc -l Cwd`

Have fun.

Maybe we should create another comp.lang.perl.* group just for people
who have the right tool for the job, know the right tool for the job,
but insist on not using the right tool for the job.

Xho

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


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

Date: 22 Jun 2004 05:45:49 -0700
From: klestes@nmhs.net (K. L. Estes)
Subject: Anyone seen Exegesis 12 ?
Message-Id: <5b63b266.0406220445.3e3ef4d8@posting.google.com>

As in shouldn't it be out now ?

do we have a picture of Damain for the milkcartons, Just In Case ?
-KL


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

Date: Tue, 22 Jun 2004 13:55:18 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Anyone seen Exegesis 12 ?
Message-Id: <x7isdj7l4p.fsf@mail.sysarch.com>

>>>>> "KLE" == K L Estes <klestes@nmhs.net> writes:

  KLE> As in shouldn't it be out now ?
  KLE> do we have a picture of Damain for the milkcartons, Just In Case ?

he was alive and well at yapc::na last week in buffalo.

he did mention working on E12 along with mucho other stuff as usual.

it will be out by christmas :)

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Wed, 23 Jun 2004 00:02:45 +0800
From: Lincoln Yeoh <junkto@tm.net.my>
Subject: Re: Embedding perl in Java
Message-Id: <qbkgd09p78sbef435f7kdj1pvptvqm3p4a@4ax.com>

On 20 Jun 2004 23:00:25 -0700, shalinij1@yahoo.com (Shalini Joshi)
wrote:

>Hey!
>
>Yeah Ben, thanks again..i managed to use perlcc to produce an
>executable on the unix system. It didnt work on windows though(like it
>had been pointed out in the doc)so used the B module to produce the
>bytecode.
>
>Yeah will let my boss know about the source code hiding issues..thanks
>again.

For windows - try par and for executable compression try upx

http://search.cpan.org/~autrijus/PAR/lib/PAR.pm

There are many commercial products that use perl. Often without
obfuscation. Whether people have the source code or not doesn't stop
them from copying your stuff and using it. I use UPX+PAR just coz it
bundles things up in a single convenient file and users do not need to
install perl. But some AV scanners[1] seem to take a bit longer to
scan stuff like this.

It only makes it harder for people to figure out or extend/modify it.
It doesn't make it impossible.

The people who don't pay and bother to figure out your source code
often aren't going to pay for it - they either have less need for it
(they're smart enough to write much of it themselves), or they aren't
going to pay for it anyway.

Whereas the people who've already paid for it may regard having the
source code as a big plus. I'd personally prefer buying a program
that's easy to fix and modify, coz often programs outlast support from
the vendors that supply them.

Given a suitably viral license it may be disadvantageous for people to
copy and reuse your code without permission. You may wish to consult
your lawyers about that.

That said, I'm not too fond about these license things. What are the
limits of such things anyway? How valid are they? Someone should
implement a software license that requires users to howl at the moon
_publicly_ every month or brush their teeth after every meal.

[1] I wonder how AV scanners deal with obfuscated polymorphic
perl/lisp/etc viruses/worms... 


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

Date: Tue, 22 Jun 2004 15:28:51 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Formatting numbers to currency format
Message-Id: <2jqqgtF1327joU1@uni-berlin.de>

Robert TV wrote:
> I would like to know if Perl has a function to correctly format a
> string of numbers into currency format.

Why did you start a new thread on this topic, instead of following up
the replies at the thread you started a few days ago??

http://groups.google.com/groups?threadm=2iva5fFpkegmU1%40uni-berlin.de

( Are only morons asking questions nowadays? :( )

> $finaltotal = sprintf("%.02f",$finaltotal);

<snip>

> ... there are no cedimal places, therefor sprintf doesnt have
> anything to round.

Did you ever run any code that made you come to that conclusion? In
that case, please show us THAT code!

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


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

Date: 22 Jun 2004 09:18:57 -0700
From: eight02645999@yahoo.com (justme)
Subject: globbing files with extension
Message-Id: <c0837966.0406220818.23e47f41@posting.google.com>

hi

say i have files that end with .txt and .TXT in a directory and i want
to list them out using a while loop such as

while( glob <*.[tT][xX][tT]> )
{
  print;
}

but it did not work.. 
i tried this also


while( glob <*.txt>  or glob <*.TXT> )
{
  print;
}

but also did not work...any other ways to do that?
thanks


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

Date: Tue, 22 Jun 2004 18:37:02 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: globbing files with extension
Message-Id: <2jr5hvF14v57tU1@uni-berlin.de>

justme wrote:
> say i have files that end with .txt and .TXT in a directory

Which directory?

> and i want to list them out using a while loop such as
> 
> while( glob <*.[tT][xX][tT]> )
> {
>   print;
> }
> 
> but it did not work..

Please define "did not work".

It should work, provided that the files you want to list are stored in 
the working directory. Otherwise, you may want to use the chdir() 
function to change the working directory.

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


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

Date: Tue, 22 Jun 2004 12:48:22 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: globbing files with extension
Message-Id: <20040622124544.C23512@dishwasher.cs.rpi.edu>

On Tue, 22 Jun 2004, justme wrote:

> hi
>
> say i have files that end with .txt and .TXT in a directory and i want
> to list them out using a while loop such as
>
> while( glob <*.[tT][xX][tT]> )
> {
>   print;
> }
>
> but it did not work..
> i tried this also
>
>
> while( glob <*.txt>  or glob <*.TXT> )
> {
>   print;
> }
>
> but also did not work...any other ways to do that?

You've tried to combine the two ways of doing glob() into one.  You want
EITHER:

while (<*.txt>){ }

OR

while (glob '*.txt') { }

glob <*.txt> is calling glob twice, the second glob being called with an
argument returned by the first glob.  This second glob only has one
result, so the while loop executes only once.

Try this:

while (<*.[tT][xX][tT]>){
   print;
}


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

Date: Tue, 22 Jun 2004 16:50:35 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: globbing files with extension
Message-Id: <10dgoqreldfbqb3@corp.supernews.com>

In article <c0837966.0406220818.23e47f41@posting.google.com>,
    justme <eight02645999@yahoo.com> wrote:

: say i have files that end with .txt and .TXT in a directory and i want
: to list them out using a while loop such as
: 
: while( glob <*.[tT][xX][tT]> )
: {
:   print;
: }

Here you're doing the equivalent of putting on your glasses while
you're wearing contacts.  See below:

    $ cat try
    #! /usr/local/bin/perl

    use warnings;
    use strict;

    my @files = qw/ one.txt two.TXT /;

    for (@files) {
        open my $fh, ">", $_ or die "$0: open $_: $!";
    }

    while (glob <*.[tT][xX][tT]> ) {
        print "1: [$_]\n";
    }

    my $glob_return_in_scalar_context = <*.[tT][xX][tT]>;
    while (glob $glob_return_in_scalar_context) {
        print "2: [$_]\n";
    }

    # one correct way
    while (glob "*.[tT][xX][tT]") {
        print "3: [$_]\n";
    }

    # another correct way
    while (<*.[tT][xX][tT]>) {
        print "4: [$_]\n";
    }

    unlink @files or warn "$0: unlink: $!";

    $ ./try
    1: [one.txt]
    2: [one.txt]
    3: [one.txt]
    3: [two.TXT]
    4: [one.txt]
    4: [two.TXT]

    $

: [...]

Note that your pattern would also match, for example, three.TxT.

Hope this helps,
Greg
-- 
Only the mediocre are always at their best.
    -- Neal Boortz


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

Date: Tue, 22 Jun 2004 08:00:07 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Help required
Message-Id: <slrncdgban.htb.tadmc@magna.augustmail.com>

Sunil Shukla <shukla@uq.edu.au> wrote:

> Subject: Help required


Subject required.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 22 Jun 2004 07:33:06 -0700
From: byqil3s02@sneakemail.com (Peter Valdemar Morch)
Subject: How can both be true: $! == 10 && $! eq 'No child processes'?
Message-Id: <b9705e3c.0406220633.5623f7a3@posting.google.com>

I can see from perldoc perlvar about $!:

"If used numerically, yields ..."
and
"If used as a string, yields ..."

Is there any way I can do this for my own variables, say $a - to let
it have one value if used numerically, and another if used as a
string? It tastes a little like wantarray for subs, but... Is this
very, very special for $!?

Peter


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

Date: Tue, 22 Jun 2004 10:45:35 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: How can both be true: $! == 10 && $! eq 'No child processes'?
Message-Id: <Pine.SGI.3.96.1040622103618.29087B-100000@vcmr-64.server.rpi.edu>

On 22 Jun 2004, Peter Valdemar Morch wrote:

>Is there any way I can do this for my own variables, say $a - to let
>it have one value if used numerically, and another if used as a
>string? It tastes a little like wantarray for subs, but... Is this
>very, very special for $!?

There are two ways to have it done, generally speaking:

1. make $foo an object of a class that overloads stringification and
   numification

2. muck with the internal representation of $foo so that Perl thinks it
   has a PV (string value) and an unrelated NV (numeric value)

Here's a brief example of the first:

  package StrNum;
  use overload ( '""' =>  'str', '0+' => 'num', fallback => 1 );
  sub new {
    my $class = shift;
    bless [ @_ ], $class;
  }
  sub str { $_[0][0] }
  sub num { $_[0][1] }
  1;

It's used thus:

  use StrNum;
  my $both = StrNum->new("string", 100);
  if ($both eq "string" and $both == 100) { print "ooh!" }

There is probably already a module on CPAN that employs this mechanism.

The second way is faster to employ because it has nothing to do with
objects and overloading, and works by fiddling with Perl's representation
of your scalar.  The Scalar::Util module includes a dualvar() function
that does just that:

    dualvar NUM, STRING
      Returns a scalar that has the value NUM in a numeric context and
      the value STRING in a string context.

        $foo = dualvar 10, "Hello";
        $num = $foo + 2;                    # 12
        $str = $foo . " world";             # Hello world

(Ok, so I had the order the other way around in my sample module above.)

-- 
Jeff Pinyan         RPI Acacia Brother #734        RPI Acacia Corp Secretary
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: 22 Jun 2004 10:25:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: if statement w/hash and subroutines
Message-Id: <cb91el$sk8$1@mamenchi.zrz.TU-Berlin.DE>

Mark Connell <mhc5@duke.edu> wrote in comp.lang.perl.misc:
> Hello,
> I am using a subroutine multiple times.  Depending on the type of hash
> I am sending to teh subroutine, I am trying to output different things
> to a file.  I was wondering how I can do this--I tried creating an if
> statement using the name of 1 type of input to output a certain way,
> and else for the other type of input... but I was unable to do this
> correctly.  If I have two diff hashes (ex %1 and %2) that will be used
> in my subroutine, can I do something like inside the subroutine:
>
> if (@_ eq %1) {print this}
> elseif (@_ eq %2) {print this}
> else {...}

%1 and %2 aren't legal hash names in Perl.  Please show your real
code.  How are the hashes passed to the sub?

> That didnt work for me, but I was wondering if the idea was reasonable
> or if I should try something different.

Depending on how you pass the hash to the sub, Perl may not even know
you gave it a hash.

You could mark the hashes themselves by adding a particular key (and
optionally value) that distinguishes it from other hashes.


Anno


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

Date: 22 Jun 2004 07:13:11 -0700
From: mhc5@duke.edu (Mark Connell)
Subject: Re: if statement w/hash and subroutines
Message-Id: <64211cc6.0406220613.56a07862@posting.google.com>

I guess here are the relevant bits of code...

sub MICe {

%Seq=@_;
lots of calculations...then I print to a file.
I tried to include the printing by doing this:
if ( @_ == %Newsq) {
print DAA so on to a file.
}
else {print something else}
}


I later cued the subroutine by this line:

MICe(%Newsq);
or
MICe(%Seqac);

I think that includes all the relevant code.  Would references be
helpful?  I haven't learned much about them yet so I'm not sure if
they would be.
Thanks again
Mark


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

Date: Tue, 22 Jun 2004 10:27:50 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Mark Connell <mhc5@duke.edu>
Subject: Re: if statement w/hash and subroutines
Message-Id: <Pine.SGI.3.96.1040622102328.29012A-100000@vcmr-64.server.rpi.edu>

[posted & mailed]

On 22 Jun 2004, Mark Connell wrote:

>  if ( @_ == %Newsq) {

Suffice to say, you cannot compare aggregate data structures (arrays or
hashes) in this manner.  You can use the Data::Compare module, though, or
you can determine "same-ness" in your own way (but that can be tricky).

-- 
Jeff Pinyan         RPI Acacia Brother #734        RPI Acacia Corp Secretary
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: 22 Jun 2004 10:37:00 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: join (@a, @b, @c)
Message-Id: <slrncdg2uc.qmf.sholden@flexal.cs.usyd.edu.au>

On Tue, 22 Jun 2004 04:01:06 -0400,
	Ken Sington <ken_sington@nospam_abcdefg.com> wrote:
> or this:
> 
[snip code]
> 
> &x(\@a, \@b, \@c...);
> 
> sub x {
>     my @a=@_;
>     foreach (@a) {
>         my @b=@{$_};
>         print join "\n", @b;
>         print "\n==============\n";
>     }
> 
> }
> 
> now I have another problem.
> how would I return all that?

by instead using;

sub x {
    my $result = '';
    foreach (@_) {
        $result .= join "\n", @$_;
        $result .= "\n==============\n";
    }
    return $result;
}

I got rid of the temporaries (@a and @b) since they cause the argument
list and then the elements in each array to get copied, you could also
do something with map (similar to my previous reply), such as:

sub x {
	return join '', map {join "\n", @$_,"==============\n"} @_;
}

[Aside: using x as a sub name, for testing purposes, is bad (IMO) since
the obvious next step is a sub named 'y', which leads to madness...]



-- 
Sam Holden


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

Date: 22 Jun 2004 03:56:00 -0700
From: Petri <Petri_member@newsguy.com>
Subject: Re: Perl DNS reverse lookups -- multiple IP addresses per line
Message-Id: <cb938001qfr@drn.newsguy.com>

In article <40D7E9AD.3FEE4E12@acm.org>, John W. Krahn says...

> Maynard wrote:

>> TCP out 65.198.222.70:43685 in 192.168.0.3:80 idle 0:00:00
>                                 ^^^^^^^^^^^
> It is not going to be very useful to do a DNS lookup on
> 192.168/16 addresses.  See RFC1918 for the reason why.

It may be useful at the OP's network.
He might be running split-DNS, with an internal reverse zone for
0.0.168.192.in-addr.arpa.
In that case he would catch names of internal systems, instead of their
IP-addresses.


Petri



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

Date: 22 Jun 2004 17:11:39 GMT
From: ctcgag@hotmail.com
Subject: Re: perl, mysql fetchrow_arrayref without package
Message-Id: <20040622131139.515$YD@newsreader.com>

smitty <joe@invalid.com> wrote:
> ctcgag@hotmail.com wrote:
> > Smithy <joe@invalid.com> wrote:


> >>$sth = $sth->execute or die $DBI::errstr;
> >>print "c-$sth\n";
 ...
> >>the select value of 1 is correct, in that there is only one entry in
> >>the table (entered by hand at mysql prompt).
> >
> >
> > No, the value is not correct.  Because the execute succeeded, it
> > returns true.  It just so happens that the true value it returns is 1,
> > and it just so happens that you expected one row.  That is luck, rather
> > than correctness. (As a further (un)luckiness, MySQL's DBD will often
> > have execute return the number of rows found by the select, but there
> > are situations where it will not. One should not rely upon it.)
>
> thanks for the pointers.  is the mysql DBD the only one that behaves
> this way, or do the others as well?

mysql is the only one (that I know of) which even attempts to return the
number of rows for an execute() on a SELECT statement handle.  Oracle, for
example, will usually (always?) return the true value "0E0" upon success.
This is because most databases (including mysql if you set
$sth->{'mysql_use_result'}=1;) may not know how many rows they will return
until they are done returning them, i.e. until the last fetch is called.

Xho

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


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

Date: Tue, 22 Jun 2004 08:37:26 -0500
From: Web Surfer <raisin@delete-this-trash.mts.net>
Subject: Re: Question on Perl printing
Message-Id: <MPG.1b41f20dbd188d59989836@news.mts.net>

[This followup was posted to comp.lang.perl.misc]

In article <1087854172.437175@sj-nntpcache-5>, robinncsu@yahoo.com 
says...
> Hi, guys. I edited a file in windows and uploaded it into unix. Then I ran
> my perl script to read into the file and then printed some results. But the
> results seems to be funny.
> 
> origianl line:
> test1.txt
> 
> printed result by perl:
>  estl.txt
> 
> The first character was erased. I noticed the file under unix was changed as
> "test1.txt^M" by using vi, which means cartridge return. Did anybody meet
> such a problem? Thanks in advance.
> 
> -bear


Any "Windows style" text file uploaded to UNIX that still has the
cartridge return on the end of the line can be "converted" to a UNIX
format with the "dos2unix" command.


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

Date: Tue, 22 Jun 2004 12:07:06 GMT
From: heitkamp@ameritech.net
Subject: Re: running multiple versions of perl
Message-Id: <KhVBc.27242$eH1.12749941@newssvr28.news.prodigy.com>

J. Gleixner <glex_nospam@qwest.invalid> wrote:
>Mothra wrote:
>> "Yoda Pugsley" <here@there.com> wrote in message
>> news:Xns94C9A13B64BADheretherecom@65.32.1.6...
>> 
>>>I'm new to perl and need to write a script for work. After doing some
>>>research into writing perl scripts (I'm a .net dev), I found that a lot of
>>>the examples I had found did not work. After a lot of head scratching (the
>>>UNIX admins are a lot of help too /sarcasm)
>> 
>> Those are bad admins then - I'm an Admin and I insisted that all our servers
>> were upgraded to 5.8.0... but then I'm a Perl coder as well. :o)

>Hopefully you have insisted that they upgrade from 5.8.0, since there 
>were a lot of issues with that release. :-)

I have been trying to figure the best way to upgrade perl.  I have a
linux system that started with Slackware a long time ago and is now
somewhat Debianized but I install a lot of programs with "configure; make; 
make install".  The best way to upgrade perl, that I've run across, is:
1. Run "perl -MCPAN -eshell" and run autobundle.
2. Completely delete all perl programs and directories.
3. Compile and install the new perl version.
4. install the bundle created with autobundle.

I am not a perl expert at all, and I wonder if any of the perl experts
can critique my procedure?
-- 

Fred

Error Loading Explorer.exe
You must reinstall Windows.


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

Date: 22 Jun 2004 13:13:04 GMT
From: Villy Kruse <vek@station02.ohout.pharmapartners.nl>
Subject: Re: Signals interrupt accept() - bug in perldoc perlipc?
Message-Id: <slrncdgc30.3bu.vek@station02.ohout.pharmapartners.nl>

On 22 Jun 2004 03:00:30 -0700,
    Peter Valdemar Morch <byqil3s02@sneakemail.com> wrote:


> I've discovered that at least CHLD signals in 5.8.0+ terminate
> accept(Client,Server) calls, so accept() now returns undef if CHLD is
> recieved if a %SIG signal handler has been assigned. Also, posts in
> this group have suggested to test for $! == EINTR, but on my Debian
> Testing 5.8.3, $! == ECHILD, not EINTR. (Is this significant?)
>

That is probably the value of errno as set by the wait() syscall.
When perl runs the perl level interrupt handler and calls the wait()
syscall the accept has already terminated and set the errno variable
to most likely EINTR.  Now the perl level signal handler calls wait()
which returns an error wiht errno ECHILD, which is bound to happen
if wait() is called in a loop as it normally would be.  That this
happens is because the perl level signal handler is no longer run
as part of the C level signal handler but is run between two perl
operations.  Usualy, if a C level signal handler may somehow modify
the errno variable, it should be saved at entry and restored when
exiting the signal handler.  Perhaps the perl level signal handler
should save $! at entry and restore it at exit.  Would "local $!;"
at the start of the signal handler work?

Do use strace to verify if the above describtion is what is actualy
happening.

> In 5.6.0 on Linux, the accept() call blocked until a server connected,
> regardless of signals. I expect that this change is related to "Safe
> Signals" in 5.8, but I didn't quite expect this behavior from the
> vague "Note that breaking out from potentially blocking operations
> should still work, though" in perldoc perl58delta. At least the
> behavior of accept() has changed...
>

In perl 5.6 and earlier everything happened in the signal handler and
accept would return and set errno after the signal handler returned.
Also, restartable syscalls would probably be restarted after catching
the signal, as that is the normal behaviour on linux.  With perl 5.8
you can't restart syscalls automatically if you wish to run the perl
level signal handler before the syscall would otherwise terminate
unless the perl runtime has been programmed to do that.

> Have any other signal related behaviors changed in a similar fashion?
> (So I can proactively inspect and fix bugs rather than find them
> through testing ;-)
>

Perhaps it is easier to suspend your program in a select call, in which
case the actual errno value when select returns an error doesn't realy
matter because you would loop back to select'ing again.  If select
returns a read read on the listen socket you can go ahead and accept the
connection.  The "can_read" method from IO::Select is probably the easiest
way to do this.



Villy


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

Date: Tue, 22 Jun 2004 15:03:18 +0000 (UTC)
From: kj <socyl@987jk.com>
Subject: Style [Q]: the placement of 'use'
Message-Id: <cb9hnm$cha$1@reader2.panix.com>





What is the "preferred" placement of use statements for *non-pragma*
modules?  Top of the file?  Within the innermost scope that uses
the imported symbols?  Any other considerations?

Thanks in advance!

kj
-- 
NOTE: In my address everything before the period is backwards.


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

Date: Tue, 22 Jun 2004 11:35:59 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: Style [Q]: the placement of 'use'
Message-Id: <Pine.SGI.3.96.1040622113430.29591B-100000@vcmr-64.server.rpi.edu>

On Tue, 22 Jun 2004, kj wrote:

>What is the "preferred" placement of use statements for *non-pragma*
>modules?  Top of the file?  Within the innermost scope that uses
>the imported symbols?  Any other considerations?

(This is just my opinion.)

It's helpful to be able to see at a glance what modules are requisites for
your code; putting them up at the top is what I do.  To place them in the
scope for which they are required is misleading, because no matter where
they are (outside of eval()s), they all execute at compile-time.

-- 
Jeff Pinyan         RPI Acacia Brother #734        RPI Acacia Corp Secretary
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: 22 Jun 2004 17:56:24 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Style [Q]: the placement of 'use'
Message-Id: <u9smcn351j.fsf@wcl-l.bham.ac.uk>

Jeff 'japhy' Pinyan <pinyaj@rpi.edu> writes:

> On Tue, 22 Jun 2004, kj wrote:
> 
> >What is the "preferred" placement of use statements for *non-pragma*
> >modules?  Top of the file?  Within the innermost scope that uses
> >the imported symbols?  Any other considerations?
> 
> (This is just my opinion.)
> 
> It's helpful to be able to see at a glance what modules are requisites for
> your code; putting them up at the top is what I do.  To place them in the
> scope for which they are required is misleading, because no matter where
> they are (outside of eval()s), they all execute at compile-time.

Of course they have to go after the package directive.

If I have top-level scope multiple package directives in a file then
each is typically followed by a series of use directives.

For modules that are neither pragmas nor import into the current
package (typically those with a pure OO interface) I usually put
'require' at the top of the file or just where they are used depending
on wether they are needed always or not.

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


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

Date: Tue, 22 Jun 2004 12:00:24 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: Why won't this split file script work?
Message-Id: <remorse-9E41AE.12002422062004@plato.harvard.edu>

In article 
<Pine.SGI.3.96.1040621171456.22064A-100000@vcmr-64.server.rpi.edu>,
 Jeff 'japhy' Pinyan <pinyaj@rpi.edu> wrote:

> [posted & mailed]
> 
> On Mon, 21 Jun 2004, Richard Morse wrote:
> 
> >According to the docs, you could actually write this as:
> >
> >   while(<IN>) {
> >      print OUT if $start .. $stop;
> >      last if $. == $stop;
> >   }
> 
> Not so.  I once (ok, more than once) fell prey to that.  The docs state
> (although not in the BOLD CAPITAL letters I'd like) that the implicit
> comparison to $. only takes place if the argument is a constant
> expression:
> 
>    If either operand of scalar ".." is a constant expression, that operand
>    is considered true if it is equal ("==") to the current input line num-
>    ber (the $. variable).

My apologies for reading too fast -- my source (the camel book, version 
3) actually says "if either operand of scalar .. is a numeric literal", 
with literal at the beginning of a new line, which I missed...

Thanks for the correction,
Ricky


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

Date: 22 Jun 2004 17:00:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Why won't this split file script work?
Message-Id: <cb9ok1$ffa$1@mamenchi.zrz.TU-Berlin.DE>

Richard Morse  <remorse@partners.org> wrote in comp.lang.perl.misc:
> In article 
> <Pine.SGI.3.96.1040621171456.22064A-100000@vcmr-64.server.rpi.edu>,
>  Jeff 'japhy' Pinyan <pinyaj@rpi.edu> wrote:
> 
> > [posted & mailed]
> > 
> > On Mon, 21 Jun 2004, Richard Morse wrote:
> > 
> > >According to the docs, you could actually write this as:
> > >
> > >   while(<IN>) {
> > >      print OUT if $start .. $stop;
> > >      last if $. == $stop;
> > >   }
> > 
> > Not so.  I once (ok, more than once) fell prey to that.  The docs state
> > (although not in the BOLD CAPITAL letters I'd like) that the implicit
> > comparison to $. only takes place if the argument is a constant
> > expression:
> > 
> >    If either operand of scalar ".." is a constant expression, that operand
> >    is considered true if it is equal ("==") to the current input line num-
> >    ber (the $. variable).
> 
> My apologies for reading too fast -- my source (the camel book, version 
> 3) actually says "if either operand of scalar .. is a numeric literal", 
> with literal at the beginning of a new line, which I missed...

You should have overlooked "numeric" instead, because also non-numeric
literals and indeed most constant expressions are compared to $.

The described behavior is more reasonable than the actual one.  Comparing
non-numeric values to $. makes little sense, so the massively irregular
behavior should be restricted to the cases where it does.

Anno


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

Date: 22 Jun 2004 08:01:50 -0700
From: djberg96@hotmail.com (Daniel Berger)
Subject: Re: WMI and boolean values from Win32_Processor
Message-Id: <6e613a32.0406220701.5e3e7d0d@posting.google.com>

Petri <Petri_member@newsguy.com> wrote in message news:<cb810t026mv@drn.newsguy.com>...
> In article <6e613a32.0406211531.6be71dab@posting.google.com>, Daniel Berger
> says...
> >Petri <Petri_member@newsguy.com> wrote in message
> >news:<cb66h602n66@drn.newsguy.com>...
>  
> >> List the names of the properties that really exist:
>  
> > Your VB led me to the Perl. They definitely exist as properties.
> > See below.
>  
> > # Output
>  
> > ConfigManagerErrorCode
> > ErrorCleared
> 
> Er, these two do NOT appear on either my WinXP or Win2K box using the VBscript
> code.
> Both boxes have WSH V5.6 and the latest service packs and hotfixes.
> 
> But the disturbing thing is, they DO appear when running the Perl code.
> I don't even know how that's possible.
> 
> > So, it looks like they're simply not defined, at least not yet,
> > though I'm guessing.
> 
> Who knows what's going on here...

I searched around a bit more on Google and the only clue I came across
was the possibility that some of these attributes depend on your BIOS
or BIOS settings, and so some values for certain attributes may come
back undefined.  Seems reasonable, though I'm not 100% sure of it.

Anyway, thanks everyone for their time and help.

Regards,

Dan


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

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


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