[12437] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6037 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 17 22:07:28 1999

Date: Thu, 17 Jun 99 19:00:18 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 17 Jun 1999     Volume: 8 Number: 6037

Today's topics:
    Re: @INC question cool_water420@my-deja.com
    Re: @INC question <cassell@mail.cor.epa.gov>
    Re: a thread on threads (the skinny on the schedule) <rra@stanford.edu>
    Re: a thread on threads (the skinny on the schedule) <rra@stanford.edu>
    Re: Afraid to ask about Y2K! (J. Moreno)
    Re: changing text in a file? <outlaw_torn@mailexcite.com>
        email owner name <arutla@csee.wvu.edu>
    Re: email owner name (Jason Kohles)
        Having trouble making this work... <portboy@home.com>
    Re: help! pattern matching question <rick.delaney@home.com>
        Help- time olmert@netvision.net.il
        Hex to Decimal?? <seongbae@students.uiuc.edu>
    Re: Hex to Decimal?? (Alastair)
    Re: Hex to Decimal?? (Andrew Allen)
    Re: how to change a line of text in a file? <fake@nospam.edu>
        Is Perl4 Y2K compliant? <dwb1@home.com>
    Re: LD_LIBRARY_PATH setting within the perl program <myparu@usa.net>
    Re: MIcrosofts Attack on Perl <watcher_q@my-deja.com>
    Re: OO-Trap! I am confused (Andrew Allen)
    Re: Open2 with smbclient (Charles DeRykus)
    Re: Personal Rant (was Re: Does Perl have a future?) <watcher_q@my-deja.com>
        Recommend a simple Online database? <neil@pacifier.com>
    Re: single vs. double quotes <palincss@his.com>
        STDOUT/STDERR Redirection (Win32) <jeffl@plaza.ds.adp.com>
    Re: Weird socket behaviour jballagh@du.edu
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 17 Jun 1999 22:52:25 GMT
From: cool_water420@my-deja.com
Subject: Re: @INC question
Message-Id: <7kbu76$10r$1@nnrp1.deja.com>




I have perl 517 on win 95 and
i want perl to access data from a personal oracle 7.2 database.

Now for this i need DBI and DBD modules for connectivity.I have downl
aded them and put them in my perl directory on my local drive.
The path where i have kept them is c:\perl\lib.
But still when i run my program i get the error

cant locate DBI.pm in @INC.
Any suggestions????????????????
Thanks in advance.

Tej


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 17 Jun 1999 17:25:10 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: @INC question
Message-Id: <376991E6.2EFD541D@mail.cor.epa.gov>

cool_water420@my-deja.com wrote:
> 
> I have perl 517 on win 95 and
> i want perl to access data from a personal oracle 7.2 database.
> 
> Now for this i need DBI and DBD modules for connectivity.I have downl
> aded them and put them in my perl directory on my local drive.
> The path where i have kept them is c:\perl\lib.

Does this mean that you literally *put* the files there 
instead of using ppm to do the installation for you?

> But still when i run my program i get the error
> 
> cant locate DBI.pm in @INC.
> Any suggestions????????????????
> Thanks in advance.

Sounds like Perl can't find them.  Perhaps you should
use the ppm program to do the installation for you.
That way you'll get the HTML docs added to your HTML
doc tree as well.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 17 Jun 1999 17:38:40 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: a thread on threads (the skinny on the schedule)
Message-Id: <ylaety5omn.fsf@windlord.stanford.edu>

Tom Christiansen <tchrist@mox.perl.com> writes:

> It's highly unclear how they light-weight processes (threads) interact
> with process-oriented features, such as signals.  It's also a lot easier
> to debug without LWP.

The standard party line in the thread programming guides that I've seen is
"if you're using threads, make sure that your threads do *not* receive
signals or you'll have no end of problems."  The recommended solution is
to devote a single thread just to signal handling, have it listen for
signals rather than receive them asychronously, and block signals in all
other threads.

> There aren't many systems I would like to run without careful memory
> protection -- which is what LWP is often like.  The only difference is
> that with LWP, memory access is dangerous, and with standard processes,
> it isn't.  processes, communication is well-defined.

