Re: Perl with Ajax issue

2019-08-13 Thread David Dorward

On 12 Aug 2019, at 19:45, Matt Zand wrote:


use CGI;


Do read [CGI: CGI.pm has been removed from the Perl core][1]

Should I install Perl on the server or does it come with Apache 
package.


Apache HTTPD does not include a Perl distribution although some 
third-party bundles include both Perl and Apache HTTPD.


You would also need to configure Apache so it will run the Perl program 
through the perl runtime.



I am getting no response.


If you are getting no response at all, then your problem is unlikely to 
be related to a lack of Perl. That would cause it to return an error 
response.



[1]: 
https://metacpan.org/pod/distribution/CGI/lib/CGI.pod#CGI.pm-HAS-BEEN-REMOVED-FROM-THE-PERL-CORE

Re: cgi development environment

2012-09-19 Thread David Dorward
On 18 Sep 2012, at 13:34, Chris Stinemetz  wrote:
> I am very interested in cgi scripting. I have only used php for web
> development in the past.

CGI or Perl? For a long time CGI with Perl was a popular combination so there 
are a lot of documents which conflate the two.

It is possible to do CGI programming in PHP (which you already know), but 
PSGI[1] is the flavour du jour for server side web programming with Perl.

CGI is still a plausible option though. It has the benefit of simplicity (but 
isn't the most efficient option).

[1] http://plackperl.org/


-- 
David Dorward
http://dorward.me.uk


--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Re: cgi development environment

2012-09-18 Thread David Christensen

On 09/18/12 05:34, Chris Stinemetz wrote:

I am very interested in cgi scripting. I have only used php for web
development in the past.
Would someone please let me know of any good tutorials to get windows
based web development environment set up and get my feet wet?


http://www.google.com/search?q=windows+cgi+howto

http://www.cgi101.com/book/

http://www.cgi101.com/book/connect/winxp.html


HTH,

David


--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Debian, Apache, Perl, CGI.pm, ErrorDocument, and POST

2011-04-02 Thread David Christensen
'REMOTE_ADDR' => '192.168.0.34',
 'REMOTE_PORT' => '55219',
 'REQUEST_METHOD' => 'GET',
 'REQUEST_URI' => 
'/cgi.pm-get-post-errordocument/nosuchfile.pl?inputText=ErrorDocument+GET&inputSubmit=Submit+Query',
 'SCRIPT_FILENAME' => 
'/home/dpchrist/sandbox/apache2/public_html/cgi.pm-get-post-errordocument/printcgi.pl',

 'SCRIPT_NAME' => '/cgi.pm-get-post-errordocument/printcgi.pl',
 'SERVER_ADDR' => '192.168.0.34',
 'SERVER_ADMIN' => '[no address given]',
 'SERVER_NAME' => 'apache2-sandbox-p43400e.holgerdanske.com',
 'SERVER_PORT' => '80',
 'SERVER_PROTOCOL' => 'HTTP/1.1',
 'SERVER_SIGNATURE' => 'Apache/2.2.16 (Debian) Server 
at apache2-sandbox-p43400e.holgerdanske.com Port 80

',
 'SERVER_SOFTWARE' => 'Apache/2.2.16 (Debian)'
   );
$q = bless( {
  '.charset' => 'ISO-8859-1',
  '.fieldnames' => {},
  '.header_printed' => 1,
  '.parameters' => [
 'inputText',
 'inputSubmit'
   ],
  'escape' => 1,
  'param' => {
   'inputSubmit' => [
  'Submit Query'
],
   'inputText' => [
'ErrorDocument GET'
  ]
 },
  'use_tempfile' => 1
}, 'CGI' );


But the fourth case (ErrorDocument, POST) does not work as expected -- 
CGI.pm doesn't see the query parameters available on STDIN:


$0 = 
'/home/dpchrist/sandbox/apache2/public_html/cgi.pm-get-post-errordocument/printcgi.pl';

@ARGV = ();
$STDIN = 'inputText=ErrorDocument+POST&inputSubmit=Submit+Query';
%ENV = (
 'CONTENT_LENGTH' => '53',
 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
 'DOCUMENT_ROOT' => '/home/dpchrist/sandbox/apache2/public_html',
 'GATEWAY_INTERFACE' => 'CGI/1.1',
 'HTTP_ACCEPT' => 
'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',

 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
 'HTTP_ACCEPT_ENCODING' => 'gzip,deflate',
 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5',
 'HTTP_CONNECTION' => 'keep-alive',
 'HTTP_HOST' => 'apache2-sandbox-p43400e.holgerdanske.com',
 'HTTP_KEEP_ALIVE' => '300',
 'HTTP_REFERER' => 
'http://apache2-sandbox-p43400e.holgerdanske.com/cgi.pm-get-post-errordocument/',
 'HTTP_USER_AGENT' => 'Mozilla/5.0 (X11; U; Linux i686; en-US; 
rv:1.9.1.16) Gecko/20110302 Iceweasel/3.5.16 (like Firefox/3.5.16)',

 'PATH' => '/usr/local/bin:/usr/bin:/bin',
 'QUERY_STRING' => '',
 'REDIRECT_REQUEST_METHOD' => 'POST',
 'REDIRECT_STATUS' => '404',
 'REDIRECT_URL' => '/cgi.pm-get-post-errordocument/nosuchfile.pl',
 'REMOTE_ADDR' => '192.168.0.34',
 'REMOTE_PORT' => '55220',
 'REQUEST_METHOD' => 'GET',
 'REQUEST_URI' => '/cgi.pm-get-post-errordocument/nosuchfile.pl',
 'SCRIPT_FILENAME' => 
'/home/dpchrist/sandbox/apache2/public_html/cgi.pm-get-post-errordocument/printcgi.pl',

 'SCRIPT_NAME' => '/cgi.pm-get-post-errordocument/printcgi.pl',
 'SERVER_ADDR' => '192.168.0.34',
 'SERVER_ADMIN' => '[no address given]',
 'SERVER_NAME' => 'apache2-sandbox-p43400e.holgerdanske.com',
 'SERVER_PORT' => '80',
 'SERVER_PROTOCOL' => 'HTTP/1.1',
 'SERVER_SIGNATURE' => 'Apache/2.2.16 (Debian) Server 
at apache2-sandbox-p43400e.holgerdanske.com Port 80

',
 'SERVER_SOFTWARE' => 'Apache/2.2.16 (Debian)'
   );
$q = bless( {
  '.charset' => 'ISO-8859-1',
  '.fieldnames' => {},
  '.header_printed' => 1,
  '.parameters' => [],
  'escape' => 1,
  'param' => {},
  'use_tempfile' => 1
}, 'CGI' );


I would like the error handler script to be able to see the POST 
parameters via CGI.pm.



Any suggestions?


TIA,

David

--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Re: when javascript is disabled in browser

2011-03-14 Thread David Christensen

On 03/14/2011 06:25 AM, Rahul!! wrote:

I am new to cgi-perl web development. When javascript is disabled in
the browser, how to validate it from the CGI file?? I want to do
something like this,

if (/javascript is disabled){
  print "  This webapp needs javascript, please enableable
javascript and retry";
  exit;
}else
#move on
}


I'd look into the NOSCRIPT tag:

http://www.w3.org/TR/html4/interact/scripts.html#edef-NOSCRIPT


HTH,

David



--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Re: Why perl lost steam...

2010-09-20 Thread David Taiaroa
Hi Bill, Eko,

Interesting question. I find that now I often use PHP and CMS options like
Joomla to handle tasks that 10 years ago I would have turned to Perl to
solve.


Panchroma Website Development
Moncton :: Riverview :: Dieppe

www.panchroma.ca


On Mon, Sep 20, 2010 at 10:50 PM, Eko Budiharto wrote:

>  dear Bill,
> not exactly this mailing list will be dead. It is probably passive for this
> moment. It is impossible perl will loose from the IT world. If there is no
> beginners, it is good, right? Because there will be more expert people can
> help beginners/newbies. :)
>
>
>
> On 9/21/2010 3:39 AM, Bill Stephenson wrote:
>
>> This email list used to bustle. It was active and vibrant.
>>
>> No more. Now it is practically dead.
>>
>> It would seem that right now, when "Web Apps" are really coming into their
>> own, CGI scripts written in Perl would be the place that "Beginners" would
>> start looking.
>>
>> But there are no beginners here anymore.
>>
>> Why is that?
>>
>>
>>
>
> --
> To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
> For additional commands, e-mail: beginners-cgi-h...@perl.org
> http://learn.perl.org/
>
>
>


Re: how to change apa...@mydomain.com to myn...@mydomain.com for emails sent out

2010-02-27 Thread David Dorward

On 25 Feb 2010, at 19:17, kitty wrote:
> Even though I can change the sender full name from Apache to MyName
> for the emails sent out from the server. But in the email header
> details, it still shows from apa...@mydomain.com instead of
> myn...@mydomain.com.
> 
> The code in perl that I use is:
> open (MAILHANDLE,"| mail $address -s \"$subject\" -- -F MyName \n");

Use an abstraction layer: http://search.cpan.org/perldoc?Email::Sender

http://search.cpan.org/perldoc?Email::Sender::Manual::QuickStart has an example 
of what you want to do.

-- 
David Dorward
http://dorward.me.uk


--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Re: script working from shell, but not from browser.

2009-12-19 Thread David Taiaroa
Hi,

When you run a script from shell it's probably as user 'you'.

When the script runs from a browser, it will be as user 'www' or something 
similar, with restricted permissions. Your shell user will have more 
permissions, so you might want to look at file permissions.

Also, you want to check the paths to any files referenced by the script. When 
runing a script as shell, you can probably access any file on the server, but 
user 'www' won't be able to.

If you haven't already done this, try something like:
perl -cw script-name.pl 
and see if it gives any more info

Good luck!

Dave

Panchroma website development
www.panchroma.ca


On Dec 18, 2009, at 7:46 PM, simas...@gmail.com wrote:

> so, i got some script with LWP and CGI using.
> When run this script from shell - everything is ok, i got response
> with data i need from the site.
> But, when i run this script from browser i get error 500 -> "Can't
> connect to www.something.com:80 (connect: Permission denied)".
> I can`t understand how can it be... working from shell, but same
> script not working from browser. Maybe there is some problem with
> apache, but i can`t find it - the error_log is clean.
> 
> i try to search the Internet but find nothing to solve this problem,
> so i decided to write here.
> 
> 
> -- 
> To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
> For additional commands, e-mail: beginners-cgi-h...@perl.org
> http://learn.perl.org/
> 
> 



Re: Logout from Apache

2009-03-19 Thread David Dorward

Naji, Khalid wrote:

How can I logout via a perl-script from Apache?
  

That depends on the authentication method used.

Usually it just comes down to "Stop sending your authentication data or 
token with each request".


--
David Dorward
http://dorward.me.uk/

--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Re: Login code

2009-01-08 Thread David Dorward

Brent Clark wrote:

