For the simple answer, it looks like you're trying to pass an array, @3, to your function. @3 is naturally empty, so @_ picks up the values in the array.
The first value in the array is 9, which $a gets set to in your function. You then change $LOCAL_CODEPAGE to $a at the end. (update: And you return that value, which is still, predictably, 9.)
Though I'm not one to criticize coding usually, I will note that you print "\n" at the end of your function, though you return before that. If for any reason the "return" part of your assignment of $LOCAL_CODEPAGE got taken out, you'd be returning the return value of the print, which I don't think is what you want.
I take it this function is a work in progress. I would rewrite it entirely, but I'm lazy. I'll just show you what I did looking at it:
sub f1{
my ($a) =@_;
$cp=1;
$LOCAL_CODEPAGE =10;
print "This is $a\n";
print $LOCAL_CODEPAGE;
if ($a==1){
$LOCAL_CODEPAGE = $cp;
break;
}
return $LOCAL_CODEPAGE = $a;
print "\n";
}
@3=(3,10, 13); ## comment this out and see your value come back as 9
print "\$LOCAL_CODEPAGE=$LOCAL_CODEPAGE: f1(@3,9,3,4,5): ".f1(@3,9,3,4
+,5)."\n";
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.