Right, threaded programs have to be written very carefully, and locking is
hard.  It took most of the class quite a while to understand locking
issues when I took a class in operating system design.

> Also, the LW part of LWP is definitely overvalued these days.  Linux
> "threads" are still faster than NT "processes".  Go figure.  Ever heard
> of NT fibers?  Sigh.

Other way around, Tom.  :)  Linux processes are faster than NT threads.

> That doesn't mean threads have no use.  I certainly don't wish to imply
> that.  But anybody who doens't understand forks, select, signals,
> semaphores, locking, deadlocks, access protocols, and shared memory
> should stay far, far away.

Yup.

Here's a good rule of thumb:  Do you know why waiting on a condition
variable has to be an atomic operation implemented in the thread libraries
itself and isn't something you can roll yourself with a mutex?

If you don't have a full and complete understanding of the answer to that
question, then you probably need to learn more about threads and locking
before you write a major application using them.  Because the particular
issue involved in that answer is precisely the sort of hairy problem
you'll run into a lot.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 17 Jun 1999 17:41:10 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: a thread on threads (the skinny on the schedule)
Message-Id: <yl7lp25oig.fsf@windlord.stanford.edu>

Greg Bartels <gbartels@xli.com> writes:

> 2a, b, c) undefined behaviour makes design and debug difficult.

> is it undefined because no one has gotten around to defining it?  or is
> it undefined by nature of it being unpredictable in who/what/when things
> get scheduled?

It's not undefined.  It's just very tricky.

Think of it this way:  By using threads, you're throwing away memory
protection.  For the memory space of your process, you now have to do the
memory protection pieces that the operating system would normally do for
you.  You also have to do the signal handling pieces that the OS would do
for you, and you have to do a little bit of the process management pieces
the OS would do for you.

As a result, you can tailor all of that to your application and make it
really fast.  But you're running without a safety net.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Thu, 17 Jun 1999 20:38:24 -0400
From: planb@newsreaders.com (J. Moreno)
Subject: Re: Afraid to ask about Y2K!
Message-Id: <1dtk79c.zoqe871umn9tfN@roxboro0-0012.dyn.interpath.net>

<finsol@ts.co.nz> wrote:

-snip-
> The Y2K problem in Perl code goes beyond just the localtime booby trap.
> The localtime issue is just the most obvious but even so few Perl coders
> on this site acknowledge it as being a problem their reasoning being
> that the manual states quite clearly how localtime should be used.

This isn't a "site" it's a usenet newsgroup (this is typical of your
inattention to proper terminology).

And few people here are willing to acknowledge it as a problem in
/their/ perl code.

If you want to convince the regulars here that there is a problem they
should beware of -- show code from the regulars that has a Y2K problem.

Here, from the Statistics for this group:

Top 10 Posters by Number of Posts
=================================

         (kb)   (kb)  (kb)  (kb)
Posts  Volume (  hdr/ body/ orig)  Address
-----  --------------------------  -------

  111   185.4 (103.7/ 67.9/ 45.0)  Tom Phoenix <rootbeer@redcat.com>
   92   165.7 ( 70.5/ 81.9/ 40.9)  Jonathan Stowe <gellyfish@gellyfish.com>
   82   137.4 ( 50.9/ 77.5/ 45.4)  lr@hpl.hp.com (Larry Rosler)
   73   151.2 ( 81.0/ 40.7/ 35.3)  abigail@delanet.com
   41    61.4 ( 23.6/ 37.8/ 23.5)  tadmc@metronet.com (Tad McClellan)
   36    76.9 ( 28.5/ 44.1/ 26.9)  David Cassell <cassell@mail.cor.epa.gov>
   32    43.1 ( 19.5/ 23.2/  9.1)  hasant@trabas.co.id (Hasanuddin Tamir)
   27    58.4 ( 22.8/ 27.3/ 13.5)  Uri Guttman <uri@sysarch.com>
   25   238.7 ( 20.3/215.5/210.1)  tchrist@mox.perl.com (Tom Christiansen)
   24    38.0 ( 15.4/ 22.5/ 11.1)  marcel.grunauer@lovely.net (Marcel Grunauer)

