[29449] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 693 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 27 16:09:41 2007

Date: Fri, 27 Jul 2007 13:09:10 -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           Fri, 27 Jul 2007     Volume: 11 Number: 693

Today's topics:
    Re: @arts <spamtrap@dot-app.org>
    Re: @arts <bik.mido@tiscalinet.it>
    Re: @arts <bik.mido@tiscalinet.it>
    Re: @arts <spamtrap@dot-app.org>
    Re: Block of statements after "open" and before "die" <noreply@gunnar.cc>
    Re: calling a script with arguments <joe@inwap.com>
    Re: ERR: 13: Missing right $] <nospam-abuse@ilyaz.org>
    Re: Looking to do work with DNS through Perl <lambik@kieffer.nl>
    Re: Math <blb8@po.cwru.edu>
    Re: Objects/Structures in Perl <1usa@llenroc.ude.invalid>
    Re: Objects/Structures in Perl (Jens Thoms Toerring)
    Re: Perl with DBI <sbryce@scottbryce.com>
    Re: standard setup for scripts <tom_spam@removethis-tabsoftwaresystems.com>
    Re: whether large hash might leak? xhoster@gmail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 27 Jul 2007 14:22:32 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: @arts
Message-Id: <m2r6mthfkn.fsf@dot-app.org>

"Mike Hartsough" <michaellhartsough@sbcglobal.net> writes:

> In what way is "stick a pen up your ass" any near the same as "please
> properly attribute your quotes" ? The latter is also in the "Posting
> Guidelines", so why do you keep looking for

Will you please give it a rest? Michele's attribution mistake may have
been mildly annoying, but your three-day whining binge about it is far
more so. Grow up.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Fri, 27 Jul 2007 20:02:59 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: @arts
Message-Id: <40cka3tqctnnirktjbd3dqpj1ukb98lde4@4ax.com>

On Fri, 27 Jul 2007 09:49:03 -0700, "Mike Hartsough"
<michaellhartsough@sbcglobal.net> wrote:

>> > http://groups.google.com/groups?as_q=&num=100&hl=en&as_epq=posting+guidelines&as_uauthors=Michele+Dondi
>>
>> Well, for one thing the search you're suggesting turned out 16, I say
>> *16* results. If you search
>>
>> http://groups.google.com/groups?q=author%3AMichele+author%3ADondi+group%3Acomp.lang.perl.misc&num=100
>>
>> instead, you'll find 2250, I say *2250*.
>
>So you just proved my point here even more. and you did a different

No I didn't prove it and funnily enough, as I had predicted, you
snipped with extreme precision the contents of the posts which I
pasted.

>search altogether. Mine is measuring how many times you mentioned the

OF COURSE I did a different search altogether: just wanting to say
that 16, or 24 (posts of mine which "mention" the guidelines) over
2250 (posts of mine in clpmisc, period) is a rather smallish fraction.
Of course, you'll beg to differ: it's a *huge* fraction, ain't it?

>guidelines. You also missed the point the it's not just you, but other

No, your search is far from "measuring how many times I mentioned the
guidelines": it just searches posts by me which also contain in the
body or in the Subject line the word "posting" and the word
"guidelines", whether I wrote them or not, and in *any group*, not
just clpmisc.

>regulars mention them almost religiously.

So, should I take responsability over what the other regulars do? Are
you a comedian?!?

>> Do those sixteen qualify as "many"?!?
>
>I actually get 24 (what is it with google groups these days only
>returning partial results?), but either way, your original assertion,

18 now.

>that you "hardly ever mention" or "direct people" to the guidelines is
>wrong, even if you don't do it as often as others.

No, your claim that my assertion is wrong, is wrong. I CHALLENGE you
to give me the urls of messages in which I properly say anything
assimilable to "please read the posting guidelines", with or without
the "please". I found 1.5 such posts this morning and judging by the
scrollbar, I was about half way through the results that your google
search returned.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 27 Jul 2007 20:50:00 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: @arts
Message-Id: <rveka3tqvjhe8qg4tbf0bu8i3sqv6m0gc2@4ax.com>

On Fri, 27 Jul 2007 14:22:32 -0400, Sherm Pendley
<spamtrap@dot-app.org> wrote:

>Will you please give it a rest? Michele's attribution mistake may have
>been mildly annoying, but your three-day whining binge about it is far
>more so. Grow up.