Would anyone have any example code of sessions for logins.


CGI::Session has some example code:

http://search.cpan.org/~markstos/CGI-Session-4.40/lib/CGI/Session.pm

If you want to use the Catalyst framework, their tutorial has a section 
on handling logins with sessions:


http://search.cpan.org/~hkclark/Catalyst-Manual-5.7016/lib/Catalyst/Manual/Tutorial/Authentication.pod

--
David Dorward
http://dorward.me.uk/

--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Re: embedding a CGI script in a HTML page?

2008-12-16 Thread David Dorward

Adam Jimerson wrote:

Correct me if I am wrong but these template systems seem to only handle
output from the CGI script, which would be nice if my scripts only
handled output but they also need user input

1. Browser sends input data to server

2. Server sends input data to program using CGI interface

3. Program does something (possibly with the data) and generates output data

4. Program passes output data to template

5. Template places output data into some HTML (or whatever)

6. Template passes HTML combined with output data to the program

7. Program outputs HTML combined with output data to server using the 
CGI interface


8. Server sends output HTML back to the browser

Templates are used because it is easier to edit HTML in a template then 
it is to edit Perl that generates HTML.


--
David Dorward



--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Re: embedding a CGI script in a HTML page?

2008-12-16 Thread David Dorward

Adam Jimerson wrote:

No I am letting CGI.pm generate the HTML for me, I figured that it would
be the easiest way to do it.
  
Most people find that templates are simpler for most purposes (since 
they can then just write HTML and say "Insert data here" rather then 
describing every element in Perl).



- From what I see in the tutorial,
http://template-toolkit.org/docs/tutorial/Web.html#section_Dynamic_Content_Generation_Via_CGI_Script,
the Templete Toolkit only outputs information from the script, but I
need it to handle input as well
You use Perl to handle the input. TT is just for making it easy to write 
the output.


I've just remembered this simpler example:
http://github.com/dorward/simple-ajax-demo/tree/master

The script itself is at 
http://github.com/dorward/simple-ajax-demo/tree/master/webroot/demo.pl


