Hi, I have an array in which the first element is either -0 or +0 (returned from the DateCalc function). How can I apply the flag value to all the values in the rest of the array.

I tried from the command line, but found a wierd quirk with -0. In order for it to work correctly, it looks like I need to use it as a string array.

perl -le '@B=qw(-0 4);$g=($B[0] lt 0?-1:1); printf"%s\n" x 3,$B[0],$g,$B[1]*$g' -0 -1 -4 perl -le '@B=(-0,4);$g=($B[0] < 0?-1:1); printf"%s\n" x 3,$B[0],$g,$B[1]*$g' 0 1 4
Can the map or regex substitute command take the sign value and apply it to the remainder of the array?

Thanks budman

In reply to Applying Sign Bit by budman

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.