Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Note: it often helps you and us if you reduce your sample code to just demonstrate the bug. Most likely in the process you will solve the problem, but even if you don't you will understand it better. In either case you will remember the lesson better at the end of the day.

Your sample could have reduced to:

use strict; use warnings; my $line = "This|that"; my @cols = split(/|/, $line); print "@cols";


T h i s | t h a t

where I expected:

This that

I know what I mean. Why don't you? has a few other related tips that may help in the future.

Why no use strict by the way? Especially puzzling as there is a use warnings.


Note too that the 3 parameter open is much preferred over the two parameter open (see open) for lucidity and security.

if ($cols[11] = $target1)

looks wrong! Do you really intend to assign $target1 to $cols[11]? Note that the if is (effectively) testing the contents of $target1, not equality of $target1 and $cols[11].

DWIM is Perl's answer to Gödel

In reply to Re: using split by GrandFather
in thread using split by maurkb

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 or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2021-05-13 15:27 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (136 votes). Check out past polls.