Find a Y2K problem in code by Tom P, Jonathan, Larry, Abigail, Tad, David, Uri
or Tom C and you'll convince *me* that it's something I need to give some extra
consideration.

-- 
John Moreno


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

Date: Fri, 18 Jun 1999 00:01:24 GMT
From: outlaw_torn <outlaw_torn@mailexcite.com>
Subject: Re: changing text in a file?
Message-Id: <7kc28g$2f4$1@nnrp1.deja.com>

First let me exlain why your script is going wrong.  When you "replace
it with something else" you are only changing the variable $_ and not
the file.  To make a change to the file you need to write the variable
to the file. I suggest you do something like this:

Add this line after you've made the substitution and exited your if
statement but still within the loop:
$file .= $_;

This will append the line you just read in into the $file variable.  If
you've made a change then the changed text will be appended (thats why
you do it outside the if).

Now to write it back out to the file:

open (MYFILE, ">$myfile");
print MYFILE $file;
close (MYFILE);

This overwrites the file with $file (which should hold the entire
content of the file anyway + your substitutions). It works similar to
your idea of writing to a temporary file and the replacing the original
file, but instead of a temporary file, you use a temporary variable.

You might want to add some tests in there as well...like open (...) or
warn "Can't open file", etc. But thats up to you.

In article <7kbqv0$njf@news.or.intel.com>,
  "Ariel" <anita.villanueva@intel.com> wrote:
> first of all i apologize if there are multiple/repetive postings of
> mine, i
> had to cancel a few messages, etc. anyways...
>
> to change a few lines of text in a file, my code went like this:
>
> $myfile = "example.txt";
> open(MYFILE, $myfile);
> while (<MYFILE>) {  #check each line
>   #use pattern matching to check each line ($_) against a pattern, and
> if so
> replace it with something else
> close(MYFILE);
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 17 Jun 1999 18:37:42 -0400
From: "Keerthi K Arutla" <arutla@csee.wvu.edu>
Subject: email owner name
Message-Id: <19990617.183759.938382.NETNEWS@WVNVM.WVNET.EDU>

Hi Everybody,

I need to find the name of a person given his email-id. Can anybody tell me
how to do that, can atleast provide some useful hints. Ant help is
appreciated. Thank You.

Keerthi






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

Date: 18 Jun 1999 01:13:23 GMT
From: robobob@blech.mindwell.com (Jason Kohles)
Subject: Re: email owner name
Message-Id: <slrn7mj79i.lc8.robobob@blech.mindwell.com>

On Thu, 17 Jun 1999 18:37:42 -0400, Keerthi K Arutla wrote:
>Hi Everybody,
>
>I need to find the name of a person given his email-id. Can anybody tell me
>how to do that, can atleast provide some useful hints. Ant help is
>appreciated. Thank You.
>
How about:

use Mail::Send;
my $msg = new Mail::Send(Subject => 'What is your name?', To => $target);
my $fh = $msg->open;
print $fh "I really need to know your name, please tell me what it is.\n";
$fh->close;



-- 
        Jason Kohles -- jason@mediabang.com
        http://www.mediabang.com/

          "This is as bad as it can get, but don't bet on it."


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

Date: Thu, 17 Jun 1999 23:40:10 GMT
From: Mitch <portboy@home.com>
Subject: Having trouble making this work...
Message-Id: <37691778.3E1246BD@home.com>

Okay, I have a simple configuration file that looks something like:

coke enable
pepsi disable
mountdew is okay
==/foo/bar1/foofile
--BEGIN
a bunch of ascii text will go here
and it can be multiline
--END
==/foo/bar2/foofile
--BEGIN
again, a bunch of text will go here
--END

Below is some code I use to slurp in the configuration file.  So
everything works great WRT doing a print "$mountdew\n" -> is okay.

However, as the config file is being slurpped in, and it see's a pair of
= sign's (==), it should check to see if /foo/bar1 is a directory, and
if it isn't - create it.  Once it is created or exists - dump the
--BEGIN
a bunch of ascii text will go here
and it can be multiline
--END
into the filename listed after /foo/bar?/foofile

And obviously, this should do the same on all the next == sign.
However, I can't seem to get it to create the subdirectory /bar?.  The
directory /foo should and will always exist, however /bar? may sometimes
be there and sometimes not.  How can I slurp in my config to get it to
do this?

So, can someone tell me what I need to do to make this happen or give me
some pointers?  Also, Let's say that my config will now look something
like this:

coke enable
pepsi disable
pepsi die        <- notice the two pepsi entries
mountdew is okay
==/foo/bar1/foofile
--BEGIN
a bunch of ascii text will go here
and it can be multiline
--END
==/foo/bar2/foofile
--BEGIN
again, a bunch of text will go here
--END

In the way I'm reading in the config file the last duplicate entry (in
this case pepsi) will get the result.  So, print "$pepsi"; -> die.

