Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
It works fine for me. In what way did it not work for you? I did not show the use strict; and use warnings; I always put at the top of my scripts in my first post. Here's the whole script again, it's output and some info on my platform and perl version

$ 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


In reply to Re^3: My 'perldar' tells me there is a 'better' solution for this list operation by johngg
in thread My 'perldar' tells me there is a 'better' solution for this list operation by OfficeLinebacker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-16 19:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found