Re: how to send a page and a file at a download script?

2008-09-23 Thread Wiggins d'Anconia
shnaxe wrote:
> dear readers,
> 
> i recently finished a small perl-cgi download script that sends files
> after some checks and logging. i call this script through a link on a
> static html-page and pass the file-id as a parameter.
> 
> this all works nice so far, the part where i'm stuck at is that with
> clicking on the link, the page containig the link is replaced by a
> white blank page. i wonder how i could instead get either:
> - the page containig the link stays, link is targeted to a new window
> (minimal version)
> - a new page is displayed containg something like 'thank you for
> downloading... you download should start now...' (deluxe solution)
> 
> for the minimal version, i thought putting a simple 'target="_blank"'
> into the link should do what i want (only tested with firefox 3.0 so
> far). this indeed works, but the focus changes to the popping up new
> blank tab and further, this tab stays open after the file is
> transferred. i remember having seen this differently on the web.
> 
> for the deluxe verson i think i somehow need to send out two headers,
> one of type 'application/x-download' (for the file) and another of
> type 'text/html' (for the page).
> but how would i do this? i'm afraid that the second header (whichever)
> will not get recognized as a second document but be embedded into the
> first. i guess a short sleep between the first and the second header
> won't do it...
> 

You shouldn't really need a new window at all if you don't want one, at
least not in some browsers. If you return the proper headers followed by
the content then the user should be able to click the download link and
stay right where they are with the standard browser action occuring. If
you return a proper content-type then the browser should just do what
you want, if you return a Content-Disposition header then you will get
to specify a suggested filename, etc. 'application/octet-stream' can
usually be used as a generic download header if you don't have a
specific content-type in mind. So your headers might be:

Content-Type: application/octet-stream
Content-Disposition: attachment; filename=some download.pdf

or in the above case if you know it will be a PDF,

Content-type: application/pdf

> thanks for help and suggestions in advance,
> regards, shnaxe

HTH,

http://danconia.org

> 
> ps: well, i am unsure if this would have been better posted to another
> group (but which) since its maybe not a pure perl-question. i got to
> admit that from my point of knowledge, the solution to the problem i
> described seems to be somewhere on a blurry line between perl/cgi and
> html...
> 
> 

I'd say it is appropriate.

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




Re: parsing a line

2008-08-19 Thread Wiggins d'Anconia

thunder wrote:

Hello all

I have the following small file that i am parsing one line at a time
(each line consists of hex values)

line 1: 0d
line 2: 
line 3: 2000
line 4: 0064
line 5: 76d457ed462df78c7cfde9f9e33724c6
line 6: bded7a7b9f6d763e
line 7: 0059010081bb300597603b6f90ef4421
line 8: 001608427754e957a0d281bb30059760
line 9: a72f731c3be6


For line 5, for example, i want to break it up into chunks of 8 hex
charaters (ie for example 76d457ed, 462df78c etc).
I tried to use the shift operator (ie << or >>) but perl gives an
error.

Any help with the above would be appreciated.

Thanks





Check out the pack/unpack functions,

perldoc -f unpack

http://danconia.org

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




Re: Extracting TD's from a Text File (Regex Help).

2008-04-08 Thread Wiggins d'Anconia
[EMAIL PROTECTED] wrote:
>  TEXT FILE ##
> 
> 
> http://mysite.com/link/here_goes?id=239";>LINK
> 
>  
> 
>  
>   http://mysite.com/link/here_goes?id=239";>LINK 
>  width="150">06/11/2007 12:29AM
>  
> 
> 
> 
> The text file contains hundreds of tds structure like above. All I need is to 
> extract the td with class "PhorumTableRowAlt thread". I have tried every 
> possible option, but finally I am coming to you for any Regex for it? TIA.
> 
> HERE IS WHAT I AM DOING:
> 
> pen(TXT, "links.txt") or die "Unable to open file";
> my @links = ;
> close (TXT);
> foreach my $link(@links) {
> if ($link =~ m|(.*?)|gsi) {
> print "$1";}
> }
> 
> 
> 
> But NOTHING coming up. No results.
> 
> Thanks for any help.
> 
> Sara.
> 

Parsing HTML with regexes is just a bad idea. Try a module from CPAN,
I've had good luck with HTML::TokeParser::Simple,

http://search.cpan.org/perldoc?HTML::TokeParser::Simple

http://danconia.org

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




Re: Adding a comma to format localtime

2007-04-09 Thread Wiggins d'Anconia

Gregg O'Donnell wrote:

All,
  I use this line of code:
  my $datetime = join ' ', (split ' ', localtime)[0,2,1,4,3];


my $localtime = [ split ' ', localtime ];
my $datetime = $localtime->[0] . ', ' . join ' ', @$localtime[2,1,4,3];

TMTOWTDI...

http://danconia.org

   
  To create this result:

  Mon 9 Apr 2007 09:15:05
   
  How can I add a comma to this result to get:

  Mon, 9 Apr 2007 09:15:05
   
  Best and thanks,

  Gregg



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




Re: Tweeking a sendmail routine.

2007-03-25 Thread Wiggins d'Anconia

Greg Schiedler wrote:

I know enough Perl to be dangerous!

I have a form that sends out several different confirmations depending on
who the receipient is.

One particular E-mail I need to be in html format so I can put it into a
specific format.  I added a couple of lines to the sendmail routine I was
using and it fixed my E-mail problem but created a problem with my fax
gateway copy.

#1 gets sent the Joe Enduser plain E-mail(Can be html my tweek forced html)
#2 gets sent to the Office HTML Format.
#3 Fax gateway (Plain E-mail).

Fax gateway is in the US Telephone format ie.  [EMAIL PROTECTED]

I thought about adding an if statment but it looks like if I added an
if/else to my tweeked else statement the receipient info has already been
sent

Greg :-)



Best suggestion would be to switch to using a module. MIME::Lite for 
instance but there a lot that will work. Check CPAN. Mail while it seems 
simple is incredibly complex, re-inventing the wheel, especially with 
such strict requirements is going to be time consuming.


http://danconia.org



file: sendmail.pl

# Give the server the message header

print SMTP "DATA$CRLF";
sysread(SMTP, $_, 1024);
if (!/[^0-9]*354/) { $Error_Message = $_; return(6) }
print SMTP "To: @to$CRLF";
print SMTP "From: $from$CRLF";
print SMTP "CC: @cc$CRLF" if $cc;
print SMTP "Subject: $subject$CRLF";

# If there are mime files to attach, we need special headers.

if ($mime_id) {
print SMTP "x-sender: $from$CRLF";
print SMTP "x-mailer: CGI/Perl Cookbook$CRLF";
print SMTP "Mime-Version: 1.0$CRLF";
print SMTP "Content-Type: multipart/mixed;
boundary=\"$mime_id\"$CRLF$CRLF";
print SMTP "--$mime_id$CRLF";
print SMTP "Content-Type: text/plain;
charset=\"US-ASCII\"$CRLF$CRLF";
}
# Greg @ Limo.Net 01/24/2007
# Added two header lines for force HTML output.
# else { print SMTP $CRLF }
#
else {
print SMTP "Mime-Version: 1.0$CRLF";
print SMTP "Content-Type: text/html;
charset=\"ISO-8859-1\"$CRLF$CRLF";
}
# End Greg @ Limo.Net 01/24/2007

# Output the message body.

if ($body) {
if (!($body =~ /^[\\\/:]/) && ($body =~ /\s/)) { print SMTP $body }
elsif (-e $body && -T $body) { &parse_template($body, *SMTP) }
}
print SMTP $CRLF;

# Attach each file.

for ($i = 0; $i < @ATTACH_FILES; ++$i) {
$attach_file = $ATTACH_FILES[$i];
$encoding = $ENCODING[$i];

# Split the filename by directories.  / for unix, \ for dos, : for
mac



Scanned for Virus by http://Barracuda.Limo.Net




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




Re: -e question

2006-12-15 Thread Wiggins d'Anconia

Lou Hernsen wrote:

I use the -e to check to see if a file is present

  if (-e "$Pics/$Game{Page}.jpg")
  {
   }

Question
I can get it to work looking for .pl and .gif but not .jpg

I have checked all the directorie vars and even did this

  print qq||;
  print qq||;
  print qq||;
  print qq||;
  print qq||;
  print qq||;
  if (-e "$Pics/$Game{Page}.jpg")
  {
  print qq|

In the above line do you mean to have '.jpg'?


height="$Game{CameraH}">|;
   }

I get the first two images but not the last one.. so I know i have the dirs
correct
are .jpg's not -e able???



-e cares not and knows not of the type of file.


yeah.. i'm nonprofessional hobbiest  my style suck... can someone answer
the question, please?


Helps?

http://danconia.org


Lou




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: trouble with meta http-equiv

2006-11-30 Thread Wiggins d'Anconia

David Bear wrote:

I'm trying to put a client side redirect with http-equiv refresh. I'm using
the syntax:

my $req  = CGI->new();

print $req->header( "text/html" );
print $req->start_html( -head=>meta({-http-equiv => 'refresh', 


In the above line the call to meta() is a function call, but you have 
started out with the object syntax. So you likely haven't imported any 
of the function lists, so you either need to import the correct list, or 
switch to the object syntax,


$req->meta(...)


-content => '1;URL=' . $req-refere()}));



Note you probably need $req->referer in the above line...

HTH,

http://danconia.org


but I get an error:
Undefined subroutine %main::meta called 


This seems to be what is documented on cpan. I must be missing something
simple. Any ideas?


--
David Bear
College of Public Programs at Arizona State University




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: figuring out if a number/character string is null in Perl

2006-08-30 Thread Wiggins d'Anconia
Mary Anderson wrote:
> Hi All,
>I know this isn't strictly a cgi problem, but it is arising in a cgi 
> application.  I have a loop which reads certain fields, hashed on names.
> Some of my fields hold character strings, some hold numbers.  Sometimes 
> the number field is a blank.  I need a test on the field value $fieldValue 
> which will tell me if my field was blank regardless of whether it holds a 
> character string or a number.
> 
>   I would like to say something like
> 
>   $fieldValue = (($fieldValue == 0) or $fieldValue) ? $fieldValue : 'null'
> 
> but perl appears to have a strange interpretation of $fieldValue == 0 if 
> $fieldValue is a character.
> 
> Thanks
> Mary
> 
>  I have seen references to a function which will do the trick, but it 
> is not mentioned in the camel book.
> 

0 or any other number translates to a string when using the 'eq'
operator, so you could check to see whether $fieldValue is blank using,

if ($fieldValue eq '') {
  # $fieldValue is defined but empty
}

--or--

if ($fieldValue ne '') {
  # $fieldValue is not blank (but may be false)
}

You could also check using the length function, but I wouldn't bother
unless for some reason the above won't work.

HTH,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: using variable in param

2006-02-21 Thread Wiggins d'Anconia
Adriano Allora wrote:
> Hi all,
> 
> I need to obtain some values (passed with a form) without knowing their
> names (but I know these variable names correspond to names of some files.
> 
> So, I tried to write  something like this:
> 
> opendir(QUERY,
> "/Users/adrianoallora/Sites/corpora/VALICO/indici_testa/") or $errtex = $!;

The above "or" condition doesn't die, or at least break the execution
loop in some way. It should.

> @interrogabili = readdir(QUERY);
> foreach $elem (@interrogabili)
> {
> next if $elem =~ /^\..*/;
> $elem = $home->param($elem);
> }
>

You haven't shown us the declaration of $elem, I suspect that is the
issue. And since you haven't shown us the declaration I would have to
guess you aren't using,

use strict;
use warnings;

And you should be.

$elem is getting clobbered each time through the loop with a new value,
from the file list, then a new value from CGI (assuming it is defined).

You need to adjust where you are storing the values to keep all of them.
Or you could just get the full list, see Vars() in the perldoc for CGI.

http://danconia.org


> Why the  $home->param($elem) line doesn't work? All the rest of the code
> works very well (It open effectively the directory, store all the
> entries in the array, read each array item...)
> 
> Any help is soo much appreciated.
> 
> alladr
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Storing a search string

2005-12-15 Thread Wiggins d'Anconia
Thom Hehl wrote:
> I have a screen that is gotten to by a rather elaborate search string. I
> want to put a button on that page that calls a CGI and passes it
> location.href, which has all of the parameters I need to get back to
> that page. The problem is, how do I do that without it mucking up the
> search string with all of the ? and &s?
> 
> Anyone?
> 
> Thanks.
>
> Thom Hehl
> Heavyweight Software for Heavyweight Needs
> www.heavyweightsoftware.com

If I understand you correctly, you should have a look at HTML::Entities.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Taking Multiple Values for The Same Form Field.

2005-10-29 Thread Wiggins d'Anconia

Bob O'Neill wrote:

Vars;

which is much neater.  My subroutine "Checkentry" untaints the input.  Is 
there an easier way which will allow the hash values created by Vars to be 
passed to my subroutine without stepping through a "foreach" loop? 



If I understand correctly then you want a hash reference to pass the 
whole hash around at once.


perldoc CGI

Should help, C understands its context, so calling it in scalar 
context will result in it returning a hashref instead of a hash.


my $params_ref = $q->Vars;

http://danconia.org



Bob





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: CGI Upload() for nonexistent files?

2005-10-28 Thread Wiggins d'Anconia
Joby Jones wrote:
> Hello all,
>   I have a question about the CGI upload()
> function.
> 
>   Why does it return a valid file handle to a file
> that does not exist on the client (web browser)
> machine, and what's the best way to handle this?
> 

Presumably because this is really a client side error. It is not an
error to upload a zero length file, a file could need to be created but
empty, and you could want to have a program do that. So it is not
unreasonable to think that a file upload could be empty, which means CGI
has to handle the case where a file is uploaded but empty.  Chances are
good the browser is creating the proper HTTP request despite the "local"
file not existing, but to me that is a browser fault.  CGI just sees the
header that says there is a file coming, then no data so it creates the
file, puts nothing in it, and happily crunches along.

> 
> Details:
> 
> 
> 1. A user enters a nonexistent file name in an upload
> field in a form handled by my cgi script. (E.g. on
> windows c:\uplaodthis.txt <-- note typo). 
>
> 2. My cgi script does something like this:
> 
> my $q = new CGI;
> if(defined($q->param('Upload'))){
> my $upload_file_handle = 
>$q->upload('upload_file');
> if(defined($upload_file_handle)){
>print "Valid file handle to empty file is:\n" .
> 
>   Dumper($upload_file);
> }
> }
> 
> 
> 3. It outputs: 
> "Valid file handle ... 
>  $VAR1 = bless( \*{FH::uplaodthis.txt ...}, 'Fh' );"
> 
> 
> 
> What to do?
> ---
> 
> Currently, I write out all valid file handles (checked
> for basic security problems as described in perlsec). 
> If the file is zero length, I delete it and report an
> error.  Which just isn't very satisfying.
> 

Why is it not satisfying? It is a requirement of yours that the file not
be empty NOT the CGI world at large, so this is an error you should be
handling. Sounds like you are doing a fine job.

> What am I missing?
> Is there a better way?

Doubtful. You could write a web server module to handle the case at the
front end of the request but the only thing that really saves is a
little processing time, you still have a server side error to throw.

> 
> 
> 
> All advice and documentation pointers (beyond 'CGI'
> :-) appreciated.
>

I say move on and work on bigger problems. Faulty user input, is well
the fault of the user. Let them deal with the consequences of having to
resubmit the form, assuming your error message is clear.

http://danconia.org


> Thanks,
> joby
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: hardcoded paths

2005-10-28 Thread Wiggins d'Anconia
Dermot Paikkos wrote:
> Hi,
> 
> I am moving a site from once host to another. There are lots of 
> hardcoded fully qualified paths to the localhost (EG 
> http://myserver/cgi-bin/someprog.pl?name=val & 
> http://myserver/css/mystyle.css).
> 
> I am pretty sure this isn't good practise but I am not a bit lost as 
> to what are good alternatives. I don't want to make the same mistake 
> and have to do all this editing again next time the hardware changes.
> 
> Should I be trying to create a module with these paths in? Or is 
> there some other way?
> Thanx.
> Dp.
> 
> 

Relative URLs as David mentioned would be good whereever they can be
used. The other option I use is to create a Setup.pm module that
contains constants for these things.

use constant CONFIG_URL_BASE => 'http://yoursite.com';
use constant CONFIG_URL_CGI_BASE => 'http://yoursite.com/cgi-bin';

Then you need to export those constants into the calling code. The only
bummer about using constants is that they don't interpolate inside
strings, but I have settled on using concatenation and prefer to have
the extra overhead to have the ease of changing all URLs on a site at once.

This also makes module code that generates links reusable across sites.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: $CGI::DISABLE_UPLOADS

2005-10-18 Thread Wiggins d'Anconia
Bill Stephenson wrote:
> I've been testing the "$CGI::DISABLE_UPLOADS" and "$CGI::POST_MAX"
> variables and I don't think I've got it feature working as it should.
> The docs say this:
> 
> "CGI.pm also has some simple built-in protections against denial of
> service attacks, but you must activate them before you can use them.
> 
> 
> 
> $CGI::POST_MAX
> If set to a non-negative integer, this variable puts a ceiling on
> the size of POSTings, in bytes. If CGI.pm detects a POST that is
> greater than the ceiling, it will immediately exit with an error
> message."
> 
> It seems to me that my script will not exit until uploading the entire
> POST has been completed. So, here are my questions about this:
>

Right, but the script exits immediately. I *suspect* the complete
request must be sent to the web server regardless of whether the script
is going to fail. Exiting immediately just means that CGI will not allow
execution of anything beyond its initial preparations, rather than
meaning it will truncate the request.

At least that would be my interpretation... But I didn't have a look at
the modules source, you might want to check there for confirmation.

http://danconia.org


> Do I misunderstand the above? (ie. the script should upload the entire
> POST before exiting with an error)
> 
> Is there something wrong with my test script (I suspect this must be the
> case, please see it below)
> 
> Or... is there something wrong with CGI.pm? (this seems to be a longshot)
> 
> I'd really appreciate any help you all can give me with this.
> 
> Kindest Regards,
> 
> -- 
> Bill Stephenson
> 
> 
> 
> 
> #!/usr/bin/perl
> 
> # deny_upload.cgi
> 
> use CGI;
> use File::Basename;
> use strict;
> 
> $CGI::POST_MAX=1024 * 5;  # max 100K posts
> $CGI::DISABLE_UPLOADS = 1;  # no uploads
> 
> my $Q = new CGI;
> my $message;
> 
> # trap error with this...
> if (!$Q->param('file') && $Q->cgi_error()) {
> $message = $Q->cgi_error();
> &error_trap( "$message");
> }
> 
> # or this...
> # if ($Q->cgi_error()) {
> # $message = $Q->cgi_error();
> # &error_trap( "$message");
> # }
> 
> if (!$Q->param) {
> print $Q->header;
> print qq ~ Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd";>
> 
> 
> Upload Test
> 
> 
>  action="/cgi-bin/test/deny_upload.cgi" enctype="multipart/form-data">
> 
> put too much text in
> here
> 
> 
> 
> ~;
> exit 0;
> }
> 
> # get on to uploading the file...
> 
> if ($Q->param('file')) {
> my $data;
> my $filePath;
> my $file = $Q->param('file');
> 
> fileparse_set_fstype("MSDOS");
> $file = basename($file);
> $filePath = "/test/$file";
> 
> open (SAVE,">$filePath") or &error_trap($message= " Error:: $! ::
> Can Not Upload $file: \n");
> while (read($Q->param('file'),$data,1024)) {print SAVE $data;}
> close SAVE;
> 
> print $Q->header;
> print $Q->start_html(-title => "Uploaded it anyway");
> print "Uploaded it anyway";
> print $Q->end_html;
> exit 0;
> }
> 
> if ($Q->param('test')) {
> print $Q->header;
> print $Q->start_html(-title => "Lotsa Text");
> print $Q->param('test');
> print $Q->end_html;
> exit 0;
> }
> 
> sub error_trap  {
> print $Q->header;
> print  $Q->start_html(-title => "MyApp Error Screen");
> print "$message";
> print  $Q->end_html;
> exit 0;
> }
> 
> 
> 
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: XML [AntiVir checked]

2005-10-11 Thread Wiggins d'Anconia
Naji, Khalid wrote:
> Hi,
> 
> Which Module  could you recommend for the use of the XML (XML::Simple,
> XML::Parser and XML::Writer, XML::DOM, XML::PATH...) ?
> 
> Thanks in advance!
> 
> KN
> 
> 

Yes.

Which one is most appropriate depends on what you need to do. I would
generally suggest starting with XML::Simple until you determine it
doesn't fit the profile of what is needed.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Query on sendmail problem

2005-10-05 Thread Wiggins d'Anconia
Dale wrote:
> Hi,
> 
> I'm hoping someone can help me with an issue I've got with, I assume,
> sendmail.
> 
> I've copied part of a script below.  If I use the first To: line (which
> takes the e-mail address from a file - and this works) then a mail
> doesn't arrive.  If, however, I used the second To: line (which is
> currently commented out - the xx is to stop spammers picking the
> address up from this mail) then a mail is received.
> 
> I added a page after the sendmail just to make sure it was reading the
> e-mail address from the file (which it was) but it still doesn't seem to
> send. $manageremail is the correct variable name.
> 
> In the datafile, I've had the e-mail addresses formatted properly (e.g.
> [EMAIL PROTECTED]) but also tried with \'s at appropriate places (e.g.
> [EMAIL PROTECTED]).  I just can't get anything to work.
> 
> Anyone have any ideas what I could be doing wrong.
>

