Fwd: Interview Questions

2004-04-20 Thread drieux
p0: don't you hate it when

a. you reply to something that was sent to the cgi list
and then accidentally send it back to the beginner's list
b. have the lack of coffee to spell 'perl' lower case when
talking about the coding language vice the binary executable.
p1: my working excuse is

a. I had a staff meeting and only the voices in my head showed up.
b. The coffee had not yet kicked in.
c. My Spellchecker is out on vacation
d. there was no adult at the keyboard, I was getting in touch
with my inner juvenile delinquint
e. something witty here
On Apr 20, 2004, at 9:04 AM, Wiggins d Anconia wrote:
[..]
This has what to do with CGI?

[..]

Wiggins, think about the idea for a moment,
what if it were you first time in the barrel
as the guy who had to do the interviewing of
folks who were going to be writing perl code
for some portion of the CGI project?
Where would you go to see if folks had a
stock set of basic perl code questions that
related to doing web-work.
My lead engineer sets them up with a basic
walk through on basic so called 'simple perl questions'
that are actually a part of a diabolical interegation
method - since it starts out with
	what is CPAN?

and based upon that he will roll into the questions
about building perl modules for CPAN. Which normally
fishes up things like have they or have they not
worked with h2xs and/or XS code, hence can they
do the bridge work to perl from pre-existing
c-code libraries that would be required for doing
some of the basic web-technology work.
That also gets us chances to talk about things like
the t/ and 'make test' as a code coverage concern.
At which point one knows a lot about what the
person does with 'perl' as a 'coder' or as a 'scripter'
and hence whether they will be useful at the design
layer or merely at the typing layer.
Toss in the usual questions about why would one use
javascript, and how, vice perl on the server side.
lace a few basic 'write me a perl code implementation
of say the towers of hanoi problem or this or that,
and one check for how they deal with an ambiguously
worded coding problem - hence whether they should
be looking before leaping - and then one catches
their basic issues with actually doing perl code.


ciao
drieux
---

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




ciao
drieux
---

--
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 add an item into Shopping cart

2004-03-24 Thread drieux
On Mar 22, 2004, at 5:53 PM, B. Fongo wrote:

I'm working on a shopping cart, and yet to implement Apache::Session.
But before then, I have a question on how to populate a shopping cart
without the page reloading. Is there a way of achieving this using 
perl?
Let me see if I get you correct here, the concern is that
you want to have an
	add to shopping cart

that will not send a message back to the web-server as
a 'form' event? yes?
 I believe it is possible to use JavaScript event-handler can be to 
keep
track of items added into the cart, and later passed to perl to do the
necessary entry into the database.
If all of the items that can be placed in the cart are
on one page, then you seem to have your solution here.
The trick becomes if one has to create a shopping cart
that will persist over several web page presentations.


ciao
drieux
---

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



Re: Virtual Directory Problem

2004-02-15 Thread drieux
On Feb 14, 2004, at 12:18 AM, Mallik wrote:
[..]
In Apache, the /usr/local/fsuser/sbin directory is mapped to the
virtual directory http://192.168.0.10/fsuser/cgi-bin/.
From browser, I am able to access all the .cgi and .pl files
present in the /usr/local/fsuser/sbin and its subdirectories.

But I am not able to access the html files present in this
directory. When I am giving the following URL it is giving
the Premature end of script error.
http://192.168.0.10/fsuser/cgi-bin/help.htm.

Whereas, I am able to access the same html with the following URL.

http://192.168.0.10/help.htm.
[..]

first off best to post it to one or the other groups,
I have sent this reply back to the cgi list.
I think you are confusing the 'logical' address
of a file - eg
	schema://host_port/logical_path

with the actual file system path to the file.

Then adding the confusion between the idea of separating
the cgi code from the actual html files - which is hte
point of having a cgi-bin directory.
The idea of the cgi_bin is that it is where one will
put executables - and a flat html file does not need
to be executed, it is merely dished up as a stream of
bits back to the browser.
So you might want to go back and review what exactly
you are trying to do in the process.
Do you really like having a declared cgi-bin directory?

ciao
drieux
---

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



Re: Email module

2004-02-09 Thread drieux
On Feb 9, 2004, at 7:46 AM, Jan Eden wrote:
[..]
which email module would you recommend? I searched CPAN and found a 
whole bunch. In CGI Programming with Perl, Mail::Mailer is mentioned, 
but since the book is a little older, this might not be the best 
choice.
[..]

Perl is a little older 8-)

If all you need is a form mail then check out
http://cvs.sourceforge.net/viewcvs.py/nms-cgi/formmail/
but it rests on even 'older' technology than the
Mail::Mailer modules...


ciao
drieux
---

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



Re: Running a system command as root

2003-12-17 Thread drieux
On Dec 17, 2003, at 3:13 PM, Dan Anderson wrote:
[..]
I know webmin panels most virtual hosts use execute root commands.
How do they do this, and how do I get around this?
[..]

I think that the webmin application is
normally
a. running as root
b. not running on the default HTTP port
As such the code is not setuid to Root.

So you might want to think about whether what you
want to integrate with webmin should be accessible
from a public cgi_bin directory anyway.
ciao
drieux
---

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



Re: Fork

2003-12-09 Thread drieux
On Dec 9, 2003, at 9:53 AM, Octavian Rasnita wrote:

Can you give me a short example about how I should create that loop?
a strategy I proposed over on the beginner's list
would look like say:
http://www.wetware.com/drieux/pbl/Sys/gen_sym_big_dog.txt

That of course was built for a command line interface
and hence loops back for checking the Children with
the classical  sig_handler model of REAPER from the
perlipc pod...
In your case you would probably want merely the
simpler dispatcher system and the 'runner()' model.
ciao
drieux
---

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



Re: pass a variable from php to the perl file

2003-12-04 Thread drieux
On Dec 4, 2003, at 7:24 AM, Ciko Parera wrote:
[..]
I am trying to call a perl script from php (with shell_exec) and
pass a variable to the perl file I need to get the value of a variable 
from a PHP script, and put it into my perl script
Does anyone know how I do this?
[..]

Since you are going to invoke
the perl code with a shell exec,
why not pass it as a command line option:
	myPerlCode $variable

and have your perlcode pick it up from
@ARGV the old fashion way???
You might want to look at formalizing
that approach with say Getopt::Long
on the perl side so that you can simplify
your interface ...
ciao
drieux
---

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



Re: Passing the hash

2003-12-04 Thread drieux
On Dec 4, 2003, at 12:21 PM, Jonathan Mangin wrote:
[..]
This is a pretty old book and I'm wondering if there's a
newer, better way? I wish to be able to achieve what would
be the results of this (if it were possible):
if ($CGI-param(Screen3)) {
   showmeScreen3($CGI, %widgets);
}
...
but, of course, %widgets doesn't exist at compile time.
Something I read in perlreftut made me think I might be
able to use a reference here. Possible?
Alternatively, is there syntax that allows passing a hash
using a hidden input variable? i.e.:
input type=hidden name=widgets value=%widgets
[..]

I think you might want to re-think your basic 'interface'
and then you might find that 'dispatchers' are your friend.
First the Interface, then the dispatcher.

Let's put in something like

	input type=hidden name=screen value=Screen3

Then you could go with a dispatcher of the form

my %process = (
Screen1 = \showScreen1,
Screen2 = \showScreen2,
Screen3 = \showScreen3,
);
	...

	my $screen = $CGI-param(screen)

if ( exists($process{$screen}))
{
$process{$screen}($CGI);
}else{
process_broken_cgi($CGI);
}

This way only the 'widgets' that need to be 'hidden'
are actually shipped out in the html... This way you
can also 'grow' your Dispatcher as you need to,
and add functionality as required...
ciao
drieux
---

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



Re: Javascript problems with -script

2003-11-23 Thread drieux
On Sunday, Nov 23, 2003, at 20:17 US/Pacific, Mike Schienle wrote:
On Nov 23, 2003, at 06:47 PM, Charles K. Clarkson wrote:

On Sunday, November 23, 2003 6:42 PM,
Mike Schienle [EMAIL PROTECTED] wrote:
[snip]
: Can someone point out what I'm missing in the -script section
: that's commented out that would make it not work correctly?
: The source of the file that's referenced is identical to what's
: in the JSCRIPT variable.
It works fine for me.
Hmm, I must be doing something silly and haven't spotted it. Maybe 
some sleep will help :-)
I'd vote for 'sleep', since you have done
a reasonable job of trying to keep the code
reasonably aligned.
my $q = new CGI;
print
$q-header(),
$q-start_html(
  -title='E-Tim Navigator',
  -author='Mike Schienle, [EMAIL PROTECTED]',
  -style={
'src'='/styles/delta.css'
  },
  -script={
 -language='JAVASCRIPT',
 -src='/delta/js/openWin.js'
   }
),
$q-start_form(
  -name='GUI',
  -onSubmit=return OpenWin()
);
in the morning you may be able to look at the rest of
the stuff after the ';' where you had the '...' since
the above generates what you say you want that part to
do. It might be that you will want to start the
next section with it's own print sequence?
ciao
drieux
---

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


Fwd: POD, Faq and tradition - Re: extracting email addys.

2003-11-22 Thread drieux


On Saturday, Nov 22, 2003, at 16:18 US/Pacific, Randal L. Schwartz 
wrote:
[..]
It's just that we keep seeing this over and over again.  That's the 
point
of the FAQ.  What happened to the ethic of even ATTEMPTING to look
for a local FAQ before posting to a list.

{sigh}
I think a part of the problem is the willingness
of some of us to 'respond' to questions, without
always thinking about the need for some discipline
about what is IN the POD and FAQ.
a part of that problem is also the fact that
most folks just don't understand 'perldoc'
let alone 'perldoc -q mail' to query the
faq that they have for things related to mail.
The other side of this may be tied up with the
lack of awareness about the CPAN, and that some
of these problems are that OLD, and keep
coming around on the list as new folks show
up and need to be taught the standards
a. how to ask an effective question
b. what resources are available
c. how to use those resources
Then there is also the 'age' problem, since
RFC822 is, well, not a Young RFC and is from
a time before time was known, or at least
closer to the Epoch than now. While at the
same time RFC2822 was reserved for the expected
day when an extension would be needed for things
no one could think about in those dark days when
we all beat out code the old fashion way with a stick
on a flat rock... And Consensus was based upon the
last person standing and all of that...
ciao
drieux
---

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


Re: Syntax error with while

2003-11-10 Thread drieux
On Sunday, Nov 9, 2003, at 17:59 US/Pacific, A L wrote:
[..]
Thank you but I prefere do it by myself, to understand what I am doing,
the target is to improve myself in Perl CGI
[..]

not a problem. I put forward the Foobar package as a way
to think about testing coding ideas. The general CGI problem
is messy enough as it is, since one is trying to marry
input that comes, as in your case from a database, into
output that is wrapped in HTML. So if the problem is
a 'perl error' - the sort of 'unable to do foo at line integer'
coming back from the Perl Compiler, the problem is a syntax
error in the perl code itself.
this is why I put the challenge in about

	print some stuff here, while(...){}, some other stuff;

since I can not find a way to do that. I tried a variety of
ways to think about it, and did some code runs at it, but
they all kept coming up with the variation on the
	syntax error with while

response at compile time.

BUT I can solve the problem

print some stuff here;
while ( my ( $id, $thing, $third, $forth) = $req-fetch())
{
print $id, $thing, $third, $forth \n;   
};
print some other stuff;
So you might want to attack the problem along that line.



ciao
drieux
---

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


Re: HTTP::Request

2003-11-10 Thread drieux
On Friday, Nov 7, 2003, at 17:12 US/Pacific, Tobias Fink wrote:
[..]
but what i didnt want to do is something like this:

my $response =
$ua-get(http://search.cpan.org/ 
search?query=$queryquery2=$query2etc);

because this only works for http-get.
Isnt it possible to create a header that works with get and post?
[..]

tobias,

remember the differences between a 'GET' and a 'POST'.

A 'GET' passes all that it knows in the URI itself,
as in the case above. The POST will pass the 'path'
portion of the URI to the web-server, and send
the 'query' itself as a part of the 'body' of the message.
hence the post will send the URI

	http://search.cpan.org/search;

and then woof the query string as content.

I have two handy dandy little subs squirrelled away that
help me remember this:
#
#
sub form_GET_msg($$)
{
my ($host_port, $url) = @_;

my $msg = GET $url HTTP/1.1 . $CRLF .
Host: $host_port . $CRLF . $CRLF ;
return($msg);
} # end of form_GET_msg

#
#
sub form_Post_msg($$$)
{
my ($dtk_host_port, $dtk_url , $string) = @_;
my $len = length($string);

my $msg = POST $dtk_url HTTP/1.1 . $CRLF .
Host: $dtk_host_port . $CRLF .
Content-Type: application/x-www-form-urlencoded . $CRLF .
Content-Length: $len . $CRLF . $CRLF  . $string;
} # end of form_Post_msg

so there really is no 'simple' way to make them 'universal'.

So if you really want to get down into the mud and write your
own munger to strip the URI into it's component parts
	schema:://host_port/path

and sort out say your 'query' as a hash then you can do
the sort of trick like:
... 
dtk_openSocket_to_webPage( $host, $port, $fd);
my $message = ($query_hash)?
form_Post_msg($host_port, $uri, http_url_packer($query_hash)) :
form_GET_msg($host_port, $uri);
	$fd-print($message);

my ($status, $headers) = dtk_get_headers($fd);
...
and I will be so behind you in that part of the Learning Process.
{ he said noting the shrapnel that makes me look like a pin cushion
I encountered on that learning curve, knowing full well that it will
be ever so nice to have someone ELSE 'up front' 8-) }
Oh dear, that is some old and crufty code, should I be showing it
in public with all of it's warts???
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: php testing in my pc

2003-11-10 Thread drieux
On Monday, Nov 10, 2003, at 07:48 US/Pacific, Daniel Hurtado Brenner 
wrote:

Hi friends:
I use activeperl for for run and testing my cgi script in my PC. It's 
fine.
Well... if i want to run and testing my PHP script and my Msql in my 
PC...
what can i use?
you will need to install the php executable.

you might want to check one of the traditional php
web-sites about the gory details.
ciao
drieux
---

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


Re: Syntax error with while

2003-11-10 Thread drieux
On Monday, Nov 10, 2003, at 14:54 US/Pacific, herve.suvigny wrote:
[..]
To morrow I am going to do this way and I have another idea ,

While in first
first stuff
second stuff
[..]

a strategy that I use is to 'build up' the page in the form

	$info .= some_function_stuff(@arglist);

This way I can cache most of the 'header' section and
things like details about the 'body' and/or CSS stuff
in a module for that project.
	my $page = make_page($page_type,$info);

so if somewhere along the line I had a problem that would
have caused a 'die' in some module, or data was incorrect
I would be able to
return(generic_error_page($error_message))
if ( $went_wrong_here );
this way I can sort out what is going on in smaller chunks
of code that build up modules...
ciao
drieux
---

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


Re: Syntax error with while

2003-11-09 Thread drieux
On Sunday, Nov 9, 2003, at 08:08 US/Pacific, lanzaroto wrote:

   while({$id, $nom, $prenom, $email} = $STH-fetchrow_array){

   $REQ-Tr,
   $REQ-td('$id'),
   $REQ-td('$nom'),
   $REQ-td('$prenom'),
   $REQ-td('$email'),
   $REQ-$id++;
}
   ),
is this the 'while' at or near line 90?
and should that be
	{$id, $nom, $prenom, $email} = $STH-fetchrow_array

or perchance

	($id, $nom, $prenom, $email) = $STH-fetchrow_array

ciao
drieux
---

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


Re: Syntax error with while

2003-11-09 Thread drieux
On Sunday, Nov 9, 2003, at 09:24 US/Pacific, lanzaroto wrote:
Le dim 09/11/2003 à 17:44, drieux a écrit :

On Sunday, Nov 9, 2003, at 08:08 US/Pacific, lanzaroto wrote:

   while({$id, $nom, $prenom, $email} = 
$STH-fetchrow_array){

   $REQ-Tr,
   $REQ-td('$id'),
   $REQ-td('$nom'),
   $REQ-td('$prenom'),
   $REQ-td('$email'),
   $REQ-$id++;
}
   ),
is this the 'while' at or near line 90?
yes
is there a reason that you have them in the form

	'$var'

vice say

	$var

eg:

	$REQ-td($id),

since the single tick will prevent 'expansion' and hence pass
a literal string there?
There is also the odd bit that you doing an interative loop
in the middle of a print statement. Hence I would split that up
into three print statements
stuff before the while loop,
the while loop printing
stuff after the while loop.
attached below find some play code, and IF you can help me
with how i would be able to do a
	print some stuff here, while(...){}, some other stuff;

then you clearly will have coolness.

ciao
drieux
---

my $req = Foobar::foobar();

$req-fill_foobar(junk_me());

while ( my ( $id, $thing, $third, $forth) = $req-fetch())
{
print $id, $thing, $third, $forth \n;
#\t$id, $thing, $third, $forth \n;

};


sub junk_me {
 [
[qw/a b c d/],
[qw/e f g h/],
[qw/i j k l/],
[qw/bob ted carol alice/]
];
}

package Foobar;

#
#
sub foobar {

my $hash = {};
bless $hash, Foobar;

} # end of foobar

#
#
sub fill_foobar
{
my ($me, $array_oh_array) = @_;

$me-{max} = @$array_oh_array;
$me-{count} = 0;
$me-{stuff} = $array_oh_array;

} # end of fill_foobar

#
#
sub fetch
{
my ($me) = @_;

my @array;
if ($me-{count}  $me-{max} )
{
@array = @{${$me-{stuff}}[$me-{count}++]};

} else
{
$me-{count} = 0;

}

 return @array;

} # end of fetch
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: HTTP::Request

2003-11-06 Thread drieux
On Thursday, Nov 6, 2003, at 15:12 US/Pacific, Tobias Fink wrote:
[..]
why doesn't

my $ua = LWP::UserAgent-new;
my $res = $ua-request(GET 'http://www.google.de/search', q  = 
'asdasd');
if ($res-is_success) {
 my  $server_response = $res-content;
 print $server_response;
}

print the html-source of http://www.google.de/search?q=asdasd ?
well there seems to be a series of issues, not the
least of which is that when I try the simple command
line routine with the lwp-request code I get a 'forbidden'
response back from www.google.com - so even IF I can put
the string
	http://www.google.com/search?q=asdasd

into a browser, the simple request
[jeeves: 13:] lwp-request 'http://www.google.com/search?q=asdasd'
HTML
HEADTITLEAn Error Occurred/TITLE/HEAD
BODY
H1An Error Occurred/H1
403 Forbidden
/BODY
/HTML
[jeeves: 14:]
suggest that they may have 'issues' with web-bots. which you
would notice with say code like:
my $res = $ua-get('http://www.google.com/search?q=asdasd');
if ($res-is_success) {
 my  $server_response = $res-content;
 print $server_response;
} else {
print request failed\n;
print $res-content ;
}
At which point let us go back and look at the problem
with your line
	my $res = $ua-request(GET 'http://www.google.de/search', q  = 
'asdasd');

sorry, but that just does NOT make sense to me. I can see what you were
trying to do, but that is way garbled.
IF you know what your query should be, then why not append it to
the base 'uri' that you have
if you will go back to

	perldoc LWP::UserAgent

you will note that the more classical form, if you do not
want to do the 'get()' method is to construct the HTTP::Request object,
( cf HTTP::Request ) and pass that object:
 $request = HTTP::Request-new('GET', 'http://search.cpan.org/');
  # and then one of these:
 $response = $ua-request($request);
