[22221] in Perl-Users-Digest
Perl-Users Digest, Issue: 4442 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 21 18:06:06 2003
Date: Tue, 21 Jan 2003 15:05:12 -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, 21 Jan 2003 Volume: 10 Number: 4442
Today's topics:
Re: ActivePerl 5.8 / MySQL / Apache Problem <lou.moran@gellerandwind.com>
Re: APL's relation to perl (Sara)
arrg, grep {"abc"} @stuff, always is true?! <abc@nowhere.com>
Re: arrg, grep {"abc"} @stuff, always is true?! <mthunter@students.uiuc.edu>
Re: arrg, grep {"abc"} @stuff, always is true?! (Tad McClellan)
Re: arrg, grep {"abc"} @stuff, always is true?! (Tad McClellan)
Re: arrg, grep {"abc"} @stuff, always is true?! <bigj@kamelfreund.de>
Re: arrg, grep {"abc"} @stuff, always is true?! (Ben Morrow)
C++ for GUI and Perl for functionality? <andreas.schmidt.2002@gmx.de>
Re: CGI.pm aligning radio buttons with pick-lists (Ben Morrow)
Re: Couple of Perl CGI problems Andrew Lee
execute b.pl script from within a.pl script and b.pl va <abc@nowhere.com>
Re: execute b.pl script from within a.pl script and b.p (Anno Siegel)
Re: execute b.pl script from within a.pl script and b.p <abc@nowhere.com>
Re: execute b.pl script from within a.pl script and b.p (Anno Siegel)
Re: execute b.pl script from within a.pl script and b.p (Ben Morrow)
Re: execute b.pl script from within a.pl script and b.p <abc@nowhere.com>
Re: execute b.pl script from within a.pl script and b.p (Anno Siegel)
Re: execute b.pl script from within a.pl script and b.p (Tad McClellan)
Re: execute b.pl script from within a.pl script and b.p (Tad McClellan)
Re: execute b.pl script from within a.pl script and b.p (Ben Morrow)
Re: GD::Graph get_hotspot() <mgjv@tradingpost.com.au>
Re: How can a SMTP mail be deleted from a Unix mailbox (Markus Elfring)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 21 Jan 2003 15:00:33 -0500
From: Lou Moran <lou.moran@gellerandwind.com>
Subject: Re: ActivePerl 5.8 / MySQL / Apache Problem
Message-Id: <ah9r2v4r4eq2o3kf2g8okf69e141okgchl@4ax.com>
On Tue, 21 Jan 2003 12:04:29 -0000, "Alex Banks" <alex@alexbanks.com>
wrote:
>Would be really grateful for any help with this... I've been surfing for
>hours to try to find a similar case.
>
>---
>
>I used to run ActivePerl 5.6 with Apache on my Windows XP box just fine -
>but since I installed ActivePerl 5.8 my old database scripts don't work.
>They come back with this error:
>
>[Tue Jan 21 11:51:24 2003] [error] [client 192.168.1.15]
>install_driver(mysql) failed: Can't load
>'C:/Perl/site/lib/auto/DBD/mysql/mysql.dll' for module DBD::mysql:
>load_file:The specified module could not be found at
>C:/Perl/lib/DynaLoader.pm line 229.
>[Tue Jan 21 11:51:24 2003] [error] [client 192.168.1.15] at (eval 1) line 3
>[Tue Jan 21 11:51:24 2003] [error] [client 192.168.1.15] Compilation failed
>in require at (eval 1) line 3.
>[Tue Jan 21 11:51:24 2003] [error] [client 192.168.1.15] Perhaps a required
>shared library or dll isn't installed where expected
SNIP
The big problem is that 5.8 and 5.6 are not binary compatible. You
need to go get new modules. One such module is DBD::mysql.
You can read more about it here:
http://dev.perl.org/perl5/news/2002/07/18/580ann/
But this is the part you'll care most about -
BINARY INCOMPATIBLE:
mainly because of the PerlIO introduction, Perl 5.8 is not
binary compatible with any earlier Perl release, XS MODULES
WILL HAVE TO BE RECOMPILED!
--
There's more than one way to do it, but only some of them work
------------------------------
Date: 21 Jan 2003 12:02:04 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: APL's relation to perl
Message-Id: <776e0325.0301211202.64b64952@posting.google.com>
Michele Dondi <bik.mido@tiscalinet.it> wrote in message news:<lhqo2vs8j5hlt7v0lmgvdonu1mopji0vm7@4ax.com>...
> On 17 Jan 2003 11:07:57 -0800, genericax@hotmail.com (Sara) wrote:
>
> >I WISH! APL is (was) one of the best linear variable programming
> >languages in existence. Imagine a primitive function (domino) to
> >invert an arbitry matrix (of ANY number of dimensions even!). How many
> ^^^^^^^^^^
>
> <OT>
> I don't know APL, I am only a beginner in Perl, and OTOH I'm not an
> expert in (multi)linear algebra either, but AFAIK there's no (+ I
> can't devise a) generally accepted/acceptable notion of multiplication
> (and thus inversion) of "ANY number of dimension"-al matrices, while
> such a notion is natural for "2-dimensional" (that is, ordinary)
> matrices (that is rank 2 tensors). But maybe you meant something
> completely different...
> </OT>
>
>
hi Michele:
My APL days are long since past, but for the most part those Greek
keys are branded into my brain! Anyhow, I may be wrong about domino
working on any dimensions. Mathematically then an inverse of
M[m,n,...] is undefined for indices greater than 2? (or less than 2)?
I didn't know that but I beleive it may be true. I'm not a
mathmetician, I'm a scientist.
Wish I had an APL Terminal here now I could test that theory in about
3 seconds! (remember the good old "domain error" APListas?)
A site I found http://www.agrenv.mcgill.ca/agreng/applmath/2/Matrix.HTM
seems to support your proposal although I don't see it explicitly
stated that way. However rule 1 seems to imply 2 dimensions. I suppose
in a sense, a 5x5x5 matrix is also square and has equal rows and
columns. But I think you're right thanks for correcting me.
1.You can use Invert with "square" matrices only (those with the
same number of rows as columns).
2.You can invert matrices up to 90 rows by 90 columns.
3.You cannot invert a matrix that is mathematically singular. A
matrix is singular when its determinant equals zero.
4.You cannot invert a matrix with mathematical redundancies or
inconsistencies.
Cheers-
-Gx
> Michele
------------------------------
Date: Tue, 21 Jan 2003 21:30:07 GMT
From: ktom <abc@nowhere.com>
Subject: arrg, grep {"abc"} @stuff, always is true?!
Message-Id: <3E2DBBDD.8050101@nowhere.com>
i have a array @stuff created with
my @stuff = qw(abc def ghi);
foreach $a ( @stuff ) { if ( $a =~ "abc" ) {print "yes";} }
behaves correctly and prints yes, if abc is changed to cba, it does not
print.
replacing the above with
if( grep { "abc" } @stuff ) { print "yes"; }
prints yes regardless of the value defined for the grep statement. abc,
xyz, cba, foobar. it will always print yes.
the reference says grep is to return the number of times that a match
occured. i can not see how a non-matching valueis returning a non-zero
#. putting scalar( grep { "abc" } @stuff ) proves no different
this seems to be such a simple issue, i am annoyed that the obvious
escapes me..
thanks. kevint
------------------------------
Date: Tue, 21 Jan 2003 21:50:57 GMT
From: Mike Hunter <mthunter@students.uiuc.edu>
Subject: Re: arrg, grep {"abc"} @stuff, always is true?!
Message-Id: <slrnb2rgbm.19g.mthunter@ux8.cso.uiuc.edu>
On Tue, 21 Jan 2003 21:30:07 GMT, ktom wrote:
> i have a array @stuff created with
> my @stuff = qw(abc def ghi);
>
> foreach $a ( @stuff ) { if ( $a =~ "abc" ) {print "yes";} }
>
> behaves correctly and prints yes, if abc is changed to cba, it does not
> print.
>
> replacing the above with
>
> if( grep { "abc" } @stuff ) { print "yes"; }
>
> prints yes regardless of the value defined for the grep statement. abc,
> xyz, cba, foobar. it will always print yes.
>
> the reference says grep is to return the number of times that a match
> occured. i can not see how a non-matching valueis returning a non-zero
> #. putting scalar( grep { "abc" } @stuff ) proves no different
>
> this seems to be such a simple issue, i am annoyed that the obvious
> escapes me..
>
> thanks. kevint
grep takes a regular expression as its first argument.
------------------------------
Date: Tue, 21 Jan 2003 16:23:56 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: arrg, grep {"abc"} @stuff, always is true?!
Message-Id: <slrnb2ri3s.4eo.tadmc@magna.augustmail.com>
Mike Hunter <mthunter@students.uiuc.edu> wrote:
> On Tue, 21 Jan 2003 21:30:07 GMT, ktom wrote:
>> if( grep { "abc" } @stuff ) { print "yes"; }
> grep takes a regular expression as its first argument.
No it doesn't.
perldoc -f grep
grep BLOCK LIST
grep EXPR,LIST
grep takes a BLOCK or EXPR as its first argument.
grep _can_ take a regex (actually "match operator") as its first arg:
if( grep /abc/, @stuff ) { print "yes"; }
But it can also take _other_ EXPRs:
if( grep -s > 1_000_000, @filenames ) { print "big file"; }
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 21 Jan 2003 16:29:26 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: arrg, grep {"abc"} @stuff, always is true?!
Message-Id: <slrnb2rie6.4eo.tadmc@magna.augustmail.com>
ktom <abc@nowhere.com> wrote:
> my @stuff = qw(abc def ghi);
> if( grep { "abc" } @stuff ) { print "yes"; }
>
> prints yes regardless of the value defined for the grep statement. abc,
> xyz, cba, foobar. it will always print yes.
No it won't, you just haven't used one of the values that
will make it skip the printing:
if( grep { "" } @stuff ) { print "yes"; }
if( grep { "0" } @stuff ) { print "yes"; }
if( grep { 0 } @stuff ) { print "yes"; }
if( grep { undef } @stuff ) { print "yes"; }
> the reference
^^^^^^^^^^^^^
Do you mean "perldoc -f grep" there?
> says grep is to return the number of times that a match
> occured.
No it doesn't. It says:
Evaluates the BLOCK or EXPR for each element of LIST (locally setting
$_ to each element) and returns the list value consisting of those
elements for which the expression evaluated to true. In scalar
context, returns the number of times the expression was true.
it says grep is to return the number of times that the
expression was true.
The expression "abc" is *always* true.
> i can not see how a non-matching valueis returning a non-zero
You are not doing any matching at all.
> #. putting scalar( grep { "abc" } @stuff ) proves no different
>
> this seems to be such a simple issue, i am annoyed that the obvious
> escapes me..
if( grep { /abc/ } @stuff ) { print "yes"; }
or
if( grep /abc/, @stuff ) { print "yes"; }
Then you _would_ be doing matching.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 21 Jan 2003 22:13:55 +0100
From: "Janek Schleicher" <bigj@kamelfreund.de>
To: xyzzy@billgates.com
Subject: Re: arrg, grep {"abc"} @stuff, always is true?!
Message-Id: <pan.2003.01.21.20.50.09.434062@kamelfreund.de>
On Tue, 21 Jan 2003 21:30:07 +0000, ktom wrote:
> if( grep { "abc" } @stuff ) { print "yes"; }
>
> prints yes regardless of the value defined for the grep statement. abc,
> xyz, cba, foobar. it will always print yes.
I'm sure you meant
if (grep { /abc/ } @stuff) {print "yes"; }
^ ^
Allthough the difference are only 2 characters, they make a big
difference.
In Perl in contrast to the unix grep, a list is grepped for a subroutine
and not automatic for a regexp. So { "abc" } ... is just a subroutine
always returning the value of the last statement which is "abc" what is
again a true value :D. In difference /abc/ is a regexp that is used with
the implicit $_ variable and it's return value isn't so always true.
I normally use the style
grep /abc/, @stuff
if I want to grep for a regexp
and I use the {} brackets only if there is a real subroutine wanted.
Greetings,
Janek
PS: By the way,
it's wrong that
if (grep { "abc" } @stuff) {print "yes"; }
always prints yes.
Look at
perl -e 'if (grep { "abc" } @stuff) {print "yes"; }'
------------------------------
Date: Tue, 21 Jan 2003 22:53:13 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: arrg, grep {"abc"} @stuff, always is true?!
Message-Id: <b0kj0p$t7c$1@wisteria.csv.warwick.ac.uk>
xyzzy@billgates.com
U wrote:
>i have a array @stuff created with
>my @stuff = qw(abc def ghi);
>
>foreach $a ( @stuff ) { if ( $a =~ "abc" ) {print "yes";} }
>
>behaves correctly and prints yes, if abc is changed to cba, it does not
>print.
This is rather misleading. You should use /abc/ or m(abc) to make a regex.
Obviously, if you pass =~ a string it treats it as a regex: I didn't know that,
but it makes sense.
>replacing the above with
>
>if( grep { "abc" } @stuff ) { print "yes"; }
>
>prints yes regardless of the value defined for the grep statement. abc,
>xyz, cba, foobar. it will always print yes.
It will. grep evaluates the block for truth for each element of the array, and
(in scalar context) returns a count of the 'true's. The string "abc" is always
true, so this grep will return a count of your array.
If, however, you use /abc/, this implicitly means
$_ =~ /abc/
and grep implicitly sets $_ to the element it's working on for the duration
of the block. So this will do what you expect.
Other ways of doing the same thing:
{ $_ =~ "abc" }
(This is a bad idea, as it's unclear. Quote regexen with // or m//)
{ $_ eq "abc" }
which may well be what you actually mean: the regex will match "xabc" as well
as plain "abc".
Ben
------------------------------
Date: Tue, 21 Jan 2003 14:01:45 -0800
From: Andreas Schmidt <andreas.schmidt.2002@gmx.de>
Subject: C++ for GUI and Perl for functionality?
Message-Id: <20030121140145.38786220.andreas.schmidt.2002@gmx.de>
Hi,
I wanna program a cross-platform application with a fast, accurate GUI. It should look like a professional "standard" application, but use Perl behind the scenes.
Is it recommendable to code the core functionalities as Perl modules and use platform-specific C++ libraries for the Linux/Windows GUIs?
Can I use SWIG for this? Or the Inline module?
And are there installers that take care of the user's installation, e.g. installs the Perl interpreter automatically if necessary? Or can I compile everything just into executables?
Sorry for the bunch of question! Any suggestions are helpful...
Andi
------------------------------
Date: Tue, 21 Jan 2003 19:12:29 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: CGI.pm aligning radio buttons with pick-lists
Message-Id: <b0k62t$kf4$1@wisteria.csv.warwick.ac.uk>
"Clyde Ingram" <cingram@pjocsNOSPAMORHAM.demon.co.uk> wrote:
>"Ben Morrow" <mauzo@ux-ma160-6.csv.warwick.ac.uk> wrote in message
>news:b0jmfc$b95$1@wisteria.csv.warwick.ac.uk...
>> "Clyde Ingram" <cingram@pjocsNOSPAMORHAM.demon.co.uk> wrote:
>> >Using CGI.pm, I can generate a vertical panel of radio buttons to select
>one
><SNIP>
>> This is an HTML problem, not a Perl problem.
>
>Correction. This is a Perl problem, not an HTML problem.
No, you have two problems here. The first is to work out what HTML you need to
produce the effect you want; the second is to work out how to make CGI.pm give
you that HTML. The first is not a Perl promlem, the second I would have
assumed was trivial but it seems isn't (I don't use CGI, I use CGI::Lite, and
write all my own HTML).
>I talked about using CGI.pm, the well known Perl Module.
Yes, but (at least I think) you should learn to write HTML before you use CGI.
>This would have been clearer if I had posted some code.
>IIRC my Perl code to use the radio_group() function went something like:
>
>print $q->radio_group(
> -name => 'Frequency',
> 'values' => [ qw/ Monthly Weekly Daily / ],
> 'default' => 'Weekly,
> 'linebreak => 1 # This stacks the
>buttons vertically
>);
>
>Note: all Perl there - not a shred of HTML.
>
>Page 247 of Lincoln Stein's "Official Guide to Programming with CGI.pm"
>assures me:
>
>"The radio_group() function creates a set of radio buttons all linked by a
>common name. In a scalar context, the function returns a string containing
>the properly formatted HTML tags. In an array context, the function returns
>a list of radio button elements which you can then manipulate in whatever
>way you like (such as incorporating it into a table in order to control the
>layout)."
>
>I do not understand the part about "array context" returning a "list of
>radio button elements". (What is a "radio button element" in Perl?) But I
>believe I should I should "manipulate . . . incorporating it into a table in
>order to control the layout". The clues are all there. I just don't
>follow them.
I think what this means is that if you do
my @radios = $q->radio_group(...);
then @radios will contain a list of strings, one for each radiobutton. To see
exactly what it does, try
use Data::Dumper;
my @radios = $q->radio_group(...);
print STDERR Dumper \@radios;
and see what you get.
You can then use the table-producing function to insert these strings
at the appropriate places in a table. You will need to design the
table first: my guess is that you want something like
<table>
<tr>
<td>radio button</td><td>drop-down list</td>
</tr><tr>
<td>radio button</td><td>dd list</td>
etc...
</table>
but, as I said, this is an HTML problem.
Ben
------------------------------
Date: Tue, 21 Jan 2003 15:08:34 -0500
From: Andrew Lee
Subject: Re: Couple of Perl CGI problems
Message-Id: <kv9r2v4gieimous7tdrptaqhh9g26dk3uu@4ax.com>
On Tue, 21 Jan 2003 11:07:37 GMT, helgi@decode.is (Helgi Briem) wrote:
>On 20 Jan 2003 19:11:59 -0800, kedaran0504@yahoo.com.au
>(UmanS) wrote:
>
>>First problem.
>>I am submitting a field contains name and email address separated by
>>"|" (Selected from a drop down list in a form)
>
>>ex: Surname.Firstname|user@mydomain.com
>
>>In the cgi script I assign this to a field and splitting this field
>>into an array.
>
>Do yourself a favour and allow warnings and strictures.
>You would have this problem solved by now if you did.
Not necessarily. Enabling strictues and warnings for the code snippet
in the OP would have complained only that "@myname used only once
possible typo?"
Which is to say all the perl in the OP was legal (if faulted).
------------------------------
Date: Tue, 21 Jan 2003 19:52:42 GMT
From: ktom <abc@nowhere.com>
Subject: execute b.pl script from within a.pl script and b.pl vars remain
Message-Id: <3E2DA507.8030900@nowhere.com>
i would like to execute a perl script, a.pl, which contain code to
execute the perl script b.pl and have the values for the variables
define in b.pl remain for use withing a.pl
so far i have tried do, use, require and all have produced the same results
--- a.pl ---
my @var;
use b; (or require "b.pl"; or do "b.pl"; and b.pm is a copy of b.pl )
print "\nvar is @var\n";
--- end a.pl ----
--- b.pl --
@var = ( "x", "y", "z" );
print @var;
--- end b.pl ---
results..
----
xyz
var is
-------
it seems the var is defined ok in the called b.pl, but the results do
not make back to a.pl.
what am i missing??
thanks kevin
------------------------------
Date: 21 Jan 2003 20:16:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: execute b.pl script from within a.pl script and b.pl vars remain
Message-Id: <b0k9rl$bb7$1@mamenchi.zrz.TU-Berlin.DE>
ktom <xyzzy@billgates.com> wrote in comp.lang.perl.misc:
> i would like to execute a perl script, a.pl, which contain code to
> execute the perl script b.pl and have the values for the variables
> define in b.pl remain for use withing a.pl
>
> so far i have tried do, use, require and all have produced the same results
>
> --- a.pl ---
>
> my @var;
This declares a lexical variable @var.
> use b; (or require "b.pl"; or do "b.pl"; and b.pm is a copy of b.pl )
All these cause the package variable @main::var to be set.
> print "\nvar is @var\n";
This accesses the lexical @var. Lexicals have precedence.
>
> --- end a.pl ----
>
> --- b.pl --
> @var = ( "x", "y", "z" );
This is the package variable @main::var. It is different from any lexical
variable.
> print @var;
...prints @main::var.
> --- end b.pl ---
>
> results..
> ----
>
> xyz
> var is
>
> -------
>
> it seems the var is defined ok in the called b.pl, but the results do
> not make back to a.pl.
Well, you're running without strict and warnings, it seems. Always switch
them on, they'll help you understand your program's behavior.
Change the declaration of @var in the main program from "my" to "our".
Add another "our" declaration in b.pl. Add "use warnings; use strict;"
at the top of both, and see what else comes up.
Anno
------------------------------
Date: Tue, 21 Jan 2003 20:44:40 GMT
From: ktom <abc@nowhere.com>
Subject: Re: execute b.pl script from within a.pl script and b.pl vars remain
Message-Id: <3E2DB135.3020906@nowhere.com>
Anno Siegel wrote:
> ktom <xyzzy@billgates.com> wrote in comp.lang.perl.misc:
>
>>i would like to execute a perl script, a.pl, which contain code to
>>execute the perl script b.pl and have the values for the variables
>>define in b.pl remain for use withing a.pl
>>
>>so far i have tried do, use, require and all have produced the same results
>>
>>--- a.pl ---
>>
>>my @var;
>
>
> This declares a lexical variable @var.
>
>
>>use b; (or require "b.pl"; or do "b.pl"; and b.pm is a copy of b.pl )
>
>
> All these cause the package variable @main::var to be set.
>
>
>>print "\nvar is @var\n";
>
>
> This accesses the lexical @var. Lexicals have precedence.
>
>
>>--- end a.pl ----
>>
>>--- b.pl --
>>@var = ( "x", "y", "z" );
>
>
> This is the package variable @main::var. It is different from any lexical
> variable.
>
>
>>print @var;
>
>
> ...prints @main::var.
>
>
>>--- end b.pl ---
>>
>>results..
>>----
>>
>>xyz
>>var is
>>
>>-------
>>
>>it seems the var is defined ok in the called b.pl, but the results do
>>not make back to a.pl.
>
>
> Well, you're running without strict and warnings, it seems. Always switch
> them on, they'll help you understand your program's behavior.
i didn't have the use strict/warnings on b.pl, but is was in the a.pl,
there were no complaints before or after the inclusion of
warnings/strict to the b.pl file.
>
> Change the declaration of @var in the main program from "my" to "our".
> Add another "our" declaration in b.pl. Add "use warnings; use strict;"
> at the top of both, and see what else comes up.
this did it !!! changing 'my' to 'our' in a.pl made all the difference.
it doesn't seem to matter whether @var is prepended with 'our' in b.pl
. it would seem to be good practice to put it b.pl,yes??
thanks for your help..
>
> Anno
------------------------------
Date: 21 Jan 2003 21:01:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: execute b.pl script from within a.pl script and b.pl vars remain
Message-Id: <b0kcf5$cfe$2@mamenchi.zrz.TU-Berlin.DE>
ktom <xyzzy@billgates.com> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > ktom <xyzzy@billgates.com> wrote in comp.lang.perl.misc:
> >
> >>i would like to execute a perl script, a.pl, which contain code to
> >>execute the perl script b.pl and have the values for the variables
> >>define in b.pl remain for use withing a.pl
[coping with scoping]
> >>it seems the var is defined ok in the called b.pl, but the results do
> >>not make back to a.pl.
> >
> >
> > Well, you're running without strict and warnings, it seems. Always switch
> > them on, they'll help you understand your program's behavior.
>
> i didn't have the use strict/warnings on b.pl, but is was in the a.pl,
> there were no complaints before or after the inclusion of
> warnings/strict to the b.pl file.
>
> >
> > Change the declaration of @var in the main program from "my" to "our".
> > Add another "our" declaration in b.pl. Add "use warnings; use strict;"
> > at the top of both, and see what else comes up.
>
> this did it !!! changing 'my' to 'our' in a.pl made all the difference.
> it doesn't seem to matter whether @var is prepended with 'our' in b.pl
Under "use strict 'vars'" it matters.
> . it would seem to be good practice to put it b.pl,yes??
It is good practice to "use strict". After that, it's a fatal error
to use an undeclared variable.
Anno
------------------------------
Date: Tue, 21 Jan 2003 20:57:47 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: execute b.pl script from within a.pl script and b.pl vars remain
Message-Id: <b0kc8b$oc5$1@wisteria.csv.warwick.ac.uk>
xyzzy@billgates.com
U wrote:
>i would like to execute a perl script, a.pl, which contain code to
>execute the perl script b.pl and have the values for the variables
>define in b.pl remain for use withing a.pl
>
>so far i have tried do, use, require and all have produced the same results
>
>--- a.pl ---
>
>my @var;
>use b; (or require "b.pl"; or do "b.pl"; and b.pm is a copy of b.pl )
>print "\nvar is @var\n";
>
>--- end a.pl ----
>
>--- b.pl --
>@var = ( "x", "y", "z" );
>print @var;
>--- end b.pl ---
>
>results..
>----
>
>xyz
>var is
>
>-------
>
>it seems the var is defined ok in the called b.pl, but the results do
>not make back to a.pl.
If you really need to do this, you can do:
my $var;
my $code;
{
open my $FH, "<b.pl";
local $/ = undef;
$code = <$FH>;
}
eval $code;
print $var;
, but what on earth do you need to do this for? I'm sure there is a better
answer if you tell us what your actual problem is.
Ben
------------------------------
Date: Tue, 21 Jan 2003 21:33:11 GMT
From: ktom <abc@nowhere.com>
Subject: Re: execute b.pl script from within a.pl script and b.pl vars remain
Message-Id: <3E2DBC95.9@nowhere.com>
Ben Morrow wrote:
> xyzzy@billgates.com
> U wrote:
>
>>i would like to execute a perl script, a.pl, which contain code to
>>execute the perl script b.pl and have the values for the variables
>>define in b.pl remain for use withing a.pl
>>
>>so far i have tried do, use, require and all have produced the same results
>>
>>--- a.pl ---
>>
>>my @var;
>>use b; (or require "b.pl"; or do "b.pl"; and b.pm is a copy of b.pl )
>>print "\nvar is @var\n";
>>
>>--- end a.pl ----
>>
>>--- b.pl --
>>@var = ( "x", "y", "z" );
>>print @var;
>>--- end b.pl ---
>>
>>results..
>>----
>>
>>xyz
>>var is
>>
>>-------
>>
>>it seems the var is defined ok in the called b.pl, but the results do
>>not make back to a.pl.
>
>
> If you really need to do this, you can do:
>
> my $var;
> my $code;
> {
> open my $FH, "<b.pl";
> local $/ = undef;
> $code = <$FH>;
> }
> eval $code;
> print $var;
>
> , but what on earth do you need to do this for? I'm sure there is a better
> answer if you tell us what your actual problem is.
i am very much a csh person the equivalent of 'source' is a comfortable
implementation.
the b.pl is the result of ls -1 *.abc | sed | sed > b.pl very easy and
quick/reliable..
>
> Ben
------------------------------
Date: 21 Jan 2003 21:50:59 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: execute b.pl script from within a.pl script and b.pl vars remain
Message-Id: <b0kfc3$eak$2@mamenchi.zrz.TU-Berlin.DE>
ktom <xyzzy@billgates.com> wrote in comp.lang.perl.misc:
> Ben Morrow wrote:
> > xyzzy@billgates.com
> >>i would like to execute a perl script, a.pl, which contain code to
> >>execute the perl script b.pl and have the values for the variables
> >>define in b.pl remain for use withing a.pl
[...]
> > , but what on earth do you need to do this for? I'm sure there is a better
> > answer if you tell us what your actual problem is.
Looks like xyzzy has led us astray with an XY problem.
> i am very much a csh person the equivalent of 'source' is a comfortable
> implementation.
>
> the b.pl is the result of ls -1 *.abc | sed | sed > b.pl very easy and
> quick/reliable..
So you want to expand a shell glob? Yikes, was Ben right!
my @files = glob( '*.abc');
does exactly that. Talk about easy...
Anno
------------------------------
Date: Tue, 21 Jan 2003 15:16:26 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: execute b.pl script from within a.pl script and b.pl vars remain
Message-Id: <slrnb2re5a.3sm.tadmc@magna.augustmail.com>
ktom <abc@nowhere.com> wrote:
> i would like to execute a perl script, a.pl, which contain code to
> execute the perl script b.pl and have the values for the variables
> define in b.pl remain for use withing a.pl
> what am i missing??
"Coping with Scoping":
http://perl.plover.com/FAQs/Namespaces.html
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 21 Jan 2003 16:17:53 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: execute b.pl script from within a.pl script and b.pl vars remain
Message-Id: <slrnb2rhoh.4eo.tadmc@magna.augustmail.com>
ktom <abc@nowhere.com> wrote:
> the b.pl is the result of ls -1 *.abc | sed | sed > b.pl very easy and
^^ ^^^^^^^^^^^
^^ ^^^^^^^^^^^
Do you get paid by the character or something?
(what's wrong with "ls *.abc >b.pl" ? (apart from not doing it in Perl))
If so, use Ada or Java instead of Perl. <grin>
Or do you have a version of sed that does something when
called with no args?
Or or do you have a version of ls that behaves the same
when it's output is/isn't a tty?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 21 Jan 2003 22:57:55 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: execute b.pl script from within a.pl script and b.pl vars remain
Message-Id: <b0kj9j$22$1@wisteria.csv.warwick.ac.uk>
xyzzy@billgates.com
>> , but what on earth do you need to do this for? I'm sure there is a better
>> answer if you tell us what your actual problem is.
>
>i am very much a csh person the equivalent of 'source' is a comfortable
>implementation.
>
>the b.pl is the result of ls -1 *.abc | sed | sed > b.pl very easy and
>quick/reliable..
I wondered if it might be something like this. This is a Bad Idea: it's much
safer and much faster to do things in Perl. In this case I think you want the
glob() function (perldoc -f glob) or just <*.abc> which does the same thing.
As a general rule, Perl is much more of a 'proper' programming language than
shell.
Ben
------------------------------
Date: Wed, 22 Jan 2003 09:28:48 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: GD::Graph get_hotspot()
Message-Id: <slrnb2rid0.7m2.mgjv@martien.heliotrope.home>
On 21 Jan 2003 08:43:37 -0800,
RR <rickraster@hotmail.com> wrote:
> Hi all,
>
> Can anyone tell me how the get_hotspot method works for GD::Graph (or
> illustrate with some sample code)? I am generating imagemaps for my
> graphs, which work fine, but so far I've only been able to hard-code
> the coords for the map. I think get_hotspot() will do what I need (get
> the dynamic column coords), but I haven't been able to get it to
> return any results for me.
sample71.pl in the source distribution uses hotspot to put some extra
text on the chart. It is commented out with an if(0), but if I uncomment
it, it works fine. Furthermore, it is quite clearly documented in the
GD::Graph documentation under HOTSPOTS (at least I believe it is). If
that isn't enough, could you please be a bit more specific about what it
is you don't understand, and what exactly you tried? At the moment, I
could come up with 10 examples of how to use it, and still miss what
you need. I also can't tell you whether you did something wrong, because
I can't read your mind.
Martien
--
|
Martien Verbruggen | The world is complex; sendmail.cf reflects
| this.
|
------------------------------
Date: 21 Jan 2003 13:53:37 -0800
From: Markus.Elfring@web.de (Markus Elfring)
Subject: Re: How can a SMTP mail be deleted from a Unix mailbox by a script?
Message-Id: <40ed1d8f.0301211353.38570e24@posting.google.com>
I think that a POP3 server will not use a mbox file.
------------------------------
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.
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 4442
***************************************