You're not using a module... Don't think that is what you meant though.

> Thanks in advance!
> 
> -
> -
>   open(MAIL, "|/usr/local/bin/sendmail -t");
> 
> print MAIL "To: $manageremail\n";

Are you chomp'ing $manageremail?  If it has a newline on it in the file
and you have added an additional new line above then you have stopped
the header, surprisingly it should still be sending but below should be
in the body. You should probably have a look at the mail logs generated
by sendmail to see if it is complaining, and more specifically about what.

http://danconia.org

> #   print MAIL "To: [EMAIL PROTECTED]";
> print MAIL "From: [EMAIL PROTECTED]";
> print MAIL "Subject: Escalation logged\n";
> 
> print MAIL "Hi $manager\.\n\n";
> print MAIL "The following escalation has been logged from your
> team.\n\n";
> print MAIL "Agent's Manager   : $manager\n";
> print MAIL "Agent's Name  : $agentname\n";
> print MAIL "Date Logged   : $day\-$month\-$year\n";
> print MAIL "Escalation Reason : $reason\n";
> print MAIL "Short Description : $short\n";
> print MAIL "Long  Description : $long\n";
> print MAIL "Justified?: $justified\n";
> print MAIL "Name of Logger: $logger\n";
> 
>   close (MAIL);
> -
> -
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: html file with form and onSubmit="return check_form(this)"

2005-09-23 Thread Wiggins d'Anconia
Edgardo Lust wrote:
> Hi.
> 
> I have a html file (created with Dreamweaver) with one form and submit
> button with 
> 
> 
>value="/contacto/message.htm">
> value="[EMAIL PROTECTED]">
> 
> 
> I need my perl script to return a valid value then the user can see
> message.htm page
> 
> 
> How can I do?
> 
> Thanks
> 
> Edgardo
> 
> 

What do you mean by return a valid value? You can either redirect to
message.htm or read it in and return the contents.

As a side note the above is basically an open relay, depending on your
other form fields a specially crafted message can probably be used to
send an e-mail to anyone.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Forcing a "save as' dialogue box to come up on left click

2005-09-19 Thread Wiggins d'Anconia
Tony Frasketi wrote:
> 
>> What I was intending was to call the cgi script and rather than it
>> printing the normal text/html header it would print the header directly,
>> that way you are guaranteed to be operating the way you intended.
> 
> Hi Wiggins
> Thanks for this suggestion... I've tried the following bit of CGI script
> with three different file types (.txt, .cgi, .dat) and in each case *DO*
> get the 'Save as...' dialogue box to come up and when I select 'Save to
> disk' and click ok, It appears as if a transfer occurs but only a
> zero-length file is saved to my local hard disk directory.  The code is
> as follows...

Ok, so almost there let's back up a step and understand the whole
thing. The HTTProtocol is very similar to other common net protocols
where there is a header section and a data (or payload) section. The two
are separated by a blank line. So right now you are providing the header
(apparently correctly). The client reads that information and based on
what it knows how to handle it decides on a way to use the payload. In
this case we are giving the browser less than optimal descriptors of the
payload. Basically we are telling it that there is something coming and
that neither I nor you know what it is. So it does the only thing it
can, "Save as...". The only hint you are providing it a suggestion about
what to call that thing. So right now you are providing a header, but
not a payload, let's add it

> 
> 
> #!/usr/local/bin/perl -w
> 
> # testoctetstream_1.cgi
> 
> # My base directory and base directory URL
> my($basedir) = "";
> my($baseurl) = "";
> 
> # Location of the file to be downloaded
> $fileloc = "$basedir/cgi-bin/test/xxx.txt";
> #$fileloc = "$basedir/cgi-bin/test/testdu1.cgi";
> #$fileloc = "$baseurl/cgi-bin/test/testdu.dat";
> 
> # Name of file to be downloaded
> $filename = "xxx.txt";
> #$filename = "testdu1.cgi";
> #$filename = "testdu.dat";
> 
> # NOTE: Uncomment the desired $filename and $fileloc above
> 
> # Set The headers
> print "Content-Type: application/octet-stream;\n";
> print "Content-Disposition: attachment; filename=\"$filename\"\n";
> 
> # ---
> # Note: Can't figure out what to put in here to actually download
> # the darn file!!!
> # ---
> 

This is the simple part, and probably looks a little like.

open file...
read in file...
print file back to browser...
close file

There are simpler ways to do this, but what I have come to use looks like:

my $READHANDLE;
unless (open $READHANDLE, $file) {
# error handling...
}
binmode $READHANDLE;

$| = 1;

while ( my $length = sysread $READHANDLE, my $buffer, $block_size ) {
next unless defined $length;

my $offset = 0;
while ( $length ) {
my $written  = syswrite STDOUT, $buffer, $length, $offset;
$length -= $written;
$offset += $written;
}
}

close $READHANDLE;

> print "\n";

You will want to remove this as it will be an addition to the actual
data which can break some formats.

> exit;
> 
> 
> The above cod was tested in both Mozilla and IE browers with the same
> results.
> 
> 
> It appears I'm missing some statement that should follow the
> Content-Disposition
> statement.
> 

Does this hit the mark?

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Forcing a "save as' dialogue box to come up on left click

2005-09-19 Thread Wiggins d'Anconia
Tony Frasketi wrote:
> Wiggins d'Anconia wrote:
> 
>> Most browsers will provide this functionality if the return header is
>> "application/octet-stream" rather than "text/html" or the like.  In
>> the case of IE you may have to fool the browser into thinking it is
>> getting something different than it is based on the URL, because it 
>> likes to look there for a file extension to determine the file type too.
>> HTH,
>> http://danconia.org
>>
> Hi Wiggins
> Thanks... I just tried putting these three lines in a .htaccess file in
> a particular directory...
> 
>   AddType application/octet-stream .cgi
>   AddType application/octet-stream .txt
>   AddType application/octet-stream .htm
> 
> Alternatively, I also triedAddType application/octet-stream .cgi
> .txt .htm
>

Interesting way to do it, not what I intended. Have you 100% confirmed
that the header is being passed back correctly? I am not sure how Apache
(or whatever web server you are using) handles setting the type, it
might be finding it from somewhere else that is overriding it. There is
a module for Firefox/Mozilla called "Live HTTP Headers" that will help
you confirm what is being sent.

What I was intending was to call the cgi script and rather than it
printing the normal text/html header it would print the header directly,
that way you are guaranteed to be operating the way you intended.

> Using the Mozilla 5.0 Suite browser, I get the following results
> 
> And then trried clicked on links to a .cgi file, a .txt file, and a .htm
> file in that directory Only  the .htm file automaticaly brought up a
> 'Save as...' diaglogue box as I left clicked on the link to the .htm file
> 
> when I clicked on the link to the .txt file, the contents of the .txt
> file appeared in a Wordpad window.

This is windows picking up the association based on the extension
(probably), didn't you know it was smarter than you? ;-)

> 
> When I clicked on the link to the .cgi file, the .cgi file was executed
> and the results displayed in the browser window.
> 
> One out of three right!
> 
> 
> Using the Microsoft IE 6.0 browser, I get the following results
> 
> .htm file -> Displays the .htm file in browser window
> .txt file ->  Displays the .txt file in browser window
> .cgi file -> Executes the .cgi script and displays results in browser
> window
> 
> zero out of three right!

Yeh I suspect that is IE picking up on the URL extension.

> 
> 
> Using Firefox 1.0 browser, I get the following results...
> .htm file -> brings up the 'Save as...' dialogue box
> .txt file -> brings up the 'Save as...' dialogue box
> .cgi file -> Executes the .cgi script and displays results in browser
> window
>

The .cgi problem is probably because you have a handler setup for .cgi
files that trumps the AddType call. What is the header printed by the
.cgi file? It should be able to print its own header of
"application/octet-stream" followed by the contents of a "file" and it
should work correctly.

> SO... Filefox wins by getting two out of the three
> right!
> 
> This method doesn't look very hopeful at this point!

I know I have used this method before, and I have done so recently from
within the context of a different web framework (specifically Interchange).

As to your question about "Content-Disposition" it can be used to preset
the filename that the user sees in the "Save as..." dialogue, but is
again not standard, it is just convention and will depend on the browser
supporting it, to my knowledge the major browsers[1] do support it.

> Thanks again
> Tony Frasketi

Keep at it, I suspect you will get it to work...

http://danconia.org

[1] When I say major browsers I mean Mozilla (and variants, Firefox,
etc.), IE (some recent version, probably newer than 4.x), Safari. I know
there are others but I don't have a copy so can't say specifically how
they act, they may work as well.

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




Re: Forcing a "save as' dialogue box to come up on left click

2005-09-18 Thread Wiggins d'Anconia

Tony Frasketi wrote:

Hello Listers
I'm trying to find a way to force a download dialogue box to come up 
when the user clicks on a link on a web page (the link will primarily be 
for htm, .txt files on the server).  Normally when the user left clikcs 
on the link the .htm or .txt file appears in the browser. And also 
normally when the user right clicks on the link, he is given the choice 
to 'Save Link Target as' in order to download the file.


What I'm looking for is to avoid right clicking and choosing to save the 
file  Is there a way to implement left clicking the link and 
automatically bringing up a "Save As" dialogue box?


I've googled for such things as "mime type download save as etc" but 
came up with dead ends


TIA
Tony Frasketi



Most browsers will provide this functionality if the return header is 
"application/octet-stream" rather than "text/html" or the like.  In the 
case of IE you may have to fool the browser into thinking it is getting 
something different than it is based on the URL, because it  likes to 
look there for a file extension to determine the file type too.


HTH,

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: problems with CGI.pm upload feature

2005-09-17 Thread Wiggins d'Anconia
Bill Stephenson wrote:
> On Sep 16, 2005, at 7:51 PM, Scott R. Godin wrote:
> 
>> Wiggins d'Anconia wrote:
>>
>>> Scott R. Godin wrote:
>>>
>>>> script is at http://phpfi.com/78748
>>>>
>>>> I followed the instructions in CGI.pm as best I could, and from what I
>>>> read the upload() function is supposed to return a filehandle ? (it
>>>> doesn't say whether this is a direct FH to the tempfile or not)
>>>>
>>>> I had dome some preliminary testing with one-liners and was pretty sure
>>>> this would work, but what I wind up with in the attachment is a file
>>>> containing the name of the file, not its actual contents.
>>>>
>>>> what did I do wrong? I can't figure it out. :/
> 
> 
> Possibly used the wrong web browser to upload the file. Not all of them
> support this feature. Firefox does not. It will however provide the CGI
> script with the file name.
> 
> Kindest Regards,
> 
> -- 
> Bill Stephenson
> 
> 

Firefox doesn't support file uploads?  I use it all the time to test
scripts that accept uploads.

Huh?

http://danconia.org

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




Re: problems with CGI.pm upload feature

2005-09-16 Thread Wiggins d'Anconia
Scott R. Godin wrote:
> script is at http://phpfi.com/78748
> 
> I followed the instructions in CGI.pm as best I could, and from what I
> read the upload() function is supposed to return a filehandle ? (it
> doesn't say whether this is a direct FH to the tempfile or not)
> 
> I had dome some preliminary testing with one-liners and was pretty sure
> this would work, but what I wind up with in the attachment is a file
> containing the name of the file, not its actual contents.
> 
> what did I do wrong? I can't figure it out. :/
> 

Just because it is easy to overlook and fairly common, did you include
the 'enctype' in the form tag?  For instance,

[form enctype="multipart/form-data" action="/cgi-bin/request" method="POST"]

HTH,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: File Modification Date

2005-09-14 Thread Wiggins d'Anconia
Vance M. Allen wrote:
> I'm trying to find out how to determine the date and/or time that a file was 
> created in a simple procedure.  I have heard about a few different libraries 
> but the examples I have found haven't been very useful.
> 
> The basic purpose I want to do is a simple footer provided by a package 
> module through CGI to inform users of the latest update to the code based on 
> the URL.  Something simple saying "Version x.xx, Last Modified MM/DD/." 
> which would automatically get the file modified timestamp.
> 
> I'd prefer to have, if possible, a simple scalar variable to store the 
> date...for example:
> 
> $modtime = filemoddate_func(filename.cgi);
> 
> If anyone can help me with the libraries I need to use for this (if any 
> special), and a code snippet if possible, I'd really appreciate it.
> 
> Thanks!
> 
> Vance
> 
> 
> 

Generally this type of information is provided by C, see,

perldoc -f stat

For the details.

To get the modification time for example you could use something like,

my $mod_time = (stat 'filename.cgi')[9];

File creation time is rarely if ever available. Obviously you could wrap
the above in a sub, but I suspect there isn't a lot of reason to since
it is so short anyways.

HTH,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Exact matching using GREP.

2005-09-08 Thread Wiggins d'Anconia
Please bottom post

Sara wrote:
> No, it's not working, probably you didnt' get my question.

How is it not working now?  What Ovid sent is exactly what I would have
answered so you probably need to provide more information. You mention
man pages and switches to grep, there are two greps here, 1) the command
line program used for searching files which is where your -x, etc. come
in and 2) 'grep' the function which is a Perl built-in. For the docs for
it, you need to check:

perldoc -f grep

They are very different things.

http://danconia.org