so yes, the line is broken, but there also seems to be an interesting
server side issue that google has with web-bots.
ciao
drieux
---

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


Re: Delete/Archive older enteries.

2003-11-06 Thread drieux
On Wednesday, Nov 5, 2003, at 23:12 US/Pacific, Sara wrote:
[..]
foreach my $line(@lines) {
chomp $line;
my ($name, $id);
($name, $id) = split (/\|/, $line);
if ($removeby  date_to_delete($id)){next;}
print DB $line\n;
}
close DB;
[..]

that's the operable part of your problem,
it is in this foreach loop that the decision is made
whether code is deletable - hence
if ( $removeby  date_to_delete($id))
{
print SAVEDB $line\n;
next;
}
and just make sure that you did the appropriate open()
for that file handle, etc...
ciao
drieux
---

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


Re: Simple CGI question

2003-11-06 Thread drieux
On Thursday, Nov 6, 2003, at 16:42 US/Pacific, Andrew Gaffney wrote:
Jack wrote:
[..]
  When
the user clicks on the Submit button on my form, I'd
like to call a CGI script and
redirect its output to the left frame.  Could anyone
please tell me how I can do this?
In the right frame, put this:

...
input type=button value='Submit' 
onClick='top.frames.leftframe.document.location.href = 
\yourscriptlocation.pl\'

substituting 'leftframe' for the name of the left frame and 
'yourscriptlocation.pl' for the URL of your script.
neet solution there, I hadn't thought about arming the 'onClick'.

but why not have the form line simple sort it out for him?

eg:

	form name=myform method=post action=myCGI.cgi 
target=leftFrame
	
	/form

my assumption is that the 'frames' were set up with something like:

 html
frameset cols=100,*
   frame name=leftFrame src=defaultLeftFrame.html
  frame name=rightFrame src=myCoolRightFrameCode.cgi
/frameset
 /html
ciao
drieux
---

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


Re: how-to: custom exception handling?

2003-11-05 Thread drieux
On Wednesday, Nov 5, 2003, at 11:55 US/Pacific, Shaun Fryer wrote:
[..]
What I hoped to have happen is that if a particular sub returns
empty, undef, or void, I will have it trigger the following sub.
What I'm unsure of, is how to get the die_msg/STDERR to pass
to Die_Mail().
[..]
Return_Something() || Die_Mail($mail_prog,$admin_email,'???');

sub Die_Mail {
$mail_prog  = shift || return;
$admin_email= shift || return;
$die_msg= shift || return; # maybe a ref, but basics 1st
open(OUT,|$mail_prog) || return;
print OUT From: '$0' [EMAIL PROTECTED]\n,
  To: $admin_email\n,
  Subject: A CGI DIED!\n\n,
  $die_msg;
close(OUT);
User_HTML_Warning(); # print a default error page for users
return true;
}
[..]

first off my complements on your Die_Mail() function, allow
me to get Fruffy if I may if it needs to have three scalars
you might want to think about the prototype solution
sub Die_Mail($$$) {

}
this way it will hurl a furball about wrong argument count
at compile time and should oblige you, others, to remember
to pass the three scalars, hence avoid the need for the
	shift || return

approach and would allow you to do the simpler, IMMHO,

	my ($mail_prog, $admin_email, $die_msg) = @_ ;

at which point I would do the User_HTML_Warning()
prior to returning if the open of the program failed.
You do have an obligation to send something back to
the web-browser, even if you can not send email to
the admin_kabal about the 'problem'.
Ob_fruffy: there are those who believe that all functions/methods
should be in lower case letters. Feel duely ob_fruffed.
That having been said, IF you are trying to trap the
'die' in the Return_Something() then you will want to
stuff the process IN an eval with a sig handler something like:

our ($page,$h) ;
our $wrapper_flag = 0;
our $bytes_read = 0;
eval {
local $SIG{'__DIE__'} = sub { $wrapper_flag = 1;} ;
($bytes_read, $page, $h ) =
get_from_server($host_port, $uri, $q);
};
return({ runtime_error =
Problems connecting to $host_port got status: $@ }
   ) if ( $wrapper_flag );

No reason to make that $SIG{'__DIE__'} 'function' massive,
harry, or complex. I opted for an autonomous function, and
as you will notice it merely sets a flag which we check AFTER
the eval. The die message is in the $@ perl variable.
if as you origianlly were concerned you got back an of
the standard 'responses' 'empty', undef, whatEver, that
would of course be in one of the 'variables'. In my
case I was returning
a. $bytes_read - an int count
b. $page - the reference to the 'page of information'
c. $h - the 'http header stuff' - since that's from a 'hey,
let us use HTTP as our session layer to call other
services from other web-browsers' chunk of code
This way I can also check things like what the 'status' was
returned from the remote web server, yadayadayada...
Your Mileage May Vary, void where prohibited by law,
may cause lab rats in cancer research facilities.
ciao
drieux
---

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


Re: interpolating a variable with a request parameter

2003-10-31 Thread drieux
On Friday, Oct 31, 2003, at 10:01 US/Pacific, radhika sambamurti wrote:

Hi,
I am trying to do this:
for( $i = 0; $i  5; $i++) {
$qty[$i] = $q-param('qty$i');
what you are probably finding is that

	$qty[0] eq 'qty$i'

since you used the single quote token.

whereas

	$qty[$i] = $q-param(qty$i);

would probably Allow the string to be interpolated as
qty0 which is what you seem to want.
ciao
drieux
---

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


Re: javascript in perl

2003-10-29 Thread drieux
On Wednesday, Oct 29, 2003, at 07:48 US/Pacific, mark o' sullivan wrote:

Hi,
Does anyone know is it possible to include javascript in perl?
yes.

it is 'just more mark up' as far as the
CGI code is concerned on the 'sending side'
and only becomes relevant on the 'browser'
side that it be 'coherent'.
One solution is start 'simple' with writing
the Java Script out in 'chunks' as a part of
the basic html and see if it still does what
you want when called.


ciao
drieux
---

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


Re: help with syntax error

2003-10-29 Thread drieux
On Wednesday, Oct 29, 2003, at 08:28 US/Pacific, Rick Triplett wrote:

#!/usr/bin/perl -w

print Enter the radius: \n;
chomp ($radius = STDIN);
$area = $radius*$radius*3.14
--^

normally that would need to have a ;
to close it out.
if ( $radius = 0 )  {
print The area is zero\n;
} else {
print The area is $area\n;
}


You might want to also

a. use strict
b. hence declare your variables
c. make sure that $radius is numeric with some form of
		die must be numeric!\n unless ( $radius =~ /^\d+$/);

etc, etc, etc...

ciao
drieux
---

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


Re: uploadfiles

2003-10-01 Thread drieux
On Wednesday, Oct 1, 2003, at 08:12 US/Pacific, A L wrote:
[..]
that refers to the following CGI:

 #!/usr/bin/perl -w
use strict;
use CGI qw/:standard/
print Content-type: text/html\n\n;
print $query-filefield('uploaded_file');
there is the minor detail here that you did not
declare what a '$query' is ...
$filename = $query-param('uploaded_file');
$fh = $query-upload('uploaded_file');
while ($fh) {
  print;
  }
I am reading the CGI.pm from Lincoln Stein's webpage.
good choice.

 But, it's too difficult for me to follow what I am supposed to do.
I just want to be able to load a file from a local drive while on
the web, then, print out the loaded file's content to the web after
it has been through CGI.  Am I making sense?  Any help would be
appreciated.  I would also like help on the very basic idea of
what I am trying to accomplish.  Thanks.
I think your basic idea might be easier to see as two different
pieces of CGI code or one HTML file that calls a cgi script.
cgi_code_a sends to the browser the HTML that is the form
the user will fill in to find a file. In the 'action' attribute
for that form it will reference cgi_code_b.
Note this part could be a static html file.
cgi_code_b will then read the parameters passed to it,
and do the file up_load sequence and as you wish present
the information from the file.
minor note - if you peek into CGI.pm you will notice

'upload' ='END_OF_FUNC',
sub upload {
my($self,$param_name) = self_or_default(@_);
my $param = $self-param($param_name);
return unless $param;
return unless ref($param)  fileno($param);
return $param;
}
END_OF_FUNC
so you might want your code to be doing

my $fh = $query-upload('uploaded_file');
while ($fh)
{
#
# stuff we do with that reference to the uploaded file
#
}
unless you are really want to play with the $query-param()
and the other method calls...
HTH.

ciao
drieux
---

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


Re: separating functionality

2003-09-27 Thread drieux
On Friday, Sep 26, 2003, at 18:07 US/Pacific, [EMAIL PROTECTED] wrote:
[..]
Can someone just
point the way? Lets say i want to create a file in lib/favfuncs.pl. I
would call funcs in favfuncs.pl in my other perl progs.
[..]

Dan has clearly pointed you in the right direction,

You will want to put them in a file named

	favfuncs.pm

so that it will be simpler to

	use favfuncs ;

because 'use' is looking for files that are suffix'd as 'pm'.

Another rule to keep in minds is that 'all low case' is
reserved for 'pragma' - so it is best to make that a
mix of upper and lower case - per the documentation
	use FavFuncs.

Hence the file would be FavFuncs.pm, and the first line
would be declaring the package.
	package FavFuncs;

at that point you need to decide whether you want to be
exporting the 'names' of your functions/subs into the
code that will be using it - hence how to do 'Exporter'
cf: perldoc Exporter - but you will also want to read
up on perldoc h2xs - since it will help making the basic
'framework' for you.
If you are just providing a stack of functionality, you can
still use the 'OO-ish' approach, so you would want say
#-
# our constructor - plain vanilla new
#-
sub new
{
my $type  = shift;
my $class = ref($type) || $type;
my $self = {};  
bless $self, $class;
	} # end of our simple new

#-
# so that AUTOLOAD finds one here
	sub DESTROY {}

which of course will require that you 'tweek' any of your
basic functions which took arguments from the form:
sub fon_gu_lea {
my ($var1,$var2,$var3) = @_;

}
into the 'more complex'

sub fon_gu_lea {
my $me = shift;
my ($var1,$var2,$var3) = @_;

}
{ for real fun, actually READ the perl module CGI.pm with
perldoc -m CGI - there is some serious rocket science... }
I use $me because it is two letters, self and this are four,
and that is way too much typing.
Now, yes, I know you asked about ONLY 'functions' - but as I noted
above, to make a module with fon_gu_lea() and simply export it into
the callers code, is actually a bit more work in some respects. Where
as this way while it may seem like a lot of upfront work and all you
really get is the simpler transition from
	my $foo_bar = fon_gu_lea(@arglist);

and this appears to be transitioning into

my $funkMgr = new FavFuncs;
my $foo_bar = $funkMgr-fon_gu_lea(@arglist);
when you get into the place where you have finished arguing with
yourself about where to cache which sets of functionality, and
whether or not to make classes that pass along by inheritence
the base set of methods, and then the sub_classes add in the
additional ones, and... and... and
my $funkMgr = new Foo::Bar::Baz::FavFuncs;
my $foo_bar = $funkMgr-fon_gu_lea(@arglist);
will seems a reasonable exchange.

But you will probably want to check out Randall Schwartz's new
book about learning perl modules, references, et al...
ciao
drieux
---

Remember if you play fairways and greens, you really
only need the bigDog, a seven iron, and a putter. But
otherwise you will need to get the rest of the woods,
and the irons, and then get a caddy But always remember,
Never play golf with anyone who brought their own golf green.



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


Re: Include Files in Perl?

2003-09-26 Thread drieux
On Thursday, Sep 25, 2003, at 17:44 US/Pacific, seldan wrote:
[..]
However, I am trying to keep this site as modular and easy to maintain 
as
possible and cannot seem to find the right equivalent for a basic PHP
include or require function.  I use several variables that stay 
the same
throughout the scripts, and would like to host them in a separate file.

Sifting through ideas on this I've come across: SSI, Embperl, Mason, 
and
possibly creating modules to handle this.  All seem like a bit of work,
which isn't a problem, I just want to make sure that I'm not missing a
simple, obvious way to make this happen!
[..]

The modules would be my first choice
since you want to be able to assert
use lib ./lib;  # we will put our PM in a directory lib
use thisProj;
my $value = thisProj-get_value();
print got $value\n;
so that you can 'keep' track of the relationship
between the 'class accessor' and the value you got.
so the snappy quick intro is to create the file thisProj.pm
and put it in the 'lib' directory.
	package thisProj;

	our $value = 'this_value_here'; # the value(s) up here

	sub get_value { $value ; }		# the accessor merely wraps it

hence you wind up with a file system layout like:

/some/path
this_code.plx
lib/thisProj.pm
eg: /some/path/this_code.plx and /some/path/lib/thisProj.pm

and you are out and away.

The alternative strategy would be to create the Package,
and just Rip out the value
	my $alt = $thisProj::value;

but personally I think that is 'garish', and that starting
down the road to doing the module is more appropriate.
you will also want to do

perldoc h2xs
perldoc perlsub
perldoc perlmod
perldoc perlmodlib
and you might as well pick up the learning perl references
and modules book.


ciao
drieux
---

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


Re: CGI.pm 2.98 breaks CGI::Carp?

2003-09-24 Thread drieux
On Wednesday, Sep 24, 2003, at 09:23 US/Pacific, Randal L. Schwartz 
wrote:
[..]
www.tpj.com - the Perl Journal, formerly a print quarterly, then 
bundled
with SysAdmin, is now back as an online monthly.

I have a column there, taken over from brian d foy, who is currently
in Iraq under military orders until next April.
[..]

p0: I look forward to the Article!

p1: I think Nestor did two good things

	a. note a concern about the CGI::Carp technical bug

b. raise the general problem of when is it time to
'unattach' from canonical CPAN Modules. And in particular
surface the 'is the cgi ready for production' general issue.
p2: There is a less well known feature in CGI::Carp
that might have been addressed - as folks will note
at the bottom of the 'perldoc CGI::Carp' - there is
a 'set_message()' that COULD have been the fast work
around for 'going to production':
use CGI::Carp qw(fatalsToBrowser set_message);
BEGIN {
   sub handle_errors {
  my $msg = shift;
  print h1Oh gosh/h1;
  print Got an error: $msg;
  }
  set_message(\handle_errors);
}
And we should all graciously apologize to Nestor if that
was the Strategy that they had used; for clearly they had
read the POD, and it was Good.
	note: the $msg is the 'die line' and could be 'fixed up'

BEGIN {
   sub handle_errors {
  my $msg = shift;
  print h1Oh gosh/h1;
  $msg =~ s/at.*line\s*\d+.*$//;
  my $paragraph = p$msg/p;
  print \npGot an error:/p\np$msg/p\n;
  }
  set_message(\handle_errors);
}
This seems to be a good enough solution IF one is only
writing a few simple CGI scripts - and for each one all
of the possibilities are nice and neatly contained...
But that way leads to having a 'common' BEGIN block
for each piece of cgi code WAY TOO MUCH WORK.
p3: But if One is Already in the process of building out a
'handle_error()' - why not simply park them where they are
really needed and 'integrate' them into the flow of the
general code and design pattern.
Especially if one's CGI code has evolved into using
modules as a core part of the process.
To help illustrate this, I have a function get_from_server()
that I built out of bits, and those bits use 'die()' in
cases where it 'should just die'. So one wraps the call
in an eval block, sets a local 'signal handler' for
the '__DIE__' and checks how things went.
our ($page,$h) ;
our $wrapper_flag = 0;
our $bytes_read = 0;
eval {

local $SIG{'__DIE__'} = sub { $wrapper_flag = 1;} ;

($bytes_read, $page, $h ) =
get_from_server($host_port, $uri, $q);
};
In this case I do not really need to know if $@ was set or not
and return an 'error' to the caller if we died, or the stuff
that is really useful.
return({ runtime_error =
Problems connecting to $host_port got status: $@ }
) if ( $wrapper_flag );

\$page;
This way all of the cgi code that will come through this module
has to deal with the fact that exception handling is going to
be built in, and that they will be on their head what they
do with the exception being passed back to them
ciao
drieux
---

ok, so I liked Randall's general write up better, as
he is a good writer... but as a Code Monkey well,
sometimes more than one way of presenting the solution
space may help FLOG THE PROBLEM
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Real beginner's questions

2003-09-24 Thread drieux
On Wednesday, Sep 24, 2003, at 10:36 US/Pacific, Bill Teschek wrote:
[..]
I'm not sure what else I need to do to get perl to work on our 
website. Also,
we had an older version of perl installed at d:\website\perl by a 
previous
administrator, and I'm not sure if there is going to be some kind of a 
conflict
between the two.

I need to learn how to get perl activated and working. Once that is 
done I can
proceed on my own to learn how to write and edit scripts. Is there 
someone else
out there who be interested in a bit of hand-holding today while I get 
this
going?
[..]

Bill,

first things first - Active Perl is a Real Perl,
the fine folks at activeState have done a lot of good
work getting it to run in the Windows Environment.
It sounds like you are totally new to both perl,
coding, and web stuff. So my general references on
the basic books you will want along the way is up at
http://www.wetware.com/drieux/CS/Proj/TPFH/gen_doc.html

Getting a feel for Perl itself is best done with something
like the Learning Perl book. You will of course want
something like the Learning Perl in WIN32
http://www.oreilly.com/catalog/lperlwin/

that should help you over the Perl Side of the problem.

Which is the first part of your problem - how to feel
at home with coding perl. The next part of the problem
is understanding CGI. The Common Gateway Interface -
this is mostly not that complex - since it is basically
the 'things the web-server will pass to my code, and
what I have to send back to it'.
If you already understand

	perldoc perl

that you can use to read perl's own 'online documentation'
you will of course be able to specifically check out the
documentation for the Perl Module CGI
	perldoc CGI

This will of course help you into the real problem which
is the HTML/XHTML standards debates - what sort of web
page are you trying to present, and what really goes into
'web page design'.
HTH.

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


Re: Real beginner's questions

2003-09-24 Thread drieux
On Wednesday, Sep 24, 2003, at 11:39 US/Pacific, Bill Teschek wrote:

HTH,
Thanks for responding. My questions at this point are more in
line with how  to get a script file to work with perl on our webserver.
I'm been doing static HTML for years now but have just never ventured
into cgi and perl stuff.
that is clearly good news. Trying to make the
Hop to HTML and cgi and perl all at once would
drive one BATTY. Everyone starts somewheres
and you have started in the right place.
I'm hoping I can get some of the basics down right away
to get a simple mailto form working on our site fairly quickly.
Why Code when you can download:

cf: http://nms-cgi.sourceforge.net/scripts.shtml

specifically I would use the TFMail - as it is
both GOOD perl code, and will give you an introduction
to how 'not a simple thing' managing a 'mailto' form
has to be - unless one wants every Spammer in the Free World
using your web-site as an open relay...
One question I have is about the first line
of perl scripts:
#!  etc etc.

I have not been able to find any explanation anywhere of how that 
works.
Is that strictly a Unix thing, and if so, how does a MS server know
where to find perl in order to run the script.
[..]

yes, that is known in the unix world, amongst
other things as the 'SheBang' - it indicates to
the 'shell' which interpretor should be invoked
to read the rest of the text as 'code'.
you might want to spin through

http://aspn.activestate.com/ASPN/Perl/

{ WOW! way too much stuff there at times, hum... }

what you can do is run the

	perl.exe my_new_file.pl

where you have put your perl CGI code into
the file 'my_new_file.pl' and it should give
you the output.
Unix geeks would of course have done say

	perl ./my_new_file.plx

but the basic idea is that anything that the Web Server
is going to 'execute for you' you can basically do by
hand at the command line.
How the Web Server 'knows' which perl to invoke is a
part of the configuration issues. In the Unix world
with the
#!/usr/bin/perl -w
use strict;
as the first too opening lines - all one has to do is
put it in a file my_code.cgi - and the webserver 'knows'
that anything ending in 'cgi' will simply be executed.
I'll defer to someone with more IIS tuning time for
the details on whether it is using the 'file name suffix'
to invoke the perl processor on it - or which.
HTH





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


Re: CGI.pm 2.98 breaks CGI::Carp?

2003-09-23 Thread drieux
On Tuesday, Sep 23, 2003, at 19:04 US/Pacific, Bob X wrote:
[..]
I am new to both Perl and CGI so please take that into account
when I ask this. Why remove the CGI::Carp dependency? I do not
doubt your word I really just wanna know why.
[..]

You will most likely want something that is your OWN
handler that will deal with things that 'die' underneath you.
The CGI::Carp approach is a 'fast and dirty' solution that
will at least allow the 'cgi code' to return the raw
error message back to the browser. But that is garish.
Whereas if you isolate the things that can die, and
have your own handler to handle them, then your code
will have other ways to working with 'failure events'
that are more robust and may allow you to 'recover gracefully'
and provide an appropriate web page to the end user that
indicates
a. that something RUDE happened
b. what the alternatives are at this point
c. will conform with the rest of the style of your web pages
just a quick knickle tour - I of course will defer to Randal
to go into more detail if required.
ciao
drieux
---

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


Re: Capturing At Compile Time

2003-09-17 Thread drieux
On Wednesday, Sep 17, 2003, at 08:00 US/Pacific, Dan Anderson wrote:

The book I am reading describes exactly what you are talking about --
compiling a script into bytecode (like java).  I have heard it 
described
as experimental by some people though.
it is experimental, and it is perchance far more
hassle than most folks want to be working with.


ciao
drieux
---

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


Re: Problem writing to a file

2003-09-17 Thread drieux
On Wednesday, Sep 17, 2003, at 11:59 US/Pacific, John Park wrote:
[..]
This is what my script looks like:
#!/usr/bin/perl
use CGI;
...
...
open(FILE,newfile.txt) || die(newfile.txt: $!); #script stops 
here due to permissions

[..]

that is the correct syntax - although you might
not want to 'die()' in a CGI script - but let us defer that.
{ especially if you have already dealt with CGI::Carp }
Remember that most web servers are running as the
web-server uid - www or apache - and so can only 'write'
where that uid has 'write permission'. It can of course
read/execute anything that is 'world readable/executable'
but as a general rule of sanity, it is NOT WISE to make
those directories 'world writable'. So when the code
executes as www, it has no problem reading IN any files
that it can read - but you really would not want to allow
it to over-write your own CGI code and/or fill up the
disk with a bunch of files, because each run of the
CGI code needs to be different...
You might try something like

open(FILE, /tmp/newfile.txt) || die(newfile.txt: $!);

assuming that the system allows users to write files there.
and then have some other piece of CGI code 'read'
from that file to verify that the file actually was written.
The alternative is to provide a directory that is world
writable so that you can create the file in that directory
outside of where you have the actual CGI
open(FILE,  ../tmp/newfile.txt) || die(newfile.txt: $!);

so you layout would look like

../cgi_bin/my.cgi
../tmp/newfile.txt
Or you may want to look at say

	perldoc IO::File

and specifically new_tmpfile() if you really only need
a quick temporary file.
ciao
drieux
---

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


Re: Problem writing to a file

2003-09-17 Thread drieux
On Wednesday, Sep 17, 2003, at 18:50 US/Pacific, ram Osuri wrote:

I agree with your assesment .. to solve this problem you might want to 
do a

chmod 777 newfile.txt and then run the program it will work then
Actually there are two problems with this.

a. there is no reason to set the execute bits,
chmod 666 would work fine enough - there is also
the problem that the file would have to exist.
b. if the problem is that the directory where the file
is to be created does not allow the user to write to
begin with, then the chmod will fail.
to demonstrate I created a directory and chown'd it to
user admin, so even those I and admin are in the same
group, I can not create files in the directory because
only the user admin has write permission on the directory.
eg:
[jeeves: 3:] ls -ltra
total 0
drwxrwxrwx  29 drieux  house  986 Sep 17 15:59 ..
drwxr-xr-x   2 admin   house   68 Sep 17 15:59 .
[jeeves: 4:] touch file
touch: file: Permission denied
[jeeves: 5:] chmod 777 file
chmod: file: No such file or directory
[jeeves: 6:] chmod 777 file
chmod: file: Operation not permitted
[jeeves: 7:] ls -l
total 0
-rw-r--r--  1 admin  house  0 Sep 17 16:01 file
[jeeves: 8:] perl -e 'open(FD, file) or die file :$!; '
file :Permission denied at -e line 1.
[jeeves: 9:]
note between command 5 and 6, I did a touch of the the file 'file'
so that it would exist and show you the problem of the chmod
on the existing file I did not have permission to write to...
HTH.

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


Re: Problem writing to a file

2003-09-17 Thread drieux
On Wednesday, Sep 17, 2003, at 14:15 US/Pacific, John Park wrote:
[..]
Although I don't understand why I can't write to the same directory
my CGI scripts are located in.  I've done this before on Free Webhosts
like tripod and netfirms.
[..]

while we are all deeply and emotionally committed
to our code,  { trust me, my source code tree was upset
I did not take it to Matrix Reloaded... } try to remember
that when YOU as 'user John Park' are writing to that
directory - eg saving your code to that space - you
are running as the uid for 'user John Park' - so it is
OK for you to write to your directories.
{ ok, actually the shell session is running as that
UID, but anthropomorphising one's shell is more normal...}
But when the web server as 'user www' invokes the code
it will be running not as 'user John Park' but as
'user www' and those may not be the same user. In
a previous response I put up the illustration of
having a directory in which it is owned by a UID
that is not the UID of the process running there...
I do not know those sites, but you may want to check
what the permissions were on the directories where your
cgi code was installed.
Some folks set those as 777 and leave it all to the gods
that no one will abuse that reality. This is less and
less acceptable on more and more web-sites. Prudence
generally dictates 755 where other members of your group
and the rest of the world can read and execute.
ciao
drieux
---

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


Re: Problem writing to a file

2003-09-17 Thread drieux
On Wednesday, Sep 17, 2003, at 18:02 US/Pacific, Dan Anderson wrote:
[..]
FWIW
It is possible to use .htaccess files, apache config directives, and
burying 777 directories in 700 directories to add to the security of
having a 777 directory.
/FWIW
dan,

my complements! on the XML.document - and yes, there are
many ways to solve the problem. Amongst the real issues that
the person will ultimately need to work out is whether it is
really SANE to be writing temp files to begin with I mean
how is he going to prevent two different 'clicked on the button'
events from stomping on the same file
ciao
drieux
---

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


Re: Still Not sure if I agree with myself.

2003-09-15 Thread drieux
On Sunday, Sep 14, 2003, at 14:00 US/Pacific, Todd W. wrote:
[..]
Beacuse of @ISA being lexically declared, it can't inherit from other
modules. And remember, for a logical scope to be called a closure, you 
have
to be dealing with lexical values.
p0: I knew there was a 'rational' explanation why it is
an 'our @ISA' vice a 'my @ISA' but had not taken the time
to walk it through
p1: Since I am not 'presuming' any lexical values,
merely a stack of subs - I think 'block' should be
the assertion. It may be a closure, but it will be a block
so that one can 'manage' the 'name space' issues:
# package main
{
package Foo;
...
}
# back to package main
that part makes good enough sense, eh no?

But I think the part that scares me is that

my $action = {
doDaemon = sub { . },
...
};
would get us into the same 'space'?
Not if you declare $action to have its own file or block scope. You 
would
have to define an accessor to access $action.
p2. Normally I do that so that it is in package 'main' so
that I do not have to create an external PM that will
manage it This specfic variant was poking at the idea
of saving on typing the 'sub doDamon {}' and then hanging
it in the Hash of Subs with
	{ doDaemon = \doDaemon , }

p3. What I was partially looking at was a
'simpler' way from my traditional approach of
'things that look like subs should be stuffed into a sub, as
somewhere along the line they May get clustered into a PM
somewhere and the code then is simpler to maintain.
And in this case taking advantage of the 'block' that would
allow me to declare a 'package' namespace as one more step
in the general process of getting there...
[..]
If you have a reuseable component that dispatches other
components you can call it an application server, for some
definitions of an application server.
p4. This just makes me NERVOUS. My normal habit is

make it work
congeal together what is common to all
If they really have a common base not unique to this project
then distill that common base out for re-use...
at which point, I fear I agree with the YA_CGI_AppServer
notion for, as you not SomDefofAppServer... It just worries me.
ciao
drieux
---

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


Re: cgi

2003-09-15 Thread drieux
On Monday, Sep 15, 2003, at 05:18 US/Pacific, Madalin Sirbu wrote:

First, sorry my english language. I need a program to receive all
the message send by other people who script in my webpage form.html
to my e-mail account. What is the most simple path/way to close this 
circle?
first off, have the form.html send email to a
special email account say 'the_web_page_account'
then have an application deal with email to that
account... It could be run as a cron job and send
your account a summary of things about that account.
ciao
drieux
---

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


Re: Truncate questions.

2003-09-15 Thread drieux
On Saturday, Sep 13, 2003, at 05:52 US/Pacific, Sara wrote:
[..]
2. I have DB with 4-8 digits number in each line e.g.

1238483
92933
09983433
093
The truncate function truncates the file very abruptly
[..]

well actually there are various types of DB's - some
such as SDBM_File will have 'information' at the start
of the 'block of data' that points to where the actual
data resides from the bottom of the block up - leaving
a potential 'space' in the middle of the data block.
What it sounds like you want is a 'compact' or 'purge'
function that will 're-write' the data into a new DB file.
Essentially the same issue that you ran into with wanting
to keep only the first N-Blocks of data from the file.
Since only 'you' know how the internals of the DB are laid
out, you will need to resolve what data in it is still good,
and which data in it is 'dead wood' that needs to be purged.
One trick to think about is

move DB_File to OLD_DB_file
create TMP_DB_FILE
traverse OLD_DB_FILE and write to TMP_DB_FILE
move TMP_DB_FILE to DB_FILE
ciao
drieux
---

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


Want CGI script to test and start daemon - was Re: CGI problem, please help

2003-09-12 Thread drieux
On Friday, Sep 12, 2003, at 00:47 US/Pacific, [EMAIL PROTECTED] 
wrote:

Sergey,

ah, I see, you are new to the Ungainly Art, of not
only programming, which you are doing well in, but
the more Arcane art of Daemonology. So bear with me
while I try to write some 'back and fill' here.
A part of the problem is that many people see this
same basic 'design pattern' -
if I had a server that could do foo
then all I need to do is test that it is up...
[..]
Here is my 'grown up' server.cgi:

[..]

basically a good piece of code. The problem seems to

a. how to check that the server is running
b. how to get the server to run as a daemon
c. how to tie those two together.
d. once started how does one stop the server?
you basic strategy so far is to try to use
a pid file - which is mostly ok-ish, but has
the problem
what if the pid file exists,
and has a PID in it, Does that
prove that the PID is
a. still alive
b. still our server
This is a classic 'oopsie' almost everyone makes.
They presume that since they can read the PID file
and it is some positive integer, that clearly the
Daemon is alive. What one needs is a
process grovelor - that will check the process table
and see what comes back.
	my $line = `ps -p $pid`

eg:
[jeeves: 7:]  perl -e 'my $pid = 665; my $server='WebServer';  my $line 
= `ps -p $pid` ;  print OK\n if $line =~/$server/g; '
OK
[jeeves: 8:]

there really is a mini-web-server running on jeeves as pid 665:
[jeeves: 3:] ps -p 665
  PID  TT  STAT  TIME COMMAND
  665  p3  S+ 0:01.47 perl -w ./WebServer.plx
[jeeves: 4:]
The second test is to change the $pid value and notice that
it will not work that way:
[jeeves: 8:]   perl -e 'my $pid = 660; my $server='WebServer';  my 
$line = `ps -p $pid` ;  print OK\n if $line =~/$server/g; '
[jeeves: 9:]  ps -p 660
  PID  TT  STAT  TIME COMMAND
  660  p3  S  0:00.06 -csh (csh)
[jeeves: 10:]

I take you on this side because of the fact that the PID_FILE
may have once held a server's pid 660 - but that PID has
been reallocated to a new process
So at best the 'pid file' gambit is a STARTING PLACE! But know what
the limits are.
The second problem is 'detaching your server from the caller'
which is the fun of actually daemonizing a process. The first
trick is to create your server as a Daemon - which means that
it will need to
a. close STDIN,STDOUT,STDERR
b. detach itself from the controlling TTY.
there is the Proc::Daemon project at the CPAN
http://search.cpan.org/author/EHOOD/Proc-Daemon-0.03/Daemon.pm
which will help with this part.
A quick lesson on 'init scripting'. Most system daemons,
and this includes the web server, are started at boot
time with a simple 'init script' of the form
	#!/bin/sh

case $1 in
start) the_daemon start_args
;;
stop) the_daemon stop_args
;;
esac
So when building a daemon it is useful to think in
similar terms - this of course normally means having
a command line option pair
'-b' : boot|begin
'-k' : kill|klose
hence 'daemon -b' will start the daemon, and if it
already knows where the pid file is going to be, it
will then check to see if another daemon of it's type
is running, and either defer to the existing one, or
tell it to die, and take over.
the '-k' option will likewise check for the existence
of the pid file and signal the daemon to shutdown
cf:
http://www.wetware.com/drieux/pbl/Sys/daemon1.txt
At which point one crawls back up to the basic question

	So I need a piece of CGI code that will start the daemon?