So, how can I manipulate the way I read in configuration files so that
it will keep duplicate entries separate?

Thanks again,

 .MITCH

p.s. slurp_config code is below......

sub slurp_config
{
        my $cfg = shift;
        open(CFG, $cfg) or die "damn't $!";
        while(<CFG>) {
        chomp;
        s/#.*//;
        s/^\s+//;
        s/\s+$//;
        next unless length;
        my ($var, $value) = split ' ', $_, 2;
        $$var = $value;
        if (/^==(.*)/) {
                my $dir = $1;
                #if(! -d $dir) { system("mkdir $dir"); }
                open DIR, ">$dir" or die "Can't open $dir $!";
        } elsif (/^\--END$/) {
                close DIR;
        } else {
                print DIR "$_\n";
        }
        }
        close(CFG);
}



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

Date: Thu, 17 Jun 1999 23:40:44 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: help! pattern matching question
Message-Id: <3769873B.9DDE9702@home.com>

[posted & mailed]

loertly@uu.net wrote:
> 
> $foo = `output of some system command`;
> 
> if ($foo =~ m/highest return code was 0 in/m) {  # this is actually a
                                            ^^    
                         
The trailing m is not needed since you are not using ^ or $.  It's not
hurting anything, though.

> text message
>  <true>;
> } else {
>  <false, text not found>;
> }
> 
> The return code is actually just a text message and  is what I am after.
> It could be a 0, 1,3.  This string is also the thriteenth line that is
> in the variable but the if statement never returns true.

Then $foo never contains 'highest return code was 0 in'.  Have you tried
printing out $foo to see what it contains?  Maybe you should post your
real code, which should not be any longer than this pseudocode.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Thu, 17 Jun 1999 22:23:23 GMT
From: olmert@netvision.net.il
Subject: Help- time
Message-Id: <7kbsgh$di$1@nnrp1.deja.com>

Hello,
I am a newbe to Perl. I want to write a script that opens a file for
reading, and prints the content to the user's screen. So far so good.
Problem is that I want that after it has completed this, it will wait 20
seconds, and check if the file was updated during these 20 seconds. if
so, it will write only the lines that were added since the last time. I
was refered to the tail -f FAQ, but i am to novice to figure it out. If
any body can help me add the function that timesout, checks for updates
and update, I'll be very very grateful.

Please reply to olmert@netvision.net.il

Thanks.



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 17 Jun 1999 18:59:10 -0500
From: seong joon bae <seongbae@students.uiuc.edu>
Subject: Hex to Decimal??
Message-Id: <Pine.GSO.4.10.9906171854180.9035-100000@ux13.cso.uiuc.edu>


How would you write a little script that converts hex to dec...?





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

Date: Fri, 18 Jun 1999 00:11:08 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Hex to Decimal??
Message-Id: <slrn7mj796.5k.alastair@calliope.demon.co.uk>

seong joon bae <seongbae@students.uiuc.edu> wrote:
>
>How would you write a little script that converts hex to dec...?