Line 32 gets user input, in exactly the same way that CGI.pm would do 
(I'm using CGI::Fast for this, which is similar).


Line 33 uses that input to change what request gets sent to the database 
on ...


Line 42 (which) gets a list of messages from the database (much like a 
guestbook would).


Line 49 wraps it up in a hash.

Ignore lines 51 to 56, these output JSON instead of HTML.

Line 59 gives that hash to a template.

http://github.com/dorward/simple-ajax-demo/tree/master/templates/html.tt 
is that template.


Lines 15 to 21 of that template loop over the data and output HTML.

The rest of the template is plain, simple HTML which is easy to edit 
(and line 6 pulls a stylesheet in).


--
David Dorward
http://dorward.me.uk/

--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Re: embedding a CGI script in a HTML page?

2008-12-15 Thread David Dorward

Adam Jimerson wrote:

I'm not trying to put perl code into the page, they way I have it now is
I have the page generated by my CGI script inside another page that is
using my CSS.  I've tried to have my CGI script directly handle my CSS
but it didn't work due to its limited support for CSS.  So now I'm
trying to find a better way to make my CGI script look like the rest of
my site, I'm guessing this is what Template Toolkit if I can figure out
how to do it, or if my solution is the best.
I've going to cover some basics here, so I apologise if its starting too 
low for you.


When a browser requests a URI, the server gets the content of that URI 
from somewhere and sends it back.


It might get it from a file, it might get it from somewhere else. In the 
case of CGI, it runs a program and returns that instead.


You need to edit the Perl program that is being called using CGI so it 
outputs the HTML that you want. (Including the  to the stylesheet 
you are using, there is no problem with support for CSS, since when is 
output is just HTML, that is comes from a program rather than a file 
isn't relevant).


We've no idea what method the program is currently using to determine 
what HTML is generated, so we can't tell you what needs to be done to 
edit it.


What we can tell you is that using Template-Toolkit is a good approach 
when it comes to writing this kind of system. When using TT the general 
approach is to:


(1) Gather up all the data you want into a Perl hash
(2) Tell TT to process a template using that data

TT then goes over the template (which might look something like: 
http://github.com/dorward/axford/tree/master/root/default.tt (sorry, its 
got a lot of legacy cruft in it, I'm in the process of cleaning it up) 
and replaces placeholders with the data (and has things to loop over 
arrays when you have repeated data).


--
David Dorward
http://dorward.me.uk/

--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Re: embedding a CGI script in a HTML page?

2008-12-14 Thread David Dorward
Adam Jimerson wrote:

> Not exactly what I was looking for I meant like using an  or
>  tags, which I did try it out and using the  tags to
> embed works with Firefox 3 I don't know if it works for all browsers.

, but frames have issues. (And  for HTML is effectively
the same as an iframe, but less well supported.

> The reason why I posted is because I wanted my page to look like this
> http://vendion.dyndns.org/guestbook.html as opposed to the basic white
> page when viewed through /cgi-bin/guestbook.cgi.

Change the script to use a template that matches the design of the rest
of the site.

-- 
David Dorward   <http://dorward.me.uk/>

-- 
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Re: cgi and ssh

2008-09-23 Thread David Dorward
Dermot Paikkos wrote:
> Hi,
>
> I have a cgi script that needs scp a file from one server to another. 
> Because the script runs under the httpd user
With suEXEC you can run that script (and only that script) under an
account you create with otherwise very limited privileges.

http://httpd.apache.org/docs/1.3/suexec.html

-- 
David Dorward
http://dorward.me.uk/


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




Re: sessions

2008-08-24 Thread David Dorward
JuneEarth wrote:
> How to make CGI sessions to be shared among multi-webservers? Thanks.

They have to use a shared data store for the session information. Using
a database for that would be one approach.

-- 
David Dorward   <http://dorward.me.uk/>

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




Re: Simple Question... I hope

2008-06-04 Thread David Dorward


On 3 Jun 2008, at 18:00, [EMAIL PROTECTED] wrote:


Ok, I'm uploading a file to a 3rd party. The file is being uploaded to
an https site with a cgi extension. The 3rd party finally provided me
with a snippet of their Perl code. They see the attempt coming
through, but there is no data. I understand how all this works... i
think there's just a dot i'm not connecting somewhere. PLEASE HELP...
Thanks in advance!!!

In my html file I have...
File: 




I'd suspect you aren't setting the enctype attribute in your form  
element correctly, but you didn't provide that bit of the code, so it  
is hard to say.


http://www.w3.org/TR/html4/interact/forms.html#h-17.3

You also appear to be using  (which is deprecated) where you  
should have a  and your HTML is invalid due to a missing start  
tag for a paragraph.


--
David Dorward
http://dorward.me.uk/
http://blog.dorward.me.uk/



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




Re: .htaccess = .WWWaccess ?

2007-12-05 Thread David Dorward

On 5 Dec 2007, at 14:00, Praki wrote:

 I m working with the CGI for authentication.



bash-2.05b$ more .htaccess
AuthType Basic
AuthName  Cisco-CEC
AuthUserFile  /isaac/www/cgi-bin/pkolanda/authen/.htpasswd
AuthGroupFile /dev/null
Require valid-user


CGI doesn't seem to be involved, you appear to be using an internal  
feature of Apache to perform HTTP Basic Authentication. While it is  
possible to perform HTTP Basic Authentication using a CGI script,  
that isn't what you are doing.


You might have better luck on an Apache mailing list.


--
David Dorward
http://dorward.me.uk/
http://blog.dorward.me.uk/



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




Re: CGI and DBI : using db queries in html

2007-11-08 Thread David Moreno Garza
On Thu, 2007-11-08 at 11:22 -0800, neil wrote:
> $q -> popup_menu(-name => 'study_select', -values =>
> [EMAIL PROTECTED]), 

You should be passing: -values => [EMAIL PROTECTED]

D.



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




Re: Premature end of script header error....

2007-10-24 Thread David Moreno Garza
On Wed, 2007-10-24 at 03:46 -0700, nexis wrote:
> This is a piece of code to print a graph object.
> 
> 
> 
> ...
>print "content-type: image/$graph_format\n\n";
> binmode STDOUT;
> print $img_obj;
> ...
> 
> This code works fine for me and I am able to see the graph. But when
> the code goes on production server, it gives Internal Server
> Error. I have check the error logs and it says the premature end of
> header.
> 
> I have check all the graph modules GD, GD::TextAlign, GD::Graph all
> are same on both machines.
> 
> I use Apache 2.0.52, Perl 5.8.5
> while the production runs Apache 1.3.29 , perl 5.8.0
> 
> Is there any compatibility issue or is there something I dont know
> about.

I suggest you using CGI::Carp to trace those errors. On the top on your
CGI place something like:

 use CGI::Carp qw/fatalsToBrowser/;

And see what comes up to your browser.

--
David Moreno Garza <[EMAIL PROTECTED]> | http://www.damog.net/
 Yo te lo juro, de que por ley, aquí todas las boricuas saben karate.



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




Re: Possible Perl/CGI Application

2007-10-23 Thread David Moreno Garza
On Tue, 2007-10-23 at 02:04 +, [EMAIL PROTECTED] wrote:
> I am experienced in Perl and have have worked with simple HTML. I was
> told CGI might be the way to go in developing such an application. My
> question is, does that seem reasonable? I don't want to throw myself
> into learning CGI if I'm going to reach a point a few weeks down the
> road when I realize I should have taken a different approach. 

Sure, why not.

--
David Moreno Garza <[EMAIL PROTECTED]> | http://www.damog.net/
 Ahora buscas chamba por la Marquesa.



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




Re: first steps with mod_perl

2007-10-09 Thread David Dorward

On 9 Oct 2007, at 04:04, Marek wrote:

if I understand well, it is extremely difficult to make CGI.pm produce
valid html

My problem are the many  tags in the form - and the checked
instead of checked="checked" in the input-tags. But probably I am not
yet understanding CGI.pm?


It has been a long while since I tried generating HTML with CGI.pm  
(these days I lean very strongly towards Template-Toolkit), but I'd  
be surprised if it produced  since its either non-Appendix C  
conformant, nonsensical XHTML (a content-less paragraph) or its, in  
HTML, "Start of paragraph followed by a greater than sign" and using  
features marked as badly supported - avoid.


checked rather than checked="checked" is fine in HTML  
(checked="checked" is another of the "avoid this, its badly  
supported" features).


According to the CGI.pm documentation, it defaults to XHTML (so it  
should be outputting checked="checked") unless you use -dtd to  
specify an HTML 2.0 or 3.2 DTD. (Why not HTML 4.x I've no idea). You  
can also use the -no_xhtml pragma to turn off XHTML generation.


Turning off XHTML generation is generally a good thing: http:// 
www.webdevout.net/articles/beware-of-xhtml


... but I'll stick to Template-Toolkit

--
David Dorward
http://dorward.me.uk/
http://blog.dorward.me.uk/



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




Re: Cant Display the image...

2007-09-06 Thread David Dorward

On 6 Sep 2007, at 13:03, jeevs wrote:

qx{chmod -R 777 /var/www/images/file.png};
print qq();


Your alt attribute is missing.

And the location of the file on the server's file system is not going  
to be the same as the path under the webroot. Otherwise you could go  
to http://www.example.com/etc/passwd on practically any system.



--
David Dorward
http://dorward.me.uk/
http://blog.dorward.me.uk/



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




Re: Cant Display the image...

2007-09-06 Thread David Dorward


On 6 Sep 2007, at 09:03, jeevs wrote:

 print "";


Where is the alt attribute?


yes i am creating a file in cgi directoy ..


Are you certain that is the current working directory?

If it is for CGI then it could well be set up to try to execute  
everything in it.



but instead of the image just a square box is displayed ..


So look at the server logs to see what the server thinks is happening  
when the image is requested.



--
David Dorward
http://dorward.me.uk/
http://blog.dorward.me.uk/



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




Re: Perl/DBI

2007-07-24 Thread David Busby

Shawn Hinchy wrote:

Hello all,

I am getting to the point where I need to start thinking about doing 
pagination for search results.


I did some searches and it looks like there are some pagination modules, 
but I am not quite interested in going that route yet.  I am using a 
handful of columns from the search so I do not think that retrieving all 
results and then only showing a subset will be very efficient.  It also 
looks like you can execute FOUND_ROWS() after doing your initial query 
and it will give you the total results.  This is probably the best 
route, but it is not easily implemented with the way I have set up my 
functions.


Are there any other options that I have missed?  Suggestions?

Thanks,

Shawn


Shawn Michael Hinchy
[EMAIL PROTECTED]


Shawn; I can only speak to Oracle but if your looking at counts be sure 
that you use it something like this.


Select * from (your real query here) where rownum >=lownum and rownum<= 
highnum or something of that nature where the lownum and highnum 
represents the beginning and end of rows you want to get.  Say you want 
to run the query get the first 5K rows.  You could write the low as 1 
and the high as 5000.  Use binds.  You could run your query first with 
something like select count(*) from (inner query) to return the total 
number of rows but you may just be wasting resources in that case.


Let me know if you have any further questions.

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




Re: .pdf files in a perl cgi application?

2007-04-24 Thread David Dorward
On Tue, Apr 24, 2007 at 08:58:52AM -0700, Mary Anderson wrote:

>> (Please keep this on the mailing list)

No, really. Please keep this on the mailing list. You do that by
emailing beginners-cgi@perl.org rather than my private address.
 
> Its not a cgi "macro image" but a "cgi macro" image.

Oh. The img method of the CGI object.

> Just the image function that expands into the html  tag.

That's an HTML issue, not a CGI issue.

PDF files aren't images, and aren't supported by browsers as images.

> It won't accept .pdf files.

No, you could try an object element, but PDFs are not nice things to
view in a browser window at the best of times, embedded inside a tiny
frame in a page - eugh.

> Is there anyway the user can download a file through the web without
> opening it?

They can configure their client to not use the plugin.

You could also look at sending a content disposition of
attachment. http://www.ietf.org/rfc/rfc2183.txt

-- 
David Dorward  http://dorward.me.uk


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




Re: .pdf files in a perl cgi application?

2007-04-24 Thread David Dorward
(Please keep this on the mailing list)

Mary Anderson wrote:

> All I do with the files is to display them using the cgi.pm macro
> image.  Then the user can download them.  Do you know if this also works
> with a pdf file?  

What is a "macro image"? The phrase does not appear it the CGI.pm
documentation ( http://search.cpan.org/~lds/CGI.pm-3.29/CGI.pm ).



-- 
David Dorward   <http://dorward.me.uk/>

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




Re: .pdf files in a perl cgi application?

2007-04-23 Thread David Dorward
Mary Anderson wrote:
>I have successfully put .gif, .jpg , etc. images into my application.  A
> user has just sent me some .pdf files, which must be read with Acrobat
> Reader, I assume.

No, there are plenty of libraries for dealing with PDFs that are not
Acrobat Reader.

>  How would I work these into my application?

In what sense? There are plenty of things you /could/ do with PDF files
in a CGI app. What do you actually want to do?

-- 
David Dorward   <http://dorward.me.uk/>

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




Re: how to force html4 output

2007-01-11 Thread David Dorward
On Thu, Jan 11, 2007 at 02:49:31AM +0100, Oliver Block wrote:

> Can anyone tell me, if there is a way to force CGI.pm to deliver the
> html code with a DOCTYPE switch for HTML4 and not XHTML?

$ perl
use CGI qw/:standard -no_xhtml/;
print start_html(); (^D)
http://www.w3.org/TR/html4/loose.dtd";>
Untitled Document

 
Unfortunately it outputs Transitional rather then Strict, and I'm not
aware of any way to override that.

I've always been unimpressed by the CGI.pm markup generation
facilities, I find that its easy to craft something of decent quality
by using Template-Toolkit (or HTML::Template, or etc. etc. etc.).

-- 
David Dorward  http://dorward.me.uk


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




Re: Getting "Content-Type: text/html; charset=ISO-8859-1" strings in my pages :(

2007-01-09 Thread David Dorward
On Tue, Jan 09, 2007 at 09:17:40AM +, peter church wrote:

> I start the program with this
> my $handler = new CGI;

use strict! use warnings! (and you probably want Taint mode on as well).
 
> print $handler->header("text/html");
> print $handler->start_html("Configurations");

I'd avoid the CGI.pm functions for generating HTML (except _possible_
form controls). They have some oddities (such as, in the version
installed on the server I just did a test with, generating invalid
XHTML 1.0 Basic).

> print $handler->startform("GET","http://${server_name}${script_name}";,
> "text/plain");

text/plain? That isn't an acceptable
value. http://www.w3.org/TR/html4/interact/forms.html#adef-enctype

> When I call the script the first time all is well however when I hit the
> submit button and the second form loads I get  "Content-Type: text/html;
> charset=ISO-8859-1"
> strings :(

I haven't a clue why you would get that. You haven't provided enough
of your script.
 
-- 
David Dorward  http://dorward.me.uk


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




Re: Can't not install Inline::Ruby module

2006-12-20 Thread David Moreno Garza
Mumia W. wrote:
> I can't tell you how to get the Ruby interpreter onto the system PATH in 
> Windows. Any Windows users out there?

If he can launch the Ruby interpreter from any location of the Windows
filesystem tree, then it's probably a bug of the module itself, when
stating that it can't find it.

-- 
David Moreno Garza <[EMAIL PROTECTED]> | http://www.damog.net/
 Lo poco que yo tengo lo gané con mi sudor.


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




Re: Can't not install Inline::Ruby module

2006-12-20 Thread David Moreno Garza
chen li wrote:
> Yes. I have a Ruby interpreter installed and it works
> fine for running Ruby scripts.  But I am not sure why
> it is not available on the system PATH.

Do you run Ruby scripts from any directory on your Windows system?

-- 
David Moreno Garza <[EMAIL PROTECTED]> | http://www.damog.net/
 Si tienes quién te quiera, entonces eres millonario.


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




Re: About MVC framework

2006-12-20 Thread David Dorward
On Wed, Dec 20, 2006 at 04:54:15PM +0800, Wan wrote:
> I'm looking for a MVC framework that fast in develop and run. and I
> don't want to build it myself, please recommend someome.

http://search.cpan.org/search?query=MVC

(Catalyst is probably the most popular option these days. It gets a
lot of buzz, at least.)

-- 
David Dorward  http://dorward.me.uk


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




Re: stuffing the document header

2006-12-06 Thread David Dorward
On Tue, Dec 05, 2006 at 07:03:46PM -0700, David Bear wrote:
> Are there other methods to stuff arbitrary html elements into the head
> section?

You could use a template engine (Template-Toolkit is my preference,
HTML::Template is also popular, there are other options) instead of
generating HTML from Perl.

-- 
David Dorward  http://dorward.me.uk


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




stuffing the document header

2006-12-05 Thread David Bear
I have tons of items to put in the  section of my html document. There
are multipl link rel statments.

Looking at the cgi docs I find this for making the  section:
   print start_html(-title=>'Secrets of the Pyramids',
-author=>'[EMAIL PROTECTED]',
-base=>'true',
-target=>'_blank',
-meta=>{'keywords'=>'pharaoh secret mummy',
'copyright'=>'copyright 1996 King Tut'},
-style=>{'src'=>'/styles/style1.css'},
-BGCOLOR=>'blue');

I don't see where I can add 

-link=>{'rel'=>'stylesheet', href=>'http://somserver'}

to it.

Even if I could, I have multiple link rel statments I would hate for the
perl behavior to be the last assignment is the only assignment.

Are there other methods to stuff arbitrary html elements into the head
section?

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


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




check for def

2006-12-01 Thread David Bear
I would like to do something like (psuedo coded)

my $req = CGI->new();
my %params = $req->Vars;

if ndef %params {
  %params = 'gets a hash time that i build'
}

The goal of course is to make sure that %params has some hash table
available even if the script is not called in a cgi environment.

Any pointers?


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


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




Re: ways to iterate over params

2006-12-01 Thread David Bear
Bill Jones wrote:

> On 11/30/06, David Bear <[EMAIL PROTECTED]> wrote:
> 
>> my $q = CGI->new();
>> my %params = $q->Vars;
>> foreach $f (keys (%params)) {
>>print "$f is $params{$f} ";
>> }
> 
> use CGI;
> 
> my $q = CGI->new();
> my %params = $q->Vars;
> foreach my $f (keys (%params)) {
>   print "$f is $params{$f}\n";
> }
> 

I was missing my... Thank you very much.

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


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




Re: trouble with meta http-equiv

2006-12-01 Thread David Bear
Wiggins d'Anconia wrote:

> 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...

Yes, this was it. I am using object syntax, so $req->meta() worked.

Yes, the above "$req-refere" was a type, I am using $req->referer()

> 
> 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
>> 
>> 
> 

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


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




ways to iterate over params

2006-11-30 Thread David Bear
I would like to iterate over the list of fields posted. Then, use the field
name to access the value of that field in params.

The CGI module says I can 
%params = $q->Vars;

to get the paramter list as a hash table.

but then I want to do

my $q = CGI->new();
my %params = $q->Vars;
foreach $f (keys (%params)) {
   print "$f is $params{$f} ";
}

But this tells me global symbol $f requires package name, ie its not getting
assigned any keys.

There must be a simpler way to get an array of the names of parameters
passed in through CGI and then use those names to index CGI->param and get
their value.

Any pointers?


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


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




trouble with meta http-equiv

2006-11-30 Thread David Bear
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', 
-content => '1;URL=' . $req-refere()}));

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]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: Store and retrive binary content via perl-cgi

2006-11-16 Thread David Dorward
On Thu, Nov 16, 2006 at 04:53:16AM -0800, cool planet wrote:

>   how it would be possible to download and upload images,videos
>   etc from perl cgi into and from mysql database?

Yes

>   can i have any helpful url ?

http://search.cpan.org/~lds/CGI.pm-3.25/CGI.pm#CREATING_A_FILE_UPLOAD_FIELD
http://search.cpan.org/~timb/DBI-1.53/DBI.pm
http://search.cpan.org/~danieltwc/DBIx-Class-0.07002/lib/DBIx/Class.pm

-- 
David Dorward  http://dorward.me.uk


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




Re: download java applications

2006-11-10 Thread David Dorward
On Fri, Nov 10, 2006 at 03:05:48AM -0800, cool planet wrote:

> How , it is possible to download java applications (jad/jar) via
> perl - cgi ?

It is no different from downloading any other resource.

> can i see few examples ?

http://search.cpan.org/~gaas/libwww-perl-5.805/lib/LWP.pm

-- 
David Dorward  http://dorward.me.uk


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




Re: Headers("Location") in Perl??

2006-11-04 Thread David Dorward
On Sat, Nov 04, 2006 at 11:12:51PM -, Richard Bagshaw wrote:
> This may be an obvious question but I am new to perl and I need some
> advice.  Basically I have written a script that makes some changes to a
> database when a drop down is selected, after this is done I then want to
> goto another page in my system.  In php I could use the
> header("Location: www.blah.com") todo this, is there anything like that
> in perl?

You can just print them directly (since CGI expects headers followed
by a blank line followed by message), or CGI.pm has a header method.

-- 
David Dorward  http://dorward.me.uk


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




Re: Convert Date to Timestamp.

2006-11-01 Thread David Romero

See the Date::Parse   Module from cpan



On 10/31/06, Sara <[EMAIL PROTECTED]> wrote:

I am getting Month, Day and Year from Drop Downs of a form to convert given 
values to Unix timestamp.
I am able to put values in all the variables below except for $wday & $yday. 
Any ideas as how I can get those with limited user input of month, day and year 
only?

#!/usr/local/bin/perl
use POSIX;

$sec = 1;
$min = 0;
$hour = 0;
$mday = 01;
$mon = 10;
$year = 107;
$wday = ?;
$yday = ?;
$timestamp = mktime($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,-1);
print ($timestamp);





--
David Romero
##
http://www.iluminawebs.com

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




Re: CGI Scripts and IE

2006-09-25 Thread David Dorward
On Mon, Sep 25, 2006 at 10:53:15AM -0400, Shawn Hinchy wrote:
> Everything works fine in Mozilla/Firefox but when I try to use IE 6,  
> it doesn't seem to call the script when the submit button is pressed,  
> kind of like it knows it is already loaded and just reloads it from  
> cache.  Is this possible?  How do I overcome it?

> The script acts differently whether it is called with no parameters or  
> whether it is called after the submit button press and has parameters  
> (action=validate, etc).

I'd /guess/ that you have something like Bar, and you are testing for
$q->param('foo') eq 'baz' and falling over IE's problem of sending
"Bar" as the value.

... but you haven't provided anywhere near enough information about
the problem to say for sure. Real URL? HTML? Perl?

-- 
David Dorward  http://dorward.me.uk


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




Re: What is the reason for different outputs for a cgi script run from a browser and run from the command line?

2006-06-20 Thread David Dorward
On Tue, Jun 20, 2006 at 10:25:33AM +0200, sfantar wrote:
> Why are there differences between the output of the CGI mentioned below 
> which displays the content of $ENV{HOME} et $ENV{PATH}?

The environment the webserver runs is different to the environment
your shell runs.

-- 
David Dorward  http://dorward.me.uk


-- 
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 do a static variable that persists from page to page

2006-05-02 Thread Luke, David
Mary,

Your program should not "wait" for a web user to click a link or a
Submit button -- ever. There are no cpu cycles and there is no storage
reserved once you finish building the web page.

Your whole program should draw a web page and exit.
The user is then not wasting your time (and money) while he reads what
you wrote and decides to click something.

When he does click something, it will start up the same or a different
program on your server from scratch, and that will create another web
page, perhaps showing the next row.


It is unnecessary to bring down an array of items from the database if
you are going to use only one. Your program should be retrieving and
displaying only one row, or enough extra to handle navigation.

You should pass some sort of information along with that row so that
when the user clicks for the next one, a program can retrieve and
display it. Several people have offered session schemes for persisting
your retrieval data during repeated calls. All are involved and some
could open vulnerabilities to hacking.

The database you use determines the exact syntax necessary for
retrieving the "Next" row, when presented with information from the
"Current" row. That information will have to go roundtrip out to the
user's browser and then back in to the server for a NEW invocation of
your program. Again, do not retrieve all of the rows unless you will
pass them all to the user WITHOUT another trip to the server.

David Luke, Systems Project Analyst
DMS Enterprise Information Technology Services
Building 4030, Suite 115
4050 Esplanade Way
Tallahassee, Florida 32399-0950
 
(850) 922-7587

-Original Message-
From: Mary Anderson [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 27, 2006 10:20 PM
To: beginners-cgi@perl.org
Subject: How to do a static variable that persists from page to page





Hi,
   I have a cgi program that pulls data out of a database and stores it
in
an array ref.  I would like to display this data one row at a time. 
Unfortunately I am having difficulty getting the current index to
persist
from one page to another.  I could do this with a hidden field.  But I
also
have difficulty getting the array ref to persist once the submit button
is
pushed.
   The general scenario is this.  I have a function which sets a value
of
x.  I would like to have that
value of x available on the next call to the function.  (Like its
supposed
to be a static variable.)

Here is what I tried:

our %x

sub fu{
my ($bar) = @_; 
our %x;  
   if ($bar){
$x{'ABC'} = 0
   } 
   else{
$x{'ABC'} = $x{'ABC'} + 1;
   }
   print "Value = $x{'ABC'}", hr;

fu(1);

fu(0);

gives
Value = 0
Value = 
}
How should I be doing this?

mary anderson








--
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 do a static variable that persists from page to page

2006-04-28 Thread David Dorward
On Fri, 2006-04-28 at 14:27 -0400, Jay Savage wrote:

> POST and GET aren't CGI...at least not exactly. They're part of the
> HTML spec, and deal with what happens when you click the submit button
> on an HTML form.

No, they are part of HTTP, not HTML.

> GET appends the form elements to the url, POST embeds
> them in the body of the transmission.

Well. Ish. That describes how form data is transmitted with POST and
GET, but there is a little more to it than that.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.3

> Sorting them out is the job of the server, not the CGI program; CGI.pm could 
> care less.

The server just dumps the data into the CGI, either as environment
variables or through STDIN. CGI.pm cares very much about how the data is
formatted, it decodes it for you.

> Values of GET and POST requests are accessed by your CGI program in 
> exactly the same way: $q->param{'param'}.

Because CGI.pm is quite smart.

-- 
David Dorward   <http://dorward.me.uk/>
"Anybody remotely interesting is mad, in some way or another."
 -- The Greatest Show in the Galaxy

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




Re: Data from web form

2006-04-20 Thread David Dorward
On Thu, 2006-04-20 at 18:49 -0600, Scott wrote:
> I am accepting data from a form via the post method. At this time I do not
> have a database server to use with it and need to write to flat files.
> 
> Is there a way to get the results of the data without getting all the +'s
> and various special characters that replace spaces and ', and such?

Use the CGI module.

perldoc CGI

-- 
David Dorward   <http://dorward.me.uk/>
"Anybody remotely interesting is mad, in some way or another."
 -- The Greatest Show in the Galaxy

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




Re: catching multiple values

2006-04-18 Thread David Dorward
>   
> and I need to catch all the values of this list but, if I write:
>   $legenda = $pagina->param("legenda");
> the variable $legenda is equal only to the first selected item.
> I read the cgi perldoc, but I cannot locate the answer to may question.

   FETCHING THE VALUE OR VALUES OF A SINGLE NAMED PARAMETER:


   @values = $query->param('foo');

 -or-

   $value = $query->param('foo');

   Pass the param() method a single argument to fetch the value of
   the named parameter. If the parameter is multivalued (e.g. from
   multiple selections in a scrolling list), you can ask to
   receive an array.  Otherwise the method will return a single
   value.


-- 
David Dorward  http://dorward.me.uk


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




Re: redirect - CGI

2006-04-11 Thread David Dorward
On Tue, Apr 11, 2006 at 10:05:15AM -0300, Augusto Flavio wrote:
> #!/usr/bin/perl
> use CGI qw/:standard/;

Seems to be missing a use strict and use warnings here.

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

You end you HTTP headers here (by printing two new lines).

> print redirect('http://www.yahoo.com');

Then you send more HTTP headers here, and your script probably
shouldn't be outputting a content-type header if its redirecting, let
the server handle that side of things.

#!/usr/bin/perl
use strict;
use warnings;
use CGI;
my $cgi = CGI->new();
print $cgi->redirect('http://www.yahoo.com');

-- 
David Dorward  http://dorward.me.uk


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




Re: C++ query with mySQL

2006-04-09 Thread David Dorward
On Mon, 2006-04-10 at 10:02 +0500, Sara wrote:
> Calling the categories starting with PHP and Perl didn't cause any issue, but 
> when I called the Categories
> starting with C_and_C++, nothing was shown because CGI.pm was removing the 
> characters ++.

> I replaced the All ++ in the mySQL database with ASCII ++, so now the 
> categories are in the DB are:
> C_and_C++/Ad_Management

The "+" character has no special meaning in HTML, so you don't need to
represent it with HTML entities unless it doesn't exist in the character
encoding you are using (which is unlikely).

> And now when I am calling the script:
> http://mysite.com/cgi-bin/index.cgi?cat=C_and_C++/Ad_Management

However, the "+" character _does_ have special meaning in URLs - it
represents a space character. You should URL encode the data you pull
from the database. The URI::Escape module can help with this.

-- 
David Dorward   <http://dorward.me.uk/>
"Anybody remotely interesting is mad, in some way or another."
 -- The Greatest Show in the Galaxy

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




Re: FTP from my web ssite question

2006-03-14 Thread David Dorward
On Mon, Mar 13, 2006 at 11:03:22PM -0500, Lou Hernsen wrote:
> I would like to offer my guest a way to download fonts and art
> from my web site... I use perl / cgi's to create my HTML web pages.
> What is the CGI code that creates the link to allow people to do this?

...
print q(Download my artwork);
...

Or, if you really want to use FTP:

...
print q(Download ftp://example.com/myfile.zip";>my artwork);
...


-- 
David Dorward  http://dorward.me.uk


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




Re: referer throwing Internal Server Error

2006-03-13 Thread David Dorward
On Mon, Mar 13, 2006 at 07:30:45PM -0600, David Gilden wrote:
> Here is my little script and it throwing a Internal Server Error

Try running it from the command line:

Software error:
Missing right curly or square bracket at - line 13, at end of line
syntax error at - line 13, at EOF
Execution of - aborted due to compilation errors.


> I can not figure out what is wrong here
> and how secure is this, can it be spoofed easily??

The referer header is optional and very easily spoofed.

e.g. (if you have LWP installed)

GET -H'Referer: http://another.example.net' http://www.example.com/

-- 
David Dorward  http://dorward.me.uk


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




referer throwing Internal Server Error

2006-03-13 Thread David Gilden
Greetings from Cow Tow!

Here is my little script and it throwing a Internal Server Error

#!/usr/bin/perl 

use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
use POSIX 'strftime';
use strict;

my $referer = referer; 

if ($referer !~ m|^https?://www\.coraconnection\.com|i) {
print "Your not authorized: Bad Referer: $referer \n";
} else {
print "all cool: $referer \n";
}


I can not figure out what is wrong here
and how secure is this, can it be spoofed easily??
Thanks.


Dave Gilden
(kora musician / audiophile / webmaster @ www.coraconnection.com  / Ft. Worth, 
TX, USA)

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




Re: Creating a table with HTML:Template

2006-02-24 Thread David Kaufman
Hi Christian,

"Christian Stalp" <[EMAIL PROTECTED]> wrote:
> i try to create a table with HTML:Template
> for this I fill a array with hashes:
> while ( $zeile = $result->fetchrow_arrayref ) {
>  $uebergabe{ name => $row->[0], link => $row->[1] };
>  push ( @suchprofile, \%uebergabe );
> }
>
> But I got nothing but an empty table. What is wrong?

try adding the following to the top of your script:

  use strict;
  use warnings;

The uninitialized variable warnings that you see will alert you that, in 
your while statement, you assigned each row's hash reference to a 
variable named $zeile, but then attempted to retrieve the values from a 
hashref named $row.

  while ( my $row = $result->fetchrow_arrayref ) {
$uebergabe{ name => $row->[0], link => $row->[1] };
push ( @suchprofile, \%uebergabe );
  }

should work much better for you.

hth,

-dave



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




Re: using variable in param

2006-02-21 Thread David Dorward
On Tue, Feb 21, 2006 at 12:22:39PM +0100, Adriano Allora wrote:
> opendir(QUERY, 
> "/Users/adrianoallora/Sites/corpora/VALICO/indici_testa/") or $errtex = 
> $!;

So you set a variable if the directory couldn't be opened ...

> @interrogabili = readdir(QUERY);

... but then carry on and try to read the directory anyway?

> foreach $elem (@interrogabili)
>   {
>   next if $elem =~ /^\..*/;
>   $elem = $home->param($elem);
>   }
> 
> Why the  $home->param($elem) line doesn't work?

You don't define $home anywhere.


-- 
David Dorward  http://dorward.me.uk


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




Re: Preventing unauthorized use of a CGI script

2006-02-07 Thread David Dorward
On Mon, 2006-02-06 at 22:28 -0600, David Gilden wrote:
> Just wanted hear opinions on how effective this is, as way of preventing 
> email relaying stoping 
> unauthorized use my script.

> This from a script that connects a  page to sendmail
> my $referer = referer; # what page called the script, check the domain
> exit if $referer = ($referer !~ /www\.mydomain\.com/i);

> If somebody from a foreign domain trys to invoke my script it should exit 
> with out a trace.
> Yes?

If you mean X puts up a form on another site with the action pointing
towards your form handler, and visitor Y to that site submits that form.
Then yes ... providing that X didn't put the form in a directory called
www.mycdomain.com.

It will also block legitimate users of your site as the referer header
is (a) optional (b) sometimes munged in the name of privacy (although in
violation of the HTTP spec - probably due to laziness in that
overwriting the referer header with junk means that the software doesn't
need to recalculate the content-length).

If you are trying to stop spammers from using the form handler to send
many messages, then no. Forging a referer header is trivial.

-- 
David Dorward   <http://dorward.me.uk/>
"Anybody remotely interesting is mad, in some way or another."
 -- The Greatest Show in the Galaxy

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




Preventing unauthorized use of a CGI script

2006-02-06 Thread David Gilden
Greetings,

Just wanted hear opinions on how effective this is, as way of preventing email 
relaying stoping 
unauthorized use my script.

This from a script that connects a  page to sendmail

#!/usr/bin/perl 

use CGI qw/:standard/;

#..snip..

my $referer = referer; # what page called the script, check the domain
exit if $referer = ($referer !~ /www\.mydomain\.com/i);

#..more code below etc...


If somebody from a foreign domain trys to invoke my script it should exit with 
out a trace.
Yes?

Thanks,

Dave Gilden


Visit my schedule page for up to the minute performance info:


Endorsing Artist for the Moog Music:


==
 Cora Connection: Your West African Music Source
  Resources, Recordings, Instruments & More!
    
==

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




RE: CGI - HTML::TEMPLATE - How do it ?

2006-02-02 Thread David Dorward
On Thu, 2006-02-02 at 16:36 -0300, Augusto Flavio wrote:
> The problem is my array... Look:

> @domains = (
>  { name => 'domain1.com'},
>  { name => 'domain2.com'},
>  { name => 'domain3.com'},
> ); 
> 
> where i place the subdomain of the value domain2.com ? 

{ 
  name => 'domain2.com',
  subdomain => 'www.domain2.com',
},

-- 
David Dorward   <http://dorward.me.uk/>
"Anybody remotely interesting is mad, in some way or another."
 -- The Greatest Show in the Galaxy

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




CGI Upload Code

2005-12-19 Thread David Gilden
Holiday Greetings,
I copied this from a CGI web site, and while it does work,
I was wondering what folks with more experience in PERL thought of 
this code.
Thanks for any comments,
Dave Gilden


#!/usr/bin/perl -w

use CGI qw/:standard/;
use CGI;
use Fcntl qw( :DEFAULT :flock );
use CGI::Carp qw(fatalsToBrowser);
use strict;

# Upload Code
use constant UPLOAD_DIR => "/home/sites/site01/web/private/mydata/";
use constant BUFFER_SIZE=> 16_384;
use constant MAX_FILE_SIZE  => 2 * 1_048_576;   #Limit each upload to 2 MB
use constant MAX_DIR_SIZE   => 10 * 1_048_576; # Limit total uploads to 10 MB
use constant MAX_OPEN_TRIES => 100;

$CGI::DISABLE_UPLOADS   = 0;
$CGI::POST_MAX  = MAX_FILE_SIZE;

my $q = new CGI;
$q->cgi_error and error( $q, "Error transferring file: " . $q->cgi_error );

my $action = $q->param( "action" );

if  ($action =~ /Update/) {
print redirect("./import_clean_csv.php");
exit;
};

if  ($action =~ /Clean/) {
my @filesToRemove;  
 
chdir UPLOAD_DIR or die "Couldn't chdir to afm_data directory: $!";

#my @filesToRemove  =  map  {$_ =~ /^(\w[\w.-]*)/} <*>;

opendir(DR,"./");
@filesToRemove  =  grep  {$_ =~ /^(\w[\w.-]*)/} readdir DR;
closedir DR;


print $HTML_HEADER;
print '';

foreach my $fr (@filesToRemove) {

print  "Deleted $fr\n";
unlink($fr)  or die "Couldn't Delete $fr $!";
}

print param( "file" ) || error( $q, "No file received." );

# my $filename  = $q->param( "filename" ) || error( $q, "No filename entered." 
);
my $fh= $q->upload( "file" );
my $buffer= "";

if ( dir_size( UPLOAD_DIR ) + $ENV{CONTENT_LENGTH} > MAX_DIR_SIZE ) {
error( $q, "Upload directory is full." );
}


# Open output file, making sure the name is unique
until ( sysopen OUTPUT, UPLOAD_DIR . "/$file", O_CREAT | O_RDWR | 
O_EXCL ) {
#   $file =~ s/(\d*)(\.\w+)$/($1||0) + 1 . $2/e;
$1 >= MAX_OPEN_TRIES and error( $q, "Unable to save your file." );
}


# This is necessary for non-Unix systems; does nothing on Unix
#binmode $fh;
#binmode OUTPUT;

# Write contents to output file
while ( read( $fh, $buffer, BUFFER_SIZE ) ) {
print OUTPUT $buffer;
}

close OUTPUT;

--snip---


Cool music.From Guineé comes this CD of kora fusion, electronica  
[ Audition Mp3s at the URL below ]


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




Re: CGI - Email Forms

2005-12-08 Thread David Dorward
On Thu, 2005-12-08 at 12:24 -0600, Bill Stephenson wrote:
> I tried your example and could not get it to send the email to the 
> spammed address. It just stuck it in the subject line like it should 
> have.

> I don't have anything special in the script to filter the newline. 

>   use Mail::Sendmail;

I'm not familiar with Mail::Sendmail, but I'm betting that it replaces
the new line with an escape sequence. That has nothing to do with
CGI.pm.

-- 
David Dorward   <http://dorward.me.uk/>
"Anybody remotely interesting is mad, in some way or another."
 -- The Greatest Show in the Galaxy

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




Re: CGI - Email Forms

2005-12-08 Thread David Dorward
On Wed, Dec 07, 2005 at 01:19:59PM -0600, Bill Stephenson wrote:

>> Nor should you allow new lines ...
>> $subject = "User entered data with\nBCC: spam victim <[EMAIL PROTECTED]>"

> I wasn't aware of that problem. I'm guessing that using CGI.pm to parse 
> input helps solve that problem. Is this correct?

No. There are plenty of times when you *want* to allow new lines in
user input, even just sticking to the rather narrow field of form
processors that send email, you often want to allow the user to enter
multiple lines of text (in the message body).

Using a prewritten, well-tested formmailer (such as NMS) is a good way
to solve the problem.

-- 
David Dorward  http://dorward.me.uk


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




Re: CGI - Email Forms

2005-12-07 Thread David Dorward
On Tue, Dec 06, 2005 at 02:37:18PM -0600, Bill Stephenson wrote:

> >What tests must be in place in order to keep your perl scripts from 
> >being hijacked from spammers? Any help would be greatly appreciated.
> 
> For forms that send email, you don't want to let the user enter a "To, 
> CC, or BCC" address.

Nor should you allow new lines ...

$subject = "User entered data with\nBCC: spam victim <[EMAIL PROTECTED]>"

-- 
David Dorward  http://dorward.me.uk


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




Re: Filering a file

2005-12-05 Thread David Dorward
On Mon, Dec 05, 2005 at 02:20:33PM +0100, Adedayo Adeyeye wrote:
>How do I write a script to parse through this file and just return the
>unique names. Ie I want the repetitions ignored.

What have you tried?  Where are you stuck? (Opening the file? Reading
the contents? The actual filtering?). Nothing in your question is CGI
related, have you got this working as a command line script but are
having trouble converting it to work under CGI? What code have you got
so far?


-- 
David Dorward  http://dorward.me.uk


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




Re: Need help with making a Modules

2005-11-27 Thread David Dorward
On Sat, 2005-11-26 at 19:48 -0800, Lou Hernsen wrote:
> I am studying modules.. 

perldoc perlmod (and perlmodlib, and perlmodstyle)

> Do I need to pass vars into the mod?

No, but you might need to pass them into subroutines you define in the
module (depending on what you want to do).

> Do i need to declare vars in the mod?

That depends on what you want the module to do.

> What is "our"? something like "my" and "local"?

perldoc -f our

> Do I need to return vars?

The module itself needs to return a true value, this is usually achieved
by sticking "1;" at the end of it.

Your subroutines may or may not return variables depending on what you
want them to do.

> The code I am writing creates part of a web page,
> so I can print it in the mod or in the main.
> (I wold prefer to print it in the mod.. if possible)

Its possible, but I find that building a data structure that represents
the page, then dropping it into a template (using Template-Toolkit of
HTML::Template) makes things more manageable.

-- 
David Dorward   <http://dorward.me.uk/>
"Anybody remotely interesting is mad, in some way or another."
 -- The Greatest Show in the Galaxy

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




Re: Turn off enctype

2005-11-07 Thread David Dorward
On Mon, Nov 07, 2005 at 05:25:27PM -, Dermot Paikkos wrote:

> I need to turn off the enctype attribute within a form

Why? 

> The docs I have read say that application is the default but that 
> doesn't seem to be the case.

[EMAIL PROTECTED]:~$ perl -MCGI -e'print CGI->start_form()' 


Looks like the case to me (assuming you mean
"application/x-www-form-urlencoded" as "application" by itself isn't
any form of encoding.

If you were talking about "the default of the encoding isn't
specified", then URL encoding is the default of every browser I've
ever tried it with. In fact, its the default type mandated by the HTML
spec:

http://www.w3.org/TR/html4/interact/forms.html#form-content-type

-- 
David Dorward  http://dorward.me.uk


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




Re: uninitialized variable

2005-11-01 Thread David Dorward
On Tue, Nov 01, 2005 at 04:34:45PM +0100, Adedayo Adeyeye wrote:

> I'm getting an error when trying to run a script. Part of the scripts is

> my $action = param('form_action');
> if($action eq 'search');

> The error I get is:
> Use of uninitialized value in string eq at connect_rodopi.cgi line 14. 

Looks more like a warning then an error to me.

> How am I supposed to initialize this value?

By assigning something to it, but in this case its possibly better to
test if something was assigned to it.

if (defined $action && $action eq 'search') ...

or 

if (!defined $action) {
  ...
} elsif ($action eq 'search') {
  ...
} 

-- 
David Dorward  http://dorward.me.uk


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




Re: hardcoded paths

2005-10-28 Thread David Dorward
On Fri, Oct 28, 2005 at 10:28:20AM +0100, Dermot Paikkos wrote:

> I am moving a site from once host to another. There are lots of 
> hardcoded fully qualified paths to the localhost

> I am pretty sure this isn't good practise but I am not a bit lost as 
> to what are good alternatives.

Relative URLs?

-- 
David Dorward  http://dorward.me.uk


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




Re: Combined and

2005-10-21 Thread David Dorward
On Fri, Oct 21, 2005 at 10:28:20AM -0500, Jonathan Mangin wrote:

> I've seen several pages with  constructs where
> the first  appears to be 
> How is this done??

With relatively complicated client side stuff, certainly not with CGI.

news:comp.lang.javascript would probably be the best place to ask.

-- 
David Dorward  http://dorward.me.uk


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




Re: XML [AntiVir checked]

2005-10-11 Thread David Dorward
On Tue, Oct 11, 2005 at 04:05:53PM +0200, Naji, Khalid wrote:
> Which Module  could you recommend for the use of the XML (XML::Simple,
> XML::Parser and XML::Writer, XML::DOM, XML::PATH...) ?

Which form of transport would you recommend for getting from one place
to another?

It depends on your specific needs.

-- 
David Dorward  http://dorward.me.uk


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




RE: "if" Question

2005-09-28 Thread Luke, David
Hi Vance,

This sounds silly, but Why do you need to know? If your operation is as
simple as trying to decide whether or not to insert a comma or other
separator, you can do that with the JOIN command without checking the
individual values.

$result = join(',' ($var1, $var2));

$result will be:
"" or "$var1" or "$var2" or "$var1,$var2"

You also have the inline if:
$result = ($var1 ne "" ? ($var2 ne "" ? "Both" : "Var1Only") : ($var2 ne ""
? " Var2Only " : "Neither");

$result will be one of:
"Both", "Var1Only", "Var2Only", "Neither"

David Luke, Application Developer IV
Isocorp, Inc.
DMS Enterprise Information Technology Services
100 Rhyne Building
2740 Centerview Drive
Tallahassee, Florida 32301
 
(850) 216-3746

-Original Message-
From: Vance M. Allen [mailto:[EMAIL PROTECTED] 
Sent: Sunday, September 25, 2005 2:42 AM
To: beginners-cgi@perl.org
Subject: "if" Question

Greetings,

I have several places in my code where I need to check if two string 
variables are empty, if one is empty and the other is not, and if they're 
both populated.

Is there any simpler way to write the code than this?:

if($var1 ne "" and $var2 ne "") {
# Both are populated...
# ...
}
elsif($var1 ne "" or $var2 ne "") {
# One or the other is populated...
# ...
}
else {
# Neither are populated...
# ...
}

The reason I ask is that some of the code gets to be fairly long when I'm 
checking things this way, and so I just wondered if there was any 
shorthand/shortcut way to have Perl check if two strings are empty in one 
expression...regular expressions, maybe?  I appreciate any help, 
suggestions, or answer you can provide.

Thanks,

Vance



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




Re: XHTML (was Re: One link to 2 frames)

2005-09-21 Thread David Dorward
On Wed, Sep 21, 2005 at 10:18:37AM -0400, Chris Devers wrote:
> On Wed, 21 Sep 2005, David Dorward wrote:
 
> > XHTML 1.1 is XHTML 1.0 Strict with Ruby added. 
 
> Really? 

Yes.
 
> As in the scripting language Ruby? 

No. As in the Ruby Annotation language. 
http://www.w3.org/TR/2001/REC-ruby-20010531/

-- 
David Dorward  http://dorward.me.uk


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




Re: One link to 2 frames

2005-09-21 Thread David Dorward
On Wed, Sep 21, 2005 at 02:29:15PM +0200, MNibble wrote:
> The time delay, well yes there is a problem, but i can't fix that on, so 
> this needs to be my workaround. There a lot a data that needs to be 
> processed, and i didn't want the user to wait for that page, so i put a 
> side befor the output and give the data some time to settle.

The trick here is that when a request comes in:

* Generate a unique ID for the job

* Fork it off into the background (or store the details in a database
  and let a continuing background process handle it)

* Return to the user a page explaining that the process will take some
  time and give them a link (including the job id) to check to see if
  it is ready yet. Idealy you will provide some time estimate on the
  issue. You can also use JavaScript or a meta refresh to periodically
  poll the server without user intervention. This should be in
  addition to the link as JavaScript is optional, and meta refresh
  isn't standardised.




-- 
David Dorward  http://dorward.me.uk


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




XHTML (was Re: One link to 2 frames)

2005-09-21 Thread David Dorward
On Wed, Sep 21, 2005 at 12:11:59PM +0200, MNibble wrote:

> I won't say you are wrong, since you are right.I (please don't throw 
> stones or bits at me) already use css und div span and stuff like that 
> and if it is called xhtml that's fine for me

That isn't what is called XHTML.

XHTML 1.0 is HTML 4.01 expressed in XML instead of SGML. In practise,
its pointless for 99/100 cases. It has Appendix C which does a bunch
of handwaving and allows you to serve XHTML with the text/html content
type so that "legacy" user agents which don't understand XHTML (like
Googlebot and Internet Explorer) can cope with it if you follow some
additional constraints (of course Appendix C depends on browsers
getting some parts of HTML wrong in the first place, and not all
browsers do, so its pretty rubbish).

XHTML 1.1 is XHTML 1.0 Strict with Ruby added. 

XHTML 2.0 isn't ready and is pretty much an entirely new language that
does a similar job to HTML.

In practise XHTML is far more trouble then its worth unless you have a
need for mixed namespaces (if you don't know what they are, you don't
need them) and should generally be avoided in favour of the better
supported HTML 4.01 (the Strict variant).

Using CSS for layout, HTML (or XHTML) for semantics, relationships and
structure, and JavaScript for behaviour is generally lumped under the
umbrella heading of "Standards based design".

-- 
David Dorward  http://dorward.me.uk


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




Re: One link to 2 frames

2005-09-21 Thread David Dorward
On Wed, Sep 21, 2005 at 08:32:47AM +0200, MNibble wrote:

> Thx both of you. But i realy think there musst be a possibilty. I have 
> two javascript funktions which i try to get rid of.

This started off as a simple case of populating two frames in response
to one user action (at least as far as I understood it). Now you've
introduced a stack of other elements into the equation, all of which
appear to be possible solutions to a larger, undefined problem.

If you specified what the actual problem you are trying to solve is,
you might get some advice that is more relevent to your situation. As
it is, we can only try to answer the questions you ask. (And the
answers you've recieved are good ones in the context of the question).

> The first is this link which fills to frames 

There are two ways to do this.

1. Linking to a new  document
2. JavaScript

In most cases the better solution to the problem is eliminating the
frames and sending the user a single combined document.

> ( i would also fork into two processes with a redirect ... maybe
> that's gonna work )

One request returns one HTTP resource, that's how the web works. You
can't return one document, then return another document a little while
later, the client won't be expecting it.

> and a time delay .. something like: if you are not in 30 sek then
> push

It would be up to the browser to determine if they are "in" or not,
and that would require JavaScript. I've no idea why you would want
that functionality though. It sounds like a band-aid solution to more
serious underlying problem.

-- 
David Dorward  http://dorward.me.uk


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




Re: One link to 2 frames

2005-09-20 Thread David Dorward
On Tue, Sep 20, 2005 at 02:05:09PM +0200, MNibble wrote:

> is there a standard solution to this problem

To what problem? (Please don't depend on people reading subject
lines).

There are two:

1. Don't use
frames. http://www.allmyfaqs.com/faq.pl?Problems_with_using_frames

2. Link to a new frameset document.

Neither really involve Perl or CGI.

-- 
David Dorward  http://dorward.me.uk


-- 
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-20 Thread David Dorward
On Mon, Sep 19, 2005 at 09:36:16AM -0500, Tony Frasketi wrote:
> Thanks for the response, David.
> I scanned thru the document to which you refer and from what I can 
> understand it appears 'to me'  that the 'Content-Disposition Header 
> Field" being described is in the context of email messages.

Whoops, beg pardon.

http://www.faqs.org/rfcs/rfc2616.html

Section 19.5.1

-- 
David Dorward  http://dorward.me.uk


-- 
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 David Dorward
On Sun, 2005-09-18 at 17:46 -0500, Tony Frasketi wrote:
> 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 

http://www.faqs.org/rfcs/rfc2183.html

-- 
David Dorward   <http://dorward.me.uk/>
"Anybody remotely interesting is mad, in some way or another."
 -- The Greatest Show in the Galaxy

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




Re: CGI.PM and IF statment....

2005-09-10 Thread David Dorward
On Sat, 2005-09-10 at 01:44 -0500, David Gilden wrote:
> 
> Choose type message

> my $mt = param('message type');
> if (length($mt) == 0) {

> This should only redirect it someone has not made a 'selection' 
> what am I missing?

If the user truly has not made a selection, the $mt will be undef, and
your script will throw a warning:

if (!defined $mt) {
  # etc
}

However, it is very difficult for the user to fail to make a selection
given a select element. It would usually require them to construct their
own form, or HTTP request by hand. If you want to test if they have
selected the "Choose type message" option, then you need to check if $mt
contains the data "0".

The length of "0" is 1 (since it is one character long), so (length($mt)
== 0) will always fail.

if (
 (!defined $mt) ||
 ($mt eq '0')
   ) {
  # Etc
}

-- 
David Dorward   <http://dorward.me.uk/>
"Anybody remotely interesting is mad, in some way or another."
 -- The Greatest Show in the Galaxy

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




CGI.PM and IF statment....

2005-09-09 Thread David Gilden
The if statement below does not seem to work as expected//

Given in the HTML:

Choose type message
Comment about a recent performance or recording
Concert or Event Booking inquiry
Personal message



and in the perl:

#!/usr/local/bin/perl 
use CGI qw/:standard/;
use strict;

#and other stuff...

my $mt = param('message type');

if (length($mt) == 0) {
print redirect("/pages/error.html");
exit;
}

This should only redirect it someone has not made a 'selection' 
what am I missing?

Thanks!

Dave
(kora musician / audiophile / webmaster @ www.coraconnection.com  / Ft. Worth, 
TX, USA)

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




Re: $ENV{'HTTP_REFERER'}

2005-08-24 Thread David Dorward
On Wed, Aug 24, 2005 at 02:12:56PM -0700, Denzil Kruse wrote:

> 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?

Reliable enough for general interest and for finding some sites with
links to moved pages on your site. Not reliable enough to depend on.

> Do browsers or other situations block it or obfuscate it?

Often. Its an optional header, isn't supposed to be sent when arriving
from an https page, and is munged by a goodly number of personal
"firewalls".

>  Is there another way to do it

No

-- 
David Dorward  http://dorward.me.uk


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




Check out CGI::Portal

2005-08-23 Thread alex david
Initially, I have created CGI::Portal for my own projects, but decided to share 
it with the community.
 
CGI::Portal should significantly speed up the development of your next projects 
since it provides core web application functionality like user login, 
registration, encrypting of passwords, sessions, recovering of passwords and 
more. You can focus on what is important for the specific applications.
 
After installing CGI::Portal, all you need to do is:
 
1. Create a user database table and a sessions database table
   It is important that those tables have at least the fields that are used by 
CGI::Portal
2. Create a startup script and configure it according to your database
3. Run the startup script from your web browser
 
For your specific applications needs create add-on components to CGI::Portal. 
As you will see, CGI::Portal applications are easily updated, installed, 
ported, and components can be shared with other developers ;-)  
 
Please check it out, and I will be available for your questions.
 
Alex David


-
 Start your day with Yahoo! - make it your home page 

Re: getstore and comments

2005-08-19 Thread David Dorward
On Fri, Aug 19, 2005 at 10:58:24AM +0200, Adriano Allora wrote:

> Some questions:
> 1) how can I write multine comments? something like /** ... **/?

You can fake it with POD. I juse use a decent editor that lets me
comment out a every line in a region.
 
> 2) the following script doesn't find the page requested in getstore 
> (baolian.local = 127.0.0.1). Why?

The second parameter for getstore is a file, not a URL.

> 3) $homepage must be a real page/file or I can use it like a normal 
> variable or a filehandle to read with whlie(<>)?

The documentation doesn't say, but usually a module which takes a file
can take either a filename or a filehandle.

If your only intention is to read it, then you might be better off
with get() instead of getstore().

-- 
David Dorward  http://dorward.me.uk


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




Re: htaccess question

2005-08-12 Thread David Dorward
On Thu, Aug 11, 2005 at 10:30:35PM -0400, Chris Devers wrote:

> > If a directory is password protected with .htaccess
...
> > or do you always get the popup box?

I'm guessing you are talking about Basic Authentication here. A
.htaccess file can contain pretty much any Apache directive, so it
could be configured to use a Perl script for authentication (which
would be more on topic for this list).

> You may, however, be able to use this syntax:
> http://Moe:[EMAIL PROTECTED]/members/index.html
> Whether this will work depends on the server configuration.

No, it depends on the browser. There is no difference between that
syntax and typing into a dialog box as far as the server is concerned,
its just different ways for the browser to gather the information from
the user.

The credentials in URL syntax hasn't got as much support as it used to
have though, it was too often used in pishing schemes.

> But note that embedding this in the URL is usually considered a bad 
> habit, unless you have no problem with this information being sent 
> across the internet in the clear for anyone to see.

It is only in the clear if you don't use HTTPS - and if you don't use
HTTPS then any password you send it going to be clear. The difference
here is that it is visible in the URL - and so exposed to the
look-over-the-user's-shoulder-in-the-real-world attack.

-- 
David Dorward  http://dorward.me.uk


-- 
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 do I make two different web pages come up from one CGI?

2005-08-04 Thread David Dorward
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).

-- 
David Dorward  http://dorward.me.uk


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




Re: Easy question

2005-07-19 Thread David Dorward
On Tue, Jul 19, 2005 at 02:54:13PM +0100, Neville Hodder wrote:

> 

* Invalid HTML. The action attribute is required. 

* You haven't specified an enctype, but the default is unstuiable for
  use with file inputs.

* You haven't specified a method, and the default (get) is unsuitable
  for use with file inputs.

http://www.w3.org/TR/html4/interact/forms.html#h-17.3

> 

Funny looking paragraph ...

Inputs without names cannot be successful form controls.

http://www.w3.org/TR/html4/interact/forms.html#h-17.13.2

>  maxlength=\"15\">
> 
> The file is: $ENV{QUERY_STRING}.

Use CGI.pm. Don't try to access CGI related enviroment variables
directly. CGI.pm solves most of the problems you will run into
already.


> 
> 
> 

You should pay a visit to http://validator.w3.org/

-- 
David Dorward  http://dorward.me.uk


-- 
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 grep out contnts of a column

2005-07-11 Thread Nazary, David
I had to download and intsall Inline-Files-0.62 module and when I run
the below script you suggested I get:

Can't locate Filter/Util/Call.pm in @INC (@INC contains: C:/Perl/lib
C:/Perl/site/lib .) at C:/Perl/lib/Inline/Files.pm line 6.
BEGIN failed--compilation aborted at C:/Perl/lib/Inline/Files.pm line 6.
Compilation failed in require at C:\temp\get_clearlicense.pl line 16.
BEGIN failed--compilation aborted at C:\temp\get_clearlicense.pl line
16.

I guess I am missing a Filter module, but there are numerous on the
CPAN. Which module should I download next?

Thanks & Regards
David Nazary

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of zentara
Sent: Saturday, July 02, 2005 8:35 AM
To: beginners-cgi@perl.org
Subject: Re: How to grep out contnts of a column 

On Sat, 02 Jul 2005 11:29:08 -0400, zentara <[EMAIL PROTECTED]>
wrote:

Sorry, I had a glitch in sending, and the previous post was foobar'd.

Here is a way. I use Inline::Files to make it a standalone running
script.

#!/usr/bin/perl
use warnings;
use strict;
use Inline::Files;

my $max_clearcase_licenses;
my $clearcase_licenses_used;
my %groups;
my %groupc;

while(){
last if $_ =~ /END/ ;  #hack to get around eof in inline files
my($user,$group) = split /\s+/, $_;
$groups{$user} = $group;
$groupc{$group} = 0;
  }

while () {
print $_ ;
 if ($_ =~ /Maximum active users allowed: (\d+)/) {
$max_clearcase_licenses = $1;
 } 
 
 if ($_ =~ /Current active users: (\d+)/) {
$clearcase_licenses_used = $1;
 }

 if ( $_ =~ /(.*)minutes(.*)/ ) {
my ($user,undef,undef) = split /\s+/, $_;  
 $groupc{ $groups{$user} }++; 
 }

}
close CLEARCASE;

print "max_clearcase_licenses $max_clearcase_licenses\n";
print "clearcase_licenses_used $clearcase_licenses_used\n";

foreach my $key (keys %groupc){
  print "group $key -> $groupc{$key}\n";
}

__CLEARCASE__
LICENSES:
Max-Users  Expires   Password [status]
62  none  3abbc829.67e2685f.02 [Valid]

Maximum active users allowed: 62
Current active users: 17

ACTIVE users:
User   PriorityTime-out in
screl none   29 minutes (at 11:24:17)
chowell none   29 minutes (at 11:23:58)
pgaray none   28 minutes (at 11:23:09)
hhung none   28 minutes (at 11:23:05)

License Usage Statistics:
0 licenses revoked since start of period 7/1/2005.
0 license requests denied.
0 active users bumped by preferred user.

__GROUPS__
screl   apple
chowell mac
pgaray   pc
hhung   apple  
__END__



-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html

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



--
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 browse and select a remote file and then return the filename

2005-07-07 Thread David Dorward
On Thu, Jul 07, 2005 at 12:14:42PM -0400, Chris Devers wrote:

> > Well, that specific example anyway :) I suspect a signed Java applet
> > could work on other systems.
 
> I thought Java applets were sandboxed, and that access to the filesystem 
> was explicitly not allowed. Have things changed in the past few years? I 
> thought the whole point of Java applets was that they were "safe", in 
> part, because they couldn't interact with the underlying filesystem. 

That's true for standard applets, but I *think* that a digital
signature and the user granting permission will let them escape the
sandbox. I wouldn't swear to it, I've done very little with applets.

-- 
David Dorward  http://dorward.me.uk


-- 
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 browse and select a remote file and then return the filename

2005-07-07 Thread David Dorward
On Thu, Jul 07, 2005 at 11:42:29AM -0400, Chris Devers wrote:

> > It isn't possible. For that sort of thing you'll need something like
> > an ActiveX control with permission to read the user's file system. (Or
> > to get the user to type the path to the file).
> 
> And that, in turn, can only be reliable with IE on Windows.

Well, that specific example anyway :) I suspect a signed Java applet
could work on other systems. Its not reliable on IE anyway - its
unlikely that all users would have their security low enough (and
accept the alerts) for it to run.

However, I have trouble conceiving of a circumstance where it would be
useful to do this over the WWW, so its probably in an environment where
user agents can be mandated.
 
> I'm not aware of anyone getting ActiveX to work on anything other than 
> the IE/Windows combination. Admittedly, that's something like 90% of web 
> users, but Firefox, in particular, seems to be growing fast now.

I seem to recall somebody managing to run ActiveX and IE under WINE :)
 