If one put most of the basic common stuff in a perl library,
then you could have say
sub server_running {
#my $obj = shift; # if we plan to OO this
my ($pid, $server) = @_;
my $line = `ps -p $pid` ;
return( ($line =~/$server/g) ? 1:0 );
}
Since the 'daemon will detach itself' you can just
call it directly or call your intermediary 'init script'
unless ( server_running($pid,$daemon) )
{
# your script will block here for the time
# that it takes to fork out the daemon
my $answer = `start_daemon start`;
#
# handle any 'wrong $answer' responses
#
}
#
# now you need to deal with what to do with the initial request
# that needed to talk with the server
#
At which point you have the other sets of problems about
how to get it to stop do you want it to listen on
an additional port for control messages that are out
of band of the usual 'user message traffic flow'
HTH

ciao
drieux
---

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


Re: Still Not sure if I agree with myself.

2003-09-12 Thread drieux
On Friday, Sep 12, 2003, at 18:54 US/Pacific, Todd W. wrote:
[..]
I dont think you can call that a closure yet. You would have to be 
defining
subroutines that refer to lexical variables outside of the subroutine 
or
something along those lines:

[EMAIL PROTECTED] trwww]$ perl
{
my $dog = 'spot';
sub dogsName {
  my $pooch = $dog;
  return(my dog is $pooch);
}
}
[..]

Mea Kulpa! What Was I Thinking? I just did the

	perldoc -q closure

but. hum...

{
package Foo::Bar
use base qw/Foo/;
...
}
Would seem to meet the minimum requirement, since
the 'use base' there deals with the @ISA for that
package name space...
But I think the part that scares me is that

my $action = {
doDaemon = sub { . },
...
};
would get us into the same 'space'?

I'm not sure I really want to actually create YA_CGI_AppServer,
although, I fear that I am in dire meandering towards that sort
of 'can one create a general enough solution'
Since, well, uh, one of my doodles is about passing in a
reference to an object, and such things ... Since the basic
'shell' of a CGI script still looks like:
my $request = $ENV{'REQUEST_METHOD'};

my ($page_type,$page) = (text/html);

if( defined($request)  $request =~ m/^POST|GET|HEAD$/)
{
my $queryString = ($request eq 'POST' )?
STDIN : $ENV{'QUERY_STRING'};

#
# a. get the query string into a useable manner
# b. verify that the query string has what you need
#   and is safe, sane and sober
# c. given some key in that query string select the
#right method for making a response
#
} else {
#
# Deal with being passed an unsupported Request Method
#
}

make_header_and_send($page_type, $page);
so that of course yearns to be in a module, rather than
as something one would cut and paste into each new CGI script...
But looking at your diagramme, I think I can see why you
are pointing towards a YA_CGI_AppServer
ciao
drieux
---

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


Re: Still Not sure if I agree with myself.

2003-09-11 Thread drieux
On Thursday, Sep 11, 2003, at 05:51 US/Pacific, fliptop wrote:
[..]
drieux - since no one has responded, i'll take a stab at some of the
issues you bring up.
[..]

Thanks for the feed back.

In the code that I implemented, I did not use the Closure
to 'wrap' my Package - but I think as a 'GP safety' I
probably would, in case I needed to have variables that
belonged in the Package Space as you noted.
The second thing that SMACKED ME upside the head as I
was working out 'what is the ugly here'?
simply because

	$obj-can($do);

does not mean

	$obj-should($do);

The problem I am looking for in my should() method
is a programatic way to solve Which Method to invoke
the correct sub to deal with a query string. I have
a tough enough time keeping my code in line as it is,
I really do not want it to be reading POD when it should
be working and generating HTML 8-)
My traditional trick is of the form
	
	my $qs = make_hash_of_query_string($request);
	my $actions = {}; # the hash of subs
	my $callForm = $qs-{'callForm'} || 'main_display'; # get the callForm 
parameter