> 
> Anyways, thanks for a prompt reply.
> 
> Sara.
> 
> - Original Message - From: "Ovid"
> <[EMAIL PROTECTED]>
> To: 
> Sent: Friday, September 09, 2005 12:01 AM
> Subject: Re: Exact matching using GREP.
> 
> 
>> --- Sara <[EMAIL PROTECTED]> wrote:
>>
>>> while (my $row = $sth->fetchrow_hashref)
>>> {
>>>   if (grep /$row->{CAT_TITLE}/, @present) {
>>>   #matching title with @present elements
>>>   print "$row->{CAT_TITLE}";
>>> }
>>>
>>> Question is how to do EXACT matching using GREP? because the above
>>> code prints every element from array for 'php' if the
>>> $row->{CAT_TITLE} is 'php' it prints php/counters, php/forums and
>>> every element containing php.
>>
>>
>> Assuming I understood your question correctly:
>>
>>  if (grep { $_ eq $row->{CAT_TITLE} } @present) {
>># do something
>>  }
>>
>> Cheers,
>> Ovid

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Force a file download for link

2005-08-30 Thread Wiggins d'Anconia
Denzil Kruse wrote:
> 
> --- Bob Showalter <[EMAIL PROTECTED]>
> wrote:
> 
> 
> 
>>   use CGI qw(:standard);
>>
>>   open FILE, ...blah blah...
>>   print header('application/octet-stream');
>>   print while ;
>>
> 
> 
> Thanks for the help Bob! Is there another way besides
> the content-disposition to specify an attachment or
> filename?  I was trying to find a way to get a file
> download box to come up to ask where to save the file
> on their local computer.  With just the above, it will
> display it in the browser, and my users will just
> go...huh?
> 
> Denzil

The 'header' function can take a key/value list of arguments to include
additional header lines. So you can pass your content-disposition header
as you had it before. The key here is that the content type be set to
'application/octet-stream' and that the disposition header will only
work if the client understands it, but in most cases it is worth a shot.

In one my libraries I use,

my %header_options = ( -Content_Type   => 'application/octet-stream',
   -Content_Length => $content_length,
 );

if (defined $self->{'filename'} and $self->{'filename'} ne '') {
$header_options{-Content_Disposition} = "attachment;
filename=\"$self->{'filename'}\"";
}

It seems to have worked for me. Obviously you need to replace
$self->{'filename'} with your variable, and preferably set
$content_length with the file size.

HTH,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: $ENV{'HTTP_REFERER'}

2005-08-24 Thread Wiggins d'Anconia
Denzil Kruse wrote:
> Hi,
> 
> I want to know the web site that someone came from,
> and so I was planning on reading $ENV{'HTTP_REFERER'}
> to figure it out.  How reliable is that?  Do browsers
> or other situations block it or obfuscate it?  Is
> there another way to do it or any other issues
> involved?  I'm using apache on red hat.
> 
> Thanks,
> Denzil
> 

Depends on your definition of reliable. From experience it would seem
most browsers set it pretty reliably.

Having said that, it is just a value passed as part of the HTTP request
so anyone can spoof it at anytime, so relying on it from a security
stand point, well, isn't secure.

I imagine if you are doing something where someone can benefit from
obfuscating it, they will.  If you want to use it for ease of UI
handling (aka redirects, prepopulating fields, marketing metrics) I
think you are safe.

HTH,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Regex Problem.

2005-08-18 Thread Wiggins d'Anconia
Sara wrote:
> I am at a loss here to generate REGEX for my problem.
> 
> I have an input query coming to my cgi script, containg a word (with or 
> without spaces e.g. "blood" "Globin Test" etc).
> What I am trying to do is to split this word (maximum of 3 characters) and 
> find the BEST possible matching words within mySQL database. For example if 
> the word is "blood"
> 
> I want to get results using regex: 
> 
> for "blood": &check(blo) then &check(loo)  &check(ood)
> for "Globin Test": &check(Glo) then &check(lob)  &check(obi) &check(bin) 
> &check(Tes) &check(est)
> 
> TIA.
>

Sounds like you need a "split" then a "substr" rather than a regex,
though I suppose it would work if you really wanted one, I wouldn't.

perldoc -f split
perldoc -f substr

It will also be faster to combine everything into one select rather than
for each possible "token", but at the least if you are going to do
multiple selects use 'prepare' with placeholders and only prepare the
query once.

So,

-- UNTESTED --

my @tokens = split ' ', $entry;
my @words;
foreach my $token (@tokens) {
  push @words, substr $token, 0, 3;
  push @words, substr $token, -3, 3;
}

(or you can put the following into the above foreach however you would like)

my $where = '';
my @bind;
foreach my $word (@words) {
  $where .= ' OR ' if $where ne '';
  $where .= "(def LIKE ?)";
  push @bind, "%$word%";
}

my $sth = $dbh->prepare("SELECT * FROM medical WHERE $where");
$sth->execute(@bind);

while (my @row = $sth->fetchrow_array) {
  print join ' ', @row;
  print "\n";
}

This also prevents SQL injection by quoting the query words properly.

> Sara.
>

http://danconia.org

> sub check {
> my $check = $dbh -> prepare("SELECT * FROM medical WHERE def LIKE '%$query%' 
> ");
> $check->execute();
> while (my @row = $check -> fetchrow_array()) {
> print "blah blah blah\n";
> }
> }
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Clearing cookies

2005-08-16 Thread Wiggins d'Anconia
Denzil Kruse wrote:
> Hi all,
> 
> I'm trying to clear a cookie using CGI::Cookies, and
> can't seem to do it :(
> 
> if ($clear_cookie eq 'yes') {
> 
>  my %cookies = fetch CGI::Cookie;
> 
>  print "getting cookie";
> 
>  if ($cookies{'id'}) {
> 
>   print "clearing cookie";
>   $cookies{'id'}->expires('-1s');
>   print "cleared cookie";
>  }
> }
> 
> I'm getting the "cleard cookie" message, but it is
> still there.
> 
> Denzil
> 

To clear the cookie in the user's client (browser) you have to "set" the
cookie again by printing it in the response headers. You are only
setting the local expiration, to have that maintained across the rest of
the session you have to tell the browser about it, which is done by
passing it back as if you were setting it initially.

HTH,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Insecure setuid?

2005-08-09 Thread Wiggins d'Anconia
Tantalo, Christopher G wrote:
> Can anyone shed some light on what this error means?
>   Insecure $ENV{PATH} while running setuid at
> /var/appl/sls/bin/driver.pl line 1104.
> Line 1104 is
> print `date`;
> 

You shouldn't shell out to date anyways, especially in the above manner
with no error checking, etc. Perl has builtin functions for collecting
date information.

> If I comment this out, then the following error message appears:
>   Insecure dependency in open while running setuid at
> /var/appl/sls/bin/driver.pl line 1249.
> Line 1249 is
> my $err_file = $ENV{"SLS_LOG_PATH"} . "/drivererror" . $rt_id ..
> ".err";
> actually 1249 --->  open(ERR_FILE,">>$err_file") ||die "cannot open
> $err_file for reading:$!";
> 
> Not sure what insecure warnings mean in terms of setuid.  Any answer
> would be much appreciated.
> Thanks
> Chris

Because you are running setuid the taint mechanism is on. See,

perldoc perlsec

For more info. Whenever you have an error/warning you don't understand
that was thrown by Perl you can find more info in:

perldoc perldiag

HTH,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: How do I make two different web pages come up from one CGI?

2005-08-04 Thread Wiggins d'Anconia
David Dorward wrote:
> On Wed, Aug 03, 2005 at 10:45:35PM -0700, Luinrandir wrote:
> 
>>I want to create two web pages in two different windows
>>from one CGI.
> 
> 
> Each request gives one file, that's how HTTP works. You will need at
> least two requests, with the script running twice (or two scripts
> running once each).
> 
> You can use JavaScript to spawn a second window, although it might be
> blocked by popup blockers (the specifics of such a solution are rather
> off topic for this list though, so I'll suggest you look elsewhere if
> you want to go down that path).
> 

Just to be thorough, not specifically because I like them, I will
mention frames. Frames are an easy way to give the appearance of two
requests (because there are actually three) without many client side
limitations. Most *graphical* browsers support frames these days.

And though I don't yet have experience with it I suppose you could look
into Ajax.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Script execution time.

2005-08-03 Thread Wiggins d'Anconia
zentara wrote:
> On Wed, 3 Aug 2005 03:00:01 -0700, [EMAIL PROTECTED] (Sara) wrote:
> 
> 
>>I have to test/optimize a script on a shared server. The script contains a 
>>couple of mySQL queries etc.
>>
>>Is there a way that I can see the query execution time (like in phymyAdmin) 
>>and total script execution time, plus memory & CPU usage? There are a lot of 
>>ways doing it in PHP but nothing in PERL/CGI? 
>>
>>I searched CPAN but failed to find my desired requirements. Are there any 
>>system commands that can be executed within the script to get these values.
>>
>>TIA.
>>
>>Sara.
> 
> 
> This should give you the idea. 
> 
> #!/usr/bin/perl -w
> sleep 5;
> print "This script took ". (time - $^T) .
>   " seconds in Perl $] on $^O\n";
> 
> 
> If you want to test just subs,  get a start time when entering
> the sub, and a finish time just before  the sub returns. Take the
> difference and you should have a pretty good indicator.
> 

Additionally if you are finding the time difference too small you can do
the same but with higher precision using Time::HiRes,

perldoc Time::HiRes

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Problem with https post using LWP

2005-08-01 Thread Wiggins d'Anconia
Denzil Kruse wrote:
> Hi all,
> 
> I'm trying send an https post:
> 
> my $url = "https://some.secure.server/secure.dll";;
> 
> my $ua = LWP::UserAgent->new;
> 
> # assemble the request
> #
> my $request = HTTP::Request->new(POST => "$url");
> $request->content_type('application/x-www-form-urlencoded');
> $request->content($content);
> 
> # send the request and get the result
> #
> my $result = $ua->request($request);
> 
> print $result->as_string;
> 
> But I'm getting this error:
> 
> 501 (Not Implemented) Protocol scheme 'https' is not
> supported
> 
> Looking on cpan, it looks like you do an https post
> the same way as a http post, but I must be missing
> something.
> 
> Can anyone help?
> 
> Thanks,
> Denzil
> 

Have you read:

http://search.cpan.org/src/GAAS/libwww-perl-5.803/README.SSL

And do you have an appropriate SSL interface installed?

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: SetEnv Variable from Apache

2005-07-20 Thread Wiggins d'Anconia
Robert wrote:
> How do I use a variable that is set with 'SetEnv' in the Apache config file?
> 
> Robert
> 
> 
> 

Have you checked the %ENV hash?

print $ENV{'VAR_NAME'};

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: MIME::Lite attachments

2005-07-17 Thread Wiggins d'Anconia
Mike Blezien wrote:
> Hello,
> 
> we're setting up a script to attach mainly PDF files. And was wondering
> when setting up the code to attach the file, what TYPE attribute is used:
> 
> 
> $msg->attach(Type =>'', # WHAT TYPE HERE TO USE ??
>  Path =>'/path/to/somefile.pdf',
>  Filename =>'Document.pdf',
>  Disposition => 'attachment'
>  );
> 
> 
> is the specific what to code MIME Lite to send a TEXT/HTML message with
> a PDF file attached ??
> 
> TIA

I'm assuming you want the MIME/Type,  application/pdf.

Not sure what this has to do with CGI though.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: quote problem and mysql

2005-07-15 Thread Wiggins d'Anconia
Bob Showalter wrote:
> Andrew Kennard wrote:
> 

[snip]

> 
> No, you shouldn't have to do that. Your first approach is correct, so we
> need to find out what's going wrong there...
> 

Can you show us GenMainRecData?  Are you sure it isn't the culprit here,
possibly it is already doing data munging that it shouldn't.

As a side note generally you should leave the '&' off the call to the
subroutine, no need for it anymore, unless you know specifically why to
include it.

my @TheRecord = GenMainRecData();

Should do.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Need a perl module

2005-06-07 Thread Wiggins d'Anconia
Tantalo, Christopher G wrote:
>  I use Mail::Box::Manager 2.00.  Works pretty well for me.
> 
 +1

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Perl Newbee

2005-06-03 Thread Wiggins d'Anconia
Yuga Chodagam wrote:
> Hi all,
>   I am newbee to Perl. Could anybody please give me head start
> with Perl programming? I am interested in playing with some CGI stuff
> and want to sese the Perl's data manipulation power.
> 
> 
> Thanks all. I appreciate any help.
> 
> Yuga.
> 

Though he lurks here I doubt he would plug it himself, so I will suggest
that several people have been pleased with Ovid's CGI Course:

http://users.easystreet.com/ovid/cgi_course/

By the time I found it/he wrote it, I was already fairly experienced so
can't say I started with it. Of course when I started I wished it had
already been written.

HTH,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Help wanted

2005-05-31 Thread Wiggins d'Anconia
Yuanxin wrote:
> Hi,
> I had a lot of data, which are all x-y values. I stored these data in MySQL 
> database. Now I wanna use Perl to get these data from database to build a 
> figure(2-dimensional) and people can use internet to see the figure. In 
> addition, when people see the figure via internet, the x-y value of a point 
> need be shown when mouse is dragged on one point of the figure. In my system, 
> I already install Perl, Perl::DBD::Mysql, CGI, Perl:DBI. So I just wanna know 
> any other Perl:Module should be installed for my case. Thank you very much!
> 
> Terence
> 

Doing the mouse over part may prove difficult, it is client side. You
might want to look into the GD::Graph module to help you with generating
the figures.  There are other modules available to do graphing with as well.

HTH,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Multiple Languages

2005-05-13 Thread Wiggins d'Anconia
Mike Blezien wrote:
> Hello,
> 
> are there Perl modules available to handle multiple language input like
> from forms. we have a situtation where we may need to enter various
> languages strings or characters and it's english counter-part version.
> As there are many languages that use unique characters in the language
> that the scripts may not understand or handled incorrectly or cause
> problems with processing the data entered.
> 
> If you've had some experence with working with multi-lingual
> applications, any info or documentation would be appreciated.
> 
> TIA,

You may want to read through:

perldoc utf8
perldoc Encode

And the suggested reading in the "SEE ALSO" section. Perl in general
should handle the input correctly, I am not sure in what context you
want to handle them.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Undefined subroutine Error

2005-05-09 Thread Wiggins d'Anconia
Mike Blezien wrote:
> Hello,
> 
> occasionally we get this error, due to a mis coding error or type-O
> error, but was wondering is there away to check, with a perl code, to
> make sure the sub routine exists before displaying this system 500
> internal error message. the error I'm referring too is this:
> 
> Undefined subroutine &main::some_routine_name called at script_name line
> XXX
> 
> TIA

If they are miscodings then not really, mostly because Perl allows you
to choose subroutines/methods at runtime. So the interpreter can't know
a pri ori what subs need to exist. If you need to check for a sub to see
whether or not you should be calling it, for instance to see if an
object has a particular method you can use the UNIVERSAL::can function,
see perldoc UNIVERSAL for more info.

Of couse having said all that, aren't you testing ;-) 

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: CGI form Caching problem

2005-05-03 Thread Wiggins d'Anconia
[EMAIL PROTECTED] wrote:
[snip]

> 
> I have tried sending all sorts of headers to the browser to stop it 
> caching the page but nothing has made a difference. So perhaps the problem 
> is not in the browser, but in apache somewhere??
> 
> anyone ever had this (or a similar) problem!!
> 

Are you behind a proxy?  Is there a web cache on the server, a la Squid
or similar.  Is this mod_perl related?

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Alternative Modules

2005-04-27 Thread Wiggins d'Anconia
Mike Blezien wrote:
> Hello,
> 
> we are currently using the Mail::Audit module to resend piped incoming
> emails to a particular domain then sends it to various aliases emails
> from a database. I'm trying locate a similar module but doesn't put alot
> of the header garbage into the body of the email. Then Mail::Audit
> doesn't really remove certain headers from the actual body of the email.
> 
> Is there a module that works similar as the Mail::Audit, but extracts
> the actual body content of the email without some of the headers
> included in it??
> 
> TIA

This is a rather confusing description of what you are doing, if you can
 clean it up a bit we might be able to give you a better solution.

Although it has a very steep learning curve, there isn't a lot that the
Mail::Box suite can't do.  If I wanted to do anything remotely complex
with mail (and I have) I would use it hands down.  It has incredible
documentation, though that too has a little bit of a learning curve :-).

http://perl.overmeer.net/mailbox/

There is also a mailing list...

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: About unoffical HTTP headers

2005-04-26 Thread Wiggins d'Anconia
Shu Cao wrote:
> Hi,
> 
> Sorry, my last email has some errors. The unofficial HTTP header should
> look like "x: y" not "x=y". 
> 
> I am new to Perl CGI programming. And I encounter a difficult problem 
> wish you guys can help me. Thank you! Here is the problem, how can Perl
> CGI program get the unofficial HTTP header value like "x: y". I examine
> the %ENV hash, and found nothing but some standard HTTP headers like
> "Accept", "User-Agent", etc..
> 
> And I check the CGI.pm module too, seems there is no method to get the
> unofficial HTTP headers.
> 

This is going to depend on the web server, as it is the software parsing
the HTTP request, it just passes execution to the CGI and sets up the
environment before hand. So it is up to the web server software to set
in the environment the extra headers, you should check the documentation
for it. It appears that Apache, if you use it, should be passing through
the additional headers with an 'HTTP_' prepended but there is no
guarantee.  Docs:

http://hoohoo.ncsa.uiuc.edu/cgi/env.html

"In addition to these, the header lines received from the client, if
any, are placed into the environment with the prefix HTTP_ followed by
the header name. Any - characters in the header name are changed to _
characters. The server may exclude any headers which it has already
processed, such as Authorization, Content-type, and Content-length. If
necessary, the server may choose to exclude any or all of these headers
if including them would exceed any system environment limits."

Which is linked from:

http://httpd.apache.org/docs/howto/cgi.html#environmentvariables

Which is (obviously) specifically for Apache.

> If you guys know the HOWTO, pls help me. Thank you!
> 
> BTW, English is not my native language, if I have any syntax or grammar
> error, pls forgive me:P
>

Thought it was fine.

> Best Regards,
> Shu Cao
> 
> 

Good luck,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: PATH problem

2005-04-25 Thread Wiggins d'Anconia
TapasranjanMohapatra wrote:
> All,
> My script goes like this...
> --
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> $cmd = "cat file_one";
> $content = qx!$cmd!;
> print "$content";
> --

You should not shell out to read a file, Perl is a full programming
language, you should use the builtin functions whenever possible.
Especially when they are common and simple ones. It is faster, safer,
and less bug/error prone.

#!/usr/bin/perl
use strict; # always
use warnings; # pretty much always

print "Content-type: text/html\n\n";

open my $HANDLE, 'file_one' or die "Can't open file for reading: $!";
while (my $line = <$HANDLE>) {
  print $line;
}
close $HANDLE;

The same thing only faster, much safer, and it will give you diagnostic
output in the error log of the web server to find out why it can't read
a particular file.  See the other poster's comments too.

http://danconia.org

> I have a case where file_one is not in the same directory. So I give the 
> absolute path of file_one
> in place of file_one. 
> When run it using perl on command line I get the contents of file printed 
> correctly.
> 
> But when accessed through browser (cgi-bin), I get nothing printed.
> 
> I thought it might be path problem , but it is not. Because when the file is 
> in same directory,
> it prints the content of the file.
> 
> Can anybody let me know where I am going wrong?
> TIA
> tapas
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Variables in Modules

2005-04-13 Thread Wiggins d'Anconia
Ovid wrote:
--- Sergio Pires de Albuquerque <[EMAIL PROTECTED]> wrote:
I tried with our, importing that var and fully qualified it, but
always 
it get the previous value. My question is: Which method is common to 

share data among apps? What Am I doing wrong? Also, I always use 
"strict" and "warnings".

You're talking about global variables and, in general, using them is a
bad thing as it makes code more difficult to maintain.  I won't go into
that, though, as there's plenty of info elsewhere about that.
In your case, don't give access to the variables.  If you're not going
to go OO, give access to subroutines which can read and alter those
variables.
  package Foo;
  use strict;
  use warningsl
  my $var = 7;
  sub var { $var }
  sub set_var {
my $new_var = shift;
unless (defined $new_var and $new_var =~ /^\d+$/) {
  require Carp;
  Carp::croak("Argument to set_var() can only be digits: ($var));
}
$var = $new_var;
  }
  1;
With techniques like that, you can at least ensure that there is one
canonical place where the data is being fetched and altered.  This
gives you some measure of protection to ensure that naughty code isn't
doing things it should not be doing and, if it ever gets set to a bad
value, you have only one place to put your debugging code.
Cheers,
Ovid
I agree with what Ovid said, but in the case where the data won't need 
or shouldn't be changed, you might consider using constants, which have 
a global nature but are considered less messy than global variables.

perldoc constant
Though I would still drop them into their own module that can be 'use'd. 
This works well for DB DSNs, base URLs, etc.

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



Re: Calling subroutines

2005-03-21 Thread Wiggins d'Anconia

Denzil Kruse wrote:
Hi,
I have a script for a cgi form that covers about 20
pages, and want to name a subroutine to handle each
page like this: page1, page2, page3, etc.
Once the script figures out which page it should go
to, I dont want to have to do this:
if ($page == 1) { &page1() }
if ($page == 2) { &page2() }
if ($page == 3) { &page3() }
.
.
.
I would like to call the subroutine with one
statement, something like this:
$page = $in->param('page');
&page$page()
but the "compiler" doesn't seem to substitute the
variable $page before figuring out the name of the
subroutine and it gives me an error.  I thought about
loading the subroutine referencees into an array, but
run into the same problem.
Is there a way to do this?  Or is there a better way
for the beginning part of the script to play traffic
cop and direct it to the right page?
Have you considered the CGI::Application module? It works essentially as 
you describe but has a good following, is likely better tested, and may 
provide a little more support structure.

http://search.cpan.org/~markstos/CGI-Application-3.31/lib/CGI/Application.pm
In any case the array method you describe should work, can you show us 
the code you have tried?  You may just not be dereferencing your sub 
correctly.  You might also consider a hash and drop the numeric (and 
confusing names) unless there really is an order to the pages.

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



Re: cgi scripts as root or similar - best method

2005-02-25 Thread Wiggins d'Anconia
Chris Devers wrote:
On Fri, 25 Feb 2005, Gavin Henry wrote:

[...] the problem is [...] cdrecord needs to be run as root.

I assume cdrecord is being invoked from a system command, right?
Have you considered prefixing that command with `sudo`, and going into 
the sudoers file to allow the www user that privilige?

Of course, it would be a bit more complicated than that, as sudo will 
prompt for a password that you have to pass back to it somehow, but 
after hurdle that I suspect that it should work fine...

[snip]
You can use the 'NOPASSWD' flag in the sudoers file for a particular 
command/alias, etc. so that the user does not have to enter a password.

man sudoers
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



sorting and printing text files (was: hello all)

2005-02-17 Thread Wiggins d'Anconia
Don Doucette wrote:
hello everyone.
my name is don doucette and I am 38 years old and have been involved 
with computers since the Timex Sinclair.

Ok. Please use a more informative subject line.
I have recently set up a server and am hosting a web site and forum for 
my community association.

I am running the YaBB forum (http://www.yabbforum.com/) and I would like 
to do the following...

I would like to use perl to look in a directory of numerical named .txt 
files (as in 0123456789.txt), find the file name with the largest number 
(as in 1234567890.txt is greater numerically than 0123456789.txt) then 
open the file and extract data from that file so it can be posted into a 
web page?

For instance...
I have a directory named Messages, in this directory there are the 
following files...

1108577587.txt
1108519222.txt
1108490078.txt
1108489912.txt
Obviously 1108577587.txt is greater numerically than the rest, this also 
happens to signify that this is the newest message. In this file is the 
following information...

Title of Post|Author|[EMAIL PROTECTED]|02/16/05 at 
12:13:07|Group|xx|0|192.168.1.1|Message||

As you can see this file is delimited by | and ends with ||
I would like to parse out the Message field first then the Author field 
and assign their value to a variable then insert the variable into html 
on a page.

Something like...


Untitled Document


Here is the newest post to the forum
$Message 
Posted by $author 


The idea is when the main web page loads it always shows the newest post 
to the forum and who posted it.

My question REALLY is do you think this can be easily done or is this a 
huge programming effort for someone just trying to figure out perl... I 
have been thumbing through my Perl book (The Complete Reference Perl 
Second Edition) but it hasn't really been helpful so far.

Thanks for your advice.

Clearly you have a good spec which is about the best start. In general 
this is a forum for specific questions about CGI, which sort of fits, 
but you might be better off with just the beginners@perl.org for non-cgi 
related questions, as yours are more general. Though they are also 
forums for learning, rather than getting free code so we usually like to 
see what you have tried first. Having said that

To get to your actual question, what you are talking about doing is 
pretty simple in Perl. I am not familar with that particular book, if 
you are interested in learning Perl you should check out the Llama from 
O'Reilly, aka Learning Perl. Having read that you should be able to 
solve the above problem. If you don't want more books and can read tech 
docs, then you should start with,

perldoc perlopentut
perldoc -f opendir
perldoc -f readdir
perldoc -f open
perldoc -f sort
perldoc -f split
perldoc -f print
perldoc CGI
Very little is a HUGE programming effort in Perl, that is why it is so 
loved by its users...

Good luck,
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Favorite Perl CGI Framework for Web Site Development?

2005-02-11 Thread Wiggins d'Anconia
Chris Devers wrote:
On Fri, 11 Feb 2005, Siegfried Heintze wrote:

I notice there are a lot of frameworks out there for .NET (eg, .NETNUK),
PHP, and Java (eg AppFuse) programmers. These are sets of files that form a
typical starter site (or skeleton) that have the basic common features for a
web site: (1) cookie/password authentication authorization, send email for
forgotten password, (2) file upload, (3) calendar etc...
Are there any such frameworks for perl cgi? I googled for perl cgi framework
but could not find any matches.

Does Bricolage count? Or Slashcode?
I would count them. There is also TypePad/Moveable Type by Six Apart.
Perl mainly offers sets of tools for plugging such things together, 
using components like CGI.pm &/or template libraries (Template Toolkit, 
Mason, HTML::Template, etc) to build sites.

We don't, however, really have any prominent web application frameworks 
to compare with, say, Zope (Python's main offering) or the many suites 
that are now available with PHP.

I'd be delighted to be corrected about this, but it seems like most of 
the people that are working on such frameworks are using other languages 
these days. 


I have one in development and have been intending to release it under a 
GPL like license but haven't gotten quite that far. Of course it has no 
documentation or testing, why would it need it there are no bugs ;-).

I agree with the other posters about MayPole, and WebGUI.
I will also throw out InterChange since I just started working for a 
company that uses it, but it appears to have a very steep learning curve 
and probably isn't as elegant as the others. It is really geared towards 
e-commerce.

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



Re: How to use sub directories in IIS and Apache HTTPD

2005-02-07 Thread Wiggins d'Anconia
Siegfried Heintze wrote:
When I try to employ subdirectories my perl cgi programs stop working. This
is because the "use" statements cannot find their files.
I could convert the "use evidence_db;" statements to "require
'../evidence_db.pm';" and that works. But this is painful.
Surely there is an easier way. I thought of going into the IIS setup and put
a "-I" switch for the perl statement IIS uses to invoke perl for CGI.
However, that could mess up other applications in other sites if I am not
the only site on the machine.
I don't know where I would change the setting in Apache HTTPD for just the
current site either.
Can someone tell me?
Thanks,
Siegfried

perldoc lib
You can add directories to the @INC array at compile time.  You may also 
be interested in

perldoc FindBin
For instance in the top of my CGI handler I have,
use FindBin;
use lib "$FindBin::Bin/../../lib";
use lib "$FindBin::Bin/../lib";
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: moving files

2004-09-25 Thread Wiggins d'Anconia
Jeff Herbeck wrote:
Hello,
I am trying to start a "transloading" and webhosting company.  This
will allow users to login via apache .htaccess type authentication and
then be able to put a url of a file into a form and the script  will
go get that file, download it to the webserver into their html
directory and then be available for world access. I have the security
setup (apache athentication) and I can get their username with
env(REMOTE_USER) but I dont' know what to do from here.  I know I want
to use "wget" to get the file, but i can't seem to get it to work in a
script.  I am a linux admin, but don't know perl.  How can I log in
the http user into linux and go get that file with wget so it will go
in their home directory, which will be their html directory.  Can
someone please get me started?
Thanks in advance
Jeff
I would avoid using 'wget' and instead opt for the LWP suite of modules. 
They should make retrieving a remote file simple (at least over http). 
Take a look at the documentation and examples and give it a shot, when 
you get stuck ask some more specific questions.

http://search.cpan.org/~gaas/libwww-perl-5.800/lib/LWP.pm
LWP is available from CPAN.
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: CGI Book Advice sought ...

2004-09-15 Thread Wiggins d'Anconia
hcohen2 wrote:
Recently I jumped in to the list and gave a correct answer, but 
unfortunately not really appropriate answer to the question asked.  I 
took the 'Beginners' adjective for this list too seriously.

Hence, to keep myself out of trouble, I think it is time to get 
another book on CGI for perl to study this topic in greater depth.  I 
have been spending time in a book store and researching further using 
Google and I have run across a title that may be appropriate.  The 
title is: "CGI Programming 101: Programming Perl for the WWW" and is a 
2004 publication.  The first 6 chapters are on line, so I can get some 
idea of the book's value by going through those chapters.  However, 
there is a reader's review of the first edition that seems to ring 
true and, moreover, is not complimentary.  That reader maintains the 
first 40 pages are good, but due to the choice of using the CGI 
package only modestly devalues the contents.  The other four reviewers 
were much more taken with this book.

I wonder has anyone here read this title and would they be willing to 
give an evaluation, having  someone in mind that has only had a brief 
introduction to perl's cgi scripting?

TIA
I would echo Chris' remarks about mod_perl, and the book not being worth 
its oats if it shys away from using CGI.pm.  Personally I would skip 
*all* of the CGI books, and get a good book on Perl itself. Learn the 
language not how to use it for a specific task. This will serve you in 
everything you do much better in the long run, then once you have 
learned Perl basics, it should be trivial to read any module's 
documentation to absorb the API and apply it.  CGI.pm has excellent 
docs, as do some of the other CGI helping tools, such as the various 
template systems, and modules like CGI::Application.  This path will 
also serve you well when it comes time to learn DBI for your database 
access, or any other module you need for core logic.  There are also 
excellent free online tutorials to teach you basic CGI programming, 
Ovid's comes highly endorsed (google).  CGI just isn't that difficult, 
-> print a header, maybe include a cookie or two, do a redirect, that's 
about it, the rest is just time and experience.

The two books I would suggest are Learning Perl and its sequence 
Learning Perl Objects, References, and Modules.  I give comments about 
them as well as other Perl books on my site.

Good luck,
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: CGI and mySQL book, any recommendation.

2004-05-31 Thread Wiggins d'Anconia
Paul Archer wrote:
Yesterday, Randal L. Schwartz wrote:

By the way... it's consensus amongst experts that MySQL has hit
nearly end-of-life.  If you're starting a new project, use PostgreSQL
instead.  A real Database... not a database wannabe.
The only reason to use MySQL these days is ignorance or legacy.
I've done a quick search on Google ("mysql vs postresql") and all the hits
I've seen, including a very detailed comparison of the two by Sourceforge
principal Tim Perdue give both high marks. I haven't read anything so far
supporting your position (MySQL is a wannabe and nearly end-of-life).
While I am not refuting your claims, I would appreciate a little evidence in
support of these claims so that I can better judge for myself.
Agreed. I have requested this from him before, but didn't get much.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Array Question

2004-05-14 Thread Wiggins d'Anconia
Luinrandir Hernsen wrote:

Can I do something like this?

perldoc -q quoting

@CityA="Suburb1, Suburb2, Suburb3";
@CityB="Suburb1, Suburb4, Suburb5";
I don't think the above is doing what you think it is. It is assigning 
one element (the first) of the array to a string.  If you are trying to 
assign the array 3 elements, you need to quote it differently,

my @CityA = ('Suburb1','Suburb2','Suburb3');
my @CityB = ('Suburb1','Suburb4','Suburb5');
$Var="TownCurrent";

$Var isn't used again in your example, what is its intended use?

$NewVar="$($TownCurrent)[1]";
The above is non-sensical...

I am trying to construct a sting from a variable.

Construct a string from a variable, or choose a variable using a string?

make sence?

Not really. Try to explain better what you are doing... Since this has 
nothing to do with CGI your question is better asked on 
[EMAIL PROTECTED] 

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Displaying Data in a Table

2004-05-08 Thread Wiggins d'Anconia
Baek, Steve wrote:
Fellow Perl-Mongers:

I'm trying to break apart the command `df -k` data and display it into an
html table:
Filesystemkbytesused   avail capacity  Mounted on
/dev/dsk/c0t2d0s03008783   83669 2864939 3%/
/dev/dsk/c0t2d0s34032654  886633 310569523%/usr
/proc  0   0   0 0%/proc
mnttab 0   0   0 0%/etc/mnttab
fd 0   0   0 0%/dev/fd
/dev/dsk/c0t2d0s719808378  250080 19360215 2%/var
swap  594216 104  594112 1%/var/run
swap  594448 336  594112 1%/tmp
/dev/dsk/c0t2d0s61985487  532663 139326028%/export
/dev/dsk/c0t2d0s51985487  356649 156927419%/opt
/dev/dsk/c0t2d0s47057565  914628 607236214%/usr/local
Would anyone happen to know the best way to do this? I'm thinking of putting
each line into an array...
Does anyone have any thoughts?

Consider using the Filesys::Diskfree module from CPAN.

What have you tried? Where did you fail?  Getting each line into an 
array is simple since the backticks will return an array when called in 
list context. Of course I assume you have taint checking on, are using 
full paths to the executable, checking its return code properly, etc.

CGI.pm has methods for building tables dynamically you should read its docs.

perldoc -f split

Might also prove useful.

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Form mailer and environment variables

2004-04-30 Thread Wiggins d'Anconia
Jan Eden wrote:
Hi all,

I wrote a little form mail script and start by setting the environment variables like this:

BEGIN {
$ENV{PATH} = "/usr/sbin";
delete @ENV{ qw( IFS CDPATH ENV BASH_ENV) };
}
Now the actual directory (.) is obviously not searched anymore, since

my $page_head = eval do('page_head.pl');

returns an empty $page_head while

my $page_head = eval do('./page_head.pl');

fills it with the appropriate content.

Commenting the BEGIN block above and printing $ENV{PATH} gives me:

/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:/System/Library/CoreServices

I cannot see the current working directory in that list (but I admit that I am not used to environment variables at all).

Can someone tell me how to restrict $ENV{PATH} but keep the script's ability to see something in its own directory?

The current working directory and the script's own directory are 
different things.

perldoc Cwd
perldoc FindBin
Does,

use FindBin qw($Bin);

my $page_head = eval do($Bin . '/page_head.pl');

Get you where you are going?

Out of curiousity what's with the 'eval do' stuff? What are you really 
trying to do?

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: OT: sockets

2004-04-30 Thread Wiggins d'Anconia
Frank DeLaTorre wrote:
All,

Is there a perl "sockets" list I can get a hold of ?

You mean mailing list?  Many mailing lists, are listed here:

http://lists.perl.org/

I didn't see one specifically for sockets. If you have socket related 
questions they wouldn't be off topic for the beginners list (not much is).

If this isn't what you meant, what do you mean?

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



OT: Re: Fwd: Interview Questions

2004-04-20 Thread Wiggins d'Anconia
drieux wrote:

This has what to do with CGI?

[..]

Sorry forgot to toggle off the 'bitterness' flag, apparently I have been 
at this way to long.


Wiggins, think about the idea for a moment,
what if it were you first time in the barrel
as the guy who had to do the interviewing of
folks who were going to be writing perl code
for some portion of the CGI project?
Couple of points that helped to create my bitterness,

1) hopefully if I were put in a position to actually interview, test so 
to speak, someone's aptitude in Perl or any technical skill, I would 
look to learn or expect to already know that skill, otherwise I have no 
way to judge what the interviewee provides as answers anyways.  which 
leads to point 2

2) as someone put in a position to handle hiring and being knowledgeable 
in a particular field, at least as well as need be for the position, I 
should be able to formulate my own questions that are pertinent to the 
situation.

I guess I have been to entirely too many interviews where the 
interviewee new next to nothing about anything, so much so that they 
couldn't tell if I was an idiot or an expert (I don't claim to know 
which I actually fall in if either, just know they can't tell either).

Where would you go to see if folks had a
stock set of basic perl code questions that
related to doing web-work.
Which brings me to my next point of bitterness

3) If I wanted Perl questions (as the OP didn't specifically request CGI 
questions) then I would go to a different Perl list, if I wanted CGI 
questions I wouldn't ask for Perl ones.  Now the bitterness, been to too 
many interviews and seen too many postings where Perl == CGI when they 
very much don't, despite what some well known and completely useless 
recruiting testers may suggest.  I could be an ace Perl programmer and 
not know thing one about CGI, or I could be a great CGI programmer and 
not know 5% of what is available from Perl (trust me I was, well not 
sure about the "great" part, but sufficient).