You mean using the 'hex' function?

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: 18 Jun 1999 00:24:25 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: Hex to Decimal??
Message-Id: <7kc3jp$ea4$1@fcnews.fc.hp.com>

seong joon bae (seongbae@students.uiuc.edu) wrote:

: How would you write a little script that converts hex to dec...?

I wouldn't. I'd look up the "hex" function in perlfunc.

Andrew





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

Date: Thu, 17 Jun 1999 16:01:04 -0700
From: "Ariel" <fake@nospam.edu>
Subject: Re: how to change a line of text in a file?
Message-Id: <7kbuk5$qna@news.or.intel.com>


David Cassell wrote in message <3769787F.BAFE0FFF@mail.cor.epa.gov>...
>[courtesy cc sent to poster]
>
>Ariel wrote:
>>
>> Greg Bacon wrote in message <7kbppd$bul$1@info2.uah.edu>...
>> >In article <7kbpdc$m30@news.or.intel.com>,
>> > "Ariel" <fake@nospam.edu> writes:
>> >: Hi, i just started learning Perl on monday, i bought a book on it,
>
>I hope it's "Learning Perl" by Randal and Tom, and not one of
>those books which call you names or promise you magic in a set
>number of days.

it is . that book is the bomb. it pretty much has everything i need to know
for what i'm doing at the moment...except it doesn't talk about
multidimensional arrays and stuff like that. but for that i guess i'll just
see the faq...

Those others have been found to have some
>serious blunders, which might not be obvious to the new Perlite
>until you got yourself into a miserable jam later.
>
>> [snip]
>> i did read several FAQs online...but none of them seemed to help with my
>> specific problem. and another thing is i'm currently using perl for win32
>> (not unix, so a lot of stuff they have on there does not apply)
>
>I'll assume you're using ActiveState Perl.

 right again. ;-)

>If so, you not only
>have all the core Perl FAQ on your machine, but you also have an
>HTML tree as part of the install, with a shortcut placed on your
>Start Menu for extra convenience.

yeah i just realized it and i went to the FAQ. basically it said to do it
the way i had done it (see other post that i made)..by just making the
changes into a temp file and then renaming it as the original. i guess i'll
stick with that method then...since it also has the feature that it doesn't
get corrupted if something weird goes on when i'm reading/writing the lines.

[snip]
>
>BTW, using a fake address doesn't protect you from spam-address-
>harvesters if you're putting your real address in your Reply-To
>line.

i've done it like that using netscape newsgroups for two years and have
never gotten spammed...but then the spammers have probably been getting
smarter and now they're using reply-to addresses as well. doh! ;-D

anita-ariel




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

Date: Fri, 18 Jun 1999 01:23:02 GMT
From: "Daniel W. Burke" <dwb1@home.com>
Subject: Is Perl4 Y2K compliant?
Message-Id: <Pine.LNX.3.96.990617205354.21090B-100000@cc569157-a.warn1.mi.home.com>


Hopefully I can wade through all these messages to see the response...
but, can perl4 be considered "Y2K Compliant"?  I imagine so, but we have
an aweful lot of scripts at work that run off perl4/oraperl...
I don't think anyone else has thought to ask at work wether or not we should
take the time to make sure all the scripts work with perl 5, and just update
the darn things, but I figured better I better ask :)


Dan.




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

Date: Thu, 17 Jun 1999 19:43:18 -0400
From: murali <myparu@usa.net>
Subject: Re: LD_LIBRARY_PATH setting within the perl program
Message-Id: <37698816.3E1B496C@usa.net>

I tried $ENV{LD_LIBRARY_PATH}='/opt/sybase/lib';
both with and without the BEGIN block... no use.
I didnt want to use a shell script wrapper to do this as it will slow the
process.

murali


Dan Wilga wrote:

