Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why is this returning the return code

Status
Not open for further replies.

cdlvj

MIS
Nov 18, 2003
676
0
0
US
This is from a class object and is supposed to return a list. It is returning an array with what looks like a TRUE/FALSE in the array.

$dati = "file1\nfile2\nfile3\n";

Code:
return $dati ? split( /\n/, $dati ) : ();
 
How are you calling this in your script?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
Code:
my @list;
my $clsa;
@list = $clsa->list();

@list = ( 1 );

should be
@list = ( "file1", "file2", "file3");
 
return $dati ? split( /\n/, $dati ) : ();

the above is returning a list in scalar context. Should be:

return @dati ? split( /\n/, $dati ) : ();



------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top