My lead engineer sets them up with a basic
walk through on basic so called 'simple perl questions'
that are actually a part of a diabolical interegation
method - since it starts out with
Right... but your lead engineer didn't have to ask experts what those 
questions were (see point 2).

what is CPAN?

A perfect example of a question that will likely find you Perl 
programmers as opposed to CGI scripters.  Depending on what you want and 
how much you want to pay it may be overkill

and based upon that he will roll into the questions
about building perl modules for CPAN. Which normally
fishes up things like have they or have they not
worked with h2xs and/or XS code, hence can they
do the bridge work to perl from pre-existing
c-code libraries that would be required for doing
some of the basic web-technology work.
Hmm not sure about that last bit, depends on how much C code you have 
around for doing web work. Personally outside of building XS modules 
others have provided on CPAN, I tend to avoid it like the plague.  But 
then I would say I am pretty good at building CPAN modules and other 
softwares, but haven't written line one of XS...

That also gets us chances to talk about things like
the t/ and 'make test' as a code coverage concern.
Boy it is really time I up and moved my *ss to a place where Perl is 
taken seriously...

At which point one knows a lot about what the
person does with 'perl' as a 'coder' or as a 'scripter'
and hence whether they will be useful at the design
layer or merely at the typing layer.
True, but the ability to decipher that from the answers provided by a 
candidate depends, to me, on knowing how to generate those questions in 
the first place.

