[31857] in Perl-Users-Digest
Perl-Users Digest, Issue: 3120 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 6 16:09:21 2010
Date: Mon, 6 Sep 2010 13:09:07 -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 Mon, 6 Sep 2010 Volume: 11 Number: 3120
Today's topics:
Re: Accessing and printing LoL fields in a loop? <sherm.pendley@gmail.com>
Re: Accessing and printing LoL fields in a loop? <jurgenex@hotmail.com>
Re: Accessing and printing LoL fields in a loop? <tuxedo@mailinator.com>
Re: Accessing and printing LoL fields in a loop? <tuxedo@mailinator.com>
Re: Accessing and printing LoL fields in a loop? <sherm.pendley@gmail.com>
Re: Ideal data structure for nested list format? <ben@morrow.me.uk>
Re: Ideal data structure for nested list format? <ben@morrow.me.uk>
Re: Ideal data structure for nested list format? <tuxedo@mailinator.com>
Re: Ideal data structure for nested list format? <tuxedo@mailinator.com>
Re: Multidimensional array <tadmc@seesig.invalid>
Re: Multidimensional array <ben@morrow.me.uk>
Re: POSIX and Math::Trig <cheney@halliburton.com>
Re: POSIX and Math::Trig <uri@StemSystems.com>
Re: POSIX and Math::Trig <ben@morrow.me.uk>
Re: POSIX and Math::Trig <bugbear@trim_papermule.co.uk_trim>
Re: POSIX and Math::Trig <derykus@gmail.com>
Re: POSIX and Math::Trig <nospam-abuse@ilyaz.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 06 Sep 2010 11:51:44 -0400
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Accessing and printing LoL fields in a loop?
Message-Id: <m2y6beyinj.fsf@sherm.shermpendley.com>
Tuxedo <tuxedo@mailinator.com> writes:
> Can you or anyone kindly post the code within
> an actual working script using example data like in the above LoL?
As it happens, the menus on my CamelBones site are generated from a
similar data structure. This script runs in my editor (BBEdit) to update
static .html pages, so you'll need to make the appropriate adjustments
to adapt it to your specific needs:
<http://camelbones.svn.sourceforge.net/viewvc/camelbones/trunk/WebSite/%28includes%29/menu.pl?revision=94&view=markup>
sherm--
--
Sherm Pendley
<http://camelbones.sourceforge.net>
Cocoa Developer
------------------------------
Date: Mon, 06 Sep 2010 09:51:45 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Accessing and printing LoL fields in a loop?
Message-Id: <i56a86p3vjmimkl3q8o3iq3cvs0gtc27nn@4ax.com>
Tuxedo <tuxedo@mailinator.com> wrote:
>Jürgen Exner wrote:
>> However if you don't insist on that loop then just pass an additional
>> parameter "$level" to print_list() which you decrement for each
>> recursive call and the actual print()s are only executed if $level ==0;
>>
>> sub print_list {
>> my $level = shift;
>> print_list_begin() if $level ==0;;
>> for my $elem (@_){
>> if (ref($elem) { # we got a sublist to process
>> print_list ($level -1, @{$elem});
>> } else { # we got a single element
>> print_item($elem} if $level ==0;;
>> }
>> }
>> print_list_end() if $level ==0;
>> }
>Thanks for answering and posting the above code examples. I can't say I
>fully understand the syntax (yet).
You see me bedazzled. I'm not using any special syntax tricks, it's all
_very_ basic stuff that you would find in virtually identical form in
hundreds of other programming languages: function definition,
assignments, conditional statements (ok, this might be a tiny bit less
common), conditional, expressions, and function calls.
>How is parameter $level passed to
>print_list() for example?
It's right in there, you just do it (well, you pass $level-1, not
$level):
print_list ($level -1, @{$elem});
>Would this be done with a regular LoL or
>something slightly different?
???
Neither, nor. You just pass it on it's own accord. No need to hide it in
some additional data structure.
Or are you confused that you can pass more than one parameter to a
function?
jue
------------------------------
Date: Mon, 6 Sep 2010 19:43:44 +0200
From: Tuxedo <tuxedo@mailinator.com>
Subject: Re: Accessing and printing LoL fields in a loop?
Message-Id: <i6398h$2r7$03$1@news.t-online.com>
Sherm Pendley wrote:
[...]
> As it happens, the menus on my CamelBones site are generated from a
> similar data structure. This script runs in my editor (BBEdit) to update
> static .html pages, so you'll need to make the appropriate adjustments
> to adapt it to your specific needs:
>
>
<http://camelbones.svn.sourceforge.net/viewvc/camelbones/trunk/WebSite/%28includes%29/menu.pl?revision=94&view=markup>
>
> sherm--
>
Hey that's cool! Thanks for sharing your work! I really like the navigation
system at http://camelbones.sourceforge.net. I must use this the same for
something; not an exact replica of course but a slightly amended version :-)
As far as I understand, a nested list system is created based on the
directory depth levels of your site. Is that right? What arguments and in
which order they meant to me passed if running/testing menu.pl on the
command line?
My particular menu however is only for pages that are at a root directory
level, yet they should always have the same nested <li> levels returned as
represented in its list structure:
my $menu = [
{ 'title' => 'Level 1.1 (node)', 'href' => '1.1.html', 'children' =>[
{ 'title' => 'Level 2.1', 'href' => '2.1.html', },
{ 'title' => 'Level 2.2 (node)', 'href' => '2.2.html', 'children' =>[
{ 'title' => '3.1.html', 'href' => '3.1.html', },
{ 'title' => '3.2', 'href' => '3.2.html', },
]},
{ 'title' => 'Level 2.3', 'href' => '2.3.html', },
]},
];
The flat HTML (without any current URL paramenter) it should produce is:
<ul>
<li><a href=1.1.html>Level 1.1 (node)</a>
<ul>
<li><a href=2.1.html>Level 2.1</a></li>
<li><a href=2.2.html>Level 2.2 (node)</a>
<ul>
<li><a href=3.1.html>Level 3.1</a></li>
<li><a href=3.2.html>Level 3.2</a></li>
</ul>
</li>
<li><a href=2.3.html>Level 2.3</a></li>
</ul>
</li>
</ul>
Maybe slightly unusual in that I have only one item at level 1. Obviously
the real version will be populated with many more items. Anyhow, is your
script adaptable to this format? I guess not without a major rewrite!?
Thanks,
Tuxedo
------------------------------
Date: Mon, 6 Sep 2010 20:15:27 +0200
From: Tuxedo <tuxedo@mailinator.com>
Subject: Re: Accessing and printing LoL fields in a loop?
Message-Id: <i63b3v$glq$00$1@news.t-online.com>
Jürgen Exner wrote:
[...]
> You see me bedazzled. I'm not using any special syntax tricks, it's all
I never thought so, especially as you comment your code, which is only
helpful.
> _very_ basic stuff that you would find in virtually identical form in
> hundreds of other programming languages: function definition,
> assignments, conditional statements (ok, this might be a tiny bit less
> common), conditional, expressions, and function calls.
Fortunately I don't think there are that many programming languages to
learn. I'm still battling with one to produce basic things like a simple
unordered html list with a few extra parameters like a current URL and tree
stem node indications...
> >How is parameter $level passed to
> >print_list() for example?
>
> It's right in there, you just do it (well, you pass $level-1, not
> $level):
> print_list ($level -1, @{$elem});
>
> >Would this be done with a regular LoL or
> >something slightly different?
>
> ???
> Neither, nor. You just pass it on it's own accord. No need to hide it in
> some additional data structure.
>
> Or are you confused that you can pass more than one parameter to a
> function?
No, that much I should know. Don't worry about my dumb questions, it's just
me trying to figure how to join your procedure with my list while not
necessarily fully understanding the general syntax of perl. If there is
anything that doesn't add up, it's always hard for me to find where to fix
it. That said, I will test your code and I'm sure it will work as intended.
Thanks for your good advise.
Tuxedo
------------------------------
Date: Mon, 06 Sep 2010 14:26:30 -0400
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: Accessing and printing LoL fields in a loop?
Message-Id: <m21v96wwx5.fsf@sherm.shermpendley.com>
Tuxedo <tuxedo@mailinator.com> writes:
> Sherm Pendley wrote:
>
>> As it happens, the menus on my CamelBones site are generated from a
>> similar data structure. This script runs in my editor (BBEdit) to update
>> static .html pages, so you'll need to make the appropriate adjustments
>> to adapt it to your specific needs:
> <http://camelbones.svn.sourceforge.net/viewvc/camelbones/trunk/WebSite/%28includes%29/menu.pl?revision=94&view=markup>
> Hey that's cool! Thanks for sharing your work! I really like the navigation
> system at http://camelbones.sourceforge.net. I must use this the same for
> something; not an exact replica of course but a slightly amended version :-)
Share and enjoy - that's why it's open source. :-)
> As far as I understand, a nested list system is created based on the
> directory depth levels of your site. Is that right? What arguments and in
> which order they meant to me passed if running/testing menu.pl on the
> command line?
If you look at any of the HTML pages, you'll see HTML comments that
look like this:
<!-- #bbinclude "menu.pl" #expand# = "docs, docs/getstarted" -->
... lots o' stuff ...
<!-- end bbinclude -->
When BBEdit runs menu.pl, the first argument is the path of the file
being updated, and the rest are the name-value pairs given as #name#
= value, like above. Other stuff is passed as environment variables.
That's why, in menu.pl, you see this:
my $rootdir = $ENV{'BBEditRootDirectory'};
my $file = shift @ARGV;
and this:
my %args = @ARGV;
After the above, $args{'expand'} == 'docs, docs/getstarted'.
I *could* have written code that examines the path of the current file,
but I'm lazy and that's too much like work - so I just pass the paths
of the menu tree items to expand in a simple comma-separated list. :-)
Also, when links are generated, they begin with "#relative#' - BBEdit's
update machinery expand that to the appropriate number of '../'s needed
to resolve the links from the current page.
sherm--
--
Sherm Pendley
<http://camelbones.sourceforge.net>
Cocoa Developer
------------------------------
Date: Mon, 6 Sep 2010 18:34:54 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Ideal data structure for nested list format?
Message-Id: <ualfl7-pmh1.ln1@osiris.mauzo.dyndns.org>
Quoth Tuxedo <tuxedo@mailinator.com>:
> Ben Morrow wrote:
> > Quoth Tuxedo <tuxedo@mailinator.com>:
> > > Uri Guttman wrote:
> > >
> > > > >>>>> "T" == Tuxedo <tuxedo@mailinator.com> writes:
>
> [...]
>
> > > I installed Template::Simple as stand-alone module, after installing
> > > File::Slurp and setting a use lib 'external_modules/lib/perl5/site_perl'
> > > call in the Makefile.PL script within the Template-Simple-0.02
> > > directory.
> >
> > Why did you do that? You shouldn't be editing the Makefile.PL at all.
> > Put external_module/.../site_perl in PERL5LIB in the environment,
> > instead.
>
> Is PERL5LIB meant to be a temporary Unix environment variable at time of
> installation, pointing to /some/external_module/.../site_perl? Eg.:
> PERL5LIB=/path/to/module_dir/
Yes. This will only apply while the envvar is set, though: you will
still need
use lib "...";
(or some equivalent) in your program when you use Template::Simple.
You may want to look into local::lib, which makes the process of
maintaining your own set of modules much easier.
> Does Makefile.PL probe for that during module installation, to find any
> relevant dependency modules that may not otherwise exist in Perl's standard
> library locations? Or do you mean something else regarding PERL5LIB?
When MakeMaker is looking for dependancies, it searches the current
@INC. When you run Makefile.PL with PERL5LIB set, those values will be
added to @INC, so any modules in those directories will be found by
MakeMaker. Similarly, when you run 'make test' with PERl5LIB set, the
test scripts will see an @INC which has those modules in.
> [...]
>
> > If you haven't run the tests you have no reason for thinking that.
>
> I'm not sure what you mean, I ran 'make test' and there were many errors.
...so you can't assume the module will work OK if you ignore the errors
and install it anyway.
> > Using T::S you would need to go through and insert class => "..."
> > entries in your main data structure. There isn't any way to use a
> > subsidiary hash the way I was suggesting. (This is one of the things I
> > find slightly irritating about T::S, though I've yet to find a better
> > alternative for basic (i.e., 'don't want TT2') stuff.)
>
> Thanks for this advise as well. It sounds highly complex to make T::S do
> what I'd like for this particular, yet simple, nested list structure.
Doing nested lists like this certainly isn't straightforward. You may
find it easier to jump straight to using TT2 (that is, Template.pm on
CPAN). It's a little heavyweight for a simple job like this, but that
probably doesn't matter.
Ben
------------------------------
Date: Mon, 6 Sep 2010 18:54:03 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Ideal data structure for nested list format?
Message-Id: <remfl7-rth1.ln1@osiris.mauzo.dyndns.org>
Quoth Tuxedo <tuxedo@mailinator.com>:
> Ben Morrow wrote:
>
> > That would be because I'm an idiot, and was typing in the code without
> > testing it, and made an elementary mistake. However, I'm going to leave
> > it to you to find it, because you need to understand the code at least
> > that well before you use it. (I'll give you a hint: $pages isn't an
> > array reference, and it ought to be.)
>
> Thank for the hint. Anyway, why should you test the code? After all, you've
> already offered some most helpful advise along with even purpose written
> code. Nobody expects it to work without errors, although it would be nice
> if it did.
Well, posting untested code is something of a faux pas here, since it
tends to just lead to wasted time discussing unnecessary errors.
> That said, I'm the better runner-up for the idiot title in not
> seeing through your code properly. However, once I know it may produce the
> relevant list order and particular variable output, I would surely study it
> character-by-character until I do know its intricate functionality.
You would do well to do that sooner, rather than later.
[ The relevant code was:
sub populate_parents;
sub populate_parents {
my ($parents, $pages, $parent) = @_;
for (@$pages) {
my $page = $_->{page};
push @{$parents->{$page}}, $parent;
my $kids = $_->{children};
$kids and populate_parents $parents, @$kids, $page;
}
}
my %parents;
populate_parents \%parents, \@pages, undef;
]
> On the line where the error is returned it says @$pages. As far as I
> understand an array reference is written \@pages
>
> So I changed @$pages to \@pages as I guess it should be. The same error no
> longer occurs but instead there are some other errors:
No, that is not the right fix at all. In fact, had you properly scoped
the @pages variable you would've got a 'strict' error, which would have
told you you were on the wrong track. The 'main' part of your script
(that part which isn't in a sub) should at least be in a block, with
only deliberate globals outside it. I have two conventions that help
with this: my 'main' code always goes in a sub, which is then called
once, and I always give intentional globals names beginning with a
capital letter.
@$pages fails if $pages isn't an arrayref, so you need to make sure it
*is* an arrayref. $pages is set in one place: from the arguments passed
to populate_parents. populate_parents is called in two places, once like
this:
populate_parents \%parents, \@pages, undef;
and once like this
populate_parents $parents, @$kids, $page;
One of these two calls *doesn't* pass an arrayref as the second argument.
> tuxedo:~$ ./menu.pl
> Pseudo-hashes are deprecated at ./menu.pl line 24.
> Argument "1.1.html" isn't numeric in hash element at ./menu.pl line 24.
> Use of uninitialized value in hash element at ./menu.pl line 25.
> Pseudo-hashes are deprecated at ./menu.pl line 26.
Wow, that's an unhelpful error message. 5.12 has (thankfully) removed
pseudohashes, so it would have said 'Not a HASH reference' instead.
Ben
------------------------------
Date: Mon, 6 Sep 2010 20:52:08 +0200
From: Tuxedo <tuxedo@mailinator.com>
Subject: Re: Ideal data structure for nested list format?
Message-Id: <i63d8o$rb6$02$1@news.t-online.com>
Ben Morrow wrote:
[...]
> > Is PERL5LIB meant to be a temporary Unix environment variable at time of
> > installation, pointing to /some/external_module/.../site_perl? Eg.:
> > PERL5LIB=/path/to/module_dir/
>
> Yes. This will only apply while the envvar is set, though: you will
> still need
>
> use lib "...";
Yes I presumed I should 'use lib' for the required T:S File:Slurp
dependency.
[...]
> You may want to look into local::lib, which makes the process of
> maintaining your own set of modules much easier.
Sounds good, my external modules are always scattered all over :-)
> When MakeMaker is looking for dependancies, it searches the current
> @INC. When you run Makefile.PL with PERL5LIB set, those values will be
> added to @INC, so any modules in those directories will be found by
> MakeMaker. Similarly, when you run 'make test' with PERl5LIB set, the
> test scripts will see an @INC which has those modules in.
Thanks for explaining this so clearly.
> ...so you can't assume the module will work OK if you ignore the errors
> and install it anyway.
True, and I will remember.
[...]
> Doing nested lists like this certainly isn't straightforward. You may
> find it easier to jump straight to using TT2 (that is, Template.pm on
> CPAN). It's a little heavyweight for a simple job like this, but that
> probably doesn't matter.
Right, it shouldn't matter, even if a procedure turns out slow because in
the end I convert everything into static html. It's just the sheer volume
of extra documentation to read. There's even a fairly thick book on the
subject of TT2 alone... But TT2 does indeed look interesting, so many
thanks for sharing this tip!
Tuxedo
------------------------------
Date: Mon, 6 Sep 2010 22:00:13 +0200
From: Tuxedo <tuxedo@mailinator.com>
Subject: Re: Ideal data structure for nested list format?
Message-Id: <i63h8d$41t$02$1@news.t-online.com>
Ben Morrow wrote:
[...]
> One of these two calls *doesn't* pass an arrayref as the second argument.
[...]
Should it be:
\@$kids
At least there are no confusing errors now. Can you give any further hints
how to print the items in a nested list structure? The script so-far is:
#!/usr/bin/perl -w
use warnings;
use strict;
my @pages = (
{ page => "1.1.html", title => "Level 1.1", children => [
{ page => "2.1.html", title => "Level 2.1" },
{ page => "2.2.html", title => "Level 2.2", children => [
{ page => "3.1.html", title => "Level 3.1" },
{ page => "3.2.html", title => "Level 3.2" },
] },
{ page => "2.3.html", title => "Level 2.3" },
] },
);
#and then build a hash of 'parents', like so
sub populate_parents;
sub populate_parents {
my ($parents, $pages, $parent) = @_;
for (@$pages) {
my $page = $_->{page};
push @{$parents->{$page}}, $parent;
my $kids = $_->{children};
$kids and populate_parents $parents, \@$kids, $page;
}
}
my %parents;
populate_parents \%parents, \@pages, undef;
# This will give you a data structure like
%parents = (
"1.1.html" => [undef],
"2.1.html" => [undef, "1.1.html"],
"3.1.html" => [undef, "1.1.html", "2.2.html"],
# ...
);
# Then, given a page name, you can build another hash
my $page = "3.1.html";
my $parents = $parents{$page};
my %class =
map +($parents->[$_] => "parent_level_$_"),
grep defined $parents->[$_],
0..$#$parents;
Thanks for your help in piecing this puzzle together. After all, this is
nothing for beginners.
I'm hoping I won't be needing a template plugin after all :-)
Tuxedo
------------------------------
Date: Mon, 06 Sep 2010 11:40:48 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Multidimensional array
Message-Id: <slrni8a5tq.har.tadmc@tadbox.sbcglobal.net>
Paul E. Schoen <paul@pstech-inc.com> wrote:
[snip: there is a race]
> This is probably due to my lack of experience with networked applications
> where multiple users may run the script simultaneously.
It isn't the networking aspect that causes a race.
It is probably due to your lack of experience with _multitasking_.
> I have implemented a form of lock on the script at the start where I put the
> 10 second delay. I was going to put this lock around the entire script, but
> it would fail if there were an error and the HTMLdie or other error exit
> occurred. I don't know if there is anything like an "OnExit" event that
> could be handled by unlocking the script.
You seek an "END block".
See the "BEGIN, UNITCHECK, CHECK, INIT and END" section in:
perldoc perlmod
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Mon, 6 Sep 2010 18:27:41 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Multidimensional array
Message-Id: <dtkfl7-3kh1.ln1@osiris.mauzo.dyndns.org>
Quoth Tad McClellan <tadmc@seesig.invalid>:
> Paul E. Schoen <paul@pstech-inc.com> wrote:
>
> > I have implemented a form of lock on the script at the start where I put the
> > 10 second delay. I was going to put this lock around the entire script, but
> > it would fail if there were an error and the HTMLdie or other error exit
> > occurred. I don't know if there is anything like an "OnExit" event that
> > could be handled by unlocking the script.
>
> You seek an "END block".
>
> See the "BEGIN, UNITCHECK, CHECK, INIT and END" section in:
Or, indeed, perldoc -q atexit :).
In the OP's case, file locks will be released by the OS when the process
exits, so it isn't necessary to release them explicitly.
Ben
------------------------------
Date: Mon, 6 Sep 2010 15:23:02 +0000 (UTC)
From: Andre Majorel <cheney@halliburton.com>
Subject: Re: POSIX and Math::Trig
Message-Id: <slrni8a1qm.6fd.cheney@atc5.vermine.org>
On 2010-09-06, Sherm Pendley <sherm.pendley@gmail.com> wrote:
> Andre Majorel <cheney@halliburton.com> writes:
>
>> #!/usr/bin/perl -w
>> no warnings;
>> use POSIX;
>> use Math::Trig;
>>
>> still spits warnings. You have to remove the -w to get rid of
>> them. I've tried blocks, eval string, eval block, "no warnings"
>> inside eval. Nothing makes a difference.
>
> Yep. That's why "use warnings" is commonly preferred nowadays, because
> "-w" is global in scope and can't be disabled with "no warnings". :-)
Is this is a recent development ? As I recall, "no warnings 'exec'"
used to work with -w.
--
André Majorel http://www.teaser.fr/~amajorel/
"This album is very well mixed, so it is difficult to tell
what is what."
------------------------------
Date: Mon, 06 Sep 2010 11:46:11 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: POSIX and Math::Trig
Message-Id: <878w3eswn0.fsf@quad.sysarch.com>
>>>>> "AM" == Andre Majorel <cheney@halliburton.com> writes:
AM> Thanks folks. My script evals its arguments so which subs are
AM> needed is not known at write time.
AM> I was hoping there was a way of saying "use X and quietly
AM> redefine whatever you want", or "use X but don't redefine
AM> anything". Or, at worst, "use X and import everything except
AM> this and that".
that contradicts yourself. use is a compile time operation and not
runtime and so is importing. you can't expect to have the functions you
want imported at run time like that. there are other ways to do it. try
a dispatch table with all the possible functions you support (you can't
support ALL of posix and/or trig!). then you can import them all and do
a runtime dispatch to get the function called.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Mon, 6 Sep 2010 16:49:47 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: POSIX and Math::Trig
Message-Id: <r5ffl7-aqg1.ln1@osiris.mauzo.dyndns.org>
Quoth Andre Majorel <cheney@halliburton.com>:
> On 2010-09-06, bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
> > Andre Majorel wrote:
> >
> >> I was hoping there was a way of saying "use X and quietly
> >> redefine whatever you want", or "use X but don't redefine
> >> anything". Or, at worst, "use X and import everything except
> >> this and that".
> >
> > I think your purpose can be served by simply
> > doing the "uses" you want, in the order you prefer.
> > and turning the warnings off during this, via
> > use/no warnings.
>
> Tried about twenty variations around
>
> use POSIX;
> no warnings 'redefine';
> use Math::Trig;
>
> and still get the warnings. Would you have a working example ?
The warnings come from inside Math/Trig.pm, since that's where the
redefinition happens. You will only get them if you are using -w rather
than 'use warnings', so don't do that.
In any case, you can perfectly well use
use POSIX qw/!asin !acos !atan !sinh .../;
Ben
------------------------------
Date: Mon, 06 Sep 2010 17:16:49 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: POSIX and Math::Trig
Message-Id: <NKadnQIT2KpsjhjRnZ2dnUVZ8kednZ2d@brightview.co.uk>
Ben Morrow wrote:
>
> In any case, you can perfectly well use
>
> use POSIX qw/!asin !acos !atan !sinh .../;
>
Cool! I didn't know that. And a brief perldoc -f use
certainly doesn't tell me that.
Ah - perldoc Exporter.
Thanks.
BugBear
------------------------------
Date: Mon, 6 Sep 2010 10:27:59 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: POSIX and Math::Trig
Message-Id: <752c157c-d2ef-4de5-b27f-ea4d6f30148f@w15g2000pro.googlegroups.com>
On Sep 6, 4:52=A0am, Andre Majorel <che...@halliburton.com> wrote:
> ...
> Thanks folks. My script evals its arguments so which subs are
> needed is not known at write time.
>
> I was hoping there was a way of saying "use X and quietly
> redefine whatever you want", or "use X but don't redefine
> anything". Or, at worst, "use X and import everything except
> this and that".
>
IIUC, 'require' with a manual 'import' should
do what you want. (Still warns if you import
the same method from POSIX and Math of course).
require POSIX;
require Math::Trig;
...
$sub=3D'atan'; Math::Trig->import($sub);
$sub->(...);
$sub=3D'sin'; POSIX->import($sub);
$sub->(...);
--
Charles DeRykus
------------------------------
Date: Mon, 6 Sep 2010 19:20:05 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: POSIX and Math::Trig
Message-Id: <slrni8afn5.knb.nospam-abuse@powdermilk.math.berkeley.edu>
On 2010-09-06, Sherm Pendley <sherm.pendley@gmail.com> wrote:
> Yep. That's why "use warnings" is commonly preferred nowadays, because
> "-w" is global in scope and can't be disabled with "no warnings". :-)
Not "commonly". (We have been on this often.)
And in this particular case, `use warnings' looks completely useless:
I do not see any warning from
perl -le "use warnings; use POSIX; use Math::Trig; 1"
Hope this helps,
Ilya
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 3120
***************************************