> In article <376810F0.106ED28E@usa.net>, murali <myparu@usa.net> wrote:
>
> > Hello,
> > I am trying to use Sybase::DBlib from a script. it works fine when I run
> > it, gets data and shows, but when I run it as a cgi, it complains abt
> > unable to load some library. I added /opt/sybase/lib to the
> > LD_LIBRARY_PATH in the %ENV from the program but that didnt work.  what
> > else can I do?
> > tia,
> > murali
>
> Add this somewhere in your Perl code:
>
> BEGIN {
>         $ENV{LD_LIBRARY_PATH}='/opt/sybase/lib';
> }
>
> That way, the var gets set as the very first thing, before anything else
> gets executed.
>
> If that doesn't work, write a shell (csh, bash, or whatever you use)
> script to set the variable first and then call your Perl script.
>
> Dan Wilga          dwilgaREMOVE@mtholyoke.edu
> ** Remove the REMOVE in my address address to reply reply  **





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

Date: Fri, 18 Jun 1999 00:22:54 GMT
From: Watcher <watcher_q@my-deja.com>
Subject: Re: MIcrosofts Attack on Perl
Message-Id: <7kc3gk$2sv$1@nnrp1.deja.com>

In article <pudge-1706990914130001@192.168.0.77>,
  pudge@pobox.com (Chris Nandor) wrote:
> In article <1dtcf89.aiwhns1bh8xklN@inksplash.demon.co.uk>,
> wayne_allison@yahoo.com (Wayne Allison) wrote:

<munched>
> # > # Are people aware of the "negative" consequences of such a move,
> # > # especially in relation to one of Perls core ojectives in
relation to
> # > # maintaining the language as "portable"?
> # >
> # > Yes.  Perl will in all liklihood become more portable as a result
of this
> # > arrangement.
> # We'll see what features are added my MSs envolvement that enhance
> # "portability". I'd be surprised if it becomes more portable than
just
> # being able to run on WinTel better, which when splitting hairs may
be
> # the political point of Microsofts involvement.
>
> No, MS' involvement will likely increase portability, not just on
Windows,
> but on other platforms.  Part of the funding will go toward certain
ways
> of getting fork() to work on Windows, which could provide fork() to
other
> platforms too (like Mac OS and VMS); hence, portability of Perl code
> increases.  Yay for Microsoft for funding something Good.

Second Yay here.  My view is that Perl poses no threat to MS's golden
goose unlike the marketing (dirty word here) done by Sun for Java
(write once run everywhere... right!).  Instead, it improves MS's
products.  Most admins for NT would agree with me that NT itself
requires a good scripting language; VBscript does not cut it.  So in
this case, I think (and hope) that it is a win-win situation.

Now, the next thing is for Perl on devices (like CE...)


Watcher


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 17 Jun 1999 23:22:46 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: OO-Trap! I am confused
Message-Id: <7kc006$a94$1@fcnews.fc.hp.com>

[mailed and posted]

Janning Vygen (janning@vygen.de) wrote:
:           ***PLEASE ANSWER VIA E-MAIL TOO ***
: i have designed some objects like described in the camel book chapter 5
: "autoloading methods" (page 311 in the german version)
: the only difference is, that i have array references as field values
: because the object can have more than one "card".

: what happens is, that the two objects share the same reference for cards
: and coins, so initializing one object, changes the other object too.
: so if i give one customer a credit card, every costomer gains it.
: This might be called a feature :-)
: how can i disable it?

You need to do a "deep copy". There's modules on CPAN to do that
(Data::Dumper comes to mind, amongst others). But for your application,
it's overkill:

: here it goes:
: ---------------------------
: package Customer;
: my %fields = (
:        cards => [],
:        coins => [],
: );