I (for one) "don't wanna grow up." (The Vandals', not Tom Waits' nor
the Ramone's cover of Tom Wait's, although that is the best IMHO.)

Adults sometimes adhere blindily to a mistaken sense of courtesy by
virtue of which they often keep from manifesting simple truths even if
doing so would be in order. If one is acting like an idiot, they may
be too ashamed to tell him. Kids will just laugh in his face. Back
when I went to the church a priest there who had been a missionary in
Brazil for a long time, told us that when learning Portoguese he tried
to talk with kids most, *because* they would laugh in his face when
sounding ridiculously wrong.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 27 Jul 2007 15:46:00 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: @arts
Message-Id: <m2ejithbpj.fsf@dot-app.org>

Michele Dondi <bik.mido@tiscalinet.it> writes:

> On Fri, 27 Jul 2007 14:22:32 -0400, Sherm Pendley
> <spamtrap@dot-app.org> wrote:
>
>>Will you please give it a rest? Michele's attribution mistake may have
>>been mildly annoying, but your three-day whining binge about it is far
>>more so. Grow up.
>
> I (for one) "don't wanna grow up." (The Vandals', not Tom Waits' nor
> the Ramone's cover of Tom Wait's, although that is the best IMHO.)
>
> Adults sometimes adhere blindily to a mistaken sense of courtesy by
> virtue of which they often keep from manifesting simple truths even if
> doing so would be in order. If one is acting like an idiot, they may
> be too ashamed to tell him. Kids will just laugh in his face.

I completely agree - I strongly prefer impolite honesty over sugar-coated
nonsense. But that's not really what I was referring to when I said "grow
up."

I was referring to the way that children tend to overreact and throw the
wildest tantrums over trivia. Maybe you did bend the guidelines a bit - I
don't see how that could possibly justify the kind of moaning and carrying
on I'm seeing in this thread.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Fri, 27 Jul 2007 20:58:29 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Block of statements after "open" and before "die"
Message-Id: <5gutp1F3hd15bU1@mid.individual.net>

bernd wrote:
> I wondering whether it is possible to execute more statements than the
> "traditional" die after the invocation of open in a perl script:
> 
> Instead of:
> 
> open (FH, ">testfile") or die "Cannot open testfile" ;
> 
> I want to do a little bit more. My idea is deployment of a "do"-block

As others have explained, a do-block may be fine. Another opportunity is 
to write a sub:

     open FH, "> testfile" or mydie("Couldn't open file: $!");

     sub mydie {
         my $msg = shift;
         my ($file, $line) = (caller)[1,2];

         # send email
         # ,,,

         die "$msg at $file line $line.\n";
     }

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


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

Date: Fri, 27 Jul 2007 12:56:35 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: calling a script with arguments
Message-Id: <36ydnRh0gtOe0zfbnZ2dnUVZ_vGinZ2d@comcast.com>

jpw wrote:
u for the replies.  While ARGV does provide me the string
> value of the command line, as opposed to the actual "content"  of the
> xml file.  Presumably I would then have to *read* the file in to a
> variable to then be posted to the url.  Incidently, I don't know how
> to do that either.

   if (@ARGV) {
     print "Reading from these files: @ARGV\n";
   } else {
     print "Reading from STDIN\n";
   }
   my @file = <>; # Read entire contents of one or more files, or STDIN


	-Joe


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

Date: Fri, 27 Jul 2007 19:51:13 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: ERR: 13: Missing right $]
Message-Id: <f8dibh$4sm$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
pp 
<pp@mm.org>], who wrote in article <13aje2itgvt250e@corp.supernews.com>:
> 
> Hi,
> 
> Can anyone tell me how to fix this error in perl?
> The above error point to the following line or perl code.
> 
> %UN_MONTH= map { lc($MONTH[$_]), $_ }  0..$#MONTH ;   # look up by month 
> name

E2LITTLECONTEXT

At least, we need to see the full error message.

Hope this helps,
Ilya


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

Date: Fri, 27 Jul 2007 20:57:53 +0200
From: "Lambik" <lambik@kieffer.nl>
Subject: Re: Looking to do work with DNS through Perl
Message-Id: <46aa3fbe$0$37712$5fc3050@dreader2.news.tiscali.nl>


