Hello, I have CGI proxy that works on my localhost, but when I try to get it work on another server I get Premature end of script headers. I have included the source below. I also tried print header instead of the text/xml and it worked localhost but it failed on the server.
use strict;
#use warnings;
use CGI qw(:standard);
use CGI::Car...
What is the best way to handle a failure in a builder method?
For example:
package MyObj;
use Moose;
use IO::File;
has => 'file_name' ( is => 'ro', isa => 'Str', required =>1 );
has => 'file_handle' ( is => 'ro', isa => 'IO::File', lazy_build => 1 );
sub _build_file_handle {
my $self = shift;
my $fh = IO::File->new(...
for a perl cgi script, what is the difference (technically) between these two?
#!/usr/bin/perl
use CGI;
$cgi = new CGI;
print $cgi->header(),
$cgi->start_html(),
$cgi->pre($cgi->param()),
$cgi->end_html();
and
#!/usr/bin/perl
use CGI;
$cgi = new CGI;
print $cgi->header(),
$cgi->start_html(),
$cgi->pre($ENV{'QUERY_STRING'}),
...
I have a Perl script that isn't working and I don't know how to start narrowing down the problem. What can I do?
Note: I'm adding the question because I really want to add my very lengthy answer to Stackoverflow. I keep externally linking to it in other answers and it deserves to be here. Don't be shy about editing my answer if you ha...
A discussion in another thread got me wondering: what do other programming languages' exception systems have that Perl's lacks?
Perl's built-in exceptions are a bit ad-hoc in that they were, like the Perl 5 object system, sort-of bolted on as an afterthought, and they overload other keywords (eval and die) which are not dedicated specif...
I'm trying to create a base template which then loads data depending on what actions are taken. I included ( required ) some pages which was fine but when I included another file which I got a 500 internal error. pasting the code straight in and it works fine:
Here's what I've got;
#!/usr/bin/perl
use strict;
use warnings;
use LWP::Sim...
With warnings enabled, perl usually prints Use of uninitialized value $foo if $foo is used in an expression and hasn't been assigned a value, but in some cases it's OK, and the variable is treated as false, 0, or '' without a warning.
What are the cases where an uninitialized/undefined variable can be used without a warning?
...
In the code below, from a blog post by Alias, I noticed the use of the double exclamation point !!. I was wondering what it meant and where I could go in the future to find explanations for Perl syntax like this. (Yes, I already searched for '!!' at perlsyn).
package Foo;
use vars qw{$DEBUG};
BEGIN {
$DEBUG = 0 unless defined $DEBU...
I'm using Perl for this but I'm not sure that matters here, this is raw HTTP.
I have various services which I've built a central login for. The services can be run off-site by third parties and I handle all the handshakes securely, with the central site always maintaining login state with sessions and session cookies.
The problem I'm ...
I have hundreds of text files in a folder named using this kind of naming convention:
Bandname1 - song1.txt
Bandname1 - song2.txt
Bandname2 - song1.txt
Bandname2 - song2.txt
Bandname2 - song3.txt
Bandname3 - song1.txt
..etc.
I would like to create folders for different bands and move according text files into these folders. How could ...
Just a quick question
printf("%d", 99 || 44) prints "1" in C
print 99 || 44 prints "99" in perl
There are two different kinds of evaluation. Does each one have a name?
edit: i'm interested to know how this Perl evaluation is commonly called when compared to C. When you say "C example is X, and perl example is not X, but Y" which w...
I've used LWP capability to handle gzip encoded content as described here, but in some cases I randomly get unexpected results at least for the one website I've tested: $response->decoded_content could become undefined while $response->content still returns original gzip encoded response. Tried even without internal charset decoding (dec...
Hi,
I am going to upload all of my photos to an Apache web server - they're all in folders & sub-folders. Filenames are not descriptive and I don't care about the meta data.
I've worked with PHP Gallery before, but find the process of creating albums, etc. a little laborious. I just want to rsync my local photo folders with my web site...
In a simple webapp I need to map URLs to filenames or filepaths.
This app has a requirement that it can depend only on modules in the core Perl ditribution (5.6.0 and later).
The problem is that filename length on most filesystems is limited to 255. Another limit is about 32k subdirectories in a single folder.
My solution:
my $filena...
I have a series of select statements in a text file and I need to extract the field names from each select query. This would be easy if some of the fields didn't use nested functions like to_char() etc.
Given select statement fields that could have several nested parenthese like:
ltrim(rtrim(to_char(base_field_name, format))) renamed_f...
Requirements:
a) I have a very large CSV file to read (about 3Gb).
b) I won't need all records, I mean, there are some conditionals that we can use, for example, if the 3rd CSV column content has 'XXXX' and 4th column has '999'. Can I use these conditionals to improve the read process? If so, how can I do that using Perl?
Please you s...
Suppose the portion that needs to be captured by regex is indicated by PORTION in the following string
,"PORTION","","a",["some_string"]
Examples of PORTION are
\"abc123
abc123\"
\"abc123\"
abc\"123\"
abc123
so the strings actually look like
,"\"abc123","","a",["some_string"]
,"abc123\" ","","a",["some_string"]
"\"abc123\...
These are the ones I'm aware of:
The behaviour of a "my" statement modified with a statement modifier conditional or loop construct (e.g. "my $x if ...").
Modifying a variable twice in the same statement, like $i = $i++;
sort() in scalar context
truncate(), when LENGTH is greater than the length of the file
Using 32-bit integers, "1 <<...
Using this function:
perl -e 'use Time::Local; print timelocal("00","00","00","01","01","2000"),"\n";'
It will return an epochtime - but only in GMT - if i want the result in GMT+1 (which is the systems localtime(TZ)), what do i need to change?
Thanks in advance,
Anders
...
Example:
my $page = $args{'p'};
exit 1 if $page =~ /[^\d\w]/;
print "Content-Type: text/html\n\n";
print "<html><head></head><body>";
require "$page.pl";
somefunc();
print "</body></html>";
Is there anything wrong with using the require after the output has started or should all requires be at the top of the script?
...