Toss in the usual questions about why would one use
javascript, and how, vice perl on the server side.
lace a few basic 'write me a perl code implementation
of say the towers of hanoi problem or this or that,
and one check for how they deal with an ambiguously
worded coding problem - hence whether they should
be looking before leaping - and then one catches
their basic issues with actually doing perl code.
When can I interview... would certainly be a breathe of fresh air 
compared to the interviews I have been in.  So you guys actually expect 
your candidates to have brains?  what a novel concept, I will mention it 
to my boss ;-)

Seriously, I understand there *might* be a place for this, just don't 
think it is on a CGI list, jobs-discuss, maybe, though they don't seem 
to enjoy these types of discussions either.

To anyone out there doing hiring, please think about what questions you 
are and aren't capable of asking.

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Problems declaring variables in external packages

2004-04-18 Thread Wiggins d'Anconia
Richard Heintze wrote:

I'm using these statements in my main program:

use DisplayPCE qw($order $fnx );

...
print join("", map { qq[$_] }
@{$DisplayPCE::order});
...
When I use the debugger, I find that order is
undefined! When I use the browser to view the page,
the value of undef is confirmed.
When I abandon packages and put the definition of
order in the main program, it works!
Can anyone help me understand why my package is not
working?
 Siegfried
Here is the contents DisplayPCE.pm:

package DisplayPCE;
our  @EXPORT = qw($order );
my $order = ["First Name", "Last Name", "E-Mail",
"User Name", "Address", "City", "State", "Zip Code",
"Country", "Phone",  "Org.", "Gender", "Ethnicity",
"Age", "Religious Affiliation" ];
1;

@EXPORT isn't a Perl standard variable, it is just a convention provided 
by the standard Exporter module. So you will need to let Perl know that 
your package is an exporter and then it will automatically export what 
is in @EXPORT, you may want to consider using @EXPORT_OK instead.

package DisplayPCE;
require Exporter;
@ISA = qw( Exporter );
For more information:

perldoc Exporter
perldoc -f import
perldoc perlmod
perldoc -f use
http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Redirect using .htaccess or ?? ( kinda [OT] )

2004-04-07 Thread Wiggins d'Anconia
B McKee wrote:
Yeah, ok, this isn't completely on topic.  Please humour me (or at least
flame me politely).  I need to redirect people to a perl-CGI script
I have written a perl script that generates a series of active web
pages.  It's in the cgi-bin and works fine when accessed directly 
eg:

http://www.example.com/cgi-bin/index.pl

So, now I want to redirect anyone going to http://www.example.com 
to the above link instead.

I thought simply putting 
   Redirect permanent index.* /cgi-bin/index.pl
in a .htaccess file would work - but it doesn't seem to do anything.
Googling about seems to say it should work.
My ISP does allow .htaccess files as I'm using them elsewhere for auth
purposes.

What am I doing wrong?  Or what should I be doing instead?

Input appreciated.

Are you using Apache, and what version?

It appears that the second portion of the Redirect must be an absolute 
link, and I don't know that the first can be a regex/glob constuct... 
for that you appear to need RedirectMatch.

http://httpd.apache.org/docs/mod/mod_alias.html#redirect

Alternatively,

I believe you can put Rewrite rules into a .htaccess, at least depending 
on the base server config, and I use the following in my apache conf to 
do exactly what you state:

   
RewriteEngine on
RewriteRule ^/$ /cgi-bin/index [R,L]

Of course that is also assuming that mod_rewrite is available

HTH,

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: interactive perl programing

2004-03-31 Thread Wiggins d'Anconia
rob lester wrote:
I'm stumped on where to look but there must be a module to handle 
interactive programming. What I mean is printing out a list of things, 
the user selects what he wants, hits enter and the program continues. I 
presume the module would enable going back to change things and handle 
multipage input.

Have I missed something basic to perl programming? I've perused the 
camel books but I tend to learn by doing and at this stage may have 
skimmed over it

You are asking this question on a CGI list, do you mean interactive at a 
shell or over the web?

To remain on topic, I will assume the latter, in general Perl is used in 
a CGI context which usually means that there is a stateless session such 
that an "interactive" (or continually running process across multiple 
HTTP pages) doesn't really exist.  There are a number of ways around 
this hinderance, but none of which truly provide a stateful, interactive 
feel.

So what do you really mean?

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: html form output

2004-03-31 Thread Wiggins d'Anconia
Alex Maceda wrote:
I have a from processing script that I am trying to modify to spit out another html form, minus text boxes.  My question is can I somehow use the name portion of the POST request as a variable to have the value portion print in it's proper location?  ie.  I get a colon separated list with name value pairs.
 

 
name: john
date: 3-30-04
...
...
 

 
Can I use the 'name' 'date' part as a variable somehow, or is there a better way that I don't know of.   Thanks for any help in advance.
 
 -Alex Maceda
I have re-read your post again and think I understand what you are after 
this time, I was so confused before. I think, you are talking about 
using some sort of templating system.  There are loads of them 
available, a popular one is Template::Toolkit.

Essentially you are looking to interpolate the values provided in a 
form, into some other sort of document?

Currently I use a homegrown system but others can suggest their 
favorites, you might also want to check the archives, this is a pretty 
frequent discussion.

If this isn't what you meant, try to rephrase your question

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: AW: Apache::Session question

2004-03-29 Thread Wiggins d'Anconia
Please bottom post...

B. Fongo wrote:
The error occurs on initial call, so id should be empty be then. I
expect the routine to open a new session (see code below) if session_id
is empty - but it fails then. 
==
my $dbh = dbConnect();

# Get value of url or cookie id if any.
my $session_id = cookie("session"); #|| param("session");
my ($cookie, $session_ref);
if (defined($session_id)){

$session_ref = Store::Session->new ($dbh, $session_id);
defined ($session_ref) || die ("Couldn't retrieve session :"); 

} else {

$session_ref = Store::Session->new ($dbh, undef);
defined ($session_ref) || die ("Couldn't start a new session:");
$cookie = cookie (-name => "session",
   -value => $session_ref,
   -expires => "+3d",
   -domain => ".shop.com"
);
}
print header (-cookie => $cookie);
start_html();
   print p ("The session id is : $session_ref");#See the value of ref
here.
end_html();
==
Those Apache::Session docs aren't of good help to me in this matter. 


I assume you have double and triple checked that $session_id is in fact 
undefined.  And that your code above will always die (unless you fixed 
the issue with the 'return' noted before) because $session_ref will 
always be undefined.

You might consider moving your header print to before the session 
constructor call, and hacking in some debugging code into the failing 
module.  Have it print the value of the session id at that time,

$session->{data}->{_session_id}

Can you provide versions for Perl, Apache::Session, is this running 
under mod_perl?

Baffled

http://danconia.org





My implementation of Apache::Session::MySQL dies along the way, and
gives
unclear warning.
[error] Died at
/usr/lib/perl5/site_perl/5.8.0/Apache/Session/Generate/MD5.pm
line 40.
I decided to implement session as a module call Store::Session, so as
to

minimize recoding it in many script.

Babs




What does your session id have in it?  Is this error produced on the 
initial construction of the session (aka first request) or on subsequent

requests?  It appears that the error you are receiving is because the 
session id is either empty or contains a non-alphanumeric character. 
Try printing the session id before calling the constructor to see if 
there is something in it that shouldn't be

