Hello, I want to draw this triangle by perl:
1 11 121 1331 14641 .......
and now have some problem with my sub partition, pls see codes below:
#!/usr/bin/perl use strict; use warnings; my $i; my $j; my $k; my @a; my @b; $a[0] = 1; $a[1] = 1; for($i=0;$i<=10;$i++){ @a = &yh(@a); print @a,"\n"; } sub yh{ my(@a)=@_; my @b; my $j; my $k; $k = $#a + 1; $b[0] = 1; for($i=1;$i<=$k;$i++){ $j = $i - 1; $b[$i] = $a[$i] + $a[$j]; } $b[$k] = 1; return @b; }
and when run it at command line,
phillip@Athen:~/script$ perl yanghui.pl Use of uninitialized value in addition (+) at yanghui.pl line 34. 121 Use of uninitialized value in addition (+) at yanghui.pl line 34. 1331 Use of uninitialized value in addition (+) at yanghui.pl line 34. 14641 Use of uninitialized value in addition (+) at yanghui.pl line 34. 15101051 Use of uninitialized value in addition (+) at yanghui.pl line 34. 1615201561 Use of uninitialized value in addition (+) at yanghui.pl line 34. 172135352171 Use of uninitialized value in addition (+) at yanghui.pl line 34. 18285670562881 Use of uninitialized value in addition (+) at yanghui.pl line 34. 193684126126843691
I know i can ignore the warning by remove "use strict and use warnings". while my question is ,if i want to remain "use strict" "use warnings" in codes, what can i do to not display this warning message? Thanks, Phillip

In reply to problem in my sub partition by PhillipHuang

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.