[Catalyst] About output in a browser
lanas
lanas at securenet.net
Tue Aug 28 23:52:28 GMT 2007
Hi folks,
In understanding how Catalyst work and how to work with , I'm making
very simple stuff, like having a model that only returns a directory
listing. I found something curious before starting to make a view.
Every line of the directory listing, obtained with 'ls -l', will be
chomped if I do not put a print "String !" just before it in the
model, like this:
prints chomped lines, which results in unstructured output in the
browser:
MyApp01/lib/MyApp01/Model/MyApp01Model.pm
sub getFiles()
{
my ( $self, $c ) = @_;
@{$c->stash->{files}} = `ls -l /home/user/`;
}
prints neatly, every line of the directory listing on a separate line
in the browser:
sub getFiles()
{
my ( $self, $c ) = @_;
print "getFiles() !";
@{$c->stash->{files}} = `ls -l /home/frodo/`;
}
'getFiles()!' will also get printed in the browser, but I presume this
is OK.
The output is in the following. There are no view defined at the
moment.
MyApp01/lib/MyApp01/Controller/Root.pm
sub end : ActionClass('RenderView')
{
my ( $self, $c ) = @_;
if (defined $c->stash->{files}) {
$c->response->body( "@{$c->stash->{files}}" )
}
else {
$c->response->body("NO DATA !");
}
}
Can someone tell me why the output of the directory listing is not the
same due to, apparently, the poresence of a print statement ?
Al
More information about the Catalyst
mailing list