"James" <djcameron60616@yahoo.com> wrote in message
news:1185495207.709821.112230@19g2000hsx.googlegroups.com...
> Hello,
>
> I'm not terribly new to Perl, I have some basics down.  What I don't
> have down is finding a way to do what I want for a particular script.
>
> What I am looking to do is to query DNS servers on both Win32 and
> UNIX, to get a list of all servers in the network ranges we have.
> For example,
> lets say I have a 10. network and a 130. network, with several subnets
> and VPN's.  I want a script to go out and:
> (This is where this post comes in handy)
> A. Query all DNS servers in the domains, in all the networks and
> either grab zone files or host files,
> B. Authenticate into each server and run several subroutines to query
> information on the current server,
> C .. A whole bunch of other stuff.
> The problems are:
> A I don't know the particular nameservers at this time (unfortunately
> the company doen't let you do ping sweeps or run sam-spade type tools
> on the networks)
> B. I don't have access to all servers at this time.
>
> Is it possible to get DNS server names from domain controllers, or
> just a nslookup on the main domains?
> If I don't have access to the DNS servers, is it possible to extract
> the information through ADS?
> Is it also possible to get the DNS information (in full) - all servers
> in DNS, if I don't have access to the nameserver?
>
> I'm pretty new to windows, and if I had access to the other platforms
> I'd have no problem getting the information.  I essentially have to
> write the tools myself.

I don't understand what exactly you want to do. If you are not allowed to
ping the network, then i guess you are in trouble. There is no way to do it
without pinging the network.

use Net::DNS;

foreach my $nr (253..254) {
 my $res = Net::DNS::Resolver->new(
     nameservers => [qq(192.168.1.$nr)],
     recurse     => 0,
     udp_timeout => 3
    );
 if ($res->search('localhost')) {
  print "Found a localhost entry on 192.168.1.$nr\n";
 };
}
__END__
is just another way of pinging. What i don't see is what this has to do with
Windows. If you want the DNS server of the current computer you could do
something like:

use Win32::OLE('in');
use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;

$computer = ".";
$objWMIService = Win32::OLE->GetObject
    ("winmgmts:\\\\$computer\\root\\CIMV2") or die "WMI connection
failed.\n";
$colItems = $objWMIService->ExecQuery
    ("SELECT * FROM Win32_NetworkAdapterConfiguration",
     "WQL",wbemFlagReturnImmediately | wbemFlagForwardOnly);

foreach my $objItem (in $colItems)
{
      print "DNS Server Search Order: " . join(",", (in
$objItem->{DNSServerSearchOrder})) . "\n";
}
__END__

But the biggest question is: why do you want to do it when you obviously
aren't permitted to do so?




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

Date: Fri, 27 Jul 2007 19:05:51 +0000 (UTC)
From: Brian Blackmore <blb8@po.cwru.edu>
Subject: Re: Math
Message-Id: <f8dfme$ete$1@gnus01.u.washington.edu>

Brian Blackmore <blb8@po.cwru.edu> wrote:
> Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> > [A complimentary Cc of this posting was sent to
> > Brian Blackmore 
> > <blb8@po.cwru.edu>], who wrote in article <f82pte$kl3$1@gnus01.u.washington.edu>:
> > > > For some unfathomable reasons, Perl uses non-invertible transformations
> > > > between strings and numbers.  So if your handling of numbers involves
> > > > converting them to strings, then back, the precision will be lost.

> > > Yes, but I would question which programming languages don't suffer
> > > from this behavior?

> > What other programming languages with multi-representation numbers do
> > you know?

> Yeah, I have to apologize here because I've conflated a couple of
> ideas and caused a minor communication problem.  Certainly the 1/3
> issue is a matter of representation, whence a different issue, but I
> brought that in from the other part of the thread.  I think I've
> been looking for a specific example to the first statement way up
> above here, about losing precision during conversion.  Is what you
> had in mind something like this:

> #!/usr/bin/perl

> $a=42.1; for (1..30) { $a+=0.1 }
> $b="$a"; print "a=",$a," b=",$b,"\n";
> $a==$b ? print "Equal\n" : print "Not equal\n" ;


Sorry, I rescind my understanding because in C:

#include <stdio.h>
#include <stdlib.h>