: sub new {
:   my $class = shift;
:   my $self = {
:      %fields,
:   };

Why not just

  my $self = { 'cards' => [], 'coins' => [] };

That way you'll get shiny-new array refs in each $self. There's other
ways to do it. Calling a sub to get your initial values might be one.

Andrew


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

Date: Thu, 17 Jun 1999 22:31:08 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Open2 with smbclient
Message-Id: <FDHt7w.C6u@news.boeing.com>
Keywords: open2, smbclient, perl, pipe 

In article <slrn7mguc3.3nq.steven@madduck.planetfall.com>,
Steven R. Evatt <steven-perl@evatt.com> wrote:
>Howdy folks!
>
>I've been attempting to solve this problem for alomst a week by
>reading four perl books and scouring the web.  Any help would be 
>appreciated.
>
>problem:
>
>  I would like to use a perl script to interface with smbclient.
>  Todate, when I use smbclient to open a connection, I read the 
>  input waiting for the command prompt so I can send it a command.
>  However, the command prompt never comes and if I send a command
>  to early, I get a broken pipe error.
>
>My code:
>
>sub findfiles
>{
>   my $addr = shift;  # a number like 128.1.1.1
>   my $share = shift; # something like \\\\fooo\\bar
>
>   open(PS_WRITE, ">&STDOUT");  #dupe a filehandle for writing
>   open(PS_READ, ">&STDIN");   # dupe a filehandle for reading
>
>   open2(PS_READ, PS_WRITE,"smbclient", $share, "-I", $addr, "-N");
>
>   my @input = <PS_READ>;
>   print @input;
>
>   print PS_WRITE "ls\n";
>
>   my @input2 = <TWREAD>;
>   print @input2;
>   die "just checking \n"; #more code follows
>				      
>}
>
>If I try to but a while statement around my first @input = <PS_READ>
>line, my side hangs forever waiting for a prompt.
>

Take a look at the fine print in IPC::Open2 (perdoc IPC::Open2). 
You can deadlock very easily particularly if you try to suck
in too much. Another timing problem: you write to a pipe when 
the plumbing on the other end's not ready - spewing a 
"broken pipe" chastisement. 

In other words, open2 works best when you can easily size the 
flow: IPC::Open2's cites `bc' with its predictable line-at-a-time 
exchange. 

You may want to take a closer look at your client IO to see if 
it's really suitable for open2. Alternatively, for example,
`Expect.pm' can give you the control to manage more closely when 
you interact with a process by trapping patterns in the 
client output so that you can safely respond with less chance
of deadlock.  


hth,
--
Charles DeRykus


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

Date: Fri, 18 Jun 1999 00:06:55 GMT
From: Watcher <watcher_q@my-deja.com>
Subject: Re: Personal Rant (was Re: Does Perl have a future?)
Message-Id: <7kc2ip$2ie$1@nnrp1.deja.com>

In article <3769662B.E2D7F515@mail.cor.epa.gov>,
  David Cassell <cassell@mail.cor.epa.gov> wrote:
> Daniel Grisinger wrote:
> > Watcher <watcher_q@my-deja.com> writes:
> > > Of course, Sun would say that they are the best.  Which company
won't?
> > > Sun is course worried.  If Java slips on the server side, its
> > > importance will greatly diminished in the enterprise space.
Then, the
> > > only place that Java would exist would be in the device space (eg
Jini,
> > > etc).
> >
> > It should be pointed out that the device space is larger than all
> > other application spaces combined.
>
> Which is why they're making a grab for it.  As is IBM, and...

Which is also why my fears of a dominate Sun is even greater than MS if
Sun become THE dominate device space company.

Returning to Perl, I'm wondering if a version can be build for these
devices?  Eg on CE (I know, I know...)?  Not the whole shebang of
course, but a interpreter engine that runs pre-build scripts.  This
request had been posted to the P5P list before but to no reply...


Watcher


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 17 Jun 1999 18:34:16 PST
From: Neil <neil@pacifier.com>
Subject: Recommend a simple Online database?
Message-Id: <3769a218.0@news.pacifier.com>

I am looking for Online database options. flatfile will work fine.          

The intn'l trade organization I work for has a Virtual Server
running on a UNIX box at our ISP.

We want to have a simple database that would consist of companies
Each company provides from 1 to a maximum of 15 services.          

We want visitors to the Web page to, using a form, query the database
based on services. Maybe a checkbox next to each service, and the user
can check those services he or she wants and then click submit and the
database would return companies that provide the services selected. The
output would just be a simple table with basic information and a hyperlink
if more information about a specific company is desired.

I am looking for a recommendation on perl scripts that would be good for  
this simple Online database.

On another topic, I am happy to report that I have ordered the Ram and
am looking forward to learning some Perl. My learning strategy will be
to read, program, and lurk in this group. Thanks.

Neil


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

Date: Thu, 17 Jun 1999 19:10:17 -0400
From: Steve Palincsar <palincss@his.com>
Subject: Re: single vs. double quotes
Message-Id: <37698059.F667D171@his.com>

Three answers to your question:

1) the diff. betw " and ' is that in a double quoted string
a variable will have its value interpolated; in a single
quoted string the literal variable name will be printed.

2) If you need to include a " in a double quoted string,
the \ character before the quote ( \" ) will remove the
specialness from the quote character, so it will print as
a literal.

3) You really ought to be using a here-document for a multiline print
statement.

And while we're at it, 

1) you should test your open statement [  open (CUSTOM, ">blah") 
or die "Can't open blah, $!";
2) Don't flock 8.  Just close the file.  That will release the lock.


Weborium wrote:
> 
> If I'm printing a statement using double quotes, and I want to use double
> quotes in the statement, will using single quotes get the same effect? Like in
> line 4 below, I want it to say <body bgcolor="black"> however I can't use (" ")
> or it'll mess it up.
> 
> open (CUSTOM, ">/edited.htm");
> flock (CUSTOM, 2);
> print CUSTOM "<html><head><title>Console</title></head>\n";
> print CUSTOM "<body bgcolor='black' text='white' link='yellow'>\n";
> print CUSTOM "<h2>Welcome\n";
> print CUSTOM "</body></html>\n";
> flock (CUSTOM, 8);
> close (CUSTOM);
> .
> .
> 
> ---- How Microsoft would like to deal with Linux:
> "Windows has detected a faster, superior, more efficient operating system on
> your computer.  Do you wish to delete it?
> [yes]   [yes]
>  ----------


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

Date: Thu, 17 Jun 1999 17:46:16 -0700
From: "Jeff Lawrence" <jeffl@plaza.ds.adp.com>
Subject: STDOUT/STDERR Redirection (Win32)
Message-Id: <7kc17f$g0i@myst.plaza.ds.adp.com>

I'm invoking software builds (MS C++/Visual Basic) from the command-line via
a PERL
script and have questions regarding stdout/stderr redirection.  Presently I
am printing
to messages to stdout in addition to the build tool output.

Is there anyway to display both stdout/stderr to the screen AND to a file
simultaneously?
Right now I'm creating a build log file that includes return status info,
etc. however if the
build fails (non-0 return) the log file does not include the error messages
returned by the
build tools which doesn't aid in identifying the build problem!

My ultimate goal was (still is if I can figure out how to do it) is to call
the PERL script
from a Visual Basic application and be able to read the build output from VB
"as" the
build is executing vice displaying the info after the build completes.

Has anyone done something similar before?  I know how to redirect the output
to
a file using ">" but the file contents is not accessible until the process
completes.

Any info would be "greatly" appreciated!

Please cc: jeffl@plaza.ds.adp.com




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

Date: Fri, 18 Jun 1999 00:39:22 GMT
From: jballagh@du.edu
To: engjs@cc.newcastle.edu.au
Subject: Re: Weird socket behaviour
Message-Id: <7kc4fp$36g$1@nnrp1.deja.com>

  Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> James Smith <engjs@cc.newcastle.edu.au> wrote:
> > The problem appears to be that the site has a number of different
> > names that translate to the same set of numbers. I have been unable
> > to figure out how Netscape works out that this is happening and
> > deals with it.
> >
>
> It is an example of a name based virtual host - the browser is
expected
> to send a header to the server which indicates which name it is
requesting
> and the server behaves appropriately.
>
Jonathan is right about the name based virtual host.  A server with one
IP can use one port to answer HTTP requests for a number of domain
names as long as the client can supply the server with the name of the
domain as part of the request.

If the name of the domain for the request is not provided, the server
defaults to a certain domain which may be different

Jeff Ballagh


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 6037
**************************************

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