Simple program style question

  I am using Test::More module to write the test cases for my perl code. This is the sample code
sub test_code {
$result = function1(arg1);
ok ( $result == 1, "Test1");
$result = function1(arg2);
ok ( $result ==0, "Test2");
$result = function1(arg3);
ok ($result =1,"test3");

for some reason i don't like this coding style..I want to get rid of assigning return value from function1 to $result everytime..I want to have just 3 "ok" statements in the function..can you suggest me something like that

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The last line should be :
ok ($result ==1,"test3");

You may want to put argument values in an array and after that use for_each
No need for result variable

@ArgArr=($arg1, $arg2, $arg3) ;

foreach $element (@ArgArr) {
        ok(1==function1($element) );

Hope this helps

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
koppchaAuthor Commented:
I can't always compare the function with 1 but that gave the idea how to do what i want..Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.