my $page = (defined($action-{'callForm'}) ? # is it defined
$action-{'callForm'}-($qs) :
main_display($qs);
Which of course requires me to maintain the Hash of $actions
so that I 'register' by hand, each of the Subs that SHOULD
be used in the cgi code. A problem that I do not escape
if I have to maintain a similar list of which 'callForms'
are legitimate tokens to be returned from the browser.
So while the UNIVERSAL::can is able to check for a
given 'symbol' and return a reference to it I was
sorta wanting something that would return a list of all
of the symbols that would return something in can()...
So that I could keep the list of 'But Not These'...
Which is merely the reverse, and perchance Worse notion
since the maintanance of that DarkUgly has to know all
of the things to exclude... To cite the Immortals
	Run Away!


ciao
drieux
---

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


Re: Still Not sure if I agree with myself.

2003-09-11 Thread drieux
On Thursday, Sep 11, 2003, at 12:17 US/Pacific, fliptop wrote:
[..]
the way i do it is to assign an action to each form.  each action has
associated parameters.  the form sends the action in an input
type=hidden tag.
oh yes, in this case the 'trigger' I use in say

	input type=hidden name=callForm value=doDaemon

This way we do not have to have 'one cgi script' per action.
My general strategy is to just pass along the HASH of
the query string and leave them up to the subs to sort out
which they need, which they use, yada-yada.
d:My traditional trick is of the form
d:  
d:  my $qs = make_hash_of_query_string($request);
d:  my $actions = {}; # the hash of subs
oh, sorry, maybe if I broke that out

my $action = {
doDaemon   = \doDameon,
showDaemon = \show_daemon,
kickDaemon = \doDameon,

};
It would be more obvious that my idea is to KNOW that
a given 'callForm' value returned from the browser is
associated with a given method that would deal with
the rest of the pack up some HTML and ship it back.
The 'kickDaemon' variant in there is when I have already
worked out that it would be a possible 'callForm' value
that can be passed to this CGI, from some other piece
of code, and that the difference between what kickDaemon()
and doDaemon() do ultimately was so negligible that I just
put a 'flag foo' into the later and consolidated code...
d:	my $callForm = $qs-{'callForm'} || 'main_display'; # get the 
callForm
d:parameter
d:
d:	my $page = (defined($action-{'callForm'}) ? # is it defined
d:		$action-{'callForm'}-($qs) :
d:		main_display($qs);
d:
d:Which of course requires me to maintain the Hash of $actions
[..]
{
  my %REQ_PARAMS = (
action1 = { # criteria for action 1 },
action2 = { # criteria for action 2 },
etc...
  );
[..]

That was what I was trying to mostly avoid. The idea of
the 'should()' would take me along the line
my $page = ($obj-should($action-{'callForm'})) ?
$obj-${$action-{'callForm'}}($qs) :
$obj-call_form_error($qs);
hence the should look like

my $REQ_PARM = {
doDaemon = 1,

};

sub should { defined($REQ_PARAMS-{$_[0]}); }

sub doDaemon {

}
sub kickDaemon { $me=shift; $me-doDaemon(@_); }
# the synonym trick...
Which still gives me a HASH to manage, plus the actual Sub.

ciao
drieux
---

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


Re: Perl/Linux problem.

2003-09-11 Thread drieux
On Thursday, Sep 11, 2003, at 06:05 US/Pacific, Sara wrote:
[..]
and simply

print Content-Type: text/html\n;

print Hello World\n;
that form will NOT have the separator
and I expect you see something like:
[..]
: [jeeves: 45:] test_cgi GET simple.cgi
: Content-Type: text/plain
: hello World
: [jeeves: 46:]
which is NOT a correct message to send back to
the web-server. You will need to have a
'blank line' between the Content-Type
and the 'hello world'.
but the:
#!/usr/bin/perl -w
use strict;
use CGI qw(header);
print header;
print Hello world;
should work since the CGI::header() will put the additional
CRLF in play and separate them...
You do have the #! line with the -w flag set?

ciao
drieux
---

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


Re: modules

2003-09-10 Thread drieux
On Wednesday, Sep 10, 2003, at 12:14 US/Pacific, Rodrigo Daniel de Lira 
wrote:
[..]
Can I to call a function that is in another script?
sorry interrupted. Allow me to illustrate a bit better

/dir_for_cgi
script1.cgi
script2.cgi
/lib/
OurModule.pm
So we start the Module off with

package OurModule
VERSION = 1.01; # since you will have finished beta on it
sub new
{
   my $type  = shift;
   my $class = ref($type) || $type;
   my $self = {};
   bless $self, $class;
 } # end of our simple new

#
# the subs go here
#
sub my_first_sub {
my $me = shift; # to get the reference
...
}
.
1; # so that the use will see a happy return
Then each of the two cgi scripts can do the simpler

use lib ../lib/;
use OurModule;
...
my $obj = new OurModule;
...
my $first_thingie = $obj-my_first_sub(@arglist);

and one is out and away... No Mus, No Fuss.

Ok, so you COULD have done the Dilbert Class Solution of


use lib ../lib/;
use OurModule;
...
my $first_thingie = OurModule-my_first_sub(@arglist);
...
Which ever makes you feel happier.

I would of course HIGHLY RECOMMEND that you get
Schwartz's Learning Perl  Objects, References  Modules.
cf: http://www.oreilly.com/catalog/lrnperlorm/
for all the detail clarifications that are useful
above the standard
	perldoc perlsub, perlmod, perlmodlib

The alternative to that is to have some funky interface
into the script with the function that will understand
that it is being called in some weird way that it should
pass the data to the function, and then return it out,
oh, say STDOUT. Trust me it can be done, but it is such
an ugly path that it should be left for the strictly
obfuscatory Perl Contest.
ciao
drieux
---

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


Still Not sure if I agree with myself.

2003-09-08 Thread drieux
Currently I am in the midst of an argument
with myself about tactics and strategies
for doing CGI coding. The side effect of
which lead me to wonder about some prejudices
I seem to have about when, where and how to
cut over to using/creating a Perl Module for
code re-use. Some of this comes from debating
ideas from Learning Perl  Objects, References  Modules.
cf: http://www.oreilly.com/catalog/lrnperlorm/
One of my first question is - why the 'closure' eg:

{
package FOO;

}
Or is that simply to make 'clear' that outside of
the Closure it is still package 'main'???
The demonstration code that goes with my longer
write up of my 'issues' -
cf http://www.wetware.com/drieux/CS/Proj/TPFH/a_bci.html
started out Strictly as a simple illustratoin of
how a command line interface piece of code CAN be written.
Unfortunately I decided to take that other look,
and hack around with other ways of doing things,
a brief coding interlude which as most of us know is similar
to a 'brief psychotic episode' but occasionally less functional.
The gooder news is that this has the look and feel
of a 'faster' way to go about playing with ideas
that one thinks need to be culled out into a
separate stand alone perl module. The information
section of course is that I am not sure that 'abusing'
the 'can()' the way I did will survive more than
that demonstration piece of code.
Which leads me to my second set of question,

as a general habit I tend to make 'private-ish' methods
with the _ prefix such as
		sub _some_private_method {  }

is there some 'general access' mechanism by which one can
ask for the LIST of all methods that an 'object' CanDo???
Or should one have a 'register_of_parser_methods' approach
that one can query?
ciao
drieux
---

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


Re: tcpdump to a perl script

2003-09-05 Thread drieux
On Friday, Sep 5, 2003, at 07:45 US/Pacific, 
[EMAIL PROTECTED] wrote:
[..]
This may be very simple, however I am missing something.  I want to 
pipe
information into a perl script.  Yet, I can not figure out what type of
system variable it will use.  $_ , @_ , or even %_.
do you mean pipe as in

	./some_cmd | ./my_perl_code.plx

what you will be reading in that case is from STDIN as in

while(STDIN) {
# read the stuff in $_ if line oriented
}
otherwise you will want to do the standard sysread().
read the perldoc on these - my handy dandy, test my
side of the pipe template is found at:
	http://www.wetware.com/drieux/pbl/perlTrick/drieuxTemplates/DoCmd.txt

This way I can work out the basic semantics for what most of
the cases of
	foo | bar

will work out to be...

or do you mean pipe as in

pipe(CHLDr, PRNTw);
pipe(PRNTr, CHLDw);
if (!($pid = fork())) {
open(STDIN, CHLDr);
open(STDOUT, CHLDw);
open(STDERR, CHLDw);
close(PRNTw); close(PRNTr); #close(DTKERRr);
select(STDOUT) ; $|=1 ;
exec( $CMD 21);
exit;
}
#
# we are the parent side of the process
#
select(PRNTw); $|=1; select(STDOUT);
close(CHLDr); close(CHLDw); #close(DTKERRw);
which again is a matter of reading the end of the pipe
that is your end, and writing to the end of the pipe that
you are ACKing on...
Since I am a DILBERT I of course do the funk like that
so I remember, me Parent, Me write on PRNTw, Me Read from CHLDr
and then simplify my world by resetting stderr to stdout...
ciao
drieux
---

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


Re: Stripping HTML from a text file.

2003-09-04 Thread drieux
On Wednesday, Sep 3, 2003, at 03:32 US/Pacific, Sara wrote:
[..]
What I want to do is to remove/delete HTML code from the text file 
from a certain tag upto certain tag.

For example; I want to delete the code completely that comes in 
between head and /head (including any style tags and embedded 
javascripts etc)

Any ideas?
I would recommend that you look into HTML-Tree
http://search.cpan.org/author/SBURKE/HTML-Tree-3.17/
since I have found it a lovely way to do most anything
that you would want to know how to do about deconstructing
the tree structure of an HTML document.
I'm not too sure you really want to blitz EVERYTHING in
the 'head' section...
but you might try say:

while ( my $line = INFO1 ) {
if ( $line =~ /head/ ) {
#
# remove everything after it. print if we have something
#
$line =~ s/head.*//;
print $line unless ($line =~ /^\s*$/);
#
# spin until we see the closing tag - assumes well formedness
#
do { $line = INFO1; } until ( $line =~ /\/head/ ) ;
#
# strip everything before the closing tag
#
$line =~ s/.*\/head//;
next if ($line =~ /^\s*$/); # get new line if blank.
}
print $line ;
}
but this assumes that the start and stop tags do not have
something else on the same line with them - eg
/headbody text=#00 bgcolor=#FF
ciao
drieux
---

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


Re: Stripping HTML from a text file.

2003-09-04 Thread drieux
On Thursday, Sep 4, 2003, at 17:55 US/Pacific, Hanson, Rob wrote:

$text =~ s|(head).*?title.*?/title.*?(/head)|$1$2$3|s;
actually that should be:

	$text =~ s|(head).*?(title.*?/title).*?(/head)|$1$2$3|s;

way stylish! I actually like.

But assumes that there will be a title element - otherwise it
will fail and not clear out the other stuff in the head element.
ciao
drieux
---

	my $text ='!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 
Transitional//EN
			http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd;
	html lang=en
	head
		meta http-equiv=content-type content=text/html; 
charset=iso-8859-1
		titleThe J Group/title
	style type=text/css
	!--
	pre  { font-size: 14px; font-weight:bold }
	//--
	/style
		meta name=generator content=BBEdit 6.5.2
		base 
href=http://www.wetware.com/drieux/CS/Proj/TPFH/the_j_grp.html;
	/head
	body text=#00 bgcolor=#FF
	font size=2 face=arialThis is the test file contentsbr
	p
	blah blah blah.
	/body
	/html';
	#$text =~ s|(head).*?(/head)|$1$2|s;
	$text =~ s|(head).*?(title.*?/title).*?(/head)|$1$2$3|s;
	print $text ;

will generate a flatter

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd;
html lang=en
headtitleThe J Group/title/head
body text=#00 bgcolor=#FF
font size=2 face=arialThis is the test file contentsbr
p
blah blah blah.
/body
/html
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [Addendum] Stripping HTML from a text file.

2003-09-04 Thread drieux
On Wednesday, Sep 3, 2003, at 06:08 US/Pacific, Sara wrote:

#!/usr/bin/perl

use LWP::Simple;

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

$url = 'http://yahoo.com';

$html = get($url);
[snip]
$html =~ s|head.*?\/head||s;

print $html\n;


what you get from 'get' is a scalar $html
that is the WHOLE PAGE - so you do not want
to step over that whole page with the sort of
'global' pattern match of
	$html =~ s|head.*?\/head||s;

so the 'foreach ' loop was not going to work

because the page you get back is of the form:

htmlhead

titleYahoo!/title
meta http-equiv=PICS-Label content='(PICS-1.1  
http://www.icra.org/ratingsv02.html; l r (cz 1 lz 1 nz 1 oz 1 vz 1)  
gen true for http://www.yahoo.com; r (cz 1 lz 1 nz 1 oz 1 vz 1)  
http://www.rsac.org/ratingsv01.html; l r (n 0 s 0 v 0 l 0) gen true  
for http://www.yahoo.com; r (n 0 s 0 v 0 l 0))'
base href=http://www.yahoo.com/ target=_top
style type=text/css!--
.yhmpabd{border-left:solid #4d99e5 1px;border-right:solid #4d99e5  
1px;border-bottom:solid #4d99e5 1px;}
.yhmnwbd{border-left:solid #9b72cf 1px;border-right:solid #9b72cf 1px;}
.yhmnwbm{border-left:solid #9b72cf 1px;border-right:solid #9b72cf  
1px;border-bottom:solid #9b72cf 1px;}
//--/style
script language=javascript!--
lck='',sss=1062732386;//--/script
script language=javascript
var b,d,l='',n='0',r,s,y;
y=' '+document.cookie+';';
if ((b=y.indexOf(' Y=v'))=0) {
y=y.substring(b,y.indexOf(';',b))+'';
if ((b=y.indexOf('l='))=0) {
l=y.substring(b+2,y.indexOf('',b));
if((b=y.indexOf('n='))=0)n=y.substring(b+2,y.indexOf('',b));
}
}
d=new Date();
s=Math.round(d.getTime()/1000);
r=Math.round(parseInt(n,32)%1021);
if (lck!=l) {
document.write('meta http-equiv=Expires content=-1');
if (location.search.indexOf('r'+r+'=')!=1) {
location.replace('http:// 
'+location.hostname+location.pathname+'?r'+r+'='+s);
}
}
/script
/head

ciao
drieux
---

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


Re: Defining Return-path.....

2003-09-02 Thread drieux
On Saturday, Aug 30, 2003, at 21:15 US/Pacific, Sara wrote:

Hi to all

I am using a simple form script in which users can send mail to other 
users using FROM and TO mail addresses.
But when a TO address is invalid the failure delivery goes by default 
to 'Return-path' owner of the cgi ([EMAIL PROTECTED])

Is there a way that we can define Return-path from the script or any 
other alternatives that failure deliveries should go to
'FROM' or anyother specified address (preferably defining something 
within the script)
[..]

may I recommend

http://search.cpan.org/author/MARKOV/MailTools-1.59/

and specifically the section in there on Mail::Header
where you can try to resolve that Return-Path element
of an RFC822 header.
cf:
http://www.faqs.org/rfcs/rfc822.html
I've used mark overmeer's tools before and they are
a reasonable interface, and he is cool about dealing
with bug reports if you actually find an edge case.
If nothing else, download the code from the CPAN,
and it will provide you with more insight into
how to do the basic email tricks correctly.
You will of course want to deal with the problem
of the 'open relay' issue, IF your web-page is
exposed to the outside world. Since spammers will
be on you in a heart beat. At which point you
may want to just download and use:
	FormMail

from http://sourceforge.net/projects/nms-cgi/
which if you follow the appropriate install and configure
documentation will allow you some modicum of sane
web based email sending...
ciao
drieux
---

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


Re: automated file removal / cache clearing

2003-08-29 Thread drieux
On Thursday, Aug 28, 2003, at 14:16 US/Pacific, [EMAIL PROTECTED] 
wrote:
[..]
I am glad someone put this into easily understood terms,
I was thinking the same thing and couldn't come up with a
compact way of saying it :-)...
Think about where I live - there are so few chances for
mathematicians to sit around and be pedantic - but every
now and then, reminding folks to DO Algorithm Analysis
is one of those rare opportunities. Or should I say
	Algorithm Analysis - Not Your Grandfather's AA???

But the real issue is in the 'design' of the OP's original
CGI code that 'wandered' him into 'caching' information in
a bunch of 'files' some of which will need to be cleaned up.
Octavian's Proposal has 'merit' when the thing that one
is 'caching' into a file needs to be unique, and is not
as 'dynamic' and/or 'session specific' as the OP's original proposal.
Allow me to illustrate the argument.

I have a web-tool that I use to create 'configuration files'
for a daemon. One CAN create those config files, 'the old
fashion way' but simply sitting there and using 'vi' and
typing... But that can be a bit annoying. So the web tool
walks the user through the process. The Basic Format is
Header_section
several basic header fields
Element_section
serveral basic element fields
With the simple caveat that there can only be one header,
but many elements. My solution was to use the SDBM_file and
write the appropriate marshelling and unmarshelling
stuff that will [add|delete|update] 'header|elements'.
All I need is a 'SID' - Session ID - so I know which
of the temp files IS the DB I am looking for. No SID,
No DB File, No Play.
This of course allows me to have different 'pages' that
deal with the basic 'operations'
edit header
add element
delete element
edit element
duplicate element
Save Configuration
Abort Configuration
Show Configuration
And the whole 'configuration file' stays in the 'cache'
until we get to the Save or Abort sequence. The problem
of course is that if the PRIMATE does not follow the
rules, and Abort Out, there will be this skanky little
SDBM_File hanging out in the temp directory. There are
several ways of solving this, the 'cron job' is one way,
or one can do 'man periodic' on BSD systems and look
at installing a 'periodic cleaner' for your specific package...
But remember this is a problem that will occur only
when folks are creating configuration files, which is
not a 'regular' event, but a very low volume sequence
in the overall project.
I had thought about having the 'save.cgi' or the 'abort.cgi'
do the very thing of,
OK, we did ours, what about checking
for any marooned config file cache's.
But the best that I could come up with was that I would
want to be 'safer' and know that the cache was older
than a day, and not merely that the primate had decided
to run off to
a. the bathroom
b. a smoke break
c. feeding time
d. an arcane argument in a technical mailing/newsgroup
e. skylarking in a happier universe.
At which point the, 'oh dear' I do not have enough
gurantee to even do the 'cron job' approach... Some folks
can get distracted for arbitrarily long amounts of time.
So in my case, it was just simpler to leave those problems
to the sort of traditional 'unix' solution of 'clearing out /tmp'
when we reboot...
The core problem the OP still needs to work out is:

so why are you caching in little files
that can be abandoned/marooned on the file system?


ciao
drieux
---

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


Re: automated file removal / cache clearing

2003-08-27 Thread drieux
On Wednesday, Aug 27, 2003, at 07:18 US/Pacific, Shahar Evron wrote:
[..]
I'm working on a CGI program that creates some user-specific
file on the server when accessed. is there a good way to make
sure theese files are cleared when they're no longer needed -
IE if a file in a specific directory was not accessed for 5 minutes, 
delete it.
[..]

I hate to suggest the alternative, but why not
use a 'cookie' to cache that information on
the user's side?
I can appreciate the problem, but what I would
argue is that you might want to set up a nightly
cron that goes in and clears out your temp-directory
in one pleasant pass for any file that has not
been accessed in the last hour.
So a part of the problem is tied up with why are
you writing out the information to a bunch of files
rather than putting in some sort of 'DB' service
that would manage the information as DB records,
then running a purge routine on the 'old records'?
ciao
drieux
---

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


Re: Call to a function is a seperate file

2003-08-25 Thread drieux
On Monday, Aug 25, 2003, at 09:30 US/Pacific, Jattie van der Linde 
wrote:
[..]
How can I call a function from my main script file located
in a seperate file i.e. for instance a reusable piece of code
that will generate the index of my site without having to copy
the code to every singe page that I generate?
[..]

The moment that you say,

Well I have these functions/methods that I want
to make common to more than one piece of perl
you want to run down and Pick Up a Copy of

learning perl Objects, References  Modules:
http://www.oreilly.com/catalog/lrnperlorm/
since you are in need of feeling at home with
how to make a perl module, and how to use them.
{ wiggins has already covered the stock perldoc sequence,
but I want to stress that for 'normal people' from 'mostly
sane backgrounds' it would be best to start with the learning
book, before falling in amongst 'the diseased' You were warned. }
My own Personal Ranting on Perl Modules is up at:

	http://www.wetware.com/drieux/CS/lang/Perl/PM/

So while I am a RELIGIOUS FANATIC about 'h2xs' - as
a way to start a new module cleanly - cf:
	http://www.wetware.com/drieux/CS/Proj/PID/

as a case study in how to spin up modules. There is
the minor issue with how to 'contain them' in a way
that they are exposed to ONLY your 'cgi code'. The
trick I use is
use lib ../lib;
.
use MyNameSpace::Stuff;

this way the cgi code will know to look 'up and over' in
a lib directory to find the 'special stack of stuff'
HTH.

ciao
drieux
---

The current state of the Documentation about
The Project From Hell:
http://www.wetware.com/drieux/CS/Proj/TPFH/gen_doc.html
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: How does CGI.pm handles Content-type: text/html\n\n ?

2003-07-29 Thread drieux
On Tuesday, Jul 29, 2003, at 18:36 US/Pacific, LI NGOK LAM wrote:
[..]
So.. if I create my own style of fatalsToBrowser.
Is that possible to do in this way :
[..]

The reason that 'fatalsToBrowser' and the rest came about
is because many perl modules are built on 'die' or 'Carp'.
And that 'die' would make the foo.cgi code 'exit abruptly'
and that would generate a 500 error.
So if the code you are building on does not do a 'die',
'Carp', 'Croak' - then you really do not need to 'worry about it'.
What you will want to learn about is how to set a local
signal handler - if you want to write your own. I built
some stuff ontop of some code that I knew had a series
of places where it would invoke 'die' - since that code
was not 'designed for the web' and in those case 'dying'
was a good thing - so the wrapper call solves it:
 sub wrapper_call
 {
my ($me,$host_port,$uri,$q) = @_;

our ($page,$h) ;
our $wrapper_flag = 0;
our $bytes_read = 0;
eval {

local $SIG{'__DIE__'} = sub { $wrapper_flag = 1;} ;

($bytes_read, $page, $h ) =
get_from_server($host_port, $uri, $q);
};
return({ run_time_error =
Problems connecting to $host_port got status: $@ }
) if ( $wrapper_flag );

return({ run_time_error =
 Server $host_port Returned: $h-{dtk_status}})
if ($h-{dtk_status} !~ /OK/);

return $page if ($bytes_read);
\$page;

 } # end of wrapper_call
In this case the caller either gets the reference to the
page, or a reference to a hash, that has the 'run_time_error'
message in it...
This way if the caller wants to report out the error case
then they can do that, or they can also decide that they
do not care that the error occurred, and go on to some
other strategy...
ciao
drieux
---

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


Re: need help/ advice

2003-07-28 Thread drieux
On Sunday, Jul 27, 2003, at 19:32 US/Pacific, Luinrandir Hernsen wrote:
[..]
I will try your suggestion
Is there another way to do this? with out the LWP::UserAgent
Quite the Correct Question!

Yes, but it would involve things like actually doing your own

use Socket;
use FileHandle;
sorts of 'open the socket, push some stuff down it, get the
answer back' and then deconstruct it...
If you have the time, I HIGHLY recommend this exercise. Nothing
will help you better understand the in's and out's of HTTP and
hence what browser/servers are doing than to actually build out
your own solution here. So yes, not only build out a 'web-bot'
but take a shot at the 'server side' as well
The question of course is whether you can avoid 're-invent the wheel'
when there is this really nice set of modules already there to be used.
If you take the time to 'do your own' - you may decide that
your 're-invention' is 'good enough' for your needs - or
you may also verify - way too much work. and hence
opt to use as many of the CPAN modules that you find that you trust
and like
I see you are using a get command.. ok I know about those

to say it better I want to get the output / HTML code from another web
site...
the stuff between the HEAD to /BODY commands... clearer?
I have appended the test code I was playing with at the end,
and as you will see I cheated by using
	use Data::Dumper;

that shows you what that $response is all about.

many thanks.. I am real new to this...
We all start some place. You will want to take a
peek at
	perldoc Data::Dumper

as it can be your best friend in all of this.

I'll look up the perldoc stuff too.
Also remember that at times

	perldoc -m foo::bar::baz

will let you look INSIDE that modual at what is REALLY going on.

[..]
The code below just gets me the name of your home page as a string.
correct?
incorrect.

but were I to do something like say
my $url = URI-new();
$url-scheme('http');
$url-host($host_port);
$url-path('/drieux');
my $response = $ua-get($url-as_string());
this code fragment returns an

	HTTP::Response

object and inside of it, you have the actual content
of the 'web page'.
I would of course recommend that you use something
like the HTML::TreeBuilder to 'deconstruct' the
web page back into information you really want out
of that web page.
ciao
drieux
---

the test code I was playing with.

#!/usr/bin/perl -w
use strict;
use URI;
use Data::Dumper;
use LWP::UserAgent;

# #FILENAME# - is for

my $host_port = 'www.wetware.com';

my $url = URI-new(); #$host_port, 'http');

$url-scheme('http');
$url-host($host_port);
$url-path('/drieux');

print Dumper($url);

print #--\n;

my $string = $url-as_string;
print $string\n#--\n;

 my $ua = LWP::UserAgent-new();
 my $response = $ua-get($url-as_string());
###
 print Dumper($response);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: return(bless $rant, $class) || Fwd: PHP vs Perl

2003-07-28 Thread drieux
On Sunday, Jul 27, 2003, at 20:03 US/Pacific, Todd W. wrote:
Drieux [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
[..]
But First off - COOL RANT!
I was hoping that _some_ day I could string a few sentences
together as well as you do =0)
[..]

flattery will get you out of some problems,
but practice and perceverance is a better strategy
[..]
I agree, as long as you agree that the more one
understands the CS theory,
the less voodoo there is in the implementation.
IF and only IF 'understanding the technical stuff'
from comp-sci really is useful for the 'implementation phase'.
May I recommend Real Genius (1984) as an alternative
study in the problems of 'science v. technology'. Given
that basically most of the current 'academic work' in
computer science is running anywhere up to a decade
back of there the 'technology' is in industry - the
New Guy on the block may be better served to 'get a
gig' and hang with the BigGeek, Buy the Books, read
them, rather than eat them, and do their own 'experimentation'.
Given some of the stuff that we have seen come out of
the academic discussions about this, that and the next thing,
I am also not at all sure that some of the 'implementation'
is really worth the candel.
One might argue that the Java adoption of 'templates', which
they call 'generics' in the hope that most folks are not going
to notice the absorption of the C++ effort to work around the
problems and unpleasantries of the 'multi-pel klass inheritence'
model that was suppose to be fixed in 'java' with it's extends
and implements, efforts to keep Java out of the FoxWorthy set
of jokes about 'family trees with more than one loop in them'
Uh, well, establishes that some academic debates, when they get to
the implementation phase, do not always add 'value' in the way
that everyone was hoping they could/should/would
In like manner, the fact that one CAN make PHP stand alone 'scripts'
that are not specifically used to create HTML web-pages, would
establish that... one SHOULD implement things that way?
Or would it be simpler to restore the kinder, gentler, more simpler

	'strongly typed v. weakly typed'

computer language academic debates in this space and decide
that we should always follow the Ivory Tower
[..]
I think that most languages are supportive of MVC as a design pattern,
[..]

as well as many other techno-babble-phrases...

would it be impolite of me to raise the scary support for the
phrase 'refactoring' rather than 'recoding' since the former
sounds less threatening to both other coders and mangelment.
while they are, mostly, dealing with the reality of needing
to 'recode' Either because they did not start with
any design pattern save 'the big ball of mud'
I had this glob of code,
and I globulate more code on it
or as a part of the naturual selection, they have come back
to the code and gone
YEE, that so smells, if my professional peers
were to peek at that, they would make rude noises
in my direction and ask me if my mommy dresses me funny
drieux to UnterStumpenFumbler
c. 2003, all rights reserved
{ yes, you will have to formally cite that with full legal
attribution, since, well, yes, I am the author of it,
and I plan to defend my IP, even if my mommy does dress me funny... }
But as I believe it was Ovid noted, there are 'meme drifts'
where a 'token' started out actually exporting meaningful content
and simply decays into the 'KultBuzzPhraseDuJure'
So you will forgive me if I do not opt to jump onto the
new band wagon that 'all developers' should wax their
surfBoards, because foo is the Next Big Wave that will
solve all problems end to end, as I will counter, your
counter to my counter below...
{ not that I am being merely contrarian... }

[..]
p4: given that hacking in perl does not require MVC as
a design pattern, but one can learn the hard way to support it
We have AxKit, but I wouldnt like to call it the canonical perl
I so love the fact that slowly but surely the One True Perl Orthodoxy
is finally being able to create the canonical perl yourPhraseHere.
insertThingiePooHere

MVC pattern. Most familiar with it probably would though.
ASP.NET has MVC with its code behind concept.
Im not aware of any other MVC based platforms right off.
You will forgive me the comedy of giggling at you,
nothing personal you understand, but we have watched
	UML - universal modelling language

evolve from the academic discussions about the
need to have a common 'tokenization system'
to the supposed automation of
'write it in UML,
turn the crank
and out comes code'
Without always pausing to answer the question,

Ok, so this idea can be discussed in an 'OO'
manner, does that mean that it MUST be implemented in
insertIdeologicallyKorrektThingiePooHere

Re: How to add modul directory to @INC

2003-07-28 Thread drieux
On Monday, Jul 28, 2003, at 04:12 US/Pacific, [EMAIL PROTECTED] wrote:
[..]
So I moved my module to /usr/lib/perl/ and it work o.k.
not a recommended strategy, trust me.

you may want to start with reading

perldoc h2xs
perldoc perlmod
for a start on how to think about creating your
modules is a reasonably sane manner.
I would of course recommend that these are topics
well covered in chapters 12-15 of
Learning Perl Objects, References  Modules
Randal L. Schwartz with Tom Phoenix
since that way you can avoid the need to deal with
such things as 'use lib' - cf
	perldoc lib

Recently I read somewhere that, instead of always moving  my modules to
/usr/lib/perl/, I could place them anywhere in my program directory and
indicate the location in my scripts e.g.
#!/usr/bin/perl -w
push(@INC, MyLibDir);
require mymodule.pm;
###
But one thing that am not sure of is: Do I need push(@INC,
MyLibDir);in all my scripts or is it enough only to indicate only
once?
if you build out your module to be a 'CPAN style Deliverable'
then you do not have to worry, since it will be installed
where ever the version of perl on the host happens to put
those things in it's 'site_perl' section.
The alternative is that you will want to

	use lib '/fully/qualified/path/to/your/stuff';

so that you KNOW that it will always be in the
correct place, one of the 'cheats' that one can
get away with in the cgi environment is that MOST
'reasonable' web-servers will 'chdir' to the directory
where the foo.cgi is invoked - so one can do the
relative path offset solution of
	use lib '../lib';

and then hang your modules there...



ciao
drieux
---

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


Re: return(bless $rant, $class) || Fwd: PHP vs Perl

2003-07-25 Thread drieux
 is there, else I invoke an alternative
function that is fully qualified, that itself checks
another hash of references to functions...
And since you asked, the above IS the core of the db_mgr.cgi
from the piece:
Remember that:

libex: 57:] GET -S -e http://db_host/HqDb/db_mgr.cgi?verb=get_both; ;  
echo 
GET http://db_host/HqDb/db_mgr.cgi?verb=get_both -- 200 OK
Connection: close
Date: Wed, 23 Jul 2003 18:33:23 GMT
Server: Apache/2.0.45 (Unix)
Content-Length: 105
Content-Type: text/plain; charset=ISO-8859-1
Client-Date: Wed, 23 Jul 2003 18:33:23 GMT
Client-Response-Num: 1

jMan=jeevesstore2=vladimirstore3=vladimirnew_style=vladimirvMan=vla 
dimirstore1=libexstore4=vladimir
libex: 58:]

conforms to the CGI spec, BUT is not returning
anything that is in 'html'...
In this case I decided that I really did not need
to be all that 'dynamic dispatching through a blessed reference'
and figured, hey, maintaining this will be so much simpler if
I simply separate the basic set of db_get_actions() from
the check_maintenance() set of actions, so that I can
manage the two in separate modules. The former 'class'
deals with the 'do some DB query stuff' while the later
deals with the traditional DB maintenance questions
about how to do Import the DB, Export the DB, Compact
the DB, and FSCK the DB. This way the exposed 'cgi code'
that gets called is, well, just there - while the
underlying DataBaseFoo is abstracted behind perl modules
in this case without having to transit through the 'blessed reference'.
I bascially trust Perl's Hashing Algorithm that much.

HTH.

ciao
drieux
---

Trust me, if you watch it go through the Perl Debugger
you too would have faith in all of the lines of code
it does not have to execute...
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: PHP vs Perl

2003-07-23 Thread drieux
 'web site' -
just as more and more are able to ID wiki sites - from a full
tilt tomcat java server site from an Adobe GoLive site...
And for those who happen to connect to

	http://localhost:631/

to connect to their CUPSd they should crawl into the source
code for that, and have a 'life moment'
So there are still at least 96 other factors that will go
into the process of picking out which is a person's preferred
'html like stuff woofer' system - I think it helps to look
at the various ways that 'CGI' gets implemented - and figure
out whether one can 'implement, update, maintain, refactor,
re-implement and reuse' stuff if one started in code language
foo or bar
I like perl precisely because it is a glue language, and has
the full range of sheer silly options, that allows me to write
'cgi code' that can itself turn around and query one or more
other servers, using HTTP and other Protocoals, for more dope,
that can get wrapped in some 'html like stuff' and woofed out
the door to a browser
Since PHP allows me to invoke 'external commands' - then all
I have to do is resolve if that is a faster,cheaper, better
way of getting that dope than 'open the socket, push, pull,
parse, puke'.
ciao
drieux
---

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


Re: Clearing a Form

2003-07-22 Thread drieux
On Monday, Jul 21, 2003, at 15:05 US/Pacific, Peter Fleck wrote:

I have a cgi that creates a form and then receives the output of the 
form and sends it to a mysql database. It also displays the form 
information as a preview of what is getting sent to the database.

You can return to the original form with data if you need to correct 
something via an 'Edit' button. This button also makes sure that 
nothing gets stored in the database (by deleting the data that was 
just sent and I know there must be a better way to do that part but 
it's not my current question).
[..]
I'm wondering if javascript is the answer?
[..]

Let me try to underscore wiggins basic idea.

Javascript can help a part of this, in that
it can do basic checking on the browser side.
If fields foo|bar|baz have to be filled in,
then a quick Java Script
alert(Must have value in field foo);
return false;
is a quick way to prevent some of those problems.
The bad news is that with some of the 'pop-up blocker'
software - those alerts will be dumped and the user
will not see them.
SO you need to always write your CGI code as IF
the javascript TOTALLY FAILED. Hence that you
check that the values returned from the form
are kosher and sane.
What I do, is then present a 'verification page'
where they have the option to 'commit' or 'go edit'.
On the 'commit' we actually execute on the DB transaction.

This is where you also need to work out your basic DB transaction model.

I have mine happily say 'yes' to any 'add' for something
that is already there - since, well, yes, it is already there.
I also generically say 'ok' to any 'delete' of things that
do not exist, since, well, they are no longer there.
This way, if the person does use the 'back button' on you,
the worst case is that they will niggle the front end of
your DB transaction system - by trying to delete a deleted record,
or add an already existing record.
What you can then deal with is a 'confirmation' process
if they send you what would be a 'modify' - in which
the record exists, but there are differences between
what is in the current record and the new information.
This too can be caught at the 'validation' stage, with
a 'warning' message - that says something like 'foo already
exists on bar - go to bar?'
So rather than doing an 'update' and recycle, make sure
that they REALLY want to go there before you even talk
to the database
Other strategies are to do the no-cache pragma, and hope
that the browser honors that. Other tricks are to run
SID's - and to have a table of active SID's - session id's,
and to delete a sid from the table if
a. the commit occurs
b. the transaction is older than time allowed
This way if you get a SID for a transaction on a back button
event, that is for something that has already been committed,
then you warn about that if the SID is 'aged out' then
you warn about that... Or you take the alternative strategy
that since you can not find the SID in the active sid table,
then you whine that the SID is not there.
You get the sid into the form as a 'hidden' - and you can
then think about dealing with a journaling database model
that will allow you full rollback, etc, etc, etc...
But basically what I would argue is that you get a better back
end model for dealing with the real back end issues.


ciao
drieux
---

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


Re: PHP vs Perl

2003-07-22 Thread drieux
[..]
Talking about PHP, someone asked me to tell him why is PHP better
and why it is used more than Perl.
[..]

This might be a good time to point people towards the

	MVC - Model, View, Controller

approach for doing software development.
{ just google search on Model, View, Controller for fun }
Web-browsers are a way of presenting a 'view' of
the 'model' - and the web-browser dialogs with
the web-server to 'get stuff done' - this may
mean using the 'common gateway interface' (CGI)
to pass stuff back to a 'controller'
That controller may be written in perl, it may
actually invoke code that is NOT written in perl.
It might be written in PHP, that understands how
to invoke things written in perl and other languages.
As we have discussed in terms of 'using java scripting'
there is actually a level of 'MVC' that is strictly at
the browser side - and that the server side needs to be
able to deal with the 'failures' that occurred because
the 'java scripting' was ignored, and 'stuff' came
back to the server side - and needs to be managed
by either the CGI code itself - or by the underlying
stuff that it rests upon
So a part of the problem is

how tightly wrapped is your 'web-browser side'
MVC to the 'server-side' MVC(s); and how tightly
coupled is your 'server-side' MVC's to each other...
At which point we start noticing that there are
'design sillies' in which we forget that the
'server side' is laying on top of other MVC's,
such as database queries, CLI invokations, proxy-ing
through other web-services
IF one started with a clean, clear and consistent
interface for each MVC on MVC, on MVC, then of
course those will all align correctly and all
will be fine, at least in theory
Allow me to offer an actual case study. I started with
a general 'abstraction layer' that said
I need a database thingie, somewhere,
and I will make my queries to it using a
CGI based solution.
This way, all of the 'cgi code' that is directly
invoked by the user - calls code that itself will
turn around and query some other web-server as if
we were a 'web-browser' doing a
	GET http://some_db_host:db_port/some/path/db_cgi.cgi?verb=doFooval=bob

get the answer back, stuff it into some html
wrappings, and push it out STDOUT to
the user's web-browser.
This allowed me to work out the basics of
what sort of DB I really wanted - so when I
decided what to use at the other end of that query,
I could swap it IN, without changing line one of
the 'cgi code' that the user will invoked.
{ as a general rule, I like to stuff the 'do the work'
side of the problem in a 'perl module' that is external
to the foo.cgi - so that modifications can be done external
to the 'foo.cgi' itself... }
We could of course go the other way with this,
and decide that for 'presentation purposes'
calling a PHP was 'much cooler' - then all I
need to do is teach the PHP to go fetch the
stuff from the DB by using a step in the process
that either knew how to invoke a CGI connection
with another web-server, or invoke some piece
of perl bridge code built with the lwp-useragent,
or roll up something that understood how to open
a socket, woof stuff down it, get a message back,
deconstruct it
Ok, I must complain here there is that other
part of the HORROR STORY - where your beautiful
web application gets 'attacked' because
	well it's just a 'check box'.

So now one has to 'just' add

trtdpbSysnames (-S):/b/p/tdtd\n .
'input type=text name=S value='.
' maxlength=256 onclick=return lineEater()/td/tr' . \n;
to the presentation layer, except of course that also means
updating the java-script to adjust for the shift in fields
of type foo, and then the back side of that cgi code has
to actually pick out the 'S' value, if it exists, then
of course one has to re-write the Freaking Controller,
to figure out how to pass that smack on through to
the CLI interface, so that it will be used, plus the
extension to that Module, to handle all of the new
classes of ERRORS that can occur, because one did
or did not pass that additional set(s) of argument(s),
with or without the newly restructured pre-ceeding Smack,
because the vendor's CLI MVC shifted more than the
	it is just a check box thingie widget...

Or should I just say, there are other more sinister
plots and conspiracies to really feast upon
than whether you want PHP or Perl to be the
primary source of the 'html like stuff' that
goes back to the user's browser...
ciao
drieux
---

ps: did I mention the part about having to shift
all of the 'online html based documentation' that
goes with the application that will also have to
be clarified where all of the previous illustrations
have been obsoleted by the addition of 'just a checkboxThingie'
not to mention the additional work of providing the primary
documentation about how the user should use it, plus
all of the new error/exceptions that can be thrown,
caught, missed

Re: sending mail to a group using perl

2003-07-15 Thread drieux
On Monday, Jul 14, 2003, at 18:18 US/Pacific, Sally Librilla wrote:

Its for global group.

Is this a global group or one you've set up for your personal use?

At 05:37 AM 7/8/2003 +, Sally Librilla wrote:
Hi,

I'm send email using the Mail::SendMail module. I understand how the 
send To field works for multiple works however, I can't get it to 
work to send mail to a group existing in my Lotus Notes mailbox. 
Does anyone knows how i can make it work?
[..]

so that we are on the same page,
we have 'mailing groups' - such as
	[EMAIL PROTECTED]

that fan out the email to everyone who is on the list,
is there some special way that 'lotus notes' hides that
type of 'group address'??? that requires you to be IN
a Lotus Notes application to gain access to it?
A part of the question is how is the 'group' in
Lotus Notes hiding the actual RFC822 compliant
headers... Or put the other way around, can you
send regular email, outside of lotus notes, that
can get to the 'group list'???
If there is nothing that is bridging between the
standard SMTP mailing system and the Lotus Notes
side of the process, then you have serious problems
in front of you. Since If I remember correctly, what
lotus is doing is advertising an entry into the
Lotus Domino server, and then doing some database
manipulations - at which point basically it winds
up 'expanding it all' and sending an individual 'note'
to everyone in the group - and also to email clients,
if an entry is to an actual RFC822 compliant email address...
We went through weirdness like that with a corporation
that believed in Lotus Notes
HTH.

Personally I would go with Mail::Mailer - which
has a bunch of simpler ways to deal with 'sending mail'
that are independent of the actual sendmail application.
ciao
drieux
---

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


Re: Getting the domain name

2003-07-14 Thread drieux
On Monday, Jul 14, 2003, at 09:37 US/Pacific, Mike Blezien wrote:

Hello,

We have a fairly simple redirect script a url is entered, and even tho 
there are directions to not enter the http://www; sometimes we get it 
or http://;... what is the simplest method to extract just the domain 
name if a http://www.somedomain_name.com; or 
http://somedomain_name.com; is enter so we can extract just the 
somedomain_name.com
The simplest of re's I can think of is

#
#
sub simple_get_domain
{
my ($string) = @_;
my $some_dom;

if ( $string =~ m!http://www.(.*)! ) {
$some_dom = $1;
}elsif ( $string =~ m!http://(.*)! ) {

$some_dom = $1;
}
$some_dom;

} # end of simple_get_domain
but this is merely a string parser -
and is not really gonna make sure that the
$some_dom returned is kosher...
The squirelly part of course are things like:

http://foo.bar.com:12345/uri_path_stuff_here
or
	http://127.0.0.1/

I start that part with something like

sub parse_url
{
my ($me,$url) = @_;

my($schema, $host_port, $uri ) = ($url =~ m!^([^:]+)://([^/]+)(.*)$!);

} # end of parse_url
sub get_host_port
{
my ($me,$host_port) = @_;
my ($host,$port) = ($host_port =~ m/([^:]+):([^:]+)/) ?
($1,$2) : ($host_port, '');
}
And then the validation part gets into either working
backwards from the TLD - top level domain - or
trying to figure out which part of the string is
the host part. try to remember that
	nas.nasa.gov

IS the domain name, not a host and domain component

ciao
drieux
---

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


Re: look arounds

2003-07-06 Thread drieux
On Sunday, Jul 6, 2003, at 04:20 US/Pacific, mark sony wrote:

Hi All,

Can anyone plz explain to me why this one is not working :

$_ = The brown fox jumps over the lazy dog;
  /the (\S+)(?{ $color = $^N }) (\S+)(?{ $animal = $^N })/i;
  print color = $color, animal = $animal\n;
When I run the program it gives :color = , animal =

I took it from this link :
http://www.perldoc.com/perl5.8.0/pod/perlre.html
first off you are running it in perl 5.8,
and not a previous version? if so, it should
work. I of course ran the code:
#!/usr/bin/perl -w
use strict;
my ($color, $animal)=('','');

$_ = The brown fox jumps over the lazy dog;
  /the (\S+)(?{ $color = $^N }) (\S+)(?{ $animal = $^N })/i;
  print color = $color, animal = $animal\n;
when I ran that code under 5.6.1 I got

vladimir: 105:] perl !$
perl junk.plx
Use of uninitialized value in concatenation (.) or string at junk.plx 
line 8.
Use of uninitialized value in concatenation (.) or string at junk.plx 
line 8.
color = , animal =
vladimir: 106:]

ciao
drieux
---

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


Re: dynamic update part of a table

2003-06-29 Thread drieux
On Sunday, Jun 29, 2003, at 17:15 US/Pacific, Ling F. Zhang wrote:

so I have a webpage done nicely with table layout...
I have one cell (long one) dedicated to update the
latest news about the website...
I want to write a perl script that reads from a file
and put up formated html code into that cell.
Two questions:
1) how do I load a perl script into a table cell?
should the code print out regular html code with a
content/type header just like what we normally do?
well if you want this to 'auto update' at the
browser, you will want to look at how to include
and 'expire' in the HTTP header. This will oblige
the browser to do a 'refresh'... At which point
your cgi will need to know how to create a new
page - and if that means that one has to put
new stuff in the long cell, so be it.
2) when the news gets too long (I intend to keep a
month worth of news in the webpage at a tile, and I
will use perl code to throw out news more than a month
old, but that's another story) the cell will no longer
be big enough.  Instead of expending the cell, is it
possible to add a scroll bar to the cell (I know how
to do it, if this were a frame...but again, it's just
a table)? that user can scroll? thanx!
what you may want to look at is the issues
with using frames and frame-sets and setting
the with scroll... It would be nice if more
browsers were willing to use say iframe
but that really limits the number of candidates...


ciao
drieux
---

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


Re: Why not Class Objects

2003-06-28 Thread drieux
On Friday, Jun 27, 2003, at 07:22 US/Pacific, Daniel J. Rychlik wrote:

Thank you sir for the response, I will have a look.  I love 
programming in
perl, but Im getting used to the idea of developing class objects and
instances in PHP.

class thisclass {

}

class otherclass extends thisclass {

}

Object oriented programming is a great way to reuse code.
you might want to do

	perldoc perl

to start with and pay attention to

perldoc perlboot
perlobj
etc

the class hierachy model is different in perl.

From a specific class extension that I have

package Wetware::Hq::Web::RCI;  
.
use Wetware::RCI;

our @ISA = qw(Wetware::RCI);
.
this way when i do things like

	my $rci = new Wetware::Hq::Web::RCI;

it inherits all the song and dance of the base class...



ciao
drieux
---

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


Re: Why should I create an object?

2003-06-28 Thread drieux
On Thursday, Jun 26, 2003, at 23:45 US/Pacific, Octavian Rasnita wrote:
[..]
You should create an object because you might import more modules in 
your
application that export the param() function/method.
In that case the program won't know which of those param() functions 
to use.
I guess this is just one reason, but I am sure there are more.
[..]

This is probably the best reason

it's a simpler way to manage 'name space' issues.

This of course presumes that one does something like

my $cgi= new CGI;
my $wombat = new Wombat;

	my $cgi_param_foo = $cgi-param('input');

if ( $wombat-param($cgi_param_foo) )
{
# right wombat
$wombat-HappyHappyJoyJoy($cgi);
} else {
#
# another waste of money brains and talent
# that has to be fixed
#
$wombat-sullen_wombat_must_fix_earther($cgi);
}
#
# cgi stuff now fixed up
#

Basically, if you do not have total control over the
libraries you work with, it is important to work out
a strategy to avoid collisions...
Another strategy of course is to be explicit

	my $input = CGI::param('input');

This way one knows that the param is the param() that
one means there is some trade off here, in that
one only imports the methods that one means to import...
ciao
drieux
---

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


Re: suexec question

2003-06-12 Thread drieux
On Thursday, Jun 12, 2003, at 04:01 US/Pacific, Eugene Geldenhuys wrote:
[..]
I have a small problem after upgrading a system from RH6.0 to RH9.0, my
apache web server went from version 1.3.6 to version 2.0.40.  This in 
itself
is probably a good thing, but a system management utility I wrote in 
perl
now will not execute system binaries unless I mark them srwxr-xr-x.
[..]

p0: did you do a 'cold upgrade' without bit twiddling
either the perl or the apache code?
p1: when you su to root and do

	suexec -V

does the

	-D AP_DOC_ROOT=/var/www

value point to where you have your DOCUMENT_ROOT
rigged to work, normally the default value in
the httpd.conf is something like
	DocumentRoot /var/www/html

hence you should be able to hang any of your stuff
that needs to be suexec'd in that path I have
my Virtual Hosts off say in
	/var/www/virtualHostNameHere

p2: you do understand that you will need the command

	SuexecUserGroup user group

in your 'virtual host' directives vice the older
apache 1.3.x versions where it was
User uname
Group group
p3: the executable - perl code - is actually owned
by the user/group that will be executing it?
p4: we basically agree that you should NOT need to
have the setuid bit set on the executable...
p5: have you any interesting information from the suexec.log
that can help you sort out what it is whining about?
ciao
drieux
---

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


Re: Needing IP addresses

2003-06-12 Thread drieux
On Thursday, Jun 12, 2003, at 16:49 US/Pacific, Chris Anderson wrote:
[..]
I have one page where I need to track all IPs going to that page.
I need this to be output to an HTML file or a text file that will
be dynamically read by an HTML file.
do you mean the
REMOTE_HOST
REMOTE_ADDR
environmental value, if set?


how about say,

	my $players = {};

$players-{remote_host} = $ENV{REMOTE_HOST};
$players-{remote_addr} = $ENV{REMOTE_ADDR};
then if you have a blank in one you can do the applicable
host look up in dns, and get the other
Granted, there is no gurantee that the actual value
there is Kosher, but if you really want to get funky
then you can of course look at the REMOTE_PORT and
try some socket getpeer types of tricks...
ciao
drieux
---

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


Re: Simple character replace problem

2003-06-09 Thread drieux
On Monday, Jun 9, 2003, at 13:05 US/Pacific, steve ryan wrote:
[..]
So... i do my hex to ascii translation first, and the character replace
second.
so simple.

AARRRGH! :)
Huzzah!

Welcome on the BigBus!!! Those who have headBashed in public that

	DuhMoment

There is always this ungainly problem of what the documentation
says about how things should happen, and then understanding where
exactly they really DO happen... As we have been sharing with
David Greenhalgh, a part of the issue is understanding IF the
problem is with the perl syntax, or with how a given browser/server
is doing it's bit and then there is the 3Dom's Problem
I should also thank you steve, as I finally took the time to
clean up a bit of ugliness when I saw it in the function when
I went to show it to you One of those things I have been
meaning to go back and better understand and refactor... so
my complements for getting me off the dime...
On Monday, Jun 9, 2003, at 09:48 US/Pacific, Kristofer Hoch wrote:
Also,
  Maybe you may want to try using CGI.pm to get query
strings.
[ lovely code snippet for reasons of National Security ]
==
That may help you out quite a bit.  Drieux, You are so
hard core dude!;)
I was rather counting on you to defend the 'mainstream'
position - and why/how it would work in canonical CGI.pm
On top of the usual problems about producing useable html stuff
that will work with IE and Netscape, and opera, and... there
is the 'server side' problems about what assumptions does one
have about what will 'be there' when your code arrives; and
some here can go back and notice, as I did, that the CGI.pm
is a relatively 'new' addition - as I have one of the boxes
that has the fan out of perl 5.003(??) - may 6th 1997 -
that did not deliver a CGI.pm Some of the folks who ask
questions here are also running off of servers that come from
those dark times, a long, long, long time ago...
A part of the problem of course is whether or not one has
control of any form over what the sys-admin on a given site
will actually be doing with how much of perl is actually installed.
So one either has to call out the full on dependency list,

perl 5.6.1 or better
and . and 
And PRAY that the nice sys-admin/WebPerKin will be ever so
polite as to make sure that the new cool and groovey modules
that one really likes are in place
Or one opts for alternative strategies such as hacking code
that lives in the middle ground which does not assume more
than one can hope for
When that project started, there was some uncertainty how far
back we were going to have to be 'compatible' - so some things
have to be hacked around So by the time it was 'ok' to presume
that we would not have to go back before 5.6.1, most of the cgi
basics had been tweeked, and there really was no good reason to
try to fall back to CGI.pm ...
The Other Side of the argument of course is the value I personally
place on,
Rip It Apart,
Put It back together
So It is my OCD to see how much I really 'know' about the stuff
I am coding up, and why I like this Kult Solution over that...
A part of what we need to be able to share with all FNG's is
that basic reality,
	We all start some place...

and hopefully also share with them our

'Once Upon a Time, I did a dumb thing like,
and so I tend to do'
things that we all do...

Fortunately I caught the 'oh that looks ugly' in the function,
as noted above, BEFORE I sent it to the list at least this time.
ciao
drieux
---

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


Re: I am having trouble using SSI(Server side includes) from cgi using perl

2003-06-06 Thread drieux
On Thursday, Jun 5, 2003, at 10:41 US/Pacific, Edson Manners wrote:

I am making a cgi script that prints a web page with SSIs in it. When I
put SSI code in my cgi which is output to STDOUT the webserver gets no
chance to parse the SSI and put the HTML code in in place of the SSI
statements. Does anyone know how to do this.
which type of SSI's are you putting in?

ciao
drieux
---

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


Re: I am having trouble using SSI(Server side includes) from cgi using perl

2003-06-06 Thread drieux
On Thursday, Jun 5, 2003, at 11:25 US/Pacific, Edson Manners wrote:
[..]
Is there anyway I can send the cgi output to a .shtml file before
handing it to the browser, or handing this output to the webserver so
that it can parse the SSI before giving it to the client browser?
[..]

I think that is the basic problem that you are
dealing with. You have a 'design pattern' that
says
something else will parse my output
for special information, and do stuff with it
so You might want to think in terms of say:

#
# we would use an ssi virtual= here were we a
# static html file
#
open(VIRTUAL, fsunetwork_header.html);
print STDOUT $_ while(VIRTUAL);
close(VIRTUAL
since if the file is going to just be included,
then it will 'just be there'
cf:
http://www.webmasterworld.com/forum13/633.htm
what most folks forget about the basic idea of SSI
was that it would allow something else to do the actual
lifting of including stuff 'on the fly' - whereas coming
to the CGI process IS about making it up 'on the fly'.
HTH.

ciao
drieux
---

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


Re: Difference of $hash, and %hash. (was Getting my head round hashes)

2003-06-06 Thread drieux
On Thursday, Jun 5, 2003, at 13:07 US/Pacific, Andrew Brosnan wrote:
[..]
my $hash = {};

while (my $rows = $response-fetchrow_hashref){
  $hash-{$rows-{task_ID}} = $rows;
}
Why is hash declared as my $hash and not my %hash?
and how does the
This creates an annonymous hash '{}' and stores a reference to that 
hash
in $hash.


As for solving -
 when to use a reference to a hash,
vice declaring a hash itself.
Some of it is merely 'art work' - but there is a useful
practical distinction, is one planning to
pass by 'value' or pass by 'reference' at
any time in the life of the variable. { and/or
all of the future refactorings of the code 8-) }
One can have a large hash, and if you pass it by value
then you have to put all of the key/value pairs onto the stack.
While if you passed merely a reference to the hash, you
will pass merely the singular reference itself.
I just hacked something where I was not sure what the
structure would really need to look like, so opted to
merely declare
my $struct;

$struct-{$sname} = src: $src_file open error:\n\t $!;

$struct-{$sname} = copy of $src_file ok;
...
so technically the code does not WARN the coder that
I plan to use it as a reference to a hash but looking
at the various places where I used it, most perl coders
would understand that it was merely a hash.
I also do this sort of trick when I am planning to do
strange return solutions:
sub some_funktion
{

return undef unless($condition_one);

		return that's not right if $error_case ;

$hash_ref;
}
hence I can 'know' a bit about what went on with

	my $got_back = some_funktion(@arglist);

unless(defined($got_back)) {
# condition_one not met

}
unless(ref($got_back)) {
#
# that's not right handle the error_case
#
}
while(my ($k,$v) = each %$got_back))
{
#
# here we deal with it just like it were a regular hash
#
}
HTH

ciao
drieux
---

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


Re: Difference of $hash, and %hash. (was Getting my head round hashes)

2003-06-06 Thread drieux
On Thursday, Jun 5, 2003, at 13:34 US/Pacific, Kristofer Hoch wrote:
[..]
This is possibly the best answer.  I won't give any
other.
[..]

why thank you.

there are basically two reasons that one should
be playing with 'just perl stuff' -
a. they have hashes well done, so if you NEED
to have a well managed associative array, it just works
b. perl has the best available RegEx engine short of
bit twiddling one's own lex and byacc - this saves on
a lot of complex wing-ding-ding to do it in say sed/awk/grep
and can be done in one Process vice forking for ever...
after that it's the name space management solutions that
come with having perl modules
ciao
drieux
---

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


Re: Difference of $hash, and %hash. (was Getting my head round hashes)

2003-06-06 Thread drieux
On Thursday, Jun 5, 2003, at 14:33 US/Pacific, Greenhalgh David wrote:
[..]
My thanks to both of you. The explanation was clear even to me,
much better than the book i am using to learn perl.
[..]

which book are you trying to learn from?

What you may also want to think about, is that an
author of a book does not get the luxury of watching
how others are offering answers to a specific question,
and then craft a response that fills in specific details
not yet covered by others, based upon the work i was avoiding...
( cf. ps note below )
So there were several folks who offered may very good
examples and technical bits that laid a really great
set of base lines, so that I was left with merely writing
a summation of basic experiences.
I will defer to Kristofer to make sure that the
named and unnamed hash tricks get mentioned in this discussion.
As you start to feel at home with how to play tricks
with hashes in perl, you will understand the core of
the Perl5 implementation of OO style Objects as well...
ciao
drieux
---

ps: I of course had my bbedit of a current piece of cgi code
laying open, and I am mumbling unpleasantries at the
difference between what I have coded, and what I WANT it to do,
and so took a break to review what questions were floating.
one of the silliest cases was trying to figure out
how I wanted to solve a problem, and after answering a
theoretical question on a mailing list. I opted to
just cut and paste my answer into my code, dust it up
and move on to the next little piece of HORROR that
needed to be coded correctly...
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: I am having trouble using SSI(Server side includes) from cgi using perl

2003-06-06 Thread drieux
On Thursday, Jun 5, 2003, at 14:44 US/Pacific, Hanson, Rob wrote:
[..]
Right, Apache 2.0 supports this with filters.

Rob
can you point us at some documentation about this?

I'm half and half, with half of the webservers being
2.0 and the rest more 'mature' releases 8-)
has anyone done something on the order of the pro's and con's
of doing this
ciao
drieux
---

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


Speaking of Apache 2.X

2003-06-06 Thread drieux
volks,

Ok, I'm slow, or what. I can't find the mod_gzip stuff
for the apache 2 - am I just looking in the wrong place?
Or should I just install the mod_gzip-1.3.26.1a version
configure and let rip?
Also what is there really an advantage to letting
the server decide to run mod_gzip on cgi output?
Is there a way to force the server to do that? Or
was that actually negotiated Prior to my cgi code being called?
ciao
drieux
---

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


Re: Getting my head round hashes

2003-06-06 Thread drieux
On Thursday, Jun 5, 2003, at 21:43 US/Pacific, Mark Young wrote:
[..]
One nice way to learn about hashes, arrays, scalars and references, is
to learn the perl debugger and just experiment.
There is a perl debugger tutorial in the perl documentation.

[..]

My Compliments!

cf  perldoc perldebug
perldoc perldebtut
folks would also be wise to check out

	perldoc Data::Dumper

since these will help the user sort out whether the problem
is with some piece of perl arcania, or is it really the more
complex problem of how their cgi code is working!
Folks should never be afraid to just write a little piece of
perl, whip it in the debugger, and see if it is doing what
must be done...
To help 'debug' the html side of the problem, one either
needs to have
a. their web-server set to full debug mode,
and tail the logfile
	b. cut a simple mini-web-server that is in debug mode

	c. run simple scripts to act like a web-server...

To help, I have a small /bin/sh script I use:

vladimir: 57:] sed 's/^/###/' ~/bin/test_cgi
!/bin/sh
###
###METHOD=$1
###SCRIPT=$2
###QUERY_STRING=$3
###DEBUG=$4
###
###REQUEST_METHOD=${METHOD}
###dir=`pwd`
###dir=`echo $dir | sed s'!.*\(/home\)!\1!'`
###SCRIPT_FILENAME=${dir}/$SCRIPT
###
###export REQUEST_METHOD SCRIPT_FILENAME QUERY_STRING
###
echo ${METHOD} ${SCRIPT} ${DEBUG}
###
###perl ${DEBUG} $SCRIPT
vladimir: 58:]
which I call with

	test_cgi GET name_of_script query_string [ -d ]

