Re: Premature end of script headers

2008-11-16 Thread Adam Jimerson
Mike Williams wrote:

 [EMAIL PROTECTED] wrote:
  Hello,
 
  i need to know the reasons for this error Premature end of script
  headers i checked with my http header content-type:text/html ,but i
  had not solved yet..
 
 
 Often this happens when some error occurs in your code before you output
 the headers.
 
 Try putting this near the top of your script:
 
 use CGI::Carp qw(fatalsToBrowser);
 
 this will redirect fatal errors to the browser window - see perldoc
 CGI::Carp for more info.
 
 If neither this nor Sean's suggestion helps post your code so we can take
 a look.
 
 Mike

I also had this problem the other day the web browser said that there was a 
Premature end of script headers but the Apache log said that it was a problem 
with permissions.  Checking my script shows that I forgot to make it 
executable.  It might be worth checking the obvious and see if you have a 
similar problem.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Problem with uploader

2008-11-16 Thread Adam Jimerson
I'm trying to make a CGI script to upload files remotely onto my server, to get 
around my uni blocking everything but port 80, but I have ran into a problem 
with it.  I followed the documentation on CPAN for uploading files and did what 
they have suggested as the best way but it doesn't work.  Here is my code:

#!/usr/bin/perl
use warnings;
use strict;
use CGI ':standard';

#Declare any variables
my $radio_button;
my $filename;

#Generate the form
print header;
print start_html (File Uploader v3);
print h1File Uploader/h1\n;
print hr\n;
print pWhich file type: /p;
print radio_group(-name='File_Type',
 -values=['HTML', 'CGI'],
 -default='HTML');
print start_multipart_form();
print pFile Upload: /p;
print filefield (-name='Uploaded_file',
-default='Give a file',
-size='50');
print brbr;
print submit('Upload', 'Upload');
print reset;
print endform;

#Do the work
$radio_button = param('File_Type');
if ( $radio_button eq HTML ) {
$filename = upload('Uploaded_file');
open (OUTFILE, /tmp/uploaded.html) || die Can't open the file: $!;
while ($filename) {
print OUTFILE $_;
}
close (OUTFILE);
open (MAIL, |mail -s \File Uploaded\ vendion);
print MAIL A file has just been uploaded!\n;
close (MAIL);
} else {
#Code soon to come
}
print end_html;

Running it locally prints out the generated HTML and it looks right and the 
page does open correctly on my server but there is not file in /tmp and the 
mail is never sent and I don't know if it is a problem with opening the OUTFILE 
handle because the die command doesn't kick in from what I can see.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Problem with uploader

2008-11-16 Thread Owen
On Sun, 16 Nov 2008 16:05:15 -0500
Adam Jimerson [EMAIL PROTECTED] wrote:

 I'm trying to make a CGI script to upload files remotely onto my
 server, to get around my uni blocking everything but port 80, but I
 have ran into a problem with it.  I followed the documentation on
 CPAN for uploading files and did what they have suggested as the best
 way but it doesn't work.  Here is my code:


Make life easy for yourself, have a look at 

http://search.cpan.org/~gunnar/CGI-UploadEasy-0.11/





Owen


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: xml question for xml::twig

2008-11-16 Thread Richard Lee

Richard Lee wrote:

Richard Lee wrote:

Chas. Owens wrote:

my $sabal = new XML::Twig(
 twig_roots  = {
'foo/yahoo'  =
#'[EMAIL PROTECTED]kingtony]'   =
sub {
   my ($yabal, $element ) = @_;
   if ( 
$element-first_child('bayking_list')-first_child('bayking')-att('id') 
eq 'kingtony' ) {

  $element-print;
}
 }
 }
);

I think I made a mistake .. this is now working...

