On 22 Feb 2008, at 14:47, Dermot wrote:

Hi,

I hope my first question isn't too dumb.

In the routine below I want to test if the method is being called with an additional parameters. So if the uri is ~/list/2 return only the files with user=id. If no parameter is called (~/ list) return all files. The functions works as it is but obviously I can not recall all files.

Without the comments the list function returns a syntax error. In fact I can also get the same error is I do:

my $files;
$files : Stashed = $c->model('ImagesDB::Files')->search({user => $id});


use base 'Catalyst::Controller::BindLex'
...
sub list : Local {
 my ($self, $c, $id) = @_;
 #my $files;
 #if (defined($id)) {
my $files : Stashed = $c->model('ImagesDB::Files')- >search({user => $id});
 #}
 #else {
 #      my $files : Stashed = $c->model('ImagesDB::Files');
 #}
 $c->stash->{template} = 'files/list.tt2';
}


Can anyone give me a pointer? Thanx.
Dp.


my $files : Stashed;

if (...) {
  $files = ...
} else {
  $files = ....
}

BindLex cant cope when you declare the same variable ($files) multiple times in different scopes.
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to