-- 
David Dorward  http://dorward.me.uk


-- 
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 browse and select a remote file and then return the filename

2005-07-07 Thread David Dorward
On Thu, Jul 07, 2005 at 03:00:02PM +0100, Neville Hodder wrote:
> I am in the process of learning how to use the CGI.pm module but can not
> find a method that will allow me to simply choose a 'remote' file. I
> need to be able to return the value "path+filename" of a file that the
> user has browsed to using something like the standard HTML form type:

It isn't possible. For that sort of thing you'll need something like
an ActiveX control with permission to read the user's file system. (Or
to get the user to type the path to the file).

Since the server doesn't have permission to access the user's file
system over the Internet, and since that file system might be UNIX
type, DOC type, or some other unknown type - it isn't a particularly
useful feature to build into HTML.

-- 
David Dorward  http://dorward.me.uk


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




How to grep out contnts of a column

2005-07-01 Thread Nazary, David
Hi everyone;

One of our tools provides following output:

<<<<<<<<<<<<< cut >>>>>>>>>>>>
LICENSES:
 Max-Users  Expires   Password [status]
62  none  3abbc829.67e2685f.02 [Valid]

 Maximum active users allowed: 62
 Current active users: 17

ACTIVE users:
  User   PriorityTime-out in
 screl none   29 minutes (at 11:24:17)
   chowell none   29 minutes (at 11:23:58)