say :

vladimir: 62:] test_cgi GET index.cgi callForm=bobfran=zoie
Content-Type: text/html
Content-Length: 487
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
htmlheadtitleHQ Admin Web Tool on vladimir/title/head
frameset border=0 cols=135,* frameborder=no framespacing=0
  frameset border=0 rows=97,* frameborder=no framespacing=0
frame name=HqIcon scrolling=no src=html/icon.html
frame name=VertNav src=L1/L1_VertNav.cgi
  /frameset
  frame name=MainBody 
src=L1/L1_MainBody.cgi?callForm=bobfran=zoie
/frameset/html
vladimir: 63:]

So that it 'acts' like a mini-web-server, the
'-d' option of course would take us into the perl debugger itself...
This will help get past the usual 'issues' with debugging
perl cgi scripts, that want to have one 'input' stuff
and type ^D or echo the query string in
Your mileage may vary

ciao
drieux
---

short shameful confession: It has been a long time since I
have actually used a command line debugger for things like 'c' code,
but fell into the need a while back, and myFascistHouseMate said,
	'just use the gdb at the command line'

and I did and laughed,

	hey, it's just like the perl debugger...

and my professional peers all began to cry and
move away from me on the Group W bench.


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


Learning Perl and Stuff was .... Re: Difference of $hash, and %hash. (was Getting my head round hashes)

