[Catalyst] newbie - syntax error
Ash Berlin
ash_cpan at firemirror.com
Fri Feb 22 14:54:59 GMT 2008
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20080222/bae4cc5b/attachment.htm
More information about the Catalyst
mailing list