pgaray none   28 minutes (at 11:23:09)
 hhung none   28 minutes (at 11:23:05)

License Usage Statistics:
0 licenses revoked since start of period 7/1/2005.
0 license requests denied.
0 active users bumped by preferred user.
<<<<<<<<<<<<<<<< cut >>>>>>>>>>>>>

Following is part of a script that pulls out Maximum and Current user.  

# Get ClearCase license usage
open CLEARLICENSE, "clearlicense -product ClearCase |" or die "Can't run
clearlicense: $!\n";
while () {
   print $_ ;
   if ($_ =~ /Maximum active users allowed: (\d+)/) {
  $max_clearcase_licenses = $1;
   } elsif ($_ =~ /Current active users: (\d+)/) {
  $clearcase_licenses_used = $1;
   }
}
close CLEARLICENSE;

However, I also need to filter out all the usernames under "User" column
and match them against a file that has a group name assigned to each
user, then print out the total number of users for each group. How can I
do this?

Thanks a lot in advance

David Nazary


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




Re: HTML::Templates

2005-06-28 Thread David Dorward
On Tue, Jun 28, 2005 at 08:21:02PM +0530, Rajesh Raghammudi wrote:

> I am using HTML::Templating system for my project and the requirement is, 
> URL given at the address bar should not be changed throughout the 
> application