int main() {
  double a=42.1;
  char* c;
  double d;
  int i=30;

  for(;i>0;i--) { a+=0.1; }
  sprintf(c,"%f",a);
  d=atof(c);

  printf("%f\n",a);
  printf("%f\n",d);

  if(a!=d) { printf("Lost precision\n"); }
  else { printf("Okay\n"); }

  return 0;
}


Both report on lost precision.

So now I'm back to being confused.  When you speak of these
non-invertible transforms, is this what you had in mind?  If so, it
doesn't seem to work on C either (contrary to a statement from
another person's post in this thread).

If this is not what you had in mind, can you give an example of Perl
going bad in the way you mentioned?  

Thanks a bunch for your time.

-- 
Brian Blackmore
blb8 at po dot cwru dot edu


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

Date: Fri, 27 Jul 2007 18:59:54 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Objects/Structures in Perl
Message-Id: <Xns997A98905F471asu1cornelledu@127.0.0.1>

"O. Olson" <olson_ord@yahoo.it> wrote in news:1185558752.760041.195290@
57g2000hsv.googlegroups.com:

> On Jul 27, 2:19 am, j...@toerring.de (Jens Thoms Toerring) wrote:
 ...
> 
> My Questions:
> 
>> package MyTime;
>>
> 
> Can this package be declared in a separate file - I tried it - but it
> would not work. I put this in a file called "MyTime.pl" and in the
> original source file put "use main::MyTime;". This does not work.

Of course it can be put in a different file but there are rules that 
determine where the resulting file goes.

See the section "Perl Modules" in perldoc perlmod.

Second, if the package is called MyTime then the package is called 
MyTime not main::MyTime.

I fact, I would prefer not to put packages in the root namespace but 
instead adopt the following convention:

package My::Time;

To use this package, suppose your application is in

C:\opt\mytime

I would then put my custom package in c:\opt\mytime\lib\My\Time.pm

That file would start with the package declaration:

package My::Time;

The application, let's assume the executable is mytime.pl, can then 
specify the custom location:

#!/usr/bin/perl

use strict;
use warnings;

use File::Spec::Functions qw( catfile );
use FindBin qw( $Bin );

use lib catfile( $Bin, 'lib' );

use My::Time;

my $time = My::Time->new;

# ...
# ...

__END__

>> sub new {
>>     my $inv = shift;
>>     my $class = ref( $inv ) || $inv;

There two schools of thought on being able to call new on the class and 
the object. I subscribe to the camp that thinks this is unnecessary.

sub new {
    	my $class = shift;


>>     die "Too many arguments\n" unless @_ <=3;
>>     my $self;
>>     if ( @_ == 0 ) {                  # no arguments
>>         my @time = localtime( );
>>         $self = { hour   => $time[ 2 ],
>>                   minute => $time[ 1 ],
>>                   second => $time[ 0 ] };
>>     } else {
>>         $self = { hour   => $_[ 0 ],
>>                   minute => $_[ 1 ] || 0,
>>                   second => $_[ 2 ] || 0 };
>>     }
>>     return bless $self, $class;
>>
>> }
>>
> 
> I think I did not understand some of the aspects of this new()
> function - though I liked the clever way you created a new hash
> everytime a new object of the class is required. Keith above mentioned
> that I should do this - but he did not elaborate that way you did it.

Because you are supposed to read the documentation that comes with Perl. 
On Windows, look in the ActiveState Perl program group. Follow the link 
for HTML docs. At least, read the table of contents. See the topics on 
object oriented programming and read them.

> 
> 1. I think from the documentation that "shift" would decrease the size
> of the array @_ by 1. So shouldn't that at the top be @_ <=2;

Again, if you had read the documentation (e.g. perldoc perlobj) you 
would have known that the first argument to a method (not a subroutine) 
is the name of the class. Again, you can easily check this:

C:\Home\asu1\Src\test\t> cat t.pl
#!/usr/bin/perl

package My::Test;

use strict;
use warnings;

use Data::Dumper;

sub new {
    print Dumper \@_;
}

package main;

use strict;
use warnings;

my $t = My::Test->new( qw(a bunch of arguments) );

__END__


C:\Home\asu1\Src\test\t> t
$VAR1 = [
          'My::Test',
          'a',
          'bunch',
          'of',
          'arguments'
        ];


> 2. I think I did not understand what the second line does:
> 
> my $class = ref( $inv ) || $inv;

Enables new to be called on an object rather than just the class so you 
can do:

my $x = My::Time->new( qw( blah blah blah ) );

my $y = $x->new;

I really see no good reason to do this. It is too confusing for people 
of limited telepathic abilities (such as myself) as it is not clear to 
me what a method named 'new' should do when invoked on an object.

> 3. Is $time sort of an implicit variable. I looked at the "localtime"
> function at http://perldoc.perl.org/functions/localtime.html and I
> could not find any mention of it.

Ahem, I cannot see any variable called $time in Jens' code.

> 4. Finally I have no idea about:
> 
> return bless $self, $class;
> 
> I looked at http://perldoc.perl.org/functions/bless.html regarding
> bless - but I did not understand how $class would refer to the current
> package.

See above.

> I would also like to know if every file in Perl should end with a 1; -
> I did not know this before - but only learnt about it when you used
> it.

No. Every file use'd or require'd should return a true value.

Again, reading the relevant documentation that is installed on your 
computer would have alerted you to this.

Sinan

>>                              Regards, Jens
> 
> Thanks a lot for your code :) I think that's exactly what I wanted.

