[26628] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8737 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 6 14:05:27 2005

Date: Tue, 6 Dec 2005 11:05:08 -0800 (PST)
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, 6 Dec 2005     Volume: 10 Number: 8737

Today's topics:
    Re: @INC and win32 <noreply@gunnar.cc>
    Re: A simple inheritance question. xhoster@gmail.com
    Re: FAQ 6.23 How do I match a pattern that is supplied  <jgibson@mail.arc.nasa.gov>
    Re: FAQ 6.23 How do I match a pattern that is supplied  <glex_no-spam@qwest-spam-no.invalid>
    Re: No Print output <wh2leung@student.cs.uwaterloo.ca>
    Re: Slow insertion to hashes? xhoster@gmail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 06 Dec 2005 18:18:48 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: @INC and win32
Message-Id: <3vlvfpF15ho1gU1@individual.net>

Jeff Thies wrote:
>>>
>>> use lib 'path to lib';
>>> push @INC, 'path to lib';
>>>
>>> Why does that not work when I do this:
>>>
>>> do 'win32.cfg';
>>
>>  Try
>>
>>     BEGIN { do 'win32.cfg' }
> 
> Damn if that doesn't work! There's no downside in doing that, that I can 
> see. It's kind of like a "use" that does not fail, so on the *nix side 
> it can be ignored.

That's an odd description of a BEGIN block. Maybe you should take a look 
in "perldoc perlmod".

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


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

Date: 06 Dec 2005 16:40:20 GMT
From: xhoster@gmail.com
Subject: Re: A simple inheritance question.
Message-Id: <20051206114020.752$0i@newsreader.com>

Don Gatlin <DG@nowhere.com> wrote:
> Let me see if I can explain the question in a way to be sensible.
> The code is at the bottom.
>
> I build an Object1 and initalise it with some data with new();
> I make an instance of it

How can "build"ing it be a different step from making an instance of it?

> and, using a method in the object,  can get or
> change the data.
> At this point I can access it from anywhere in main and the data is
> valid, including changes and additional keys in the hash %self.
> Normal simple OO stuff.
>
> Now it is inheritance time.
> I build an Object2 and and inherit the original Object1.

Objects don't inherit, classes inherit.  Class2 inherits from Class1.
Object2 is unrelated to Object1.


> The methods in
> both objects work fine, but only the original data exists in Object1 when
> I access Object1 from Object2,

You are not accessing Object1 from Object2.

> not changes or additions.   I think I know
> why from tracing through the process.  It appears that when I inherit
> Object1 from Object2, it reinitalises the copy with the start data when
> it flows through the Object1->new() process.

There is no Object1->new() "process" anywhere in your code.

>
> Fine.  But how do you inherit an object with all the changes to the data?

It is not clear what that means.  Whatever it means, it seems very
data-oriented, not object-oriented.  Maybe you want an has-a, rather than
an is-a, relationship?  Or maybe singleton objects?


> I am more interested in understanding the process than fixing the code.

You just said you think you know "why from tracing through the process".
If that is so, then what is left to understand?  The problem does not seem
to be that you are seeing something incorrectly, but rather that you are
seeing something when there is nothing to be seen.  You don't need to
change the way you see things, you just need to stop seeing things that are
not there.

Xho

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


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

Date: Tue, 06 Dec 2005 09:37:52 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: FAQ 6.23 How do I match a pattern that is supplied by the user?
Message-Id: <061220050937527721%jgibson@mail.arc.nasa.gov>

In article <dn3624$2u2$1@reader2.panix.com>, PerlFAQ Server
<comdog@pair.com> wrote:

> 6.23: How do I match a pattern that is supplied by the user?
> 
>     Well, if it's really a pattern, then just use
> 
>         chomp($pattern = <STDIN>);
>         if ($line =~ /$pattern/) { }
> 
>     Alternatively, since you have no guarantee that your user entered a
>     valid regular expression, trap the exception this way:
> 
>         if (eval { $line =~ /$pattern/ }) { }
> 
>     If all you really want to search for a string, not a pattern, then you

Please insert 'is' ----------^

>     should either use the index() function, which is made for string
>     searching, or if you can't be disabused of using a pattern match on a

Possible comma ----^ needed here.