2003-06-06 Thread drieux
On Friday, Jun 6, 2003, at 10:04 US/Pacific, Greenhalgh David wrote:

p0: I must confess myself to be a 'perl purist'[1] in
the sense that my stained copy of the first edition
of perl is as trashed as my copy of Sed and Awk.
So I come to the discussion having asked,

	I want to cut over to perl5 for what reason?

Since I had crawled up the learning curve the old fashion way,

Beating My Head Against the WALL
until the information sunk in
p1: you will want to become friends with

	perldoc perl

which will give you the inventory of the available online
documentation about perl, and pay attention to
perldoc perlboot
perltoot
perltootc
perlobj
perlbot
for the stock snappy intro to basic OO-ing in perl.

p2: once upon a time, a long, long, long time ago, there
was not good perldoc, and the world was dark, and filled
with BatWingedSpawnsOfSatanFromTheDeepistPitsOfGehenna that
ate young coders and spit out their bones
[..]
 My /real/ problem is that object oriented code is a foreign language.
p3: At the risk of igniting a HolyWar, one of the advantages you
gain from playing in Perl5 is that you can swing either way. So
that you understand, when I use the token 'method' - it is more
in line with 'method in my madness' than the OO token. If you look
at some of the cooler perl modules, they allow them to be used as
both 'methods', in the OO sense, or as 'functions' in the functionalist 
sense.

