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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
      Why the followig code is not working.

My son, let me give you some priestly advice: When you want to find out why something isn't working you first have to establish for the reader what your criteria for "working" is. In other words: what were you expecting to happen, and what really happened.

As has been noted before and I quote from the perldoc for reverse:

reverse LIST In list context, returns a list value consisting of the + ele- ments of LIST in the opposite order. In scalar context +, con- catenates the elements of LIST and returns a string val +ue with all characters in the opposite order. print reverse <>; # line tac, last line f +irst undef $/; # for efficiency of <> print scalar reverse <>; # character tac, last l +ine tsrif

So with that in mind, if I run the following on-liner:

perl -e 'print scalar reverse "dog" . "\n";'
I get the following terse output:

Let us play... If I run the following one liner:

perl -e 'print join( ",", reverse ( split "", "dog")) . "\n";'
I am now feeding reverse an array and I can now get the result

I hope this clears things up for you....

Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

In reply to Re: Why the print is not working by blue_cowdawg
in thread Why the print is not working by jesuashok

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, 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?

    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 cooling their heels in the Monastery: (3)
    As of 2020-02-23 02:46 GMT
    Find Nodes?
      Voting Booth?
      What numbers are you going to focus on primarily in 2020?

      Results (102 votes). Check out past polls.