Re: sub and return question
Richard Lee wrote: > > can't you do below?? > > sub criteria { >return qw/ 1,3,5,7,9 /; > } > > I was going to do > > sub criteria { > my @array = qw/1,3,5,7,9/; > } > > but was wondering if I can do without if i was calling the sub like this > > > my @array_result = criteria(); Yes, it works fine (once you replace the commas with whitespace). You could have tried it yourself though :) Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: sub and return question
Mr. Shawn H. Corey wrote: Don't use commas inside a qw #!/usr/bin/perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Indent = 1; $Data::Dumper::Maxdepth = 0; sub criteria { return qw/ 1 3 5 7 9 /; } my @array_result = criteria(); print Dumper [EMAIL PROTECTED]; __END__ yes, thank you! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: sub and return question
On Fri, 2008-10-10 at 14:06 -0400, Richard Lee wrote: > can't you do below?? > > > sub criteria { >return qw/ 1,3,5,7,9 /; > } > > I was going to do > > sub criteria { > my @array = qw/1,3,5,7,9/; > } > > but was wondering if I can do without if i was calling the sub like this > > > my @array_result = criteria(); > > ?? > Don't use commas inside a qw #!/usr/bin/perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Indent = 1; $Data::Dumper::Maxdepth = 0; sub criteria { return qw/ 1 3 5 7 9 /; } my @array_result = criteria(); print Dumper [EMAIL PROTECTED]; __END__ -- Just my 0.0002 million dollars worth, Shawn Linux is obsolete. -- Andrew Tanenbaum -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: sub and return question
Richard Lee wrote: can't you do below?? sub criteria { return qw/ 1,3,5,7,9 /; } I was going to do sub criteria { my @array = qw/1,3,5,7,9/; } but was wondering if I can do without if i was calling the sub like this my @array_result = criteria(); ?? actually qw/ 1 3 5 7 9/; i was wrongly adding commas there.. sorry abou thtis post.. disregard please. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
sub and return question
can't you do below?? sub criteria { return qw/ 1,3,5,7,9 /; } I was going to do sub criteria { my @array = qw/1,3,5,7,9/; } but was wondering if I can do without if i was calling the sub like this my @array_result = criteria(); ?? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/