Perl Monk, Perl Meditation | |
PerlMonks |
Re: a few basic questionsby IraTarball (Monk) |
on Aug 23, 2001 at 20:41 UTC ( [id://107392]=note: print w/replies, xml ) | Need Help?? |
Well, 1) is easy. Use the modulo operator % It returns the remainder after a division so $number % 2 is only zero for even numbers and is 1 for odd numbers. See the perlop page for lots of info. 2) is a bit harder. I'm sure there are many elegant solutions. Some probably got posted while I was looking into it. My first try, if the files aren't too big, would be to slurp them into arrays and then fold them together. the t1 file looks like the END block but with 2 instead of 1 I get Not sure what the warnings for, I guess because one of the array's is empty maybe? I'll bet if you put that into an if/else it wouldn't complain. There's probably a more elegant solution, but this is what comes to mind. 3) Did you try it? I just ran the code you posted (cleaned up with ';' :-) and got this and got
Hope this helps
"So... What do all these little arrows mean?"
In Section
Seekers of Perl Wisdom
|
|