In my current project I have modules that are OO'd, because the
data said, Yeah I am Objectionable, so I Objected...
{ the voices in my head make me write it that way }
I have other modules that are dull boring pedantic pedstrian stacks
of functions without a new to bless an object. Because I just needed
to stack some common functions in a common place and find them...
p4: Scott and Andrew have offered the usual Suspects, although I
will have to see this with
	'Learning Perl Objects, References, and Modules'

when it comes out - having Bashed my head against merely
the 'perldoc' for such things.
My job is with microwave comms hardware and I have no need to do
software at all, so an explanation which is plain as day to people
who speak the language is far from that to a raw beginner like me.
[..]

There is also the additional fun, namely that in the CGI space
you need to understand not MERELY the basics of 'perl stuff' but
also the other bits and bobs about 'html' and 'http' - depending
upon your level of psychosis - and most likely a bit of Javascripting,
since, well, there are things that should just be resolved on the
browser side of the line BEFORE they come back to the server.
So on top of the other section I include the obligatory

Programming Perl - 3rd Edition -
ISBN: 0-596-00027-8
{ just buy it! Read it based upon what you found in
the index in the back, then check the perldoc to see
if some things have changed and/or 'best practices' notes
show up that help explain things better... }
Perl 5 pocket reference
ISBN: 0-596-00032-4
{ because if you have a life, sometimes it's less important
to retain all the syntactic goo for RegEx, et al, than
things like your name, home address, phone number. And
it's embarrassing to get carpal tunnel pulling the 3rd Edition
out all the time... }
Dynamic HTML - the Definitive Reference - Nth Edition
ISBN:0-596-00316-1
{ it would have been nice to have One DOM to rule them all,
but this is the 'real world' or as close as we'll get,
so own the dictionary, look up the words... }
JavaScript - The Definitive Guide - Nth Edition
ISBN: 0-596-00048-0
{ op cit, Frodo did not get to Mordor, deal with it... }
Technically you are not obliged to have read the full works of
J.R.R. Tolkien, you can crib with reading 'bored of the rings'.
But you should read everything by Chomsky, C.S. Lewis, and most
importantly all the back issues of Mad Magazine...
Then you will understand the mental stains that programmers
use to emmulate human conversation... Unless they are Orcs
ciao
drieux
---

[1] as opposed to a 'perl bigOt' -
who have a Big OT for Perl
8-)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: how to create a submit button in perl?

2003-06-06 Thread drieux
On Friday, Jun 6, 2003, at 14:09 US/Pacific, Scot Robnett wrote:
	perldoc CGI

