I'm back again, struggling with some basics (I have read up on this but I just can't figure it). I will post code below but in a nutshell I pass a string to a function and do stuff, then return a variable. The problem is if, at the end of the function I use:
print $title;
I can see the result in the perl script I called the function from. However, if I use:
return $title;
I can't use that $title back in the script I called it from. There is no error (I am using strict) it just seems the string is empty.
The code I use is below:
foreach my $j (@fucntion64)
{
if(substr($j,0,2) eq "AU") {
my($item,$title) = split(' ',substr($j,2),2);
return $title."<br />";
}
If I change that return to print, the function prints the correct result back in the script. If I use return, then try and print $title from the script, I get nothing!
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.