Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

output buffering
hi all,

is there any possibility, how to easy and fast install some script,
which changes perl script output ? For cleaner explanation:

I want do script which takes *any* (perl,cgi site) output, parse it for
mails (2g@2g.us) and all occurencies changes to [2g]-at-[2g]_us
for example. I look into php, and they call such a functions as
"Output Buffering Functions"

thanks


-=x=-
Skontrolované antivírovým programom NOD32


Report this thread to moderator Post Follow-up to this message
Old Post
Ing. Branislav Gerzo
11-30-04 01:55 AM


Re: output buffering
Probably the simplest way is to save all your output into a variable, say
$html, rather than printing directly, as you would typically.  Then, make a
simple function that displays $html and performs any filtering you like.
Such a subroutine might look like:

#somewhere in the code....
my $html='';
$html='hello world';
filter_and_output($html);

#and the output subroutine....
sub filter_and_output {
my $html=shift;
#in a CGI environment, put header, start_html, etc. here.
$html=~ s/@/at/g;
print $html;
#and in CGI, put end_html, etc. here.  You could also put a "footer"
with email for symin, etc. here.
}

Mind that this is untested!
----- Original Message -----
From: "Ing. Branislav Gerzo" <konfera@2ge.us>
To: <beginners-cgi@perl.org>
Sent: Monday, November 29, 2004 4:46 PM
Subject: output buffering


> hi all,
>
> is there any possibility, how to easy and fast install some script,
> which changes perl script output ? For cleaner explanation:
>
> I want do script which takes *any* (perl,cgi site) output, parse it for
> mails (2g@2g.us) and all occurencies changes to [2g]-at-[2g]_us
> for example. I look into php, and they call such a functions as
> "Output Buffering Functions"
>
> thanks
>
>
> -=x=-
> Skontrolovane antivirovym programom NOD32
>
>
> --
> To unsubscribe, e-mail: beginners-cgi-unsubscribe@perl.org
> For additional commands, e-mail: beginners-cgi-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Sean Davis
11-30-04 01:55 AM


Re: output buffering
Sean Davis [SD], on Monday, November 29, 2004 at 17:45 (-0500) has on
mind:

SD> Probably the simplest way is to save all your output into a variable, sa
y
SD> $html, rather than printing directly, as you would typically. Then, make
 a
SD> simple function that displays $html and performs any filtering you like.
SD> Such a subroutine might look like:

yes, I thought about this, I am just curious, if exist any other way.
This is ofcourse easy, but what about with really complex CGI sites ?

SD> Mind that this is untested!

that's not a problem :)

--

..m8s, cu l8r, Brano.

[When taglines are outlawed, only moderators will have tag]



-=x=-
Skontrolované antivírovým programom NOD32


Report this thread to moderator Post Follow-up to this message
Old Post
Ing. Branislav Gerzo
11-30-04 08:55 AM


Re: output buffering
On Nov 30, 2004, at 1:42 AM, Ing. Branislav Gerzo wrote:

> Sean Davis [SD], on Monday, November 29, 2004 at 17:45 (-0500) has on
> mind:
>
> SD> Probably the simplest way is to save all your output into a
> variable, say
> SD> $html, rather than printing directly, as you would typically.
> Then, make a
> SD> simple function that displays $html and performs any filtering you
> like.
> SD> Such a subroutine might look like:
>
> yes, I thought about this, I am just curious, if exist any other way.
> This is ofcourse easy, but what about with really complex CGI sites ?
>

Perhaps you should tell us exactly what you want to do.  For CGI, many
cgi application environments build in a post-processing hook that is
called right before the HTML is dumped to the browser.  However, one
still has to build this hook, and a VERY simplified version is what I
sent earlier.  Perhaps you need to let us know what your exact needs
are and what constraints you must work within so that we can be more
specific?

Sean


Report this thread to moderator Post Follow-up to this message
Old Post
Sean Davis
11-30-04 01:55 PM


Re: output buffering
Sean Davis [SD], on Tuesday, November 30, 2004 at 05:55 (-0500) typed:

SD> Perhaps you should tell us exactly what you want to do.  For CGI, many
SD> cgi application environments build in a post-processing hook that is
SD> called right before the HTML is dumped to the browser.  However, one
SD> still has to build this hook, and a VERY simplified version is what I
SD> sent earlier.  Perhaps you need to let us know what your exact needs
SD> are and what constraints you must work within so that we can be more
SD> specific?

Ok, imagine I want give out free, simple script for CGI websites,
which I wrote (changes every mail...). I am interesting about, how
I can spread this script, so people can import it without any
problems, or high knowledge. That's all.

--

..m8s, cu l8r, Brano.

[Computer User Group - Nerd Heard]



Report this thread to moderator Post Follow-up to this message
Old Post
Ing. Branislav Gerzo
11-30-04 01:55 PM


Re: output buffering
Ing. Branislav Gerzo wrote:
> hi all,
>
> is there any possibility, how to easy and fast install some script,
> which changes perl script output ? For cleaner explanation:
>
> I want do script which takes *any* (perl,cgi site) output, parse it for
> mails (2g@2g.us) and all occurencies changes to [2g]-at-[2g]_us
> for example. I look into php, and they call such a functions as
> "Output Buffering Functions"
>

Just my idea, not sure if it will work: use urlrewriting to catch all
requests with one script, in that script read the original request, call
it and catch it's output. hope you understand me :)

Report this thread to moderator Post Follow-up to this message
Old Post
Marek Kilimajer
11-30-04 08:55 PM


Re: output buffering
Marek Kilimajer [MK], on Tuesday, November 30, 2004 at 15:59 (+0100)
wrote:

MK> Just my idea, not sure if it will work: use urlrewriting to catch all
MK> requests with one script, in that script read the original request, call
MK> it and catch it's output. hope you understand me :)

no, I don't. Which original request ? You are talking about apache ?

--

..m8s, cu l8r, Brano.

[You had to give up. I'm too dangerous for you.]



Report this thread to moderator Post Follow-up to this message
Old Post
Ing. Branislav Gerzo
11-30-04 08:55 PM


Re: output buffering
Ing. Branislav Gerzo wrote:
> Marek Kilimajer [MK], on Tuesday, November 30, 2004 at 15:59 (+0100)
> wrote:
>
> MK> Just my idea, not sure if it will work: use urlrewriting to catch all
> MK> requests with one script, in that script read the original request, ca
ll
> MK> it and catch it's output. hope you understand me :)
>
> no, I don't. Which original request ? You are talking about apache ?
>

User requests /cgi-bin/script.pl

De to the rewrite rule (yes, apache) will execute
/cgi-bin/rewrite_emails.pl instead.

In rewrite_emails.pl you wil find out what is the original request, it
should be available in some env variable I don't remember. It's
/cgi-bin/script.pl in this case

Then you open a connection to the localhost, repeat the request with the
same headers, read in the responce and do whatever transformation you
need. Or you can do a subrequest, I think it's posible in perl.

This is just an idea. I'm not fluent in perl, I do php. The difficult
part is the rewrite rule, you have to be carefull not to make an
infinite loop - request from rewrite_emails.pl must not be rewritten
again to /cgi-bin/rewrite_emails.pl. You can filter by IP address,
subrequest, maybe other options.

Report this thread to moderator Post Follow-up to this message
Old Post
Marek Kilimajer
11-30-04 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL CGI Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:22 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.