yahoo 
V=bazbay_idvalue1000/valuefactyes/fact/bay_idbay_seenvalue50/valuefactno/fact/bay_seenbay_overall 
value=disabled/bayking_listbayking active=true 
country=Russia id=kingtonybayking type=dictator/bay_usage 
value=none/bayking_originbayking_origin_name emmigrate=no 
value=ohio_usaeconomy_status_previous value=very 
poor//bayking_origin_name/bayking_origin/bayking/bayking_listbayqueen_listbayqueen 
active=true country=japan id=queensarahbayqueen 
type=dictator/bay_usage 
value=none/bayqueen_originbayqueen_origin_name emmigrate=no 
value=ca_usa/economy_status_previous value=very poor/previous 
marriage=no//bayqueen_origin/bayqueen/bayqueen_list/yahoo


Now, I just need good way to put this into hash of hash referernce.
ok so I gave up putting them into has of hash reference because of 
unpredictableness of items..
I can get to all values by doing manual $_-first_child method... but my 
problem is, I don't know how to extract all information on

yahoo V=baz.  how do I get that?  $_-parent?

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Quoting hash keys changes things sometimes

2008-11-16 Thread Dr.Ruud
Rob Dixon schreef:
 Kelly Jones:

 Consider:
 
 perl -le '$hash{foo-bar} = 1; print $hash{foo-bar}'
 [no result]
 
 perl -le '$hash{foobar} = 1; print $hash{foobar}'
 1
 
 I sort of understand this: in the first script, Perl treats foo-bar
 as a subtraction, and sets $hash{0} to 1. In the second one it
 assumes you just left off some quotes.
 
 My question: since Perl doesn't have constants, what exactly IS
 foo-bar? Why is it 0?
 
 The behavior above seems inconsistent to me. Is it considered a bug?
 
 I have said that I have no time for command-line perl. What you have
 published doesn't work on my platform, nor on many others.
 
 Of course I could rewrite the question in my head to a proper Perl
 program, but then I shall be looking for a bug either in my mental
 rewrite or in your original code.
 
 So since you can't be bothered to publish a proper Perl program,
 neither can I be bothered to interpret your question. What is more,
 nor will all the other people who could have answered your question
 wisely. 

Rob, start sparing us this. Perl isn't what you (and I) limit it to. 

-- 
Affijn, Ruud

Gewoon is een tijger.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Need Help

2008-11-16 Thread a b
Hi ,
Can any body tells me what do we mean by below code
snip
$ROUTE::COMM{NEWROUTE}{OS()}
/snip

Thanks in Advance
a b .


Re: MySQL statement with REGEX / RLIKE containing a scalar variable possible?

2008-11-16 Thread Wolf
On Nov 13, 4:56 pm, [EMAIL PROTECTED] (Deviloper) wrote:
 I have a SQL-Statement with a Regular Expression and I want to use a scalar 
 in that expression: (Looking for something like $tool =~ m/\Q$x\E/ )

 #Find tools with xx in the name:
 $dbh-prepare (SELECT name FROM toolbox WHERE name REGEX '$x');
 #or
 $dbh-prepare (SELECT name FROM toolbox WHERE name RLIKE '$x');
 $sth-execute();
 my ($name_of_tool) = $sth-fetchrow_array;
 $sth-finish();

 (Don´t need to mention that this don´t work as expected, but I don´t know how 
 to escape it the right way. ^^)

 Thanks,
 Bastian

Why dont you just use LIKE '%$x%' in your double quoted sql query if
its just a string you want to search within a string? Remember to
untaint $x if it's untrusted.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




need help

2008-11-16 Thread chillidba
Hi ,
Can any body tells me what do we mean by below code
snip
$ROUTE::COMM{NEWROUTE}{OS()}
/snip

Thanks in Advance
a b .

Re: need help

2008-11-16 Thread Rodrick Brown
On Sun, Nov 16, 2008 at 9:01 AM, chillidba [EMAIL PROTECTED] wrote:

 Hi ,
 Can any body tells me what do we mean by below code
 snip
 $ROUTE::COMM{NEWROUTE}{OS()}
 /snip

 Thanks in Advance
 a b .


This isnt a Perl command per say, it seems to be a user defined function
unless you post more code its not very easy to interpolate what's going on
here.