Yup, another dish of fish served.

Sinan



-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>



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

Date: 27 Jul 2007 19:03:16 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: Objects/Structures in Perl
Message-Id: <5gutrkF3hjomhU1@mid.uni-berlin.de>

O. Olson <olson_ord@yahoo.it> wrote:
> My Questions:

> > package MyTime;

> Can this package be declared in a separate file - I tried it - but it
> would not work. I put this in a file called "MyTime.pl" and in the
> original source file put "use main::MyTime;". This does not work.

You need to name it 'MyTime.pm' since it's a module. And in the
file that uses it you just put 'use MyTime;', without the 'main::'
in front of it.

> > sub new {
> >     my $inv = shift;
> >     my $class = ref( $inv ) || $inv;
> >     die "Too many arguments\n" unless @_ <=3;
> >     my $self;
> >     if ( @_ == 0 ) {                  # no arguments
> >         my @time = localtime( );
> >         $self = { hour   => $time[ 2 ],
> >                   minute => $time[ 1 ],
> >                   second => $time[ 0 ] };
> >     } else {
> >         $self = { hour   => $_[ 0 ],
> >                   minute => $_[ 1 ] || 0,
> >                   second => $_[ 2 ] || 0 };
> >     }
> >     return bless $self, $class;
> >
> > }
> >

> I think I did not understand some of the aspects of this new()
> function - though I liked the clever way you created a new hash
> everytime a new object of the class is required. Keith above mentioned
> that I should do this - but he did not elaborate that way you did it.

It's not "my" clever way, it's copied staight from the Camel
book, "Programming Perl";-)


> 1. I think from the documentation that "shift" would decrease the size
> of the array @_ by 1. So shouldn't that at the top be @_ <=2;

Actually, the new() methid gets called with up to 4 arguments,
the first one being either the name of the package or an
object of the class. When you write

my $a = new MyTime();

(the parenthesis after MyTime are redundant), then you pass
1 argument to the new() method, the name of the class. So,
after the shift, you still should have up to 3 remaining
arguments.

> 2. I think I did not understand what the second line does:

> my $class = ref( $inv ) || $inv;

Since new() is a methid it can be either called with the name
of the class or via an object of that class. The first way
is either

my $a = new MyTime;

or, more verbose,

my $a = MyTime::new( 'MyTime' );

In this case the argument is the name of the class, so it's
not a reference and calling ref() on it returns false. The
other way to call it is as a method (if you already have an
object of that class)

my $b = $a->new;

