Re: printing/echo'ing vars/arrays within mason tags?

Federico Thiella <[email protected]> Tue, 16 Aug 2016 21:15:13 +0000
Newsgroups gmane.comp.web.mason.user
Message-ID <CAEzMO=D_qELZ+zX8-PGwNqryUBBSq1NT7KYFXitpjAXYMLykRw@mail.gmail.com>
--===============3014629190910721418==
Content-Type: multipart/alternative; boundary=001a1142b940ccde0e053a36d808

--001a1142b940ccde0e053a36d808
Content-Type: text/plain; charset=UTF-8

Hello,
what I can understand from your question is that:

- you have a web application, written by someone else
- the application is currently working
- you want to fix/enhance/troubleshoot it
- whenever you add something to the output of some components, using
data::dumper, the application stops working and it hangs

Why the application hangs? Well it's hard to tell without seeing the actual
code, if data::dumper is correctly installed one reason is that the page is
probably trying to make some AJAX calls, maybe it expects some JSON output,
but if you add some debugging info to the output the JSON output will be
messed up, the Javascript code won't be able to interpreter it and the
application would just hang...

Some suggestions:

- you can check your log files (are you running your app under Apache?) to
see if there are some problems with the page
- then you can use Chrome/Firefox developer tools to see what's going on
(which component has been called? what GET/POST data has been submitted? is
there any error at the Javascript console?)
- and then Guido's answer is correct: don't just print your variable to the
page output:

% print Dumper \%my_hash;

print it to the standard error output:

% print STDERR Dumper \%my_hash;

this won't mess the page output (so your app should still work without any
problem): the dump will be sent to the web server logs files and you can
read it from there.

If you are using Poet/Mason2 you can also have a look at Poet::Util::Debug (
https://metacpan.org/pod/Poet::Util::Debug)

Bye

Il giorno mar 16 ago 2016 alle ore 17:33 Hiram Gibbard <[email protected]>
ha scritto:

> Hi All,
>
> I'm wondering if there is a way to echo or print our vars or arrays within
> the Mason tags? I'm trying to trouble shoot this application so I can make
> enhancements, and I can't tell why pages are not loading.
>
> I tried data::dumper, but anytime I try and add anything to print out it
> just hangs. What do i mean by hang? well the developer used mason within
> javascript, so when this div tries to load it just sits there saying
> searching and never completes. So I know its error'ing out, but I can't see
> it anywhere. So I'm trying to figure out a way to print out some vars or an
> array so I can see the data.
>
> I've tried using the <%text><text> mason tag but i'm either not doing it
> right or that doesn't apply. I guess my main question would be, how can one
> get verbose information from data within the mason tags? I will take any
> tips. can i call the text tag within other tags like init or once?
>
> Thanks in advance,
>
> --
> Hiram Gibbard
> [email protected]
> http://hiramgibbard.com
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Mason-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mason-users
>

--001a1142b940ccde0e053a36d808
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><div><div><div><div><div>Hello,<br></div>what I =
can understand from your question is that:<br><br></div>- you have a web ap=
plication, written by someone else<br></div>- the application is currently =
working<br></div>- you want to fix/enhance/troubleshoot it<br></div>- whene=
ver you add something to the output of some components, using data::dumper,=
 the application stops working and it hangs<br><br></div>Why the applicatio=
n hangs? Well it&#39;s hard to tell without seeing the actual code, if data=
::dumper is correctly installed one reason is that the page is probably try=
ing to make some AJAX calls, maybe it expects some JSON output, but if you =
add some debugging info to the output the JSON output will be messed up, th=
e Javascript code won&#39;t be able to interpreter it and the application w=
ould just hang...<br><br></div><div>Some suggestions:<br><br></div>- you ca=
n check your log files (are you running your app under Apache?) to see if t=
here are some problems with the page<br>- then you can use Chrome/Firefox d=
eveloper tools to see what&#39;s going on (which component has been called?=
 what GET/POST data has been submitted? is there any error at the Javascrip=
t console?)<br>- and then Guido&#39;s answer is correct: don&#39;t just pri=
nt your variable to the page output:<br><div dir=3D"ltr"><br>% print Dumper=
 \%my_hash;<br><div dir=3D"ltr"><div><div><div><br></div><div>print it to t=
he standard error output:<br></div></div></div></div></div><div dir=3D"ltr"=
><div dir=3D"ltr"><div dir=3D"ltr"><div><div><div><br>% print STDERR Dumper=
 \%my_hash;<br><br></div></div></div></div></div></div><div dir=3D"ltr"><di=
v dir=3D"ltr"><div dir=3D"ltr"><div><div><div>this won&#39;t mess the page =
output (so your app should still work without any problem): the dump will b=
e sent to the web server logs files and you can read it from there.<br></di=
v><div><br></div><div>If you are using Poet/Mason2 you can also have a look=
 at Poet::Util::Debug (<a href=3D"https://metacpan.org/pod/Poet::Util::Debu=
g">https://metacpan.org/pod/Poet::Util::Debug</a>)</div><div><br></div><div=
>Bye<br></div></div></div></div></div></div><div dir=3D"ltr"><div dir=3D"lt=
r"><div dir=3D"ltr"><div><div><div><div><div><div><div><div><br><div class=
=3D"gmail_quote"><div dir=3D"ltr">Il giorno mar 16 ago 2016 alle ore 17:33 =
Hiram Gibbard &lt;<a href=3D"mailto:[email protected]" target=3D"_blank">h=
[email protected]</a>&gt; ha scritto:<br></div><blockquote class=3D"gmail_q=
uote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1e=
x"><div dir=3D"ltr">Hi All,<div><br></div><div>I&#39;m wondering if there i=
s a way to echo or print our vars or arrays within the Mason tags? I&#39;m =
trying to trouble shoot this application so I can make enhancements, and I =
can&#39;t tell why pages are not loading.</div><div><br></div><div>I tried =
data::dumper, but anytime I try and add anything to print out it just hangs=
. What do i mean by hang? well the developer used mason within javascript, =
so when this div tries to load it just sits there saying searching and neve=
r completes. So I know its error&#39;ing out, but I can&#39;t see it anywhe=
re. So I&#39;m trying to figure out a way to print out some vars or an arra=
y so I can see the data.</div><div><br></div><div>I&#39;ve tried using the =
&lt;%text&gt;&lt;text&gt; mason tag but i&#39;m either not doing it right o=
r that doesn&#39;t apply. I guess my main question would be, how can one ge=
t verbose information from data within the mason tags? I will take any tips=
. can i call the text tag within other tags like init or once?</div><div><b=
r></div><div>Thanks in advance,<br clear=3D"all"><div><br></div>-- <br><div=
 data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><div>Hiram Gibbard<br>=
<a href=3D"mailto:[email protected]" target=3D"_blank">[email protected]<=
/a></div><div><a href=3D"http://hiramgibbard.com" target=3D"_blank">http://=
hiramgibbard.com</a></div><div><br><div style=3D"display:inline"></div></di=
v></div></div>
</div></div>
---------------------------------------------------------------------------=
---<br>
_______________________________________________<br>
Mason-users mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank">Maso=
[email protected]</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/mason-users" rel=3D=
"noreferrer" target=3D"_blank">https://lists.sourceforge.net/lists/listinfo=
/mason-users</a><br>
</blockquote></div></div></div></div></div></div></div></div></div></div></=
div></div></div>

--001a1142b940ccde0e053a36d808--


--===============3014629190910721418==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------

--===============3014629190910721418==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users

--===============3014629190910721418==--