-- 
[ Rodrick R. Brown ]
http://www.rodrickbrown.com http://www.linkedin.com/in/rodrickbrown


Re: need help

2008-11-16 Thread Mr. Shawn H. Corey
On Sun, 2008-11-16 at 19:31 +0530, chillidba wrote:
 Hi ,
 Can any body tells me what do we mean by below code
 snip
 $ROUTE::COMM{NEWROUTE}{OS()}
 /snip
 
 Thanks in Advance
 a b .

This is a deference of a hash of a hash in another package.

ROUTE is the package name.

COMM is the hash in ROUTE

NEWROUTE is a key to the hash.

OS() is a function that returns a key to the anonymous hash referred to
by $ROUTE::COMM{NEWROUTE}


-- 
Just my 0.0002 million dollars worth,
  Shawn

The map is not the territory,
the dossier is not the person,
the model is not reality,
and the universe is indifferent to your beliefs.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: xml question for xml::twig

2008-11-16 Thread Richard Lee

Richard Lee wrote:


I think I made a mistake .. this is now working...

yahoo 
V=bazbay_idvalue1000/valuefactyes/fact/bay_idbay_seenvalue50/valuefactno/fact/bay_seenbay_overall 
value=disabled/bayking_listbayking active=true 
country=Russia id=kingtonybayking type=dictator/bay_usage 
value=none/bayking_originbayking_origin_name emmigrate=no 
value=ohio_usaeconomy_status_previous value=very 
poor//bayking_origin_name/bayking_origin/bayking/bayking_listbayqueen_listbayqueen 
active=true country=japan id=queensarahbayqueen 
type=dictator/bay_usage 
value=none/bayqueen_originbayqueen_origin_name emmigrate=no 
value=ca_usa/economy_status_previous value=very poor/previous 
marriage=no//bayqueen_origin/bayqueen/bayqueen_list/yahoo


Now, I just need good way to put this into hash of hash referernce.
ok so I gave up putting them into has of hash reference because of 
unpredictableness of items..
I can get to all values by doing manual $_-first_child method... but 
my problem is, I don't know how to extract all information on

yahoo V=baz.  how do I get that?  $_-parent?
After I extracted above xml, what is the proper way to loop through them 
and extract all information?

I like my final output to look like,

yahoo V: baz
bay_id value: 1000 fact: yes
bay_seen value: 50 fact: no
.. and so on



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Need Help

2008-11-16 Thread Chas. Owens
On Sun, Nov 16, 2008 at 09:11, a b [EMAIL PROTECTED] wrote:
 Hi ,
 Can any body tells me what do we mean by below code
 snip
 $ROUTE::COMM{NEWROUTE}{OS()}
 /snip

 Thanks in Advance
 a b .


No, there is not enough context for me to know why this code is being
used and off hand it looks like useless code to me (it is asking for a
value and not doing anything with it), but I can tell you a few things
that may be true about it:

There is a subroutine named OS defined somewhere.
There is a module named ROUTE.
That module has a hash named COMM.
That hash (possibly) has a key named NEWROUTE whose value is expected
to be a hashref.

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Need Help

2008-11-16 Thread Mr. Shawn H. Corey
On Sun, 2008-11-16 at 13:23 -0500, Chas. Owens wrote:
 On Sun, Nov 16, 2008 at 09:11, a b [EMAIL PROTECTED] wrote:
  Hi ,
  Can any body tells me what do we mean by below code
  snip
  $ROUTE::COMM{NEWROUTE}{OS()}
  /snip
 
  Thanks in Advance
  a b .
 
 
 No, there is not enough context for me to know why this code is being
 used and off hand it looks like useless code to me (it is asking for a
 value and not doing anything with it), but I can tell you a few things
 that may be true about it:
 
 There is a subroutine named OS defined somewhere.
 There is a module named ROUTE.
 That module has a hash named COMM.
 That hash (possibly) has a key named NEWROUTE whose value is expected
 to be a hashref.

There is a package named ROUTE.  Whether it's a module or an object is
yet to be determined.  If it's an object then %ROUTE::COMM is a class
variable.


