should i format it to

The former is not valid Perl - it doesn't compile. The latter is valid Perl. Neither looks like a string. Is the input to your subroutine a string? Does the content of the string look like Data::Dumper output? Or is the input to your subroutine a reference to an array of references to hashes, each with quantity and name keys?

is it a string format?

Since I can't examine the input to your subroutine I can't tell you whether it is a string. You are the only one who has access to your subroutine input to determine what it is. If you want help, you must determine what the input is and post that information. It does no good to ask people who don't know and can't find out except by asking you.

is it ok to pass a string to the sub?

It is OK as long as the string contains the required information and the subroutine is written to process that information appropriately. Otherwise the subroutine will not produce the required output.


In reply to Re^5: WHAT IS WRONG TO PASS PARAMETER TO THE ARRAY? by ig
in thread WHAT IS WRONG TO PASS PARAMETER TO THE ARRAY? by courierb

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, 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.