[30517] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1760 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 4 17:48:14 2008

Date: Fri, 1 Aug 2008 08:09:11 -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, 1 Aug 2008     Volume: 11 Number: 1760

Today's topics:
    Re: && is not an lvalue xhoster@gmail.com
        CAREER <getupurcareer@gmail.com>
    Re: EPIC and "my" variables <rvtol+news@isolution.nl>
    Re: EPIC and "my" variables <rvtol+news@isolution.nl>
    Re: Extracting bits out of huge numbers <ben@morrow.me.uk>
    Re: extracting double from a string <rvtol+news@isolution.nl>
    Re: extracting double from a string (Jens Thoms Toerring)
    Re: extracting double from a string <a@a.com>
    Re: FAQ 4.42 How can I tell whether a certain element i <justin.0805@purestblue.com>
    Re: Help with Button Placements using TK <zentara@highstream.net>
        How do I tell sendmail where to send bounced mail? <John.Smith@invalid.com>
    Re: How do I tell sendmail where to send bounced mail? <verma.abhinav@gmail.com>
        Perl - Gnuplot Topics <edgrsprj@ix.netcom.com>
        Teradata Perl Connection Question. <gary.t78@gmail.com>
    Re: Teradata Perl Connection Question. <smallpond@juno.com>
    Re: Teradata Perl Connection Question. <gary.t78@gmail.com>
        Use single perl instance multiple times <mseele@gmail.com>
    Re: Use single perl instance multiple times <rvtol+news@isolution.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 01 Aug 2008 15:03:31 GMT
From: xhoster@gmail.com
Subject: Re: && is not an lvalue
Message-Id: <20080801110332.677$Up@newsreader.com>

Ben Morrow <ben@morrow.me.uk> wrote:
> Quoth xhoster@gmail.com:
> > It seems like almost everything in Perl is an lvalue.  So why isn't the
> > result of && an lvalue?
> >
> > I wanted to do this:
> > ($h{$big}{$nasty}[$dereferencing]{operation($x)}{$done}[here(y)]and
> > die)=6;
> >
> > Obviously, that just isn't the way perl was implemented.  But is there
> > a reason that "?:" yields an lvalue but && doesn't?
>
> Perhaps because it's not entirely clear which operand would be returned
> when both are true or both false? That doesn't apply to your case, of
> course, since one of them is 'die' and can never be returned, but perl
> doesn't know that.
>
> Which one you actually get is rather confusing. If either is false, you
> get that one; if both are false, you get the first; and if both are
> true you get the second. || is the other way around: both false gives
> the second operand, and both true the first. I suppose it makes sense
> when you consider the short-circuiting.

Yep.  And I was consider short-circuiting, so I didn't find it all that
confusing.  Off the top of my head, I can't think if anything I'd use this
for that didn't have a die as the second.  (but I probably wouldn't use
that construct in anything except one-offs or one-liners, anyway.)

>
> Oddly, you *can* take a ref to the result of && (which is in fact an
> lvalue), which means
>
>     ${\( $x and die )} = 6;
>
> *does* work as you expect, despite being hideously ugly.

Yeah, I did that experiment myself.  But I didn't make the valid deduction
that you have, that it actually is an l-value, just an l-value which
the compiler pitches a fit over.  Which makes it even stranger to me.
It seems like the programmers must have went out of their way to make
this syntax error happen, rather than it being a natural consequence of
something else.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Fri, 1 Aug 2008 06:29:24 -0700 (PDT)
From: ur-opener <getupurcareer@gmail.com>
Subject: CAREER
Message-Id: <90b8fc5b-f9d1-4dd5-b9fc-69c0a8f12b7e@q5g2000prf.googlegroups.com>

May I help to find your right career

$$$$$$$$$$$$$$$$$$$$$$$$
WWW.freewebs/basquelag/
$$$$$$$$$$$$$$$$$$$$$$$$


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

Date: Fri, 1 Aug 2008 14:33:44 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: EPIC and "my" variables
Message-Id: <g6v78r.ko.1@news.isolution.nl>

rupert@web-ideas.com.au schreef:

> First - Activestate 5.10
> has got a couple of library problems, PadWalker and DBD::mysql are not
> normally available for it. I had to specify full paths to repositories
> for both:
>
> ppm install http://cpan.uwinnipeg.ca/PPMPackages/10xx/DBD-mysql.ppd
> ppm install http://www.bribes.org/perl/ppm/PadWalker.ppd