-- 
Just my 0.0002 million dollars worth,
  Shawn

The map is not the territory,
the dossier is not the person,
the model is not reality,
and the universe is indifferent to your beliefs.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Need Help

2008-11-16 Thread Chas. Owens
On Sun, Nov 16, 2008 at 14:33, Mr. Shawn H. Corey [EMAIL PROTECTED] wrote:
 On Sun, 2008-11-16 at 13:23 -0500, Chas. Owens wrote:
 On Sun, Nov 16, 2008 at 09:11, a b [EMAIL PROTECTED] wrote:
  Hi ,
  Can any body tells me what do we mean by below code
  snip
  $ROUTE::COMM{NEWROUTE}{OS()}
  /snip
 
  Thanks in Advance
  a b .
 

 No, there is not enough context for me to know why this code is being
 used and off hand it looks like useless code to me (it is asking for a
 value and not doing anything with it), but I can tell you a few things
 that may be true about it:

 There is a subroutine named OS defined somewhere.
 There is a module named ROUTE.
 That module has a hash named COMM.
 That hash (possibly) has a key named NEWROUTE whose value is expected
 to be a hashref.

 There is a package named ROUTE.  Whether it's a module or an object is
 yet to be determined.  If it's an object then %ROUTE::COMM is a class
 variable.
snip

Well, if we are going to be picky about language it is a class not an
object (objects are created at runtime from classes).  Also, there is
no difference between a package and a class in Perl.  To be a module a
package must be in a separate file and must end with a true value, so
it is true that ROUTE is not necessarily at module; it could be a
package inside the same file (which is one of the reasons I said may
be true).  Of course, given the existence of source filters, it could
do anything.


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Array manipulation

2008-11-16 Thread hotkitty
Hi,

I have two arrays, as follows:

Array1=(
date 11/01/2008 newstuff1,
date 10/27/2008 newstuff2,
date 10/24/2008 newstuff3
)

Array2=(
date 11/01/2008 oldstuff1,
date 10/31/2008 oldstuff2,
date 10/30/2008 oldstuff3,
date 10/29/2008 oldstuff4,
date 10/28/2008 oldstuff5,
date 10/27/2008 oldstuff6,
date 10/26/2008 oldstuff7,
date 10/25/2008 oldstuff8,
date 10/24/2008 oldstuff9,
date 10/23/2008 oldstuff10
)

How do I combine the arrays so that the the newstuff in array1 gets
appended only to an item in array2 if the dates match?
In other words:

Array3=(
date 11/01/2008 oldstuff1 and newstuff1,
date 10/31/2008 oldstuff2,
date 10/30/2008 oldstuff3,
date 10/29/2008 oldstuff4,
date 10/28/2008 oldstuff5,
date 10/27/2008 oldstuff6 and newstuff2,
date 10/26/2008 oldstuff7,
date 10/25/2008 oldstuff8,
date 10/24/2008 oldstuff9 and newstuff3,
date 10/23/2008 oldstuff10
)

All I can figure out is how to append array2 onto array1 and vice
versa, but that just doesn't work for my project.




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Array manipulation

2008-11-16 Thread Mr. Shawn H. Corey
On Sun, 2008-11-16 at 08:35 -0800, hotkitty wrote:
 How do I combine the arrays so that the the newstuff in array1 gets
 appended only to an item in array2 if the dates match?

Create a hash of lists with the dates as its keys.  Go through Array2
and push each oldstuff on the list stored in the hash.  Then do it for
Array1.  Sort the keys by date, then run through them and create Array3
by joining the stuff from the hash.


-- 
Just my 0.0002 million dollars worth,
  Shawn

The map is not the territory,
the dossier is not the person,
the model is not reality,
and the universe is indifferent to your beliefs.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Array manipulation

2008-11-16 Thread John W. Krahn

hotkitty wrote:

Hi,


Hello,


I have two arrays, as follows:

Array1=(
date 11/01/2008 newstuff1,
date 10/27/2008 newstuff2,
date 10/24/2008 newstuff3
)