>     non-pattern, then be sure to use "\Q"..."\E", documented in perlre.
> 
>         $pattern = <STDIN>;
> 
>         open (FILE, $input) or die "Couldn't open input $input: $!; aborting";
>         while (<FILE>) {
>             print if /\Q$pattern\E/;
>         }
>         close FILE;

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


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

Date: Tue, 06 Dec 2005 12:39:41 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: FAQ 6.23 How do I match a pattern that is supplied by the user?
Message-Id: <OVklf.25$P_3.4038@news.uswest.net>

Jim Gibson wrote:
> In article <dn3624$2u2$1@reader2.panix.com>, PerlFAQ Server
> <comdog@pair.com> wrote:
> 
> 
>>6.23: How do I match a pattern that is supplied by the user?

>>    should either use the index() function, which is made for string
>>    searching, or if you can't be disabused of using a pattern match on a
> 
> 
> Possible comma ----^ needed here.

Also, "dissuaded from" instead of "disabused of", reads a bit better. IMHO.


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

Date: Tue, 6 Dec 2005 12:14:43 -0500
From: William <wh2leung@student.cs.uwaterloo.ca>
Subject: Re: No Print output
Message-Id: <Pine.GSO.4.58.0512061211360.28384@cpu02.student.cs.uwaterloo.ca>

I have modified the syntax to the following:
#!/usr/bin/perl

require "../accmgr";

# need to get accmgr to pass the userid's desk back to this file
$desk = getDesk();
print $desk;


where getDesk() is in accmgr:

    554 sub getDesk{
    555     return $USERS{$Group};
    556 }

Still, $USERS{$Group} is not being printed for print $desk

I did set up the environment before running the CGI script.



On Sun, 4 Dec 2005, Joe Smith wrote:

> William wrote:
>
> >      25 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
> >      26 print $desk;
>
> Do you understand the distinction between
>
>    $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
>
> and
>
>    $desk=`/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk`;
>
> ?  And are you aware that one CGI program cannot call another
> CGI program using the syntax you're using?
>
> It appears that you are under the mistaken impression that
> a perl script treats URLs the same way that a browser does.
>
> For URLs pointing to an external server, use LWP::Simple.
> For CGI scripts running on the same server as the perl script,
> you have to set up the right environment before executing
> the second script, and use either backticks or pipe to read
> the results.
>
> 	-Joe
>


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

Date: 06 Dec 2005 17:03:20 GMT
From: xhoster@gmail.com
Subject: Re: Slow insertion to hashes?
Message-Id: <20051206120320.695$B0@newsreader.com>

Jindroush <jindroush.nospam@seznam.cz> wrote:
> Hi,
>
> I have to load a file. I 'index' the records in two hashes. At the
> beginning I do:
>         my $fl = -s $in;
>         my $recs = int( $fl / 85 );
>         keys( %$hr1 ) = $recs;
>         keys( %$hr2 ) = $recs if defined $hr2;

I've never found this type of preallocation to be worthwhile.

You don't seem to be using strict.  This quite likely is the problem.

>
> then for each record:
>                 $$hr1{ lc $fname } = \%H;

Where did %H come from?  If I could see that, perhaps I could help you.

>
>                 if( defined $hr2 )
>                 {
>                         $$hr2{ $H{ hdr } . $H{ ent } } = \%H;
>                 }
>
> In %H is my data stored. This works good up to cca 70000 records (file1
> has about 91000 records, each record is about 85 chars, split in 6
> strings). Then it is _DEAD SLOW_.

It sounds like you are swapping.

> I load three such files in 3 (6)
> different hashes. The two other files are also _DEAD SLOW_.

It sounds like you are swapping.

> I have quite
> fast computer and s**tloads of free ram.

I have no idea what you consider to be a s**tload.  If you want real
answers, post real information.

> Running: v5.6.1 built for
> MSWin32-x86-multi-thread (activestate) on WXP (no way to change the perl
> version/os).
>
> Why is it so slow?

Probably because you are swapping?  Why are you swapping?  I don't know,
you haven't given us enough information to know.  Or you could be having
hash key collisions.  periodically Print your hashes in a scalar context
to see what the bucket usage is.

> How can I make it faster?

You could post code that is actually runnable, so we can try it out and
see if we can see what the problem is.  In other words, you could follow
the posting guidelines.

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 V10 Issue 8737
***************************************


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