[snip comments we don't need]


package Store::Session;
use vars qw(@ISA @EXPORT);
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(new getId closeSession deleteObject);
use strict;
use Apache::Session::MySQL;
sub new {
   
   my ($dbh, $session_id) = @_;
   my %session;
   tie %session, "Apache::Session::MySQL", $session_id,{ 
   
   Handle => $dbh, LockHandle => $dbh

   };

return;#(\%session);



Why do you have the session reference commented out, your %session goes 
out of scope immediately following this method and no longer has any 
referents so will no longer be available, which could be part of your 
problem.  You may want to just remove the 'return' completely as 'tie' 
will return the referent, and assuming there is nothing after your 'tie'

then it will be the last expression in the sub and will be returned 
automagically.

See if that helps, if not come back...

http://danconia.org



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Active 'back' buttons

2004-03-29 Thread Wiggins d'Anconia
Rob Dixon wrote:
Hi guys.

What's the 'usual' way (if there is one) of implementing an 'active' back
button (which does the equivalent of the browser's back button but is
implemented in CGI code)?
If, say, I'm doing a database search and come up with a list of records,
each of which can be clicked on to provide the complete data for the single
record, how do I get back to the page with the list of records?
Obviously I can pass all the search criteria to the detail script and have
it pass them back again to repeat the search. But I know there must be a
better way to do it.
Thanks for any help.


Alternatively, if James and Andrew didn't get you there, possibly 
because you want to nest multiple levels, I have used cookies for this 
purpose. For instance if you attach a discussion forum to the detail 
record of a search listing, then if a user goes to the detail record, 
then to any number of postings in the forum they will lose their search 
link.  You could pass it around in links but I feel it is easier to 
throw a cookie at the user when they hit the search results, then at any 
point I know the last search result seen. I use the same code to set a 
cookie for the detail record so that cruising around the forum will also 
take them back to the record.  Naturally these are session cookies, and 
I am not terribly picky about dropping (l)users that don't have cookies 
enabled.  Mileage may vary

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: CGI module comparison

2004-03-29 Thread Wiggins d'Anconia
Andrew Gaffney wrote:
John Goodleaf wrote:

Hello,
I'm not on the list, so please CC me directly.
Although I'm a reasonably competent Perl user I have never actually
used it for CGI purposes, just for database querying/data munging.
You can imagine my perpetual confusion at finding the Perl books in
the "Web programming" section of the bookstore.
Anyway, I suddenly need to create CGIish app on short notice so I
need to ramp up quickly. I notice there are a lot of CGI modules on
CPAN, so I wonder if anyone has ever seen some kind of comprehensive
review of these modules--a summary of their various strengths and
weaknesses. I'd like to figure out which ones I might make use of,
so I'm actually looking to RTFM. I just haven't found an M that
suits.


CGI.pm seems to be the standard module for CGI programming. Look here:

http://search.cpan.org/~lds/CGI.pm-3.04/CGI.pm

Agreed, but do you have any particular ones in mind?  Some are wrappers 
or off shoots of the one referenced, such as

CGI::Lite and CGI::Safe

Others may be part of the core CGI installation.  Speaking of 'core' 
that would be a good reason to choose CGI.pm, aka it comes with newer 
versions of Perl by default.

PS How do you pronounce 'munging'? I'm having an argument with a
coworker. The split is between 'munjing' and 'mung -ing' (hard G).


I've always pronounced it the first way.

Yep, first.

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: GD Install Failure (was: Re: elsif issues ....still)

2004-03-29 Thread Wiggins d'Anconia
Allen Wang wrote:
-Original Message-
From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
Sent: Friday, March 26, 2004 6:11 PM
To: Allen Wang
Cc: [EMAIL PROTECTED]
Subject: Re: GD Install Failure (was: Re: elsif issues still)
Please bottom post...

Allen Wang wrote:

The first error message should be 
 "
   Warning: prerequisite GD failed to load: Can't load '/opt/perl5/lib/site_perl/5.6.0/PA-RISC2.0/auto/GD/GD.sl' 
for module GD: No such file or directory at /opt/perl5/lib/5.6.0/PA-RISC2.0/DynaLoader.pm line 200.
at (eval 4) line 3
Compilation failed in require at (eval 4) line 3.
Warning: prerequisite GD::Text 0.80 not found at /opt/perl5/lib/5.6.0/ExtUtils/MakeMaker.pm line 340.
Unable to open MakeMaker.tmp: Permission denied at /opt/perl5/lib/5.6.0/ExtUtils/MakeMaker.pm line 747.



What OS are you on?
HP/UX 11.0
Don't have experience on it...

 What c compiler do you have installed?
Regular C, not gcc
This shouldn't matter, but probably prevents me from debugging 
compilation and linking issues...

Do you have GD.pm installed?
Not sure
GD is a prerequisite for GD::Graph and will likely be the hard part of 
this installation, concentrate on getting it installed.

perl -MGD -e 1

Will succeed if GD is available, otherwise it will give you the "Can't 
locate GD.pm in ..." error.  If it is not found install GD, after 
reading content of next answer.

 Do you have gd libs installed? 
Not sure
GD.pm is simply a Perl module wrapper around the gd c libs, so they are 
a prerequisite to get GD.pm installed.  Sorry I can't provide help to 
find gd libs on HP/UX with cc.   I can tell you that GD is available at 
the following location:

http://www.boutell.com/gd/

And is probably available for HPUX, it works on Solaris 8 and Linux with 
gcc.

Are you running this through CPAN or directly from a download?  
I download this through CPAN
Are you root and/or did you specify a prefix that you can write to?  
Yes, login as root
Do you have write permission on the cwd?
Yes
I'm surprised you would get a permission denied error, hmm

See if this helps, if not you might post to the regular 'beginners' list 
as there is probably more diversity there.  Surely someone around is on 
HP-UX and can help.

http://danconia.org

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



Re: Apache::Session question

2004-03-26 Thread Wiggins d'Anconia
B. Fongo wrote:


My implementation of Apache::Session::MySQL dies along the way, and
gives
unclear warning.
[error] Died at
/usr/lib/perl5/site_perl/5.8.0/Apache/Session/Generate/MD5.pm
line 40.
I decided to implement session as a module call Store::Session, so as to
minimize recoding it in many script.
Babs


What does your session id have in it?  Is this error produced on the 
initial construction of the session (aka first request) or on subsequent 
requests?  It appears that the error you are receiving is because the 
session id is either empty or contains a non-alphanumeric character. 
Try printing the session id before calling the constructor to see if 
there is something in it that shouldn't be

[snip comments we don't need]



package Store::Session;
use vars qw(@ISA @EXPORT);
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(new getId closeSession deleteObject);
use strict;
use Apache::Session::MySQL;
sub new {

my ($dbh, $session_id) = @_;
my %session;
tie %session, "Apache::Session::MySQL", $session_id,{ 

Handle => $dbh, LockHandle => $dbh

};

return;#(\%session);

Why do you have the session reference commented out, your %session goes 
out of scope immediately following this method and no longer has any 
referents so will no longer be available, which could be part of your 
problem.  You may want to just remove the 'return' completely as 'tie' 
will return the referent, and assuming there is nothing after your 'tie' 
then it will be the last expression in the sub and will be returned 
automagically.

See if that helps, if not come back...

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: GD Install Failure (was: Re: elsif issues ....still)

2004-03-26 Thread Wiggins d'Anconia
Please bottom post...

Allen Wang wrote:
The first error message should be 
  "
Warning: prerequisite GD failed to load: Can't load '/opt/perl5/lib/site_perl/5.6.0/PA-RISC2.0/auto/GD/GD.sl' 
for module GD: No such file or directory at /opt/perl5/lib/5.6.0/PA-RISC2.0/DynaLoader.pm line 200.
 at (eval 4) line 3
Compilation failed in require at (eval 4) line 3.
Warning: prerequisite GD::Text 0.80 not found at /opt/perl5/lib/5.6.0/ExtUtils/MakeMaker.pm line 340.
Unable to open MakeMaker.tmp: Permission denied at /opt/perl5/lib/5.6.0/ExtUtils/MakeMaker.pm line 747.

What OS are you on?  What c compiler do you have installed?
Do you have GD.pm installed?  Do you have gd libs installed? Are you 
running this through CPAN or directly from a download?  Are you root 
and/or did you specify a prefix that you can write to?  Do you have 
write permission on the cwd?

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



GD Install Failure (was: Re: elsif issues ....still)

2004-03-26 Thread Wiggins d'Anconia
Please start a new thread when posting (and bottom post when replying)...

Allen Wang wrote:
When I was trying to install GDGraph-1.43
It failed due to the following message
"
Warning: prerequisite GD failed to load: Can't load 
'/opt/perl5/lib/site_perl/5.6.0/PA-RISC2.0/auto/GD/GD.sl' for module GD: No suc.
 at (eval 4) line 3
Compilation failed in require at (eval 4) line 3.
Warning: prerequisite GD::Text 0.80 not found at 
/opt/perl5/lib/5.6.0/ExtUtils/MakeMaker.pm line 340.
Writing Makefile for GD::Graph
"
But I could not find GD::Text 0.80 through CPAN


In general the value specified is a minimum version, so you should try 
whatever the most recent is, unless it is documented that the module 
can't accept newer versions.  So I would go with GD::Text 0.86 it 
appears to be the most recent.

The first error is a bigger concern though, and appears to be related to 
the GD module rather than GD::Text.  Did GD successfully install?  What 
is the full error message as provided, the one you pasted appears to be 
snipped ('No suc.')?

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Regex Help!

2004-03-21 Thread Wiggins d'Anconia
Sara wrote:
I am looking for a regex which would extract the intials from a
string i.e.
str = "Doe, John L.L.M";

$str =~ /(^(\w)).*?((\s)(\w)).*?((\s)(\w))/;

$initial = $1.$2.$3;

print "$initial";

The above code is not serving my purpose.

String constants: There would be always 3 words (obvioulsy with 2
spaces in between) in the string however string may contain periods
(.) and (,) in it. I am looking to extract.
Negation is probably easiest in the case that you know a word does NOT 
contain a space...

1. First Character of the string.
2. Next two Characters after space in the String.
#!/usr/local/bin/perl
use strict;
use warnings;
my $str = "Doe, John L.L.M";

if ($str =~ /^(\S)\S*\s(\S)\S*\s(\S)\S*/) {
print "$2.$3.$1\n";
}
else {
warn "Pattern failed";
}
Doe, John L.L.M should be "DJL"
Simth, G. M.D. should be "SGM"
Interesting order for initials, you will have to adjust mine back...

Any help, please?
HTH,

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: General question about HTML form

2004-03-20 Thread Wiggins d'Anconia
WC -Sx- Jones wrote:
Bill Tribley wrote:

CGI was written from the beginning to not compromise
 > the security of the box on which it runs.

Just because a module is secure doesn't mean the
resulting application is.
Correct, but I think Bill was specifically meaning 'CGI.pm' is secure so 
you don't have to worry about *it*.  In other words, if you use some 
other library you have to worry about your application *and* that 
library's faults, as opposed to just your application's.

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: problems parsing web form information into a perl script

2004-03-07 Thread Wiggins d'Anconia
Mark Martin wrote:
Hi,
I've got a web form that allows a user to browse to an excel file on their computer 
and input it and the year as parameters to run a perl script
FORM :



SCRIPT:

use strict;  # always
use warnings;# usually
use CGI;
use Spreadsheet::ParseExcel;
$q=new CGI;
my $oExcel = new Spreadsheet::ParseExcel;
my $user_ssheet=$q->param('file');
my $oBook = $oExcel->Parse($user_ssheet);
my $year=$q->param('year');
BUT I keep getting a "HTTP 500 - Internal server error". However if I hard code in the reference to the excel file, like so :

my $user_ssheet="excel_file.xls";

it works fine !? Is it something to do with paths from the file input type?
I assume your form's enctype is set to allow uploads. You should review 
the docs for CGI particularly the section on uploading files,

http://search.cpan.org/~lds/CGI.pm-3.04/CGI.pm#CREATING_A_FILE_UPLOAD_FIELD

You should switch to using the 'upload' method and store the contents of 
the file locally first, or check to see if Spreadsheet::ParseExcel will 
accept a filehandle instead of a location.  Essentially you are correct 
the value returned in scalar context for param I think is going to be 
the path of the file on the remote (client) side, which will be invalid 
on the server side.  Your 500 error is probably from lack of header 
rather than anything to do with the file upload, unless 'Parse' is 'die'ing.

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: help with perl setup...and upgrade

2004-02-24 Thread Wiggins d'Anconia
Catriona Pure Scents wrote:
Hi guys,

many moons ago when I was a complete novice on perl...(only a little more advance now, but at least I have some scripts running and modifying them as need be..) I had a version of perl that ran on my pc as though it were a web servernot through the command line.

Although it is great to see what is happening on the command line, I want to see the way it runs on a more visual basis, the way it will when uploaded.

would anybody kindly let me know what I need to get hold of and where to get hold of I am presuming it is the interpreter that I need.

I am also looking for a program to run in conjunction with win2000 to operate as a mail server type thing on the same pcany recommendations would be fantastic.

Yep I am setting up and old pc to do all my testing on without internet connectivity.

Out of curiousity why not install a free unix on it instead of Windows? 
Linux, OpenBSD, etc.  You should probably install whatever is installed 
on the production machine so that they match if you are really going to 
use it as a test bed.  Alternatively you could install Cygwin which will 
provide easy installation for Perl, Apache, Sendmail (or others) and 
simulate a Unixesque world on your windows installation.  IIS was 
mentioned and personally I would avoid it like the plague, other than 
the licensing and cost issues, there is security and performance issues 
to worry about.  Apache should install cleanly on windows outside of 
Cygwin, but is more difficult I imagine.

http://www.cygwin.com

and finally

I am hoping that someone may be able to point me in the right direction for websites docs that can help me upgrade my perl3 perl4 scripts to perl5.

Upgrade them how?  Most Perl3-4 should run using the Perl 5 interpreter, 
any modules will need to be reinstalled but CPAN can help with that.

perldoc perl

Will provide a list of delta's from older versions to more recent, 
though I don't think they go back past Perl5's initial release.  I would 
give the scripts a shot and see where they fail, then ask specific 
questions (probably in [EMAIL PROTECTED] rather than CGI).

Thanks in advance to one and all who read and / or respond.

Good luck and welcome back...

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Apache::Cookie problems

2004-02-16 Thread Wiggins d'Anconia
Andrew Gaffney wrote:
Andrew Gaffney wrote:

sub init_db {
  $dbh = 
DBI->connect("DBI:mysql:database=skyline;host=192.168.254.25", "root", 
"linux", {'RaiseError' => 1});
}


And before anyone gets on me about posting DB passwords, keep in mind 
this is on a test server not connected to the internet.

Why would we care, just don't complain when you have a security breach 
:-)... personally I have more problems with using 'linux' as a password.

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Apache::Cookie problems

2004-02-16 Thread Wiggins d'Anconia
Andrew Gaffney wrote:
I'm creating my own module to handle sessions and other stuff for my site:


package Skyline;
use Apache::DBI;
use Apache::Cookie;
use Exporter;
@ISA = ('Exporter');
@EXPORT_OK = ('check_login', 'init_db', '$dbh');
@EXPORT = ('check_login', 'init_db', '$dbh');
our $dbh;
sub check_login {
  my %cookies = Apache::Cookie->fetch;
  return ($cookies{uid}->value, $cookies{ut}->value, 
$cookies{sid}->value, $cookies{rnd1}->value);
}

sub init_db {
  $dbh = DBI->connect("DBI:mysql:database=skyline;host=192.168.254.25", 
"root", "linux", {'RaiseError' => 1});
}

1;

In order to test my code, I've written another little test script:


#!/usr/bin/perl
use CGI;
use Skyline;
my $cgi = new CGI;

my ($uid, $ut, $sid, $rnd1) = check_login();

print $cgi->header;
print "sid = $sid, rnd = $rnd1, uid = $uid, ut = 
$ut";


which give me 'sid = Apache::Cookie=SCALAR(0x872a958), rnd = , uid = 
Apache::Cookie=SCALAR(0x86b1ce0), ut = Apache::Cookie=SCALAR(0x86c0874)' 
or a variation with different scalar addresses. What am I doing wrong? I 
know the cookies exist. I wrote another test script:
So how do you set rnd?  I am assuming that is what you are asking about, 
though the question "What am I doing wrong?" is difficult to answer if 
we don't know what you are *trying* to do.  Have you checked the 
expiration date of the cookie, and if it has a domain/path restriction? 
 I don't see anything in your code specifically, other than the absence 
of strict and warnings naturally.


#!/usr/bin/perl
use CGI;
use Apache::Cookie;
my $cgi = new CGI;
my %cookies = Apache::Cookie->fetch;
print $cgi->header;
foreach (keys %cookies) {
  $cval = $cookies{$_}->value;
  print "$_ = $cval";
}

This outputs all 4 cookies and their values. Anyone have any idea what 
I'm doing wrong?

I assume you aren't calling this the second time after calling a script 
that sets the cookies.  Have you tried adding an exists or definedness 
in the 'check_login' function to make sure the cookie really is in the 
hash? How about printing all of your cookies from there?

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Webhosting with good Perl support

2004-02-14 Thread Wiggins d'Anconia
Casey West wrote:
It was Saturday, February 14, 2004 when Robert took the soap box, saying:
: Casey West wrote:
: 
: >It was Saturday, February 14, 2004 when Jan Eden took the soap box, saying:
: >: Hi all,
: >: 
: >: Does anyone have an additional recommendation, so I can compare
: >: some more?
: >
: >I'm somewhat partial to pair Networks. :-)
: >
: >I think we've got some really great Perl support.
: >
: >http://www.pair.com/support/knowledge_base/our_network_and_servers/installed_perl_modules.html
: >
: >I think we do a good job.  So does netcraft, for what it's worth.
: >
: >http://uptime.netcraft.com/perf/reports/Hosters
: >
: >  Casey West
: >
: Is this CGI only?

In most cases, yes. mod_perl doesn't play nice with managed hosting.

  Casey West

After getting used to it this was my compelling reason for using 
Westhost, though it is not as speedy the account runs in a "Virtual 
Private Server" such that I have my "own" apache instance, chroot 
environment, mysql instance, etc.  So I can shell in, hack up the apache 
config however I like and HUP the servers, setting whatever I want. 
Which makes mod_perl not a problem, even in the managed hosting 
environment, of course I wouldn't suggest this for someone who doesn't 
already know what they are doing, as the ISP might not look to highly 
upon you breaking something...

http://www.sphera.com for more...

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: OT: Webhosting with good Perl support

2004-02-14 Thread Wiggins d'Anconia
Frank DeLaTorre wrote:
bob,

yep that helps me a ton, thanks...honestly! Dang, now I'm wondering if I
should wipe Debian GNU/linux off the HDD and put OpenBSD...this is an
Ultra10 so I may not be able to find a port...

Are we talking a home box or a server?  Randal's original point was 
security, while I don't know (never used OpenBSD personally), I would 
bet that there are things Linux distros can offer that OpenBSD can't. 
Out of the box OpenBSD beats Linux hands down on security, but ease of 
use, features, installed software, speed, hardware support, support 
community, etc. are all factors to consider, not *just* security.

Even Randal admitted to conceding one of these features,

"It's just a difference in philosophy, and has its trade offs, but I'm
willing to put up with fewer compatible packages in exchange for more
security."
While I do think logging into the server every 3 hours is a bit of an 
exageration, of course with automated patching these days not sure why 
one would need to at all

Running out and switching OSes based on one opinion, even if it is a 
valid one, is more of a security risk than any of the Linux bugs. Want 
to play around with OpenBSD, then by all means, but don't switch your 
environment based on a couple comments in a CGI perl forum.

Besides you are in a *nix world, you are 95% (at least) more secure than 
any windows boxen...

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: compile error

2004-02-14 Thread Wiggins d'Anconia
Rick Triplett wrote:
Help -- I'm getting the following compile error:
Can't declare scalar assignment in my at 
/big/dom/xlibertylearning/cgi-bin/reader_writer.cgi line 12, near ");"
The offending code is ...
#!/usr/bin/perl -w
use strict;
use DB_File; # module for Berkeley DBM w/ DB_HASH file type
use Fcntl; # to help with file handling

# Declare and assign 'header' variables
my ($file_to_read = "subj.tab",
$file_to_write = "subj",
$course_name = "subj",
$course_quarter = "1",
$course_level = "1",
$course_max = "5"
);
Multiple assignment in list context is not handled like the above, you 
are trying to 'my' a list of expressions, which doesn't work

my ($file_to_read, $file_to_write, $course_name, $course_quarter, 
$course_level, $course_max) = ('subj.tab','subj','subj',1,1,5);

Don't know what you are doing but you may want to consider a hash...

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Alternative to Storable

2004-02-13 Thread Wiggins d'Anconia
Jan Eden wrote:
zentara wrote:

I will check this out. My ISP is really cheap, though, but more and more it looks like being too cheap. ;)

Cheap and inexpensive are two different things, especially in the land 
of hosting.  zentara's looks like a pretty good deal, I will also 
suggest Westhost (don't work for or have a relationship other than as a 
client)...

http://www.westhost.com

Shop around and definitely challenge your ISP about their default 
software installations and shell access

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Include Files in Perl?

2004-02-13 Thread Wiggins d'Anconia
Charlie somerville wrote:
Yeah, that looks pretty good
"Alexander Blüm" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
that doesn't sound too good. sounds like loading all into memory, split
it up into arrays and then finally printing the contents to the browser.
bleh!
how aout this:

#somewhere in the code:
&include("/includes/header.html");
...
&include("/includes/footer.html");
### subroutine
sub include{
 my $filename = shift;
 open(FH, "<$filename") || die "cannot open $filename: $!\n";
 while (){
   print $_;
 }
 close FH;
}
Drop the ampersands, they aren't needed in this context... from perldoc 
perlsub:

"Subroutines may be called recursively.  If a subroutine is called using 
the "&" form, the argument list is optional, and if omitted, no @_ array 
is set up for the subroutine: the @_ array at the time of the call is 
visible to subroutine instead.  This is an efficiency mechanism that new 
users may wish to avoid."

Also remember that your CGI script has no way to understand your 
relative paths, so /includes is at the root of the server *NOT* the root 
of your web document tree, so you will need relative paths or full 
filesystem paths, unless you really do have an 'includes' directory off 
of /, which I suppose is possible in a chroot jail or the like (though 
isn't all that common).

If you are going to use $_ then you might as well drop it from the 
print, it is implicit.

perldoc -f print
"If LIST is also omitted, prints $_ to the currently selected output 
channel."

Personally I prefer to avoid using $_ altogether, but this is probably 
the simplest scenario where it makes sense, but if you are going to use 
it, use it all the way.

And you may want to either not 'die' in your include sub or wrap the 
whole call in an eval, at this point you have to have printed a header, 
and if you die because of a failed open (missing file, permissions, or 
many other reasons) then you will be sending back a malformed document 
that possibly (probably?) won't render properly, if at all, your user 
rather than getting a silly error may be staring at a completely blank 
screen.

eval { include('../htdocs/includes/header.html'); };
if ($@) {
   print "

Re: How to explicitly declare an array of hashes?

2004-02-08 Thread Wiggins d'Anconia
Please group reply so everyone can help and be helped, and bottom post.

Richard Heintze wrote:

Wiggins and Jan,
 Thank you very much for such an extremely prompt
response. 

 You are right, I want 

my @PCEs = ();

 I'm using the Win32 ODBC API on acres of legacy code
that does not "use strict" or "use warnings". I
thought the Win32 ODBC API was compatible with DBI but
according to your comments, I'm nonstandard. I guess I
should try to be compliant. I thought I read that the
Win32 ODBC API was a subset of DBI. I guess I'm
incorrect.
Legacy code is a bear, obviously sometimes it can't be helped and just 
adding strict/warnings won't work, but you should get into the habit of 
writing new code and your changes so that eventually they can be added 
once all the legacy code is updated.  As for the ODBC API, I am not 
familar with it, so your code may be correct, but the DBI itself does 
not have the two methods you used, which isn't necessarily a problem, 
but you need to make sure to provide us enough info so that we know what 
you are up to.  It seems very odd that FetchRow would be called in a 
boolean context but maybe it is (read: I would hate to have a method 
called 'Fetch' anything and not store the value it returns, eck). I 
don't know if it is a subset of DBI but I sort of doubt it since it has 
different method names.

 I'm working on a cgi page called "Administer Cases". 
I just explained to my client that the labor costs are
three or four times what they should be on account of
the fact that this page is in desperate need of a
rewrite. He said no, patch it up some more. Oh well.

Yep, sounds about right. Just make sure you charge him what you 
should... if he wants to pay it, then by all means let him.

  So if say '$PCEs[0]{"xyz"} = 44;' is there any way I
can make '$PCEs[1] = "abc";' generate a syntax or
runtime error because I forgot the extra "{}"
(assuming I could turn on "use strict; use
warnings;").
Not a syntax error, but if it is in a loop or you are calling a sub with 
the value or something then you could add an extra check using the 'ref' 
method.

perldoc -f ref

But then you just have more code in there to look for bugs, rather than 
handling the business logic and fixing the bugs.  Type issues should 
either be fixed in the interface by checking values passed to 
encapsulated code, or in the main by testing.  It should be very 
apparent at runtime if you are assigning a scalar where a hashref was 
expected.

http://danconia.org

--- Wiggins d'Anconia <[EMAIL PROTECTED]> wrote:

Richard Heintze wrote:

Is there a way I can explictly declare that each
array

cell contains a hash?

Only with a loop of some sort.


Here is the only way I know to do it:

my @PCEs=[];
This does not do what you think it does. This is
assigning an anonymous 
array reference into the first element of the array.


while ($Data->FetchRow()) {
What is 'FetchRow' doing?  This is not normal DBI,
and is being used in 
a true/false context? You also don't need the empty
parens, but that is 
more stylistic.


 my %dh = $Data->DataHash();
 $PCEs[$cn]{$dh{"id"}} = $dh{"ridPCE"};
Where did $cn come from?  Are you using strict and
warnings? If not you 
need to be.  $cn is not changing in your loop so
while FetchRow is true 
you are going to continually overwrite the value you
are assigning which 
will cause your array to have one value, the last.
If you are changing 
$cn in the DataHash method you shouldn't be and have
broken the 
encapsulation, but that is a design issue.


}

This "my" declaration only says that it is an
array,

not an array of hashes. Can I improve upon this?

'my' is for defining scope and nothing more. It is
how you use the 
variable that determines what it contains. Your
assignment statement 
will autovivify the element in the array into a hash
reference as you 
want so there is no need to improve it. If you want
to force an array 
element into a hash reference then something like,

$PCEs[$cn] = {};

Will set the element of PCEs at index $cn to an
empty hash reference, 
but isn't necessary if you use the variable
initially as above.

perldoc -f my
perldoc perlreftut
perldoc perlref
perldoc perllol
perldoc perldsc
You should read through the docs above, it will help
you understand 
complex data structures in Perl.  You may also want
to look at,

perldoc Data::Dumper

To help you visualize what your data structures
contain. And ALWAYS do,
use strict;
use warnings;
At the top of your code

http://danconia.org


__
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html



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



Re: How to explicitly declare an array of hashes?

2004-02-08 Thread Wiggins d'Anconia
Jan Eden wrote:

Richard Heintze wrote:


Is there a way I can explictly declare that each array
cell contains a hash?
Here is the only way I know to do it:

my @PCEs=[];
while ($Data->FetchRow()) {
my %dh = $Data->DataHash();
$PCEs[$cn]{$dh{"id"}} = $dh{"ridPCE"};
}
This "my" declaration only says that it is an array,
not an array of hashes. Can I improve upon this?


Why would you want to declare this? Since the anonymous hashes spring into existence automatically, no declaration is necessary.

To access an element of your referenced hash, you have to add another scalar symbol like this:

$$PCEs[$cn]{$dh{"id"}} ...

Adding an extra $ here causes Perl to look for $PCEs a scalar, which 
doesn't exist rather than dereference the PCEs array.

Alternatively, you could improve the readability by using the arrow dereference, though:

$PCEs[$cn]->{$dh{"id"}} = $dh{"ridPCE"};

Using the arrow operator is a good idea for readability but isn't 
related to your extra $ above.

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: How to explicitly declare an array of hashes?

2004-02-08 Thread Wiggins d'Anconia
Richard Heintze wrote:
Is there a way I can explictly declare that each array
cell contains a hash?
Only with a loop of some sort.

Here is the only way I know to do it:

my @PCEs=[];
This does not do what you think it does. This is assigning an anonymous 
array reference into the first element of the array.

while ($Data->FetchRow()) {
What is 'FetchRow' doing?  This is not normal DBI, and is being used in 
a true/false context? You also don't need the empty parens, but that is 
more stylistic.

  my %dh = $Data->DataHash();
  $PCEs[$cn]{$dh{"id"}} = $dh{"ridPCE"};
Where did $cn come from?  Are you using strict and warnings? If not you 
need to be.  $cn is not changing in your loop so while FetchRow is true 
you are going to continually overwrite the value you are assigning which 
will cause your array to have one value, the last. If you are changing 
$cn in the DataHash method you shouldn't be and have broken the 
encapsulation, but that is a design issue.

}

This "my" declaration only says that it is an array,
not an array of hashes. Can I improve upon this?
'my' is for defining scope and nothing more. It is how you use the 
variable that determines what it contains. Your assignment statement 
will autovivify the element in the array into a hash reference as you 
want so there is no need to improve it. If you want to force an array 
element into a hash reference then something like,

$PCEs[$cn] = {};

Will set the element of PCEs at index $cn to an empty hash reference, 
but isn't necessary if you use the variable initially as above.

perldoc -f my
perldoc perlreftut
perldoc perlref
perldoc perllol
perldoc perldsc
You should read through the docs above, it will help you understand 
complex data structures in Perl.  You may also want to look at,

perldoc Data::Dumper

To help you visualize what your data structures contain. And ALWAYS do,

use strict;
use warnings;
At the top of your code

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: db to HTML with checkboxes

2004-02-03 Thread Wiggins d'Anconia
Andrew Gaffney wrote:
Wiggins d'Anconia wrote:

Andrew Gaffney wrote:

I have a Perl CGI script that runs a query against a MySQL table. I 
have about 20 boolean values that I want shown as checkboxes in the 
produced HTML, but I don't want to have to do something like the 
below for every value.

The key to this is contriving good names for the check boxes, usually 
such that they can be looped over...


That's not an option. The values have been defined months and months ago 
and are hard-coded in a number of places.

Ah the power of poor planning

[code]
if($ref->{somevalue}) {
  print "";
} else {
  print "";
}
[/code]
foreach my $index (1 .. 20) {
   print "{"somevalue$index"} ? ' checked=checked' : '') . ">";
}

The (exp ? string : string) is called the ternary operator, perldoc 
perlop for more.


Will this work in a here doc?
Don't know... god I hate here docs... give it a shot but I doubt it.


Converting back is easy enough:

[code]
use CGI;
my $cgi = new CGI;
my $p = $cgi->Params;
$somevalue = $p->{somevalue} or $somevalue = 0;
[/code]
If it was checked, it will be passed along with a value of 1. If it's 
not checked, it won't be passed along and will return undef if I try 
to grab it from the $p hash. Although, how could I quickly convert 
all the values back for something like:

[code]
$dbh->do("UPDATE table SET somevalue1='$p->{somevalue1}', 
somevalue2='$p->{somevalue2}', somevalue3='$p->{somevalue3}', 
somevalue4='$p->{somevalue4}', somevalue5='$p->{somevalue5}', 
somevalue6='$p->{somevalue6}'");
[/code]


Generally what I do is break up the statement, so

my @bind;
my $set = '';
foreach my $index (1 .. 20) {
  if (defined $p->{"somevalue$index"}) {
  $set .= ', ' if ($set ne '');
  $set .= '?';
  push @bind, $p->{"somevalue$index"};
  }
}


Won't work in my case due to the already defined field names.
Theoretically the looping construct should still work, but rather than 
creating a list based on an incrementing index just create an array and 
step through the elements of the array... If that isn't possible then 
likely you need to rethink your design and refactor a lot or grunt it 
out and the next time you have a chance to re-examine the whole 
structure do so Sometimes the simplest (and only) solution is to 
copy and paste, granted that usually indicates a lack of upfront 
planning or a mindset where the system is evolving constantly isn't 
taken (read: eXtreme Programming or the like).


my $st = "UPDATE table SET $set";

Now you have constructed your update statement, pass it and the bind 
variables to a prepare/execute ('do' might work too) but binding 
variables works really well here (and for any other fields that may 
need to be apostrophe escaped, etc.).

Would MySQL choke if it was expecting a non-null integer value for 
all of those? If so, how can I handle that without a lot of code? I 
currently handle the data both ways by having a textfield with a '1' 
or '0' in the generated HTML, but it looks ugly.


Depends on the table definition.  If you have fields marked as NOT 
NULL then it might since it won't like NULL values, though empty 
strings are not NULLs.  Alternatively set a default value in the table 
definition, for instance I use 0 for off usually, anything that I am 
not checking NULLs against I automatically have initialized to 0.

I am not entirely sure I understood what you are after, if this didn't 
get it please clarify and I (we) will see what we can come up with...


At first glance, as long as the ternary operator works in a here doc, 
displaying the HTML will work. I already have all of the boolean values 
set as NOT NULL with a default value of '0' so I shouldn't have to do 
anything extra to put them back in if they're not checked.

Alternatively you could use an HTML parser to look for the input fields, 
then adjust the values of the fields while looping over your template, 
rather than dropping a bunch of ternaries (plural?) into a here doc, but 
I suspect you won't like that suggestion either, though it has worked 
very well in the past for me, and means I only need one form parsing 
routine and some template files rather than a bunch of HTML hardcoded 
into a heredoc.

to each their own

http://danconia.org

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



Re: Deleting a file(s) with variables _HELP!

2004-02-03 Thread Wiggins d'Anconia
Luinrandir Hernsen wrote:
I have a group of files I need to delete.
They have a format like this.
c:\game\data\(variable)info.file(variable)

the actual file name is
c:[EMAIL PROTECTED]
I need to delete all files in this directory with the partial name of
"info.file"
where the (variable) is a wildcard.
In dos it would be *file*.*

What is it in perl?

I found the delete command as "unlink"
$gamedata="?player.dat?";
unlink($gamedata);
perldoc -f unlink
perldoc -f glob
This is generally handled with either a fileglob as the above docs 
indicate or by using a loop with opendir,readdir...

perldoc -f opendir
perldoc -f readdir
will this delete the file on the players computer or on my server
I want it to delete the file on the players computer.
Back up a minute... where is the script?  Since you are posting in a CGI 
forum, if the script is server side it won't delete it from the 
'players' computer...but then how did it get created there in the first 
place?  We are going to need more info about what you are doing, be 
careful with the client/server model You may also want to consider:

use taint;   (perldoc taint)

Thanks for your help.


http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: db to HTML with checkboxes

2004-02-03 Thread Wiggins d'Anconia
Andrew Gaffney wrote:
I have a Perl CGI script that runs a query against a MySQL table. I have 
about 20 boolean values that I want shown as checkboxes in the produced 
HTML, but I don't want to have to do something like the below for every 
value.

The key to this is contriving good names for the check boxes, usually 
such that they can be looped over...

[code]
if($ref->{somevalue}) {
  print "";
} else {
  print "";
}
[/code]
foreach my $index (1 .. 20) {
   print "{"somevalue$index"} ? ' checked=checked' : '') . ">";
}

The (exp ? string : string) is called the ternary operator, perldoc 
perlop for more.

Converting back is easy enough:

[code]
use CGI;
my $cgi = new CGI;
my $p = $cgi->Params;
$somevalue = $p->{somevalue} or $somevalue = 0;
[/code]
If it was checked, it will be passed along with a value of 1. If it's 
not checked, it won't be passed along and will return undef if I try to 
grab it from the $p hash. Although, how could I quickly convert all the 
values back for something like:

[code]
$dbh->do("UPDATE table SET somevalue1='$p->{somevalue1}', 
somevalue2='$p->{somevalue2}', somevalue3='$p->{somevalue3}', 
somevalue4='$p->{somevalue4}', somevalue5='$p->{somevalue5}', 
somevalue6='$p->{somevalue6}'");
[/code]

Generally what I do is break up the statement, so

my @bind;
my $set = '';
foreach my $index (1 .. 20) {
  if (defined $p->{"somevalue$index"}) {
  $set .= ', ' if ($set ne '');
  $set .= '?';
  push @bind, $p->{"somevalue$index"};
  }
}
my $st = "UPDATE table SET $set";

Now you have constructed your update statement, pass it and the bind 
variables to a prepare/execute ('do' might work too) but binding 
variables works really well here (and for any other fields that may need 
to be apostrophe escaped, etc.).

Would MySQL choke if it was expecting a non-null integer value for all 
of those? If so, how can I handle that without a lot of code? I 
currently handle the data both ways by having a textfield with a '1' or 
'0' in the generated HTML, but it looks ugly.

Depends on the table definition.  If you have fields marked as NOT NULL 
then it might since it won't like NULL values, though empty strings are 
not NULLs.  Alternatively set a default value in the table definition, 
for instance I use 0 for off usually, anything that I am not checking 
NULLs against I automatically have initialized to 0.

I am not entirely sure I understood what you are after, if this didn't 
get it please clarify and I (we) will see what we can come up with...

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: use lib "../" for javascript and css files?

2004-01-25 Thread Wiggins d'Anconia
Richard Heintze wrote:
I have a perl cgi file that works fine. However, I
want to move it into a sub directory -- the cgi-bin
directory for Apache HTTPD is just getting too
crowded.
I know that feeling...

So I created a directory and moved my file. It could
not find my evidence_db.pm file (which defined
variables like $sCssRoot that contain the paths to my
cascading style sheet directory). So I added the
command use "../" and this lib statement solved one
problem.
Generally all lower case module descriptions are used for pragmas, with 
all upper case used for top level groupings, you may want to switch to a 
mixed case module name...


However, as I mentioned, I also have js (javascript)
and css (cascading style sheet) files that work in the
top level directory but don't work now. Is there a way
I can painless move files around in directories?
In general no.  The 'use lib qw()' is really a Perl specific mechanism 
for adding a directory to @INC for Perl's module search path, so has 
nothing to do with CSS, Javascript, or the web in general.  To go along 
with this is that generally code runs out of a cgi-bin which is 
inherently different than a regular htdocs directory, and may be on a 
completely different server than where the CSS is served from, and since 
these types of files are client side they need to have a relative or 
absolute URL path as opposed to file system path like the Perl libs. 
Now having said that, if your css/js files are served from a path that 
stays the same with respect to your program then the use of FindBin 
might provide an easy way to manipulate all three at once:

perldoc FindBin

Here is my source code:



After all of that, I generally keep my css and js in top level 
directories off the root of the server, so that I can reference them 
very easily in *all* scripts no matter the depth within my cgi-bin by 
using a plain slash, so

/cgi-bin/folder/script.pl
/cgi-bin/lib
/htdocs/styles
/htdocs/js
/htdocs/some/random/page.htm
In script.pl when I print the location of the css, my variable (actually 
I use a constant) I simply need '/styles' in that location, so that when 
the code actually comes out it has an absolute path for the URL.  The 
same goes for the js.

Although this isn't entirely true either, as recently I have gone really 
insane (as drieux warned me against, sorry drieux), and decided to run 
several sites out of the same code base, so my directory structure 
actually looks like:

/domains/lib
/domains/forms
/domains/formats
/domains/styles
/domains/danconia/cgi-bin
/domains/danconia/lib
/domains/danconia/htdocs
/domains/danconia/htdocs/styles (this directory contains symbolic links 
to the base level styles I need in all domains, yikes)
/domains/danconia/htdocs/js
/domains/danconia/htdocs/images
/domains/danconia/formats
/domains/danconia/forms

Then to add another domain I add the 2nd level directory structure 
starting at 'danconia'... edit one config file that just stores a bunch 
of constants and I am ready to roll... In each of the scripts I then 
have a use lib line that references first the specific domain lib 
directory and second the main lib directory so that I can override for 
any specific domain any specific Perl lib.  For instance a top level 
script has at the top:

use FindBin;
use lib "$FindBin::Bin/../../lib";
use lib "$FindBin::Bin/../lib";
A second level script merely adds a '../' to each, and so onI have 
considered using the same symlink mechanism for the cgi scripts 
themselves, but at current they represent a minimum of the code (as most 
of it is in modules in the top 'lib' anyways) and may change more 
frequently on a per site basis (though I am starting to question that).

Hopefully this does less scarying you, and more showing you that the 
possiblities are virtually endless, but you need to keep in mind the 
difference between a local filesystem and URLs.

HAND,

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: help with progress bar -test site

2004-01-18 Thread Wiggins d'Anconia
zentara wrote:



So now all you have to do is setup the mailings.
For example, this code should work, but there are many mail modules
available to make it easier.
my $mailprog='/usr/sbin/sendmail';
my $email = $emailaddr;
my $from = '[EMAIL PROTECTED]';
open( MAIL, "|$mailprog -t" )
 || safe_die("Can't start mail program $mailprog $!");
print MAIL "To: $email\n";
print MAIL "From: $from\n";
print MAIL "Subject: Upload Notification\n";
print MAIL "\n\n";  #important to print this
print MAIL "Thank you for your upload .\n\n";
print MAIL "$file_upload  -> $fsize\n";
print MAIL "-" x 75 . "\n";
close(MAIL);
And you can do it again to mail it to yourself with the $comment.

So there it's basically all done for you.

I agree with everything he's said, but please don't do mail this way, 
use a module from CPAN. There are plenty of good ones out there that 
range from incredibly simple to very complex.  I suspect zentara didn't 
want to go down this route as it involves CPAN, installing modules, 
learning documentation, and many more questions.  In the long run you 
are better off learning these things, in the end do what you will...But 
don't necessarily expect help on why your sendmail code is broken or you 
don't receive messages, etc.

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Script within a script

2004-01-17 Thread Wiggins d'Anconia
Barbara Lindsey wrote:
I haven't seen this before. Can you do this to add more subs to a module 
without making a parent module out of them?

With the 'system' definitely not, it executes in a separate process 
completely.  'require' simply loads the code, which may or may not have 
subs in it. In the case that it does, the subs will be in whatever 
package space is defined within the lib, if no package space is defined 
then they will be in the main or :: namespace.  You can specify a 
pre-existing namespace to have them load into using a 'package' 
statement, or I would imagine there is a way (read: no one would 
probably bother, but since this is Perl there just about a way to do 
anything, if you can find it) to export the subs into the current 
namespace at which point your goal would be achieved.

perldoc -f package
perldoc perlmod
perldoc perlsub
My question would be would you want to?

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: php testing in my pc

2003-12-25 Thread Wiggins d'Anconia
Please bottom post

Charlie somerville wrote:
POST TO THE DAMN PHP NEWSGROUP NOT THIS ONE!
There are certainly more polite ways to indicate that a poster's 
question is off topic for a particular group...

http://danconia.org

"Daniel Hurtado Brenner" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Hi friends:
I use activeperl for for run and testing my cgi script in my PC. It's
fine.

Well... if i want to run and testing my PHP script and my Msql in my PC...
what can i use?
Thanks
Daniel, from Peru







--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Hit counter

2003-12-25 Thread Wiggins d'Anconia
Please bottom post...

Charlie somerville wrote:
You don't need to get that from a database! All you havve to do is put a
lock on a file read the file, increment it write the file and take the lock
off, easy!
Without knowing more about the OP's design how can you possibly 
determine whether a DB is or isn't the right implementation. Maybe the 
OP needs to generate images for 10,000 unique numbers, doing this with 
file operations would be incredibly slow compared to a DB. Or maybe the 
information is already stored in the DB to generate the numbers, so 
would you suggest pulling the info from a DB, storing it to a file, and 
then re-reading the file?  Seems a bit silly... Besides the OP's 
question wasn't about getting the numbers it was about creating gifs

http://danconia.org

"Parvez Mohamed" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Plaese use http://www.scriptarchive.com/readme/counter.html#counter

in responce to:

I want to write a CGI in perl that when called, grabs a number from a
MySQL db or a file,
increments it, writes the number back out, and then returns a GIF with
that number. I want
to have 10 separate GIFs, each one containing an image (that I have
created to match the
site design) of a number, 0-9. I need to be able to piece together any
number of these
GIFs from left to right into one large (relatively) GIF. I know how to
do everything but
actually create the GIF. Can anyone point me in the right direction?


-
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard






--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Help with PPM install

2003-12-25 Thread Wiggins d'Anconia
Charlie somerville wrote:
Shouldn't you bbe posting to perl.scripts? i mean, cross posting is rude so don't do it

Shall we mention spamming the list posting about threads that are 
ancient, top posting, and in general not being terribly helpful, 
'perl.scripts'??

http://danconia.org

  "Ash Singh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
  I am trying to install Text-CSV from my dos prompt. I downloaded the ppd from 
activestate perl. I get this error, what shall I do.
   

  C:\Perl\ppds\cpan>ppm install Text-CSV.ppd

  Error: No valid repositories: Error: 501 Can't locate object method

  "new" via package "LWP::Protocol::http" Error: 501 Can't locate object

  method "new" via package "LWP::Protocol::http"

   

   

   

   

   
Developer
eMessageX.com

Tel: +27 (0)11 789 1808
Fax: +27 (0)11 326 0152
Cell: +27 (0)72 203 5989
Email:[EMAIL PROTECTED]
   

   



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Calling JavaScript from Perl

2003-12-25 Thread Wiggins d'Anconia
Please bottom post.

Charlie somerville wrote:
Not neccisarily, javascript can be a server side for example in ASP you can
set the <%@ Language=""%> bit to <%@ Language="javascript" %>
Hence the words "in general"

http://danconia.org

"Wiggins D Anconia" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

Hi,
Does anyone know is it possible to call javascript from perl? Can
javascript be included in the same page? Can anyone provide an example
of

this?
Thanks in advance,
Mark.
How do you mean "call javascript from Perl"?  In general Javascript is a
client side language that executes within a browser (client).  Perl on
the other hand is traditionally a server side language, executed on the
server (conveniently).   So CGI is *usually* used to send some HTML like
stuff to the client, what that stuff is really doesn't matter, as long
as the client can understand what the heck to do with it.  So if you are
asking whether a Perl based CGI script can send Javascript down that
particular pipe then sure, if you want Javascript to use the values and
methods of Perl, etc. then you will have to work out how to convert
those into Javascript and then use them as if they are not linked.
Having said that, this is the general case, clients and Javascript can
be more powerful than they are often given credit for so more extreme
tasks can be accomplished, but with complexity comes learning curve...
http://danconia.org

--
Boycott the Sugar Bowl! You couldn't pay me to watch that game.






--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: sendmail error: No reciient address found in header

2003-12-08 Thread Wiggins d'Anconia
B. Fongo wrote:
It's my first time to use sendmail. I want to my script to send a mail 
to [EMAIL PROTECTED] or whoever is in the To: line.   The script warns:"No 
recipient name found in the header" and dies, even though there's a 
recipient. I'm puzzled.

###
#!/usr/bin/perl -w
use strict;

mail_users();

sub mail_users{

open(MAILPROG, "|/usr/sbin/sendmail -oi -t") || die "Can't open 
sendmail: $!\n";
print MAILPROG <<"END_MAIL";
From: ftp_update.pl
To: root <[EMAIL PROTECTED]>
Subject: Software updates

Hello

You may copy and paste this at the shell-prompt to test dependencies:

You may also use this command to install the Packages:

END_MAIL

close(MAILPROG);

#
Well obviously it isn't that you are missing a curly brace in your post 
as that gives a syntax error.  Your example brings up two very good points,

1) why I don't drool over using heredocs as much as some of the other 
Perl gurus, too much can go wrong too fast,
2) why you should not mess with sending e-mail in a manual way such as 
piping a poorly made message into an incredibly complex program such as 
sendmail, but should instead employ one of the plethora of modules 
available from your local CPAN distributor.

I *believe* the reason why your message is failing is because the header 
is not being constructed properly, because the header lines start with a 
'tab' rather than being left aligned as they are supposed to be.  I 
realize that you did so to follow indenting standards, an excellent 
idea, one that wouldn't affect HTML or the like, but has a large impact 
on the mail standards, which naturally you could have avoided had you 
used a module because in that case you were not likely to use a heredoc.

That was a tough one, and yes I am a big geek who has worked on e-mail 
systems too long if I can spot that one HTH,

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: How to verify whether a directory exists

2003-12-06 Thread Wiggins d'Anconia
Please don't cross post, if your question is CGI based then use that 
list, otherwise use the other...

B. Fongo wrote:
I want to use mkdir(blah blah, o777), but want to first find out  
whether the directory "blah blah" exists.
I'm not if the -e option will bw right here. Let's say:

   unless (-e blah_blah) mkdir(blah_blah, 0777);
# Is this okay?

In general -e checks for file existence, -d checks to see if an existing 
file is a directory (or complains that the file doesn't exist).

perldoc -f -e

So your above code leaves a condition, where blah_blah exists but is 
*not* a directory which is likely to cause you problems. But since you 
haven't told us what happens in this failure case it is hard for us to 
say, but,

if (-e blah_blah) {
unless (-d blah_blah) {
die "File exists but is not directory";
}
}
else {
# don't forget to check mkdir's failure
mkdir(blah_blah, 0777) or die "Can't make directory: $!";
}
HTH,

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Bad referrer!

2003-12-06 Thread Wiggins d'Anconia
Sara wrote:

There was a script which people were using remotely, so I have to add this
simple subroutine
to check referrers. Currently, the site is getting approx. 20,000 hits per
day.
I don't think you are using the correct ENV variable. The referer tells 
you what page the user was linking from when they made the submission, 
which among other things is very spoofable so really shouldn't be used 
for much of anything, especially supposed security.  It can allow you 
assuming someone isn't messing with you to track a users path through a 
site, etc. but beyond that is pretty much worthless.

NO one, not even a single person claimed that they have experienced any
problem after
implementing this change, except for the owner of the site. I am webmaster
for the site.
And now she is pushing to undo this change immediately because she is
constantly
getting &error(bad_referrer) and unable to use this script and we both know
she is the only one
experiencing this problem.
Sounds like it is bookmarked or she is typing it in directly in 
whichcase there will be no referer (at least for most clients (browsers)).

Is there something wrong below? If yes, then why others are not getting any
bad referrer error.
If no, what could be the possible reasons that owner is the only person
getting bad referrer error?
What are you *really* trying to do? If you are trying to add a security 
mechanism to a set of scripts this is definitely NOT the way to do it.

TIA,
Sara.


@referers = ('http://www.foo.com', 'http://foo.com');

The above is not scoped, which means you are still not using 'strict' 
and 'warnings' which you have been warned of.

sub check_url {
local($check_referer) = 0;
This is a misuse of 'local'.

if ($ENV{'HTTP_REFERER'}) {
foreach $referer (@referers) {
if ($ENV{'HTTP_REFERER'} =~ m|$referer|i) {
$check_referer = 1;
last;
}
}
}
if ($check_referer != 1) { &error('bad_referer') }
}


http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: CGI.pm question

2003-12-02 Thread Wiggins d'Anconia
Greg Zartman wrote:
I'm relatively inexperienced at using this module as I've always 
preferred coding my own cgi functions.  A question:

If one were to use the CGI::Safe CGI subclass to turn-off uploads, does 
this shut off uploads in general for the cgi session or is it required 
that one use CGI form objects to take advantage of this security feature?

Thanks.

How do you mean "for the cgi session"??  Because we are just talking 
about a request that is really just some well formatted content being 
sent down a pipe, and then being handled by something that has the 
ability to handle such content on the other end, there are multiple 
places where this can and may be handled.  So the important thing is to 
understand where in the processing of an HTTP request the CGI.pm fits, 
and hence what kind of "security" this provides.  So having said that,

The client can make any kind of request it wants and send any amount of 
data, as long as something on the other side will listen to it. In 
*most* cases, assuming we are dealing with normal CGI, and no one has 
thown any mod_perl or one of his cousins in the mix, then the server 
will pass control to the cgi script, at which point it is up to it to 
wrangle the request into something meaningful. Part of CGI.pm does this 
automagically when you first use one of its methods or instantiate the 
object, part of this magic is to store uploaded file content to a 
temporary location, unless it is told not to (which is really 
CGI::Safe's goal).  If you have shut off the feature then the data is 
simply ignored and may either be dropped all together or eaten up by the 
next handler in the request chain (if there is another, after the CGI, 
which there usually isn't in a normal CGI session) then presumably it 
would have access to this data (although this isn't likely as it has 
been read from STDIN which you can't seek back to, at least in *most* 
cases).

All of this depends somewhat on the features and protocol version of the 
client, the server, and how the request/response model is handled.

Also note that at no time did I mention across multiple requests if 
*that* is what you mean by "session". I speak of "session" as one 
request/response cycle.

So does this help?  This type of question is the reason why I suggest 
everyone should read (at least skim) the ORA mod_perl book, regardless 
of whether you intend to use mod_perl, it *will* improve your 
understanding of CGI, HTTP, and the web, regardless if you develop for 
Apache, IIS, PoCo::HTTP...

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: pagination of dbi results on html browser

2003-11-28 Thread Wiggins d'Anconia
A L wrote:
Hello [EMAIL PROTECTED],
This continuation post is from another post at [EMAIL PROTECTED]; it's posted here 
because this is more relevant to CGI.  Previously, I had 2 questions, one being 
pagination (the other question is yet addressed until pagination issue is understood). 
 Now, after following great advices from [EMAIL PROTECTED], I've looked up SQL's Limit 
and Offset concept, which I was able to understand-demonstrate by only getting first 
20 rows of the selections from mysql database.  However, when I tried to implement the 
rest of the rows, I got stuck as to how to approach what I wanted to do, which is to 
make a result that is similar to google search shown on the web.  Then, I searched 
more on the web about pagination without restricting my search to beginner and perl.  
Luckily, I found a lot more information and tried to use some of the concepts which 
were given.  Previously, Jeff 'japhy' Pinyan had give me some script (thanks, Jeff)  
that he used to do the similar thing that I'm trying t
o do, but
 I couldn't get all of his codes (ones near the end of his script).  Therefore, I had yet ventured the web again to better understand what I'm trying to do.  Yet, I have no luck in solving my issue with pagination.  In the end, I even used Jeff's code, only changing what is necessary (I think), to do see if it would work, and it didn't. I'm beginning to feel that I'm missing some fundamental concept of cgi, but I don't know what.  Can any one of you tell me what that may be by looking at my script?  Also, if possible, what is wrong with my code to get it to work?  Or, better yet, if it's really bad, could you show me how you would do it, as Jeff did, to see if I can get better sense of what I'm trying to do?  Or, if I'm being really dumb that I can't get this?  Currently, I'm going around a circle by testing my code each time I change to the script to see what it would do when it doesn't seem to change anything.  Thanks for your help or any input that may help me get the id
ea of what
 I can do to get the pagination.  Following is three of my numerous scripts that had been tested.
Angela 


Ok, let's step back from the problem for a bit and look at what needs to 
actually happen. I only caught the tail end of the previous discussion 
so don't know what all has been stated.

First of all you should be using 'use strict' at the top of all of your 
code, this should be the first step of fixing any of your problems, when 
you have mastered that then the help will be more forth coming. 
Secondly, Perl ignores whitespace and text formatting for a reason, a 
*very* good one at that, so use it judiciously. I didn't even attempt to 
read your code, not because it was long, or incorrect, etc. I didn't 
read it because it was crammed together without any discernible breaks 
in the code, comments, or indenting.  Finally half of the code you gave 
us was related to table formatting, etc. which while it may be important 
to you and your users only serves to clutter the code you have posted 
and hide the problems you are having. Now having said that...

Generally when I want to do pagination of a result set I need to know 3 
things:

1) the total # of records possible,
2) my current position (0 if not provided),
3) the number to display (some default if not provided)
From these I can easily determine the next, previous, and number of 
possible pages of results.  Now, the current position and the number to 
display I generally pass from my form or link to the script creating the 
result set, so they are hard set.  To find the total number I build a 
where clause independent of any particular statement, that where clause 
can then be used in two statements, the first which selects just a 
"COUNT(*) AS total" from the table using the where clause to give me the 
total rows in my query. Then (assuming there are results) I issue a 
second select that retrieves my actual display data using the 
offset/limit that is built from the current position and the number to 
display.  To display my result I step through all of the results from 
the second select. From the total, position, and display # I can 
calculate my 'next/previous' positions. Position twiddling is really all 
you need to do, then I take the current URL and "edit" it swapping out 
the current position with my next or previous position to create links 
to those destinations. Because I know all of my goodies are passed in 
the url still, the script can be generic.

So the next steps are getting your script so that it can get the 3 
parameters above, using those three parameters to generate the positions 
you want, using those positions to generate links that will call the 
script in the same manner with only changing the starting position.

To help with that I am going to post a very old subroutine that I used 
in the past to do this sort of thing, it takes 4 arguments, a bool of 
whether or not to display "clear" links when a link is not need

Re: Rounding Off

2003-11-22 Thread Wiggins d'Anconia
Mike Blezien wrote:
Hello,

I need the ability to round off dollar amounts to the nearest 100th of a 
dollar amount, IE $14.9564 to $14.96 or $132.1123 to $113.11

what is the best way to accomplish this ??

perldoc -q 'have a round'
perldoc -f sprintf
http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: MySQL beginner's script

2003-11-22 Thread Wiggins d'Anconia
Teresa Raymond wrote:
Hello,
I was wondering if anyone could help me solve this problem. The script 
appears not to be connecting to the database.  This script prints "Here 
we go" but never prints "Database connected". I used the format that the 
hosting company supplied. 
"DBI:mysql:$database:localhost","$username","$password"" Could it be 
that I use underscores in my database and user names?

#!/usr/bin/perl -w

use strict;
use DBI;
use CGI;
my ($dbh, $sth);
my $database = '';
my $username = '';
my $password = '';
print "Content-type: text/html \n\n";
print "Database Output";
print "";
print "Here we go";
$dbh = DBI -> 
connect("DBI:mysql:$database:localhost","$username","$password") or die 
$DBI::errstr;
If your script is dieing at the above point then the error message will 
be sent to the server log rather than to the screen. You should look 
into using fatals to browser for this, or rather than just using 'die' 
as above you should provide your own error handling.  So, what does the 
server log have in it?



http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  1   2   3   >