In this case the method receives the object as it's first
argument (that's basically the 'this' variable from C++)
and ref() returns the name of the class.

> 3. Is $time sort of an implicit variable.

No, @time is just a simple array that is used locally to this
function. There's nothing "magic" about it.

> I looked at the "localtime"
> function at http://perldoc.perl.org/functions/localtime.html and I
> could not find any mention of it.

localtime() returns an array, which gets assigned to @time.

> 4. Finally I have no idea about:

> return bless $self, $class;

That's what ties it all together. Up to this line $self was
just a simple reference to an anonymous hash. But we want
it to be a bit more, a real object, and that's what the
bless function makes out of it - it makes $self an object
of the class MyTime (and returns the new object which we
then return to the caller. Only because of this you can
use it later with all the object-oriented bells and wistles
like calling

my $string = $a->as_text;

If you would leave out the call of bless you would get a
error message like "Can't call method "new" on unblessed
reference".

> >
> > 1;
> > ------8<-------------------------------------------------------
> >

> I would also like to know if every file in Perl should end with a 1; -
> I did not know this before - but only learnt about it when you used
> it.

Yes, every package and module needs to end in '1;' (or something
else that indicates success, so e.g. '"a";' would also do).

                              Regards, Jens
-- 
  \   Jens Thoms Toerring  ___      jt@toerring.de
   \__________________________      http://toerring.de


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

Date: Fri, 27 Jul 2007 12:40:57 -0600
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Perl with DBI
Message-Id: <8-idnasgm5yroTfbnZ2dnUVZ_vHinZ2d@comcast.com>

Peter J. Holzer wrote:

>>ITYM $param('var').
> 
> 
> What is that supposed to mean?

That I shouldn't be trying to answer questions when I am not thinking 
clearly.


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

Date: Fri, 27 Jul 2007 15:25:12 -0400
From: Tom Bolick <tom_spam@removethis-tabsoftwaresystems.com>
Subject: Re: standard setup for scripts
Message-Id: <iErqi.6055$WN1.6046@bignews2.bellsouth.net>

Tad McClellan wrote:
> Tom Bolick <tom_spam@removethis-tabsoftwaresystems.com> wrote:
> 
> 
>>$IS_WEBSITE = (-e "/home/userme/lib/site_perl");
>>if ($IS_WEBSITE){
> 
> 
> 
> You don't need a variable:
> 
>    if ( -e "/home/userme/lib/site_perl"){
> 
> 

Understood.  But I use $IS_WEBSITE to know which database to attach to 
later in my code.  And while I could use the same check elsewhere, I 
wanted the path specific stuff in as few places as possible (should it 
ever change).



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

Date: 27 Jul 2007 19:12:28 GMT
From: xhoster@gmail.com
Subject: Re: whether large hash might leak?
Message-Id: <20070727151230.257$1T@newsreader.com>

Kimia <chemiestor@gmail.com> wrote:
> hi, girls and dudes,
>
> ....I doubt whether hash might leak when it comprises of a large
> amount of pairs.
>     Recently I have been asked to do some statitic work over large
> files. All I wanted to do is to find the duplicated lines of a file
> and I wrote the snippet as below:
> code:
>   mysort.pl
> ------------------------
> #!/usr/bin/perl
>
> use strict;
> use warnings;
> my %in;
> my $cnt = 0;
> while(<>){
>         chomp;
>         $_ or ++$cnt,  next;
>         ++$in{$_};
> }
> foreach(sort keys %in){
>         $cnt += $in{$_};
>         print "$_*$in{$_}\n";
> }

What is the stuff with $cnt?

>
> However, when I used it for a large file, which contains 10M lines, it
> failed.

It doesn't fail.  I gives you output you didn't expect.

>
> $ ./mysort <TenLinesInput.dat >out
> $ echo $?
> 0
> $ tail out -n 5
> ------------------------
> ??????????????*2
> ????????????????*1
> ??????????????????*1
> ?????????????????????????????*2834
> ?????????????????????????????????????????????????????????????????????????
> ?????????????????????????????????????????????????????????????????????????
> ?????????????????????????????????????????????????????????????????????????
> ????????????????????? *1
> ------------------------
>     Where '?' is \0xff, when viewed as binary file.
>     I'm sure that the input contains no char as: \0xff.

I am not sure of that.  Try this and see what it gives, and if
it consistently gives the same thing:

perl -lne 'print $. unless -1==index $_, chr(0xff)' TenLinesInput.dat


> Most of lines
> are tens of char long, few exceeds 100 and none exceeds 1000.
>     The other output lines, except last 10, all are as expected.
>
>     Then I tried it for a input file conprised of one million lines
> and it failed with the same error;

It didn't fail with an error.  The value of $? shows that.  (And I don't
see anything suggestive of a "leak", either.)  It seems like what it comes
down to is that you and Perl disagree over what is in your file.


Xho

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


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

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 V11 Issue 693
**************************************


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