Array2=(
date 11/01/2008 oldstuff1,
date 10/31/2008 oldstuff2,
date 10/30/2008 oldstuff3,
date 10/29/2008 oldstuff4,
date 10/28/2008 oldstuff5,
date 10/27/2008 oldstuff6,
date 10/26/2008 oldstuff7,
date 10/25/2008 oldstuff8,
date 10/24/2008 oldstuff9,
date 10/23/2008 oldstuff10
)

How do I combine the arrays so that the the newstuff in array1 gets
appended only to an item in array2 if the dates match?
In other words:

Array3=(
date 11/01/2008 oldstuff1 and newstuff1,
date 10/31/2008 oldstuff2,
date 10/30/2008 oldstuff3,
date 10/29/2008 oldstuff4,
date 10/28/2008 oldstuff5,
date 10/27/2008 oldstuff6 and newstuff2,
date 10/26/2008 oldstuff7,
date 10/25/2008 oldstuff8,
date 10/24/2008 oldstuff9 and newstuff3,
date 10/23/2008 oldstuff10
)

All I can figure out is how to append array2 onto array1 and vice
versa, but that just doesn't work for my project.


$ perl -le'
my @Array1 = (
date 11/01/2008 newstuff1,
date 10/27/2008 newstuff2,
date 10/24/2008 newstuff3,
);

my @Array2 = (
date 11/01/2008 oldstuff1,
date 10/31/2008 oldstuff2,
date 10/30/2008 oldstuff3,
date 10/29/2008 oldstuff4,
date 10/28/2008 oldstuff5,
date 10/27/2008 oldstuff6,
date 10/26/2008 oldstuff7,
date 10/25/2008 oldstuff8,
date 10/24/2008 oldstuff9,
date 10/23/2008 oldstuff10,
);

LINE:
for my $line ( @Array2 ) {
for ( @Array1 ) {
if ( substr( $line, 5, 10 ) eq substr( $_, 5, 10 ) ) {
$line .=  and  . substr $_, 16;
next LINE;
}
}
}

print for @Array2;
'
date 11/01/2008 oldstuff1 and newstuff1
date 10/31/2008 oldstuff2
date 10/30/2008 oldstuff3
date 10/29/2008 oldstuff4
date 10/28/2008 oldstuff5
date 10/27/2008 oldstuff6 and newstuff2
date 10/26/2008 oldstuff7
date 10/25/2008 oldstuff8
date 10/24/2008 oldstuff9 and newstuff3
date 10/23/2008 oldstuff10




John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.-- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Question

2008-11-16 Thread craig
Is there any way to remove an item from @INC in a built perl  
permanently?


I got my perl5.8.7 to print out all of the libraries in its INC  
array, and then

copied and pasted them (separated by :s) into the appropriate response
in the 5.8.8 Configure interaction.  Now all of the 5.8.7 'i386-freebsd'
libraries occur twice in 5.8.8 @INC.

I feel sorry for the thing having to check all those libraries twice  
for the

rest of time, or at least until 5.10.1 comes out :-)

This was the only one among the many perl forums (forii?) that looked  
to me
like a place one could ask this Q.  If anyone can suggest a more  
appropriate

forum, I will try that if no answer is forthcoming here.

Thanks for being there,
Craig MacKenna
How To Get a Head Without Hunting
www.animalhead.com
Los Gatos, CA


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Question

2008-11-16 Thread Chas. Owens
On Mon, Nov 17, 2008 at 00:21,  [EMAIL PROTECTED] wrote:
 Is there any way to remove an item from @INC in a built perl permanently?

 I got my perl5.8.7 to print out all of the libraries in its INC array, and
 then
 copied and pasted them (separated by :s) into the appropriate response
 in the 5.8.8 Configure interaction.  Now all of the 5.8.7 'i386-freebsd'
 libraries occur twice in 5.8.8 @INC.
snip

You built from source once, is there a reason you don't want to
rebuild it (with the right options)?

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/