Those repositories are predefined in the ppm-GUI, see Edit / Preferences
/ Repositories / Suggested.

You'ld better not update an 8xx installation, just start with 5.10 from
scratch, this because of the @INC site/lib order change with 820(?).

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Fri, 1 Aug 2008 16:32:23 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: EPIC and "my" variables
Message-Id: <g6ve3o.18s.1@news.isolution.nl>

Dr.Ruud schreef:
> rupert:

>> First - Activestate 5.10
>> has got a couple of library problems, PadWalker and DBD::mysql are
>> not normally available for it. I had to specify full paths to
>> repositories for both:
>>
>> ppm install http://cpan.uwinnipeg.ca/PPMPackages/10xx/DBD-mysql.ppd
>> ppm install http://www.bribes.org/perl/ppm/PadWalker.ppd
>
> Those repositories are predefined in the ppm-GUI, see Edit /
> Preferences / Repositories / Suggested.
>
> You'ld better not update an 8xx installation, just start with 5.10
> from scratch, this because of the @INC site/lib order change with
> 820(?).

Just found out that "http://cpan.uwinnipeg.ca/PPMPackages/10xx/" doesn't
work anymore, but
"http://cpan.uwinnipeg.ca/PPMPackages/10xx/package.xml" does.

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Fri, 1 Aug 2008 15:15:01 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Extracting bits out of huge numbers
Message-Id: <5cibm5-9u1.ln1@osiris.mauzo.dyndns.org>


Quoth "Dr.Ruud" <rvtol+news@isolution.nl>:
> sisyphus schreef:
> 
> > $and = (2 ** 16) + (2 ** 15) + (2 ** 14) + (2 ** 13) + (2 ** 12);
> 
> Or as Ben Morrow suggested: 
> 
>   my $mask = 0; 
>   $mask |= 1 << $_ for 12 .. 16;

I particularly don't like using 2**$N for bit operations, as it returns
a floating-point result.

> or just
> 
>  my $mask = 0x0001_F000;

Well, yes :), but I was assuming the bits to mask in were not known
until runtime.

Ben

-- 
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
   From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes,        [ Heracles shoots Vulture with arrow. Vulture bursts into ]
 'Alcestis')        [ flame, and falls out of sight. ]         ben@morrow.me.uk


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

Date: Fri, 1 Aug 2008 12:06:29 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: extracting double from a string
Message-Id: <g6uu8h.1oc.1@news.isolution.nl>

perlcoder schreef:

> We store an array of 32 doubles as a string in a database. When the
> data is fetched
> from the database it is first read to a char[257] and then converted
> to an array of 32 double, by using C union.
>
> Now we want to do the same in perl. We get the data from the database
> using DBI. How do you convert from a $scalar to an array.

    perldoc -f pack   (will point you to unpack).

Your doubles seem to be 8 octets each. What is the extra octet for? (a
length value? at the start or end?)

Perl doubles are stored in "native" format, so you need a little luck in
a mixed platform environment, or a search in the CPAN for appropriate
conversion modules.

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: 1 Aug 2008 10:16:30 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: extracting double from a string
Message-Id: <6fg63uFb9hs8U1@mid.uni-berlin.de>

perlcoder <a@a.com> wrote:
> We store an array of 32 doubles as a string in a database. When the data
> is fetched from the database it is first read to a char[257] and then
> converted to an array of 32 double, by using C union.

What mean "using a C union"? Are you storing binary values of the
doubles in the database?

> Now we want to do the same in perl. We get the data from the database
> using DBI.  How do you convert from a $scalar to an array.

If the "string" contains binary data for the doubles have a look
at the unpack() function (also see the documentation for pack()
since that contains more relevant information). Without testing
I guess you need

