in reply to Re^2: My 'perldar' tells me there is a 'better' solution for this list operation
in thread My 'perldar' tells me there is a 'better' solution for this list operation
$ cat spw582186 #!/usr/bin/perl # use strict; use warnings; my @l1 = qw(Date IndexID Maturity OnTheRun CompositePrice CompositeSpread ModelPrice ModelSpread Depth Heat); my @l2 = qw(OnTheRun CompositePrice CompositeSpread Depth); my @l3; { local $" = q{|}; @l3 = map {m{^@l2$} ? $_ : q{null}} @l1; } print qq{$_\n} for @l3; $ ./spw582186 null null null OnTheRun CompositePrice CompositeSpread null null Depth null $ uname -a SunOS b4rsk 5.10 Generic_118833-03 sun4u sparc SUNW,Ultra-60 $ perl -v This is perl, v5.8.4 built for sun4-solaris-64int (with 28 registered patches, see perl -V for more detail) Copyright 1987-2004, Larry Wall Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using `man perl' or `perldoc perl'. If you have access to + the Internet, point your browser at http://www.perl.com/, the Perl Home Pa +ge. $
You may well be right regarding efficiency, I haven't run any benchmarks. The object of the post was to show an alternative method to those already given.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: My 'perldar' tells me there is a 'better' solution for this list operation
by OfficeLinebacker (Chaplain) on Nov 04, 2006 at 18:22 UTC |