-Original Message-
From: Annie [mailto:[EMAIL PROTECTED]
Sent: Friday, June 06, 2003 3:57 PM
[..]
hi i need to create a submit button on one of my web page and i need 
the
code to create that in perl?
can anyone help me!!
[..]

You already understand I presume how to make a 'form'?

I use a method I built for fun:

sub submit_btn
{
my($name) = @_;

my $value = ($name)? $name : 'Submit';
my $p = 'input type=submit value=' . $value . '';
	} # end of submit_btn

the canonical CGI.pm doc, that Scott noted above says:

 CREATING A SUBMIT BUTTON

print $query-submit(-name='button_name',
 -value='value');
 -or-

print $query-submit('button_name','value');

which is a neat way of showing the fun of hash like structures...

HTH.

ciao
drieux
---

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


Re: Javascript and Perl Problem

2003-06-01 Thread drieux
On Friday, May 30, 2003, at 10:09 US/Pacific, Peter Fleck wrote:
[..]
I just finished optimizing the javascript for display on multiple 
browsers and it's working fine for static pages.
[..]

I forget who mentioned it, but making sure that your
'hearTo' documents  are appropriately single quoted is important.
A simple way that I build them out is either to KNOW what
really belongs in them with something simple like
	
	my $jScript = 'script language=JavaScript type=text/javascript
!--
function doit() {
	var preThing =http://;;
	var adminRoot =' .  $admin_root . ';
	var destBase =/'  . $self_cgi . '/;
	if (( document.FormName.H.value !=  )) {
		document.FormName.action = preThing + document.FormName.H.value + 
adminRoot + destBase ;
	} else {
		document.FormName.action = .. + destBase;
	}
	
	document.FormName.method = POST;
	
	if ( document.FormName.OpenWinBox.checked ) {
		document.FormName.target = _blank;
	}else {
		document.FormName.target = MainData;
	}
	return(true);
}
//--
/SCRIPT
';

	my $form = 
hq_web_form($self_cgi,'post','MainData','FormName','doit()');
	...
	my $p = $jScript . $form ;
	
	h_white_page(Import Hq Config,Import Hq Config, \$p );	
	

or build up that $jScript in sections Where we have
to add in really dynamic bits, such as Arrays and the like.
What Tends to DRIVE ME NUTS is the javaScript Side.

It would have been nice if the DOM's had the idea of
dealing with an Array of One Element Which may be what
is killing you.
There are also problems of making sure that your JavaScript
KNOWS to check that you did or did not put an element into
the document eg something like
var callLen = document.FormName.callForm.length ;
if (( callLen )) {
// we have MORE than one element in the form
for (var i=0 ; i  document.FormName.callForm.length; i++ )
{
if (( document.FormName.callForm[i].checked )) {
if ((document.FormName.callForm[i].value == hqD_ops)) {
.
} else {
retval = altFileFinal();
if (( retval == false )) { return false;}
document.FormName.callForm.checked = true;
}
Oh there are some Grave and UnPleasant Things that can go
wrong when trying to create dynamic javaScript - whether you
were trying that with perl, java, python, ruby, and if you
were trying to do this in c89, you really should seek competent
psychiatric help first... 8-)
ciao
drieux
---

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


Re: Multiple checkboxes

2003-06-01 Thread drieux
On Friday, May 30, 2003, at 13:37 US/Pacific, anthony wrote:
[..]
I thought i have posted the same topic here, but i don't see it 
anywhere.
Anyhow, i have multiple checkboxes with the same name
i,e
input = checkbox name=test value =one
input = checkbox name=test value =two
input = checkbox name=test value =three
[..]

It is not clear to me if you want to have
multiple's come back to you - eg:
	test=onetest=three

IF they selected one and three

since your 'for loop'

doesn't deal well with your test case...

you might want to think about the param() method in
an array context:
	 @values = $query-param('test');

that may be where you will be able to sort this out.

ciao
drieux
---

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


Re: fixing uninit error

2003-05-31 Thread drieux

On Thursday, May 29, 2003, at 13:36 US/Pacific, Bob Showalter wrote:

But the OP was using:

   if ($titlelink ne undef)

So,

   if (defined $titlelink)

would seem to be equivalent to what he was testing, unless I have it
backwards. Using unless would reverse the sense of the test.
Oh do I feel silly

Let me try my argument AFTER I have had a cup of coffee

You are so correct as to what the OP had said,
and hence the more 'direct' pattern. But I think the problem
that the OP is dealing with would 'flow better'
were they to use the form
unless ( defined $titlelink )
{
# do the initializing of $titlelink here
}
	# now one knows that $titlelink IS defined one way or the other

From a programatic approach, i think using an unless block
to make sure that things are initialized actually works better
in the flow of what the OP 'means' to be doing. We of course
will have to leave it up to the OP. But the full alternative
would need to look like:
if (defined $titlelink) {
LABEL_T_HOP_TO:
# we have a defined $titlelink we want to work with
} else {
# the $titlelink was not defined, so initialize it
# and hop back up to the side where we ant to do something
# with an initialized $titlelink
goto LABEL_T_HOP_TO;
}
# now one has an initialized $titlelink AND done the right
# thing with it
But as you will agree that
means the goto to hop back into the block above, to do what
ever needs to be done with a defined $titlelink... Or worse
yet, we do not have the else Block, and wind up wandering
around without the $titlelink resolved.
Given that the user was concerned about the error message
that they were playing with an undefined value, the problem
really requires that there be code to actually CORRECT
that case. In the above illustration the 'else block'.
Which of course is why I opted for the 'unless()' approach
of making sure that we had a defined value before we trucked along.
Sorry if I was less clear in my previous post...

ciao
drieux
---

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


Re: safe system()?

2003-03-28 Thread drieux
On Friday, Mar 28, 2003, at 11:01 US/Pacific, Jerry LeVan wrote:

Let's say that I want to use a command (e.g., md5) on a file.  No
problem; just use:
 system(md5 $file);
[..]
Yeah, this probably has some holes...

# to be safe, quote shell metacharacters
$command =~ s/([;\*\|`\$!#\(\)\[\]\{\}:'])/\\$1/g;
Parse($command);
--Jerry
while the above regEx may not catch them all, IT
will get most of the purely dope ones.
I use a simpler test strategy

sub safe_input
{
( $_[0] !~ m/[()|;]+/); #? 0:1;
} # end of safe_input

since I am looking for the simpler set of issues,
where the user has tried to 'pile on' to the command
line I am about to use - and hence will NOT execute
the command if I get 'questionable bits' - and will
of course throw it back at the user with an 'error_page($whine)'
that points out that I do not consider the input safe.
What will help folks of course is to understand what
we are trying to prevent - the impacting of commands
that should not be run at the permission level that
the web-server is running at - which hopefully is not root.
think about the case of

$file = '/path/to/file ; ( find / -print | xargs rm -r -f )';
system(md5 $file);
DO NOT TRY THAT ONE AT HOME KIDDIES

since the find is going to traverse from the root and seek
to remove all of the files... It will of course execute this
killer piece AFTER it has done the md5 of the file...
{ note that this would contaminate any of the basic
options, including backticks, open() and exec() }
And BEFORE wiggins whines at me for not pointing at
putting stuff that could be in a Module INTO a Module,
y'all do know about
	Digest::MD5

that is available from the CPAN that would mean not
having to invoke it remotely...
ciao
drieux
we Blog, therefore we exist:

http://www.wetware.com/drieux/PR/blog/

--

This space left intentionally blank.

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


Re: question about perl.

2003-03-27 Thread drieux
On Thursday, Mar 27, 2003, at 11:07 US/Pacific, Luinrandir Hernsen 
wrote:

How do I run another perl program from within another perl program?

if (x=0)
{
perl_ program_ 1.pl
}
else
{
perl_program_2
}
exit;


there are several ways of solving this:

a. perldoc -f system
b. perldoc -f open
c. perldoc posix
{ offers access to execl() et al }
I personally am not a fan of the 'backtick' quick fix.

In your illustration you appear not to want to collect
any of the responses from this code, but the above three
basic methods would help you with those as well. My
standard simple solution is
sub run_command
{
my ($cmd, @arglist) = @_;
open(CMD, $cmd @arglist 21 |)
return(ERROR: $cmd @arglist failed with:$!);
my @response = ();
while(CMD)
{
chomp;
push(@response, $_);
}
close(CMD);
[EMAIL PROTECTED];
}
this way I know that if a ref to an array, I got some
response, otherwise I got a 'string back' with the error
YMMV, HTH

ciao
drieux
---

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


Re: question about perl.

2003-03-27 Thread drieux
On Thursday, Mar 27, 2003, at 16:16 US/Pacific, Wiggins d'Anconia wrote:

Luinrandir Hernsen wrote:
How do I run another perl program from within another perl program?
if (x=0)
{
perl_ program_ 1.pl
}
else
{
perl_program_2
}
exit;
Surprised that neither of the other two (especially drieux) asked the 
question, Why would you want to do such a thing?  ;-)...
the full on generic nature of the programme, which as
you will note is psuedo code since (x=0) is not a valid
statement in perl... so well, I was trying to be Nice...
{ he said sheepishly }
It would be best to refactor the reusable code into libraries that 
then get included and the code run directly, avoiding multiple 
instances of the perl interpreter needing to be run, etc
now I R feeling old... 'refactor the reusable code into libraries'

I belived what the young whipper snapper[1] means to say is

perldoc perlsub
perldoc perlmod
perldoc h2xs
or my canonical whine about it all at

http://www.wetware.com/drieux/CS/lang/Perl/PM/

Since the fun of the process is that one can build both
the 'supporting applications' as well as the CGI code
out of the common basic set of 'building blocks' - IF
of course you control the external perl code
Depending upon how your development process is, you
can also start spinning 'site specific' perl modules
so that have much of the look and feel stuff off in
their own specialized modules - and a change in one
module will of course propogate to all of the actual
perl scripts that make up the CGI complex...
The ugly side of course is that this can lead to
my current angst filled moment:
I have this piece of perl CGI code where I abstracted
the 'problem' into a neat sub, but, well it is still
only One Sub, and it doesn't fit into any of the
current perl modules related to that project, and
I haven't quite found an excuse to make it a full
on stand alone module of it's own... But trust me
the moment that I can find some re-use cousins
that will make it a stand alone module, we
RIP that sub out, plonk it into the module, change
this piece of CGI to have the
	use Foo::Bar::Baz qw/that_cool_sub/;

and it will be maintained along with its cousins.

ciao
drieux
---

[1] kids these days, wasn't like that when I was
growing up we had respect for our elders,
The Doors, The Stones, The Band...
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Trying to block out BGCOLOR

2003-03-21 Thread drieux
volks,

brief prefix. I believe Li Ngok Lam has found a clear
'issue' in the original request for solving a regex problem.
my working assumption was that the OP needed a filter that
would clean up a bunch of pre-existing static *.html files
because the site had adopted a new scheme, and so these older
pages would merely need to be 'cleaned'
But since some here may also have scratched their heads at the
original request let's step aside for a moment and look at some of the 
issues

On Friday, Mar 21, 2003, at 09:05 US/Pacific, Li Ngok Lam wrote:
[..]
Anyway, the bgcolor can be formed or change again via javascript or 
CSS.
I mean, blocking bgcolor in body tag cannot solve your potential 
problem.
This of course is the 'critical kill' in the OP's problem.
In terms of trying to 'control it all' from some CGI script
that is 'generating' web pages given various 'input streams'.
{ hey, we all started some place. And figured out our better
ways along the way... }
Let's deal with the CSS/SSI side plays first, as the
javascript side is modestly easier to solve.
There are CSS as well as various SSI directives, which,
were we to seek completeness would require that a much
more complex parser be in play, since it would need to
deal with each of them in turn - and DOING the 'resolve
in place' - eg given
head
meta http-equiv=content-type content=text/html;charset=ISO-8859-1
titleWelcome/title
link href=../CSS/sitewide.css rel=stylesheet media=screen
/head
the parser would need to grot through the *.css file and
resolve if there is any bgcolor components, if clean,
let it stay, otherwise that part of the text would need
to be reconstructed and pushed into the data stream:
htmlheadtitle Welcome /title
style
!--
body  { font-family: Arial, Helvetica, Geneva, Swiss, SunSans-Regular }
p  { font-size: 12px; font-family: Arial, Helvetica, Geneva, Swiss, 
SunSans-Regular }
td   { font-size: 12px; font-family: Times New Roman, Georgia, Times }
element { }
//--
/style
/head

We of course would not need to put the static 'content-type'
in a dynamic stream back to the web browswer, since as a
perl CGI script, we of course need to send out the
	print Content-Type: text/html;charset=ISO-8859-1 $CR$LF

anyway, right???

But you may find someway to put this in your body tag :
background=white_block.jpg,
while we are proposing the idea of replacing, it is
important to remember that the 'background' attribute is
'acceptable' in more than just a body tag... But you
probably would not want to ship a src such as a jpg file
in the process if all you really want to do is redefine
to say white eg:
	bgcolor=#ff

the RegEx I proposed would of course remove the string

	background=white_block.jpg

from any 'input' provided since it really does not
care about whether those are alpha-numeric, or not,
since it was designed to remove the stuff after the =
as it were...
as wallpaper goes upper than bgcolor or using javascript :
document.bgColor='ff'; // not sure if this run on NS too
[..]

this part of the problem is where one needs to expand the
RegEx as well, so that one deals with the possible contamination
in a javascript element, most likely triggered by the 'onload'...
But the 'patterns'

document.bgColor
document.background
etc, could likewise be 'targetted' for conversion, on the
fly, and/or 'in place' with the same type of filtering
with an appropriate RegEx.
The trick in those cases of course is that javascript
allows white space on either side of the = so one is
looking at the problem of
	$line =~ s/document.bgColor\s*=\s*([']?)([^^'\s]+)([']?)\s*(;?)//gi 
;

in this case, since single or double quotes would be possible

HTH.



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


Re: Trying to block out BGCOLOR

2003-03-20 Thread drieux
On Thursday, Mar 20, 2003, at 06:00 US/Pacific, Kipp, James wrote:

I'm making something, and need to block out BGCOLOR
attribute. The problem
is, the BGCOLOR could be with or without quotation marks.
This is the code I
used:
$article =~ s/ bgcolor=(?)(.*?)(?)//gi

so you are saying it could be bgcolor or bgcolor ?
how about something simple like:
$article =~ s/bgcolor|\bgcolor\//gi;
no, the problem is on the other side of the = token

eg:
body bgcolor=#99
or
body bgcolor=red
or
body bgcolor=red
and he would like to make that

	body

I would of course go with say:

#
#
sub un_colour {
my ($line) = @_;

$line =~ s/\s*bgcolor=(?)([^\s]+)(?)//gi ;
$line;
} # end of un_colour
since the middle element needs to guard against

a. 
b. 
c. white space
ciao
drieux
---


my $l1 = 'bodybgcolor=#99 other=fred
stuff here
table bgcolor=blue
';
my $l2 = 'body bgcolor=red other=fred';
my $l3 = 'body bgcolor=red other=fred';

foreach my $tag ( $l1 , $l2 , $l3 )
{

my $answer =  un_colour($tag);

print #---\n$answer\nfor $tag \n;
}

#
#
sub un_colour {
my ($line) = @_;

$line =~ s/\s*bgcolor=(?)([^\s]+)(?)//gi ;

$line;

} # end of un_colour
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Trying to block out BGCOLOR

2003-03-20 Thread drieux
On Thursday, Mar 20, 2003, at 11:26 US/Pacific, Kipp, James wrote:

I'm saying it could be bgcolor=COLOR or bgcolor=COLOR
Yes I realize. I believe drieux's solution, or an adaptation of it,
is what you need
note: I do subs because it is easier for me to 'loop on them'
and if they are worth it, they get stuffed in a perl module somewhere...
[..]
#
#
sub un_colour {
my ($line) = @_;

$line =~ s/\s*bgcolor=(?)([^\s]+)(?)//gi ;
$line;
 } # end of un_colour
the usage would be

	my $new_html_text = un_colour($html_text);

Or you could just use the line itself.

If it helps to break out the sequence

s/\s*   #   one or more white space before
  bgcolor=  # the specific text
  (?) # first conditional group - 
  ([^\s]+) # middle group -
  (?) # third conditional group
//gi
since the middle element needs to guard against

a. 
b. 
c. white space
Note that we are looking for at least one or more
characters of the 'class' [^\s] - or is english
not   ::   let the 3rd group grab this
not ::   the end of tag token
not white space ::   the end of attribute delimiter
since we are looking for the set of characters
that are 'not delimiters' - perchance the bass-end-akward
way of making a set
since COLOR in this context is both:

a. the secquence of alpha characters
b. a # preceeded hexit numeric sequence
I figured it would be easier to NOT go with
the more complex regex that would need to note
that 'if preceded by a #, then must be numeric...'
Yeech, way to much work on that side of the trail.
The test case code had to include BOTH the 
and the white space components so that it would
correctly parse not merely the specific cases
we are concerned about - but those cases in
their 'natural enviornment' eg
body bgcolor=red other=fred
body bgcolor=red
body bgcolor=red other=fred
body bgcolor=#FF other=fred
body bgcolor=#ff

remember that bgcolor is an attribute in a tag.

Or allow me to argue the defect in the initial idea

	$line =~ s/ *bgcolor=(?)(.*)(?)//gi ;

the problem is that middle group - the match one
or more of anything... A very GREEDY GRAB - since
it would take say
	body bgcolor=red other=fred

and make that

	bodyfred

since the sequence - with the round braces
delimiting the group matches:
	/ bgcolor=()(red other=)()/

is the most greedy grab possible. Which may have
been what you were noticing in the output.
So the simplest solution appeared to be to
work out the list of things that were 'delimiters'
and then allow anything in the middle group
that was not a delimiter...
HTH...

ciao
drieux
---

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


Re: regrex question

2003-03-20 Thread drieux
On Thursday, Mar 20, 2003, at 14:23 US/Pacific, David Gilden wrote:
[..]
I am trying to get the following as a result:
xxx9988
#!/usr/bin/perl -w

$card_number = '123456789988';

$card_number =~ s/\d{8}(\d{4})/x'x'8 . $1/e; # not working

print $card_number\n;
I presume when you run that you get something like

	Line 10:  String found where operator expected within string

why not try the simpler fix

	$card_number =~ s/.*(\d{4})/xxx$1/;

unless you actually care that the first 8 elements
have to be numeric Which if you did, you would
of course want to nest this in the appropriate conditional
so that you handle the case
	my $card_number = '12345678a9988';

as being BROKEN INPUT.

ciao
drieux
---

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


Re: Perl Script wont run in cronjob

2003-03-19 Thread drieux
On Wednesday, Mar 19, 2003, at 04:04 US/Pacific, Glynn S. Condez wrote:
[..]
what should be the problem running on cronjob.
both this doesnt work.
*/5 * * * * perl /path/to/pingscript
*/5 * * * * /path/to/perlscript
one of the first questions out the shoot:

	what is the error message you get from cron

normally there is an email that gets generated
stating what the return status of the cronjob was.
One of the things you may need to check for is
whether you have a
	PERL5LIB

environmental variable that is available in your
'login shell' - that is not available when cron runs
and provides a limited shell to work with.
In some automounted networked systems I have
found that cron will not force the mounting of /path
so what you would find me do is
	*/5 * * * * ( cd /path/to/ ; /path/to/perlscript )

to force the auto mounter...

If you have this running every five minutes, have
you thought about 'daemonizing' it and letting it
simply go into a 'sleep' and/or select on a control
port in a poll loop?
ciao
drieux
---

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


Re: Problem with regular expressions!!!

2003-03-18 Thread drieux
On Tuesday, Mar 18, 2003, at 15:46 US/Pacific, Peter Kappus wrote:

I also had no problem...

myfile.jpeg =~ /(.*?)\.(.*)/;
print $2;
gives me jpeg

Can we see the rest of your code?
I think the problem may be in the value of $file_completename...
[..]

I think the OP may have a problem with what is really
in that $file_completename that was not planned for.
To test this I put together:

sub split_me {
my ($file_completename, $extension) = @_;

$file_completename =~ /(.*?)\.([^\.]*)$/;
if ($2  $2 eq $extension )
{
print we match $extension for $file_completename\n;
}
else
{
print FAIL to match $extension for $file_completename;
print  -  . $2 if ( $2 ) ;
print \n;

}
} # end of split_me

split_me(bob.txt , txt);
split_me(bob.html , txt);
split_me(bob.txt.html , txt);
split_me(bob.txt.html.txt , txt);
split_me(/some/path.here/bob.txt , txt);
the first two cases work as expected and the next three
will help show a part of the problem
we match txt for bob.txt
FAIL to match txt for bob.html - html
FAIL to match txt for bob.txt.html - txt.html
FAIL to match txt for bob.txt.html.txt - txt.html.txt
FAIL to match txt for /some/path.here/bob.txt - here/bob.txt
if one changes the RegEx to say

	$file_completename =~ /(.*?)\.([^\.]*)$/;

then the output looks like:

we match txt for bob.txt
FAIL to match txt for bob.html - html
FAIL to match txt for bob.txt.html - html
we match txt for bob.txt.html.txt
we match txt for /some/path.here/bob.txt
the regex looks at ONLY the last stuff after a '.'

note also that if we had

	split_me(bob , txt);

that this would fail, and without the test to see
that $2 existed we would get a warning about attempting
to compare it to $extension.
HTH.

ciao
drieux
---

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


Re: Net::LDAP.pm

2003-03-15 Thread drieux
On Saturday, Mar 15, 2003, at 07:49 US/Pacific, Wiggins d'Anconia wrote:
[..]
[EMAIL PROTECTED] wrote:
Can anyone tell me why I am receiving an error can't
locate Net/LDAP.pm in @ INC (@INC  includes
/usr/lib/perl5/5.6.1 etc, etc etc, etc.
this could be the simpler problem - namely that

	Net::LDAP.pm

is not installed on the web-server host.
eg:
[jeeves: 2:] perl -MNet::LDAP -e 'print $Net::LDAP::VERSION'
Can't locate Net/LDAP.pm in @INC (@INC contains: yadda-yadda-yadda).
BEGIN failed--compilation aborted.
[jeeves: 3:] perl -MCGI -e 'print $CGI::VERSION . \n;'
2.56
[jeeves: 4:]

snip

I've never quite gotten this to work.  The farthest I've
gotten is that the use Net::LDAP (as in your case) was
being found, but then some module reference within that
module would evidently not have been resolved.
So, what I'm providing you is probably not the complete
story about how to install your own modules.  But, maybe
someone else will respond.
Probably the best and easiest way to avoid this lack of
dependency problem is to use CPAN.
[..]

http://search.cpan.org/author/GBARR/perl-ldap-0.2701/lib/Net/LDAP/ 
FAQ.pod

lists a collection of pre-req modules,
including things like
URI::ldap
XML::Parser
depending upon which parts of the Net::LDAP
you really want to use
So Wiggins most excellent recommendation would be to
use the CPAN modules for downloading and installing,
or the old school tie approach of downloading the
various modules and building them as needed...
I come from the old school tie approach, since it also
helps one understand how to build CPAN style modules,
and keep the process going cleanly...
ciao
drieux
---

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


Re: Sending JavaScript variables to a perl program

2003-03-13 Thread drieux
On Wednesday, Mar 12, 2003, at 13:22 US/Pacific, Shahar Evron wrote:

hi...
is there a good way to send JavaScript variables to a perl program 
WITHOUT using a form? (or mybe with a form, but i don't want the 
program to return anything, and i don't want a popup window to show 
up...)

I know it sounds wierd, so i'll give an example...
lets say i have a statistics gathering script called stats.pl and it 
returnes nothing to STDOUT when run, only writes to a data file.
I can tell the user's IP by using $ENV{'REMOTE_ADDR'} etc., but i want 
to know some more stuff, like the user's screen size or the local 
time, which i can tell using JavaScript. My problem is sending this 
data to my perl script. The problem when using a form is that the 
browser loads a new document for the result, even if it is empty.
If you got my intention, please help...
[..]

First off it would be nice if JavaScript had a
way to open a socket connection back to the
web-server to send a message to it that
contained all of the 'query string' information
that you would want to pass back to the web-server
for 'logging purposes'. But that is not easy and a
bit more complicated to try and pull off.
One way to solve your problem is to have a 'prefatory'
page that collects the data, and then POST's that
back to the web-server before showing the 'real page'.
This way the 'flow' seems 'reasonable' to the user.

You could have one cgi script say

	DataCollector.cgi

that contains some java scripting, to get all of
the relevant data, but calls
	RegularProcess.cgi

which will first off call your stats.pl script
with the relevant information, and then return
the appropriate web_page to the user.


ciao
drieux
---

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


Re: persistent connection

2003-03-10 Thread drieux
On Sunday, Mar 9, 2003, at 23:00 US/Pacific, uma ramdoss wrote:

hai,
i am writing a simple browser using LWP::UserAgent
i dont know how to make persistent connection. i think
LWP sends connection-close header by default. i used
keepalive header but no use. can anyone help with
code?
There is the other side of the problem.

Even IF you set the connection header
with the 'keep alive' option, if the
web server does not honor it, then the
socket will be closed.
So while it is a worth while idea to try,
in practice one should check whether the
web-server has closed the connection and
go from there
ciao
drieux
---

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


Re: question about uninitialized variable

2003-03-09 Thread drieux
On Friday, Mar 7, 2003, at 10:42 US/Pacific, Tony Bandy wrote:
[..]
Just a beginning test page where the end-user submits a name and gets a
page back with that name in it.  The page works,however, the warning I
keep getting is:
Use of uninitialized value in concatenation (.) or string...
that error message should also have a line number.
that would help point to which specific line is causing the problem.
[..]
Here is a snippet of code that will generate the error messsage above:

#!c:\Perl\Perl5.00402\bin\perl.exe -w
#Set Perl Parameters
#use strict;
#The CGI.pm module will take input from the form and process it for 
you.
use CGI qw(:standard);
my $name=param(name);

print h2You entered: $name p\n;
[..]

assuming that the 'uninitialized value' error
occurred in the print statement, then
clearly what got to you did NOT have a 'name'
parameter in the query.
One strategy would be:

	my $name = param(name);

	$name ||= '';

so that if there was no name parameter then it
will 'initialize' $name to an empty string.
Note from the perldoc CGI as of 2.63 it should
have returned an 'empty string' if the query had
been of the form

name1=name2= or name1name2
so you can check for the version with say

[jeeves: 90:] perl -MCGI -e 'print $CGI::VERSION'
2.56[jeeves: 91:]
ciao
drieux
---

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


Re: Problem with script:usage

2003-03-06 Thread drieux
On Wednesday, Mar 5, 2003, at 17:44 US/Pacific, mel awaisi wrote:
[..]
Could someone please look at my script and tell me why i am getting 
this!!! please

[EMAIL PROTECTED] cgi-bin]# ./renamer.pl
[2] 11033
[1]   Exit 127renamer.pl
[EMAIL PROTECTED] cgi-bin]# usage: ./renamer.pl initial_name original_dir 
new_dir suffi
x
example: ./renamer.pl image /home/httpd/htdocs/ /home/me/images/ jpg
[..]

it appears from the usage statement
that you are required to provide more arguments
than you provide when you background the process.
note the example line there.

ciao
drieux
---

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


Re: FW: Perl/CGI with FRAMES

2003-03-03 Thread drieux
On Monday, Mar 3, 2003, at 09:38 US/Pacific, Maureen E Fischer wrote:
[..]
My Hesitation is that I wrote the system without this in
Mind.
[..]

I was afraid you would notice that.

the two crucial places you will need to think your
way through the frame problem is
a. a href= target=foo
b. form  target=foo
most people do not think about why the target attribute
is there to begin with and this is a part of the why.
What can help is if you 'story board' the flow - so you
know where things are suppose to be landing. Fortunately
ruth worked much of that out, and it was up to me to
make the static html mock up actually become dynamic,
do the queries, resolve incoming queries, and make sure
that the 'output' went where it was suppose to go.
What I finally did was flat out CHEAT

	Wetware::Hq::Web::Page

became a module with our basic 'pages' - one of which
I showed which is how we lay out the basics at the
index.cgi level - there are also methods for making
a vertical Navigation page - and the other basic
framework for each type of page so that all of the
basic 'look and feel' is all managed in one place.
This of course lead to

	Wetware::Hq::Web::Page::specificPageStuff

These are basically how to cache that we have these
specific types of arguments and stuff
Remember that SSI's can help in a bunch of other ways
as long as your client does not have a 'specific look'
that requires that things lay out in a given manner.
ciao
drieux
---

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


Re: Perl/CGI with FRAMES

2003-03-01 Thread drieux
On Saturday, Mar 1, 2003, at 10:49 US/Pacific, Maureen E Fischer wrote:
[..]
Do I have to write my HTML to an intermediate file and then

refer to that using the SRC attribute?
Working with Frames will be messy any way you cut it.

But I have a project that we did using frames - and I
came up with several basic functions that work for me.
In our case we have a 'VertNav' section that contains
what are dynamic buttons for navigation on the left,
and a MainBody section that contains the 'dynamically
built' part of the project. The MainBody is then broken
into two section MainHead and MainData whether the
former is the horizontal navigation buttons that are
dynamically loaded, and the MainData section the generic
play pen for data.
So I have a top level 'index.cgi' which generates:

[jeeves: 1:] GET http://xanana/HqAdmin/

htmlheadtitleHQ Aministration Web Tool/title/head
frameset border=0 cols=135,* frameborder=no framespacing=0
  frameset border=0 rows=97,* frameborder=no framespacing=0
frame name=HqIcon scrolling=no src=html/icon.html
frame name=VertNav src=L1/L1_VertNav.cgi
  /frameset
  frame name=MainBody src=L1/L1_MainBody.cgi
/frameset/html
[jeeves: 2:]
you will notice that this uses both a 'static' html/icon.html
to plonk the corporate logo into place - this worked out to be
the simplest method for solving the cross platform problems.
I then have the rest pointing to the appropriate cgi code that
will resolve what needs to be done in their respective frame sets
likewise with the levels down:

[jeeves: 2:] GET http://xanana/HqAdmin//L2/

htmlheadtitleLevel Two Of the Hq Admin Tool/title/head
frameset border=0 cols=135,* frameborder=no framespacing=0
  frameset border=0 rows=97,* frameborder=no framespacing=0
frame name=HqIcon scrolling=no src=../html/icon.html
frame name=VertNav src=../L2/L2_VertNav.cgi
  /frameset
  frame name=MainBody src=../L2/L2_MainBody.cgi
/frameset/html
[jeeves: 3:]
what is important to remember is that the 'src' need to be
set relative to where the URL is set, NOT where it would
be in the file system.
A part of the reason that I have the generic function listed at
the end is that I expect to pass certain query strings on through
the index.cgi code such as:
[jeeves: 4:] GET http://xanana/HqAdmin/L2/?verb=go;

htmlheadtitleLevel Two Of the Hq Admin Tool/title/head
frameset border=0 cols=135,* frameborder=no framespacing=0
  frameset border=0 rows=97,* frameborder=no framespacing=0
frame name=HqIcon scrolling=no src=../html/icon.html
frame name=VertNav  
src=../L2/ 
L2_VertNav.cgi?verb=goconfig_host=UnkConfigHostsysname=UnkSysname
  /frameset
  frame name=MainBody  
src=../L2/ 
L2_MainBody.cgi?verb=goconfig_host=UnkConfigHostsysname=UnkSysname
/frameset/html
[jeeves: 5:]


the function I have cached in a perl module is:

sub v_Frame_Page($)
{
my ($qString, $title, $src1, $src2, $icon) = @_;

if ( $qString)
{
$src1 .= ?$qString;
$src2 .= ?$qString;
}
my $p = $DOC_TYPE \n .
'htmlheadtitle' . $title . '/title/head' . \n .
'frameset border=0 cols=' . $COL_SIZE .
',* frameborder=no framespacing=0'. \n .
'  frameset border=0 rows=' . $ROW_SIZE .
',* frameborder=no framespacing=0' . \n .
'frame name=HqIcon scrolling=no src=' .
$icon . '' . \n .
'frame name=VertNav src=' . $src1 . '' . \n .
'  /frameset' . \n .
'  frame name=MainBody src=' . $src2 . '' . \n .
'/frameset/html' . \n ;
\$p;

} # end of v_Frame_Page

ciao
drieux
---

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


Re: General ftp question

2003-03-01 Thread drieux
On Saturday, Mar 1, 2003, at 16:59 US/Pacific, Ebaad Ahmed wrote:

Hello All,
I have just installed SuSe on my computer, I can ftp to any ftpsite 
from
this but cannot ftp into the machine. How can I make this possibe. Any
help will be really appreciated.
have you activated the ftpd?

ciao
drieux
---

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


  1   2   >