Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
A couple issues here.
  1. my is used to declare a lexical variable. In general, my $lines should appear once in your code, when you first use it. If you are going through a file, it might look like:

    while (my $lines = <$fh>) {...
    The text you have written declares two new, undefined variables named $lines.
  2. and is a logical operator. The code you wrote takes two lists (( my $lines, $schemePOS, 20) and ( my $lines, $abiPOS, 3)) and tests if they are both logically true. Since the lists are both longer than 0 elements, and returns a true value, and this true value is then fed into substr, which expects at least two arguments, thus the returned error.

  3. Lastly, print takes a list (parentheses), not a block (curly brackets) as an argument. Either

    print $arg1, $arg2, ...
    or, if you want to have a clear delimiter,
    print($arg1, $arg2, ...)
The code you meant to write would probably look like:
print substr($lines, $schemePOS, 20), substr($lines, $abiPOS, 3);
I have fed print a list of two values, which are the return values of the substrs. There are a number of ways to do this, but they'd all fit this general pattern.

Given your apparent familiarity with the language, I'd suggest going through some introductory learning materials. http://learn.perl.org has a number of resources available, including free access to Beginning Perl.


#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.


In reply to Re^3: Printing set characters from offset. by kennethk
in thread Printing set characters from offset. by Jalcock501

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (22)
    As of 2015-07-01 15:40 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (6 votes), past polls