@array = unpack( "d32", $string" );

But since I rarely have used pack/unpack this could be completely
wrong...

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


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

Date: 1 Aug 2008 04:01:17 -0700
From: perlcoder <a@a.com>
Subject: Re: extracting double from a string
Message-Id: <g6uqdt01j9m@drn.newsguy.com>

In article <6fg63uFb9hs8U1@mid.uni-berlin.de>, Jens Thoms Toerring says...
>
>perlcoder <a@a.com> wrote:
>> We store an array of 32 doubles as a string in a database. When the data
>> is fetched from the database it is first read to a char[257] and then
>> converted to an array of 32 double, by using C union.
>
>What mean "using a C union"? Are you storing binary values of the
>doubles in the database?

Yes we store the binary value of 32 doubles in a char field of the database 
of length 256. When we fetch it from the database, we read it to a struct
which contains char[256] union an array of 32 doubles.
[ we are a single platform shop - all Solaris where doubles are 8 bytes ]


>> Now we want to do the same in perl. We get the data from the database
>> using DBI.  How do you convert from a $scalar to an array.
>
>If the "string" contains binary data for the doubles have a look
>at the unpack() function (also see the documentation for pack()
>since that contains more relevant information). Without testing
>I guess you need
>
>@array = unpack( "d32", $string" );
>
>But since I rarely have used pack/unpack this could be completely
>wrong...

let me try this.

thanks to all who replied.



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

Date: Fri, 01 Aug 2008 12:38:50 -0000
From: Justin C <justin.0805@purestblue.com>
Subject: Re: FAQ 4.42 How can I tell whether a certain element is contained in a list or array?
Message-Id: <3ad4.489303da.8f640@zem>

On 2008-08-01, PerlFAQ Server <brian@stonehenge.com> wrote:
> 4.42: How can I tell whether a certain element is contained in a list or array?
>
>             if( $item ~~ %hash )
>                     { 
>                     say "The hash contains $item"
>                     }

I don't currently have access to 5.10, so can't check this out, but out
of interest does the above apply to keys, to values, or to both?

	Justin.

-- 
Justin C, by the sea.


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

Date: Fri, 01 Aug 2008 07:48:25 -0400
From: zentara <zentara@highstream.net>
Subject: Re: Help with Button Placements using TK
Message-Id: <slt594thl9bmcc224is5uftts6r7ijao6n@4ax.com>

On Fri, 1 Aug 2008 09:26:28 +1000, "Graham Feeley"
<grahamjfeeley@optusnet.com.au> wrote:

>Hi I am a Newbie and trying to get a menu to work.
>I have place 3 buttons so far on a form, however I would like to know how to 
>place them where I want them.
>EG: on this form I would like the buttons to be on the bottom of the form 
>and in one row????
>Any help would be appreciative!!

As Ben Morrow said, pack is usually preferred because it resizes
nicely.  Get in the habit of making separate frames and using the
-expand and -fill options. You can have frames nested in frames
for very complex packing behavior.
This is how I would do it, make a top and bottom frame, but only
let the topframe expand in the y direction. Make the buttons uniform,
by letting them expand, and padx them. (You don't need to specify
the -state => 'normal'....it's normal by default.)

#!/usr/bin/perl -w
# Display Hello World program
use diagnostics;
use Tk;
use strict;
use warnings;

my $font1 = "arial 10 bold";
my $font2 = "courier 12 bold";

my $mw = MainWindow->new;
$mw->geometry( "600x400" );
$mw->title( "GUI Test" );

my $tframe = $mw->Frame(
    -relief => "raised"
)->pack(-fill=>'both',-expand => 1);

my $bframe = $mw->Frame(
   -relief => "raised"
)->pack(-fill=>'x',-expand =>0);

my $text = $tframe->Text()
   ->pack(-fill=>'both',-expand => 1);

my $btn1 = $bframe->Button(
   -text  => "Exit",
   -font  => $font2,
   -relief => "raised",
   -command => sub { exit }
)->pack(-side => 'left', -fill=>'x',
        -expand => 1, -pady => 5, -padx => 10 );

my $btn2 = $bframe->Button(
   -text    => "Btn2",
   -font    => $font2,
   -relief  => "raised",      
   -command => sub { exit }
)->pack(-side => 'left', -fill=>'x',
        -expand => 1, -pady => 5, -padx => 10 );


my $btn3 = $bframe->Button(
   -text    => "Btn3",
   -font    => $font2,
   -relief  => "raised",      
   -command => sub { exit }
)->pack(-side => 'left', -fill=>'x',
       -expand => 1,-pady => 5 , -padx => 10 );

MainLoop;
__END__


zentara

-- 
I'm not really a human, but I play one on earth.
http://zentara.net/Remember_How_Lucky_You_Are.html 


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

Date: Fri, 01 Aug 2008 14:42:02 +0300
From: John <John.Smith@invalid.com>
Subject: How do I tell sendmail where to send bounced mail?
Message-Id: <c6t5945199dqh9lb2ghin2f3psngbr30vk@4ax.com>


I am using the following code to send email from a Perl script:

open(MAIL,"|/usr/sbin/sendmail -t") || return 0;
select (MAIL);
print "To: mycustomer\@home.com\n";
print "From: me\@mybiz.biz\n";
print "Return-Path: me\@mybiz.biz\n";
print "Subject: Hello world\n";
print "\n";
print "It works!\n";
close(MAIL);
select (STDOUT);


The code works just fine provided the From address is OK.
If the address is invalid (but lexically OK) I want to get a "bounced email
receiver is no longer" etc. note but I get nothing.

The Return path does not seem to help.

What should I do to get info what email bounced or were invalid?


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

Date: Fri, 1 Aug 2008 06:17:11 -0700 (PDT)
From: scooter <verma.abhinav@gmail.com>
Subject: Re: How do I tell sendmail where to send bounced mail?
Message-Id: <8f0d29f6-d629-4898-9155-13a10d60301c@w39g2000prb.googlegroups.com>


You need to set the value of  "Reply-to" to either a vaild address or
"no_auto_replies@domain.com" etc.

hth, Abhinav.


On Aug 1, 4:42=A0pm, John <John.Sm...@invalid.com> wrote:
> I am using the following code to send email from a Perl script:
>
> open(MAIL,"|/usr/sbin/sendmail -t") || return 0;
> select (MAIL);
> print "To: mycustomer\@home.com\n";
> print "From: me\@mybiz.biz\n";
> print "Return-Path: me\@mybiz.biz\n";
> print "Subject: Hello world\n";
> print "\n";
> print "It works!\n";
> close(MAIL);
> select (STDOUT);
>
> The code works just fine provided the From address is OK.
> If the address is invalid (but lexically OK) I want to get a "bounced ema=
il
> receiver is no longer" etc. note but I get nothing.
>
> The Return path does not seem to help.
>
> What should I do to get info what email bounced or were invalid?



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

Date: Fri, 1 Aug 2008 05:19:03 -0500
From: "E.D.G." <edgrsprj@ix.netcom.com>
Subject: Perl - Gnuplot Topics
Message-Id: <1PSdnQEBL4PRfg_VnZ2dnUVZ_r7inZ2d@earthlink.com>

If you have a response that contains information for both Perl and Gnuplot
users then you might post to both groups.  Otherwise you should probably
post responses to just one group or the other.

1.  Using Perl And Gnuplot With Windows XP And Windows Vista
2.  Perl And Gnuplot Recommendations
A.  A Formal Perl - Gnuplot Interface
B.  A Real Time Version Of Gnuplot
3.  Perl .exe Program Assistance Needed

1.  USING PERL AND GNUPLOT WITH WINDOWS XP AND WINDOWS VISTA

Gnuplot can be a powerful graphics program when used by itself or with Perl
and probably any of a number of other programming languages.  One of the
advantages of using them together is that both are actively supported.  When
new versions of Perl are developed, older graphics modules might work and
they might not.  But once a Perl - Gnuplot interface is developed, Gnuplot
programs should work with any Perl updates.

Perl is great for fast, complex calculations and data array management.
Gnuplot produces high quality graphics and appears to use relatively little
computer memory.

Using them together can be tricky.  It probably took me a year of trying one
thing or another to determine how to get the two programs to work together
effectively with both Windows XP and Vista.  The main problem is with
starting Gnuplot from a Perl program and then having the Perl program
continue running.  That is necessary because after my Gnuplot program starts
the Perl program monitors keyboard keys and instructs the Gnuplot program to
draw different types of charts etc. in response.  For example, with an arrow
key press a cursor will move a small distance left or right on the display
screen.

When the Perl system and exec commands are used Gnuplot starts running and
the Perl program usually pauses until Gnuplot is stopped.  That appears to
be a problem that is somewhat unique with Gnuplot.

The following routines should allow Perl to continue running in the
background.

A Windows shortcut link such as Plot.gnu.lnk has to be created for the
Gnuplot program.  And instead of directly accessing the Gnuplot program the
link has to be accessed in the following manner with Perl commands.

system 'c:\programs\Plot.gnu.lnk';#  For Windows XP
system 'start c:\programs\Plot.gnu.lnk';#  For Windows Vista

Windows "Run" commands can also be used to start a Gnuplot program.  But
that is more complicated.  And the programs can get confused if they loose
track of which Windows screen is active.

So far I have not had much success with passing information from the Perl
program to Gnuplot through a pipe.  Instead I have been storing data and
commands in files which Gnuplot then reads.  If that is done some
handshaking is necessary so that Perl does not try to store data in a file
at the same time Gnuplot is trying to read it.  When that happens the Perl
program keeps running and the Gnuplot program crashes, probably because the
Perl program is compiled and the Gnuplot program interprets one command line
at a time.

2.  PERL AND GNUPLOT RECOMMENDATIONS

A.  A Formal Perl Gnuplot Interface

This combination of programs can be so useful for researchers that it would
be helpful if program developers created some type of interface that made it
possible for the two programs to work together in a seamless manner.

A special Perl command could be created that would start Gnuplot and allow
Perl to continue running in the background.  For example,

startgnuplot 'c:\programs\plot.gnu';

Another command could be created that would send commands and data from Perl
to Gnuplot without the need to create a pipe.  For example,

print 'plot.gnu', 'command', 'data', "\n";

or

print 'plot.gnu', 'command', 'c:\programs\data.txt', "\n";

"\n" would tell plot.gnu to execute the command on the data it had been
sent, or on the appropriate data file.

Those are just a few of the possibilities.

B.  A Real Time Version Of Gnuplot

It would be helpful if a version of Gnuplot were developed that would enable
the user to make small changes to the display screen without the need to
completely replot all of the data.  For example, a vertical cursor could
move one unit to the right or left on the screen.  And as it moved Gnuplot
would replace the original screen data where the cursor was located before
the move.  With simple plots my program combination will move a vertical
cursor and redraw the entire screen about four times a second.  With more
complex plots the refresh rate slows dramatically and Gnuplot eventually
crashes.

3.  PERL .EXE PROGRAM ASSISTANCE NEEDED

Something that I need to learn how to do is create .exe versions of my Perl
programs so that I can send them to other disaster mitigation researchers
around the world.  They could probably get Perl running on their own
computers without too much trouble.  But then they would need to link a
number of modules to Perl.  And that would be too confusing for those people
most of whom have no computer programming experience at all.  They need a
simple .exe program that you click twice and it starts running.

So far I have not been able to determine how to create the .exe programs.
If anyone has actually done that and can assist with the effort including
information on which module to link with Perl then that would be
appreciated.  On my main computer I am running ActivePerl 5.10 with Windows
Vista.

Even with that assistance I probably still have a few hundred hours worth of
programming to do before the final Perl code will be ready for the .exe
program.  I need to translate complex Basic and Excel programs to Perl, 
merge them with my current 4600 lines of code Perl program, and then check 
the new program for accuracy.  So, any help with the .exe program creation 
that could save some time would be appreciated.



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

Date: Fri, 1 Aug 2008 07:08:29 -0700 (PDT)
From: Gary <gary.t78@gmail.com>
Subject: Teradata Perl Connection Question.
Message-Id: <bbee6c93-50c0-40bc-9f3b-99cf4bcafed6@79g2000hsk.googlegroups.com>

Hi

I'm trying to post to the teradataforum but couldn't find any link to
post.

I'm trying to connect to Teradata and getting the following error.

CODE:



my $dbh;

my $sth;

my @row;

$dbh = DBI->connect('dbi:Teradata:DB', 'user', 'password') or die
"Connecting : $DBI::errstr\n ";

$sth = $dbh->prepare('select *  from TableX) or die "preparing: ",$dbh-
>errstr;
$sth->execute()  or die "executing: ", $dbh->errstr;

while (@row = $sth->fetchrow_array()) {
      print "displaying";
        print join(',',@row);
        print "\n";
}



--Note DB, user, password have been supplied.



ERROR:

Cannot init, result is 510

Use of uninitialized value in concatenation (.) or string
at /...../......../DBD/Teradata.pm line 5078



Also does DBD:Teradata module supports encrypted logons?



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

Date: Fri, 1 Aug 2008 07:16:19 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: Teradata Perl Connection Question.
Message-Id: <9a613793-94d7-4f6f-8360-069510ae0724@j22g2000hsf.googlegroups.com>

On Aug 1, 10:08 am, Gary <gary....@gmail.com> wrote:
> Hi
>
> I'm trying to post to the teradataforum but couldn't find any link to
> post.
>
> I'm trying to connect to Teradata and getting the following error.
>
> CODE:
>
> my $dbh;
>
> my $sth;
>
> my @row;
>
> $dbh = DBI->connect('dbi:Teradata:DB', 'user', 'password') or die
> "Connecting : $DBI::errstr\n ";
>
> $sth = $dbh->prepare('select *  from TableX) or die "preparing: ",$dbh->errstr;
>
> $sth->execute()  or die "executing: ", $dbh->errstr;
>
> while (@row = $sth->fetchrow_array()) {
>       print "displaying";
>         print join(',',@row);
>         print "\n";
>
> }
>
> --Note DB, user, password have been supplied.
>
> ERROR:
>
> Cannot init, result is 510
>
> Use of uninitialized value in concatenation (.) or string
> at /...../......../DBD/Teradata.pm line 5078
>
> Also does DBD:Teradata module supports encrypted logons?


What happened when you ran the test as suggested by the documentation?

"After installing, you can verify the install by running
        perl t/test.pl <host> <user> <password>"

--S


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

Date: Fri, 1 Aug 2008 07:30:38 -0700 (PDT)
From: Gary <gary.t78@gmail.com>
Subject: Re: Teradata Perl Connection Question.
Message-Id: <48287b15-4236-46ef-b30a-8e539862f7fb@a21g2000prf.googlegroups.com>

smallpond,

Thank you for your reply.

This is what I get when I run test.pl

TdTestBulkload.pm line 4:

This Perl hasn't been configured and built properly for the threads
module to work.  (The 'useithreads' configuration option hasn't been
used.)

Having threads support requires all of Perl and all of the XS modules
in
the Perl installation to be rebuilt, it is not just a question of
adding
the threads module.  (In other words, threaded and non-threaded Perls
are binary incompatible.)

If you want to the use the threads module, please contact the people
who built your Perl.

Cannot continue, aborting.
BEGIN failed--compilation aborted at /usr/opt/BASperl/5.8.6/lib/sun4-
solaris/threads.pm line 28.
Compilation failed in require at TdTestBulkload.pm line 4.
BEGIN failed--compilation aborted at TdTestBulkload.pm line 4.
Compilation failed in require at test.pl line 17.
BEGIN failed--compilation aborted at test.pl line 21.


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

Date: Fri, 1 Aug 2008 05:32:17 -0700 (PDT)
From: mseele <mseele@gmail.com>
Subject: Use single perl instance multiple times
Message-Id: <34c19020-7cbb-400b-9980-ec5fd9e017e9@b1g2000hsg.googlegroups.com>

Hi,

i have to "parse/compile" lot's of perl files (as fast as possible)
and work with the output (...Can't locate XYZ.pm in @INC (@INC
contains: XYZ) at - line 7. BEGIN failed--compilation aborted at -
line 7....).

For now i iterate over the files, create a new perl process for every
file (perl -c -W -Mstrict -I XYZ) and write the bytes of the current
file into the process.
But it is very expensive to start a new perl process for every file to
parse.

Is it possible to use only one perl process for parsing multiple perl
files?
I mean: open only one perl process, write in the bytes of a file, read
the output, "reset" the perl process (change @inc...), write in the
bytes of the next file, read the output, "reset" the perl
process...and so on till all files will be parsed/compiled. Then exit
the perl process. Is this possible?
What do i have to "reset/new initalize" after one file is processed?
Only the @INC or more?
How can i tell the perl process that one file is fully written to the
input stream and the parser/compiler should write the output to the
output stream?

Thanks,
Michael


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

Date: Fri, 1 Aug 2008 16:32:45 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Use single perl instance multiple times
Message-Id: <g6ve3o.18s.2@news.isolution.nl>

mseele schreef:

> Is it possible to use only one perl process for parsing multiple
> perl files?

Not without side effects, but maybe good enough:

  package JEQVCHSAFCUDFNDGSADKFFH;

  for $file (@files) {
      eval {
          require $file;
          1;
      }
      or do {
          my $err = $@;
          printf STDERR "%s\n", $err;
      };
  }

Next progress would be forking suicidals, I suppose.

Alternative approaches:
  for f in *.pm ; do perl -Mstrict -wc $f ; done 2>&1 |grep -vP "\.pm
syntax OK$" |less
  for f in *.pm ; do perl -Mstrict -wc $f 2>&1 |grep -vP "\.pm syntax
OK$" ; done |less

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

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


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