Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Send before headers - in perl,

by bizactuator (Sexton)
on Jun 30, 2022 at 05:32 UTC ( #11145187=perlquestion: print w/replies, xml ) Need Help??

bizactuator has asked for the wisdom of the Perl Monks concerning the following question:

I programmed a site in Perl back in 2007, from then until about 2012. I wrote well over 100k lines, maybe 250k lines in over 100 files.

I cannot remember how I did it, but I remember something about it, isn't there a way to have something execute before the headers?

Like if we already printed the headers but then need to do something to do before them, I remember I used to have to do that somehow, but I for the life of me cannot find it in my programming, or on here, but I'm pretty sure someone on here helped me with it back then.

I may not be describing it right, but I think it was for window redirects, when we already had printed header files.
but I cannot recall for sure.

Do you know what I'm trying to say? or what I'm talking about?

Sorry, I got sleep apnea so severe I almost died and it ruined my brain, I cannot recall a lot of things in whole sentences.

I would appreciate anyone who can understand what I'm trying to say.

Thank you,
-Richard

Replies are listed 'Best First'.
Re: Send before headers - in perl,
by haukex (Archbishop) on Jun 30, 2022 at 05:51 UTC
    I think it was for window redirects, when we already had printed header files.

    Perhaps you mean <meta http-equiv="refresh"...? The other way is with JavaScript, both methods can even be combined on the same page.

    isn't there a way to have something execute before the headers?

    If you mean on the server side, then you'd have to delay the output of the headers; once they've been sent to the client there is no way to take it back. But in general you can execute anything you like before you send the headers.

      JavaScript could be disabled though, so securest way is in code... eval worked for me in Perl, I went and searched my code and it did work.

      maybe not the way it was intended but it worked for me.
        eval worked for me in Perl, I went and searched my code and it did work.

        I'm not sure eval explains it, though, so it would be interesting to see your code. The only way I can think of at the moment that eval could be used to delay something is to delay a BEGIN block or use.

        JavaScript could be disabled though, so securest way is in code...

        Yes, my first example doesn't require JavaScript.

Re: Send before headers - in perl,
by ait (Hermit) on Jun 30, 2022 at 11:56 UTC

    Are you just trying to remember as a mental exercise or are you stuck trying to solve some problem right now that may require a similar technique?

    If the latter, perhaps if you describe the actual problem you are trying to solve right now, it would be easier than to determine what you did back then

      I was trying to remember, because I wanted to show someone about PHP that Perl could do it, so is there a similar way to do that in PHP... but there is not, at least, I could NOT find a way. So, I'll just have to change what I'm doing in PHP.

      The programmer that created all of that PHP died recently, so we are changing the code, but it is way to big to change it all to Perl, so leaving it php.

      Big job but changing it is important, to update it to a new system.

      anyhow, the eval works so different in PHP.

      My best,
      -Richard
Re: Send before headers - in perl,
by bizactuator (Sexton) on Jun 30, 2022 at 05:35 UTC
    It was eval or something like that, right?

    where if we wrap it in there, it will process that BEFORE headers?

    is that right?

    Sorry my brain really is trying.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11145187]
Approved by haukex
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2022-08-19 08:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?