Yuck. The web is not designed to work like that.

> I could able to achieve this and works fine for me (I have a 
> login page and users have to login to access the application).
> 
> The problem I am facing is, If the user refreshes or does anything, nothing 
> will happen and everything works fine, but when the user places cursor at 
> the address bar and presses Enter, then the page is getting redirected to 
> login page asking the user to login again.

I'm guessing you are passing everything as POST data? Use a session to
track where the user is at any given point, and return them there if
they revisit the page without submitting POST data.

-- 
David Dorward  http://dorward.me.uk


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




RE: Mmodifing Windows registry key

2005-06-22 Thread Nazary, David
Thanks for the suggestion, but here is how I finally ended up doing it
and it does what I needed:

@lic_servers = ("nike0",
"dhps",
"gksc",
"fhd6",
"FM6S",
);

foreach $lic_serv (@lic_servers)
{   
system ("reg add HKLM\\SOFTWARE\\Atria\\ClearCase\\CurrentVersion \/f
\/v LicenseHost \/t REG_SZ \/d \"$lic_serv\"");
system ("get_clearlicense.pl license.txt $lic_serv");
}

David Nazary

-Original Message-
From: Chris Devers [mailto:[EMAIL PROTECTED] 
Sent: Monday, June 20, 2005 11:47 AM
To: Nazary, David
Cc: Perl Beginners - CGI List
Subject: Re: Mmodifing Windows registry key

On Mon, 20 Jun 2005, Nazary, David wrote:

> I want to run a script in a continuous loop so that each time it runs 
> it will modify a registry key and get the data against the new key.
> 
> Basically, I need to use "reg.exe UPDATE" command from inside a perl 
> script. Is it possible?

Yes, but why would you do it that way? Windows Perl provides ways to 
poke at the registry directly, without having to invoke reg.exe by hand.


It would make far more sense to do things with a CPAN module. A quick 
Google / CPAN search suggests that Win32::TieRegistry is the way to go; 
there's an older Win32::Registry, but several sources I found claim that

it is obsolete & Win32::TieRegistry is the best option available now.

<http://search.cpan.org/~tyemq/Win32-TieRegistry/TieRegistry.pm>
<http://www.xav.com/perl/site/lib/Win32/TieRegistry.html>

Quoting from (& reformatting) the beginning of the documentation...


SYNOPSIS

  use Win32::TieRegistry 0.20 ( UseOptionName=>UseOptionValue[,...]
);
  $Registry->SomeMethodCall(arg1,...);
  $subKey  = $Registry->{"Key\\SubKey\\"};
  $valueData   =
$Registry->{"Key\\SubKeyValueName"};
  $Registry->{"Key\\SubKey\\"} = { "NewSubKey" => {...} };
  $Registry->{"Key\\SubKeyValueName"} = "NewValueData";
  $Registry->{"\\ValueName"}   = [ pack("fmt",$data), REG_DATATYPE
];

EXAMPLES

  use Win32::TieRegistry( Delimiter=>"#", ArrayValues=>0 );
  $pound  = $Registry->Delimiter("/");
  $diskKey= $Registry->{"LMachine/System/Disk/"}
  or die "Can't read LMachine/System/Disk key: $^E\n";
  $data   = $key->{"/Information"}
  or die "Can't read LMachine/System/Disk//Information
value: $^E\n";
  $remoteKey  = $Registry->{"//ServerA/LMachine/System/"}
  or die "Can't read //ServerA/LMachine/System/ key:
$^E\n";
  $remoteData = $remoteKey->{"Disk//Information"}
  or die "Can't read ServerA's System/Disk//Information
value: $^E\n";
  foreach $entry (  keys(%$diskKey)  ) {
  ...
  }
  foreach $subKey (  $diskKey->SubKeyNames  ) {
  ...
  }
  $diskKey->AllowSave( 1 );
  $diskKey->RegSaveKey( "C:/TEMP/DiskReg", [] );


I'm not a Windows programmer, so I can't vouch for how well this stuff 
work in practice, but it looks pretty straightforward to use. Both 
versions of the documentation linked above provide lots of examples of 
both reading & writing registry keys, so there should be a method that 
maps well to the kind of work that you're doing. 
 
 

-- 
Chris Devers

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




Mmodifing Windows registry key

2005-06-20 Thread Nazary, David

Hi;

I want to run a script in a continuous loop so that each time it runs it
will modify a registry key and get the data against the new key.

Basically, I need to use "reg.exe UPDATE" command from inside a perl
script. Is it possible?

I have seen some examples on the web but they are too complicated. Is
there an easier way to do this?

Thanks
David Nazary



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




Re: hide source code 2 - online game

2005-06-19 Thread David Dorward
On Sat, Jun 18, 2005 at 09:21:55PM -0400, Luinrandir Insight wrote:

> my web host's cgi-bin is password protected.
> is this enough to hide my perl-cgi code that makes the HTML pages?
> the player files are in the same dir as the cgi code.
> I have an online game, so I don't want people to cheat.

Do the players have access to the server other than through http?  If
you request one of the player files over http, what do you get?
 
As a general rules, any data files should be kept out of the web root
entirely.

> now I am hearing that PHP is the way to go for maximum hacker
> protection...  comments?

Err... "Ha!"? (Code is only secure as the person who writes it, I find
it rather harder to write secure code in PHP, it doesn't come with
such sane features as, for example, DBI bind variables.)

-- 
David Dorward  http://dorward.me.uk


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




Re: hide source code

2005-06-18 Thread David Dorward
On Sat, Jun 18, 2005 at 07:43:58PM +0200, Glauco Magnelli wrote:
> Excuse me, you're right. I want hide Perl code from
> other users of the server.

http://perlmonks.org/?node_id=423870
 
-- 
David Dorward  http://dorward.me.uk


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




Re: hide source code

2005-06-18 Thread David Dorward
On Sat, Jun 18, 2005 at 02:51:51PM +0200, Glauco Magnelli wrote:
> I would hide source code in my CGI Perl scripts.

Which source code (Perl, HTML?)? From whom (other users of the server,
visitors to the website?)?

-- 
David Dorward  http://dorward.me.uk


-- 
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 do I change the font color of a checkbox group

2005-06-13 Thread David Dorward
On Mon, Jun 13, 2005 at 09:23:00AM -0400, miwalsh wrote:

> I am building a web page using CGI. The page contains checkboxes,
> popup menus etc. I have been able to change the font of most of the
> page by surrounding the statements on the page with the  color='color> tag. For example, some of the code might look like
> this: print "This is my web page.";

The  element is deprecated, you really should be using CSS for
this.

http://www.w3.org/Style/CSS/learning
 
> I would like to change the font of the words in the checkbox groups so that 
> they match the rest of the page. However, I don't know how to do this and I 
> can't find anything in the documentation that helps. If anyone has any ideas 
> about this I would be greatfull to hear them.

It really depends on the markup that is being generated, something
like:

legend { color: red; }
label  { color: red; }

... should do the trick if the generated markup is good.

-- 
David Dorward  http://dorward.me.uk


-- 
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 save the state of a CGI script

2005-05-30 Thread David Dorward
On Sat, May 28, 2005 at 09:57:55PM +0530, Ankur Gupta wrote:

> I read perldoc CGI and found that state of a script could be saved by the
> following function.

> $myself = $query->self_url;
> print q(I'm talking to myself.);

Not quite. If you used "qq" so that the string would interpolate
variables then it would create a link back to the current URL -
including the query string.
 
> print $q->start_form(-method=>'POST',

You cannot create POST requests using a hyperlink, in HTML the only
way to set this up is with a form. Additionally, since the data not
sent using the query string then simply reading the query string won't
include the same values.

You would need to loop through the posted data and generate form
controls (such as hidden inputs) for each value. Since the rest of
your message discusses sorting of data, you should consider that GET
is supposed to be used when retrieving any information from the server
and POST when you are changing something. (This has implications such
as GET being bookmarkable, and POST causing most browsers to warn
about resubmitting data).

-- 
David Dorward  http://dorward.me.uk


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




  1   2   3   4   5   >