Thanks very much

Eugenio Duran Aroche <[email protected]>
Newsgroups gmane.comp.web.mason.user
Message-ID <[email protected]>

----- Mensaje original -----

De: "Jérôme Étévé" <[email protected]> 
Para: "Mason List" <[email protected]> 
Enviados: Martes, 28 de Febrero 2012 9:45:58 
Asunto: [Mason] Fwd: I need help, please 

---------- Forwarded message ---------- 
From: Jérôme Étévé <[email protected]> 
Date: 28 February 2012 14:45 
Subject: Re: [Mason] I need help, please 
To: [email protected] 


>From the FAQ: 

<%init> 
$m->clear_buffer; 
my $fh = IO::File->new('< binary_file') or die $!; 
my $buffer; 
while (read $fh, $buffer, 8192) { 
$m->print($buffer); 
} 
$m->abort; 
</%init> 

Notice that $m->print is the way to output something. 

You might want to output the appropriate headers as well as the file content. 
I suppose you could also use File::Slurp to slurp your file in one go, 
although this method is probably better for large files. 

Cheers. 

On 28 February 2012 14:42, <[email protected]> wrote: 
> On Tue, 28 Feb 2012 09:05:36 -0500 (CST) 
> Eugenio Duran Aroche <[email protected]> wrote: 
> 
>> I need know how open, write and read files in Mason, I put this code and not show nothing in the browser, neither can't write in the file 
> 
> Well, you are not checking whether your open() succeeded. Nor are you 
> HTML-escaping your output. Not to mention the useless subject of your 
> e-mail. I'm not even mentioning the HTML mail your client sends out. 
> 
> You probably aren't in the correct directory or your web server doesn't 
> have the correct read permissions to the file. You might want to refer 
> to a netiquette guide for the other problems. 
> 
> 
> Anyway, as loth as I am to give ready solutions, I wrote a trivial 
> program to function as a scratch pad some time ago: 
> 
> <%args> 
> $text => undef 
> </%args> 
> <html> 
> <head><title>Scratchpad</title></head> 
> <body> 
> <form action="" method="post"> 
> <div> 
> <textarea name="text" cols="80" rows="25"><% $text |h %></textarea> 
> </div> 
> <div><input type="submit" value="Save" accesskey="s"></div> 
> </form> 
> </body> 
> </html> 
> <%init> 
> $r->content_type('text/html; charset=utf-8'); 
> 
> if ($text) { 
> if (-e $fn) { 
> rename($fn, "$fn.bak") or die "cannot rename"; 
> } 
> open my $fh, ">", $fn or die "cannot open for writing: $!"; 
> print $fh $text or die "cannot write: $!"; 
> close $fh; 
> } else { 
> my $fh; 
> if (-e $fn) { 
> open($fh, "<", $fn) or die "cannot read: $!"; 
> local $/ = undef; 
> $text = <$fh>; 
> close $fh; 
> } 
> } 
> </%init> 
> <%once> 
> my $fn = '/full/path/to/scratchpad.txt'; 
> </%once> 
> 
> ------------------------------------------------------------------------------ 
> Keep Your Developer Skills Current with LearnDevNow! 
> The most comprehensive online learning library for Microsoft developers 
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, 
> Metro Style Apps, more. Free future releases when you subscribe now! 
> http://p.sf.net/sfu/learndevnow-d2d 
> _______________________________________________ 
> Mason-users mailing list 
> [email protected] 
> https://lists.sourceforge.net/lists/listinfo/mason-users 



-- 
Jerome Eteve. 

http://sigstp.blogspot.com/ 
http://twitter.com/jeteve 


-- 
Jerome Eteve. 

http://sigstp.blogspot.com/ 
http://twitter.com/jeteve 

------------------------------------------------------------------------------ 
Keep Your Developer Skills Current with LearnDevNow! 
The most comprehensive online learning library for Microsoft developers 
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, 
Metro Style Apps, more. Free future releases when you subscribe now! 
http://p.sf.net/sfu/learndevnow-d2d 
_______________________________________________ 
Mason-users mailing list 
[email protected] 
https://lists.sourceforge.net/lists/listinfo/mason-users 




Fin a la injusticia, LIBERTAD AHORA A NUESTROS CINCO COMPATRIOTAS QUE SE ENCUENTRAN INJUSTAMENTE EN PRISIONES DE LOS EEUU!
http://www.antiterroristas.cu
http://justiciaparaloscinco.wordpress.com

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d

_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.