Leaving this list.

2007-06-05 Thread Ron Goral
I am leaving this list even though I've been here for several years. While I
find the information and ideas exchanged very helpful, I am fully disgusted
by the amount of spam I receive. Over this last weekend, of 172 emails I
received from this list, 52 were spam. That's nearly 1 in every 3. I am told
that I get this spam simply because I sent a couple emails to the list and
that exposed this exclusive address to these spammers. Well, say what you
will, but I feel it is the list manager's job to protect me from this crap.
Since they either can't or won't, I'm signing off and deleting this mailbox.



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




RE: Free PERL Editor

2006-11-22 Thread Ron Goral


 -Original Message-
 From: Suja Emmanuel [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, 22 November, 2006 00:45
 To: beginners@perl.org
 Subject: Free PERL Editor



 Hi all,

 Could you please suggest me any good PERL editor which is
 available in open source tools.  I have tried 'EngineSite Perl Editor
 -LITE' and 'PerlExpress' which I am not comfortable with. Kindly refer
 me some good bug free tools.


 Thanks in advance,

 Suja Emmanuel.

Not exactly free (shareware for $29 USD), I use Textpad for all my scripting
and HTML work.

http://www.textpad.com/products/textpad/index.html

HTH -
Ron Goral



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




RE: Free PERL Editor

2006-11-22 Thread Ron Goral
 -Original Message-
 From: Octavian Rasnita [mailto:[EMAIL PROTECTED]
 Sent: Thursday, 23 November, 2006 00:25
 To: Ron Goral; Suja Emmanuel; beginners@perl.org
 Subject: Re: Free PERL Editor


  Not exactly free (shareware for $29 USD), I use Textpad for all my
 scripting
  and HTML work.
 
  http://www.textpad.com/products/textpad/index.html
 
  HTH -
  Ron Goral

 Do you have any idea if there are plans of making TextPad UTF-8 aware?

 Thanks.

 Teddy

Well, according to their website, they already are. However, there is some
discussion in the site's forums about the fact that there are issues with
these features. As you can see from these links, while the textpad folks
'say' it is compliant, it is not, or at least, there are significant issues
with this feature:

news release 06 APR 00 - http://www.textpad.com/news/index.html (toward the
bottom of the page).
forum entry  15 AUG 06 -
http://www.textpad.info/forum/viewtopic.php?t=7551highlight=utf8
forum entry  22 SEP 06 -
http://www.textpad.info/forum/viewtopic.php?t=7658highlight=utf8

HTH -
Ron Goral



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




Spam from this list

2006-10-25 Thread Ron Goral
Is anyone else receiving spam from this list? I use this email address only
for this list, so it must be originating from someone on it. Any ideas?



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




RE: Spam from this list

2006-10-25 Thread Ron Goral
 -Original Message-
 From: Mumia W. [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, 25 October, 2006 07:07
 To: Beginners List
 Subject: Re: Spam from this list


 On 10/25/2006 06:45 AM, Ron Goral wrote:
  Is anyone else receiving spam from this list? I use this email
 address only
  for this list, so it must be originating from someone on it. Any ideas?
 
 
 

 Spammers harvest e-mail addresses from mailing lists and their archives.
 If this list is archived on the web, spammers can and will grab the
 e-mail addresses and spam them.

I had not considered the archives. Makes sense.

For the record:

I was not accusing anyone on the list of generating spam, just curious if
someone may have ingested a worm or some such. Sorry if anyone took it as
though I were accusing.

Peace -
Ron



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




RE: reading Perl syntax

2006-06-07 Thread Ron Goral


 -Original Message-
 From: Mr. Shawn H. Corey [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, 07 June, 2006 07:16
 To: beginners@perl.org
 Subject: Re: reading Perl syntax


 On Tue, 2006-06-06 at 22:23 -0500, [EMAIL PROTECTED] wrote:
  46:  $self-{file} = $args-{file};

 This is the line were $self-{file} is set to undef.

  48:  $self-_read_file($self-{file});
 
  ** = 214:  my $file = shift;

 And here $file is set to $self-{file}, which is undef

Merely referencing a key in a hash sets it into the hash, though with a
value of undef. A good idea is to check whether it exists in the hash:

if (exists $self-{file}){
# do something about it...
}

Then, if it exists, check for a value:

if (exists $self-{file}){
if ($self-{file} ne undef){
# do something about it...
}
}

Or, if it exists, check for a value other than undef, 0,  (empty string):

if (exists $self-{file}){
if (defined $self-{file}){
# do something about it...
}
}

There are a million ways to write this out in code, but if a piece of data
is crucial to the smooth operation of your application, you need to check
that it fits your validation expectations before trying to reference it.

Peace -
Ron Goral



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




RE: reading Perl syntax

2006-06-07 Thread Ron Goral


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of
 Tom Phoenix
 Sent: Wednesday, 07 June, 2006 08:00
 To: Ron Goral
 Cc: beginners@perl.org
 Subject: Re: reading Perl syntax
 
 
 On 6/7/06, Ron Goral [EMAIL PROTECTED] wrote:
 
  Merely referencing a key in a hash sets it into the hash, though with a
  value of undef.
 
 This turns out not to be the case. In Perl, merely referencing a key
 in a hash doesn't change the hash. Some non-Perl hash implementations
 do change the hash in those circumstances, though, so your confusion
 is understandable.
 
   my %last_name;
   $last_name{'fred'} = 'flintstone'; # creates key 'fred' in hash
   my $x = $last_name{'barney'}; # does not create key 'barney'

Ouch. Tom is, of course, right in this. Sorry for the misinformation.

Peace -
Ron Goral


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




RE: Chomp method

2006-04-27 Thread Ron Goral


 -Original Message-
 From: Randal L. Schwartz [mailto:[EMAIL PROTECTED]
 Sent: Thursday, 27 April, 2006 10:18
 To: beginners@perl.org
 Subject: Re: Chomp method


 For example, almost no amount of experimentation will stumble across
 how chomp actually removes $/, not just \n.


Does this mean it resets the default record separator or just removes the
one that is at the end of the line/record?

Peace -
Ron



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




RE: Coding Styles

2006-04-20 Thread Ron Goral


 -Original Message-
 From: Brent Clark [mailto:[EMAIL PROTECTED]
 Sent: Thursday, 20 April, 2006 09:39
 To: Perl FAq
 Subject: Coding Styles


 Hi all


 I seem to be having a few run ins with the Project Leader, in
 terms of my coding style.

 Im very much for modularizing my work - hence the OO concept.
 That is creating packages using return in my subroutine etc (Oh
 and using strict)
 But the ex Cobol Project Leader does not want .pm. Varibables has
 to be of a certain naming type convention like the value from a
 html text box has to begin
 with an i (e.g, $iabc), and strict does not need to be used, hell
 neither is #!/usr/bin/perl -T.

 Obviously im frustrated, and either im totally missing the point
 and dumb or im working with a real tosser.

 So my question is, for those out there working a dev environment,
 would anyone care to share if my way of thinking is wrong etc.
 Or anything for that matter

 Kind Regards
 Brent Clark

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


Typically, it's been my experience that the guy signing the paycheck, or the
one in charge of the project, is the guy calling the shots. If he wants to
utilize a coding technique that is neither secure nor understandable, then
he will eventually reap the benefits of his narrow-mindedness. If you have
done your part in explaining the reasons for using modules, taint mode, etc
and he refuses to (or cannot) understand the wisdom, then do it his way.

Of course, there are three other alternatives -

1) Do it your way and send out some resumes.
2) Go over his head to his boss, explain your logic and send out some
resumes.
3) Just send out some resumes.

Welcome to the wonderful world of working for others. =)

Peace -
Ron



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




RE: Skipping blank lines while reading a flat file.

2005-10-07 Thread Ron Goral


 -Original Message-
 From: Dave Thacker [mailto:[EMAIL PROTECTED]
 Sent: Friday, October 07, 2005 07:05
 To: beginners@perl.org
 Subject: Skipping blank lines while reading a flat file.
 
 
 Perl 5.6  on linux
 
 Given this test file.
 --start-
 this
 
 is
 
 my file
 end--
 I want to skip the blank lines and just print the lines with 
 text, like this
 this
 is 
 myfile
 
 This is my test case code. 
 #!/usr/bin/perl -w
 use strict;
 
 my $opt_testfile=test-text.txt;
 open (TS, $opt_testfile) or die can't open file;
 while (TS) {
 chomp;
 next if ($_ =~ /^\s+/);
 print $_\n;
 }
 
 I'm not skipping the lines.  My regex must be wrong.   Can 
 someone show me my 
 error please?
 
 TIA
 DT

Try dropping the parens -

next if $_ =~ /^\s+/;

HTH -
Ron


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




RE: Refernces on SWIG wanted

2005-04-18 Thread Ron Goral
 -Original Message-
 From: Tommy Nordgren [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 18, 2005 12:14 PM
 To: beginners perl
 Subject: Refernces on SWIG wanted


 Do anyone out there know of any book on using the SWIG system for
 extending
 perl. I've tried to search amazon.com, and the major it book publisher
 sites that
 I know about, but so far I have not found anything. There are many hits
 on Swig on amazon, but none appears relevant to ANY computer-related
 subject.

Howdy -

Did a simple browser search for swig AND perl and came up with quite a few
hits on computer-related subjects.  The first hit was to
http://www.swig.org/papers/Perl98/swigperl.htm;, so I'd suggest going to
www.swig.org and rummaging around.  Afraid I don't know anything about the
subject though.

HTH -
Ron Goral



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




RE: www.perldoc.com

2005-02-28 Thread Ron Goral
 Is anyone having trouble getting to this domain?

 I can never get a connection.


YES !!

I've been asking about this for months and no one else seemed to have any
problems.  However, no one in my geographical area can connect to the site.
Even my ISP cannot.  I've tried sending email to them, but it either doesn't
get through or they've ignored me.  Where are you? I'm in rural south
central Wisconsin USA.

Peace -
Ron



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




RE: www.perldoc.com

2005-02-28 Thread Ron Goral


 -Original Message-
 From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
 Sent: Monday, February 28, 2005 8:53 AM
 To: Gavin Henry
 Cc: beginners@perl.org; [EMAIL PROTECTED]
 Subject: Re: www.perldoc.com


 Gavin Henry wrote:
  Is anyone having trouble getting to this domain?
 
  I can never get a connection.
 
 

 Yes, it has been flaky for at least the past couple of weeks.

 Not sure who runs perldoc.com, Ask do you?

 http://danconia.org

In a cached version of perldoc.com from google, it shows Carlos Ramirez
([EMAIL PROTECTED]) as the creator and maintainer.  Whether that is true
anymore, I don't know, but that is the best I can find.  I've sent him an
email a few weeks ago, but as I said, he either ignored it or it never got
to him.  This has been a great site, but I've rather given up on ever being
able to access it again.

Peace -
Ron



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




Problem assigning with File::Find

2005-01-29 Thread Ron Goral
Greetings all -

I am having some problems understanding an issue of assignment within a
closure (I think its a closure).  My code is below.  I've added the line
numbers for reference. Note that this is an excerpt from a module.
'$hr_self' is a blessed hash ref to the module. 'FindDGLibDir' is called
with: $hr_self-FindDGLibDir();

1  sub FindDGLibDir
2  {
3  # Modules to use
4  use File::Find;
5  use Cwd;
6
7  my ($hr_self) = @_;
8
9  my $process_file = sub
10  {
11  # Exit the process if we have the directory already
12  return if $hr_self-{dglib_dir} ne '';
13  # This is a directory and the name ends in 'dglib'
14  if (-d  m/dglib$/){$hr_self-{dglib_dir} = $File::Find::name;}
15  };
16
17  # Get the root to cgi-bin
18  cwd =~ m'(.*\/cgi-bin)';
19  # Search cgi-bin looking for dglib and return any errors
20  find(\$process_file, $1);
21  return 0 if $hr_self-{dglib_dir} eq '';
22
23  return 1;
24  }   # end FindDGLibDir

'$hr_self-{dglib_dir}' at line 14 cannot be assigned to.  If I substitute
'my $string' there, it works fine. '$hr_self-{dglib_dir}' is obviously a
valid var since it is used successfully in line 12. Can anyone tell me why
there is trouble in line 14?

Thanks
Ron



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




RE: Variable Value into MySQL DB

2004-12-27 Thread Ron Goral


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]
 Sent: Monday, December 27, 2004 12:08 PM
 To: beginners@perl.org
 Subject: Variable Value into MySQL DB


 Hi guys,

 I´m having kind´a problem... Here´s the deal... I´m using CGI so that the
 user can, by a browser, type the data that must be recorded into the
 database.
 I use CGI library to do that... the user type what he wants in the fields,
 and these values are sent to some variables... Then, I´d like to record
 these variables values in the db... But I just can´t get it done!
 I´m using Net::MySQL to do so... when I test the script by writing fixed
 values in it, it works fine... but when i try to record variables values
 it doesn´t work... could you help me? Here´s my code:
 #!/usr/bin/perl
 use strict;
 use CGI qw/:standard/;
  use Net::MySQL;
 print header,
 start_html('Cadastro de Processos'),
 h1('Cadastramento Processos'),
 start_form,
 Numero do Processo: ,textfield('process'),br,
 Tipo do Processo: [1-2],textfield('type'),br,
 Nome do advogado: ,textfield('name'),br,
 Email do advogado: ,textfield('email'),br,
 submit,
 end_form,
 hr,
 my $process =param(process);
 my $lawyer =param(name);
 my $email =param(email);
 my $type =param(type);

   my $mysql = Net::MySQL-new(
   database = 'tj',
   user = 'user',
   password = 'pass'
   );

$mysql-query(q{
INSERT INTO processo (process, name, email, type) VALUES ($process,
 $lawyer, $email, $type)
});

I think you have to quote the param:

my $process =param('process');
my $lawyer =param('name');
my $email =param('email');
my $type =param('type');

HTH
Ron



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




RE: MySQL and flock

2004-12-15 Thread Ron Goral
 -Original Message-
 From: Octavian Rasnita [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 14, 2004 9:21 AM
 To: Ron Goral; [EMAIL PROTECTED]
 Subject: Re: MySQL and flock


 Thanks but I don't have access to MySQL nor to the client that makes the
 update. I don't even know if it locks the tables or not.

 I would like to just copy some files in order to create a backup
 but I don't
 want to copy them while they are locked.
 However, I don't know if this is possible, because now I am
 thinking that if
 my program starts copying the files, they might start beeing updated just
 after I have started the copy process...

 Teddy

Hm.  Guess I thought you'd be doing this using SQL via a perl script.  Are
you going to be physically copying files?  If that is the case, you will
either have to deny access to them while you're copying or perhaps hold your
breath and hope for the best.  If you are using SQL, then the link I gave
you outlines how you can lock them while copying the data.

Ron



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



RE: MySQL and flock

2004-12-14 Thread Ron Goral


 -Original Message-
 From: Octavian Rasnita [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 14, 2004 6:57 AM
 To: [EMAIL PROTECTED]
 Subject: MySQL and flock


 Hi all,

 Does anyone know if MySQL uses flock when it modifies the data from a
 database for locking the files in which are kept the modified tables?
 I want to make a perl program which gets the file and store a
 back-up but I
 don't want to get the files while they are modified.

 Thank you.

 Teddy

Howdy -

Check out http://dev.mysql.com/doc/mysql/en/LOCK_TABLES.html for information
about MySQLs method of locking tables.

HTH -
Ron



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



RE: Is try-catch a better method for handling errors ?

2004-12-03 Thread Ron Goral


 -Original Message-
 From: Nilay Puri, Noida [mailto:[EMAIL PROTECTED]
 Sent: Saturday, December 04, 2004 1:09 AM
 To: [EMAIL PROTECTED]
 Subject: Is try-catch a better method for handling errors ?


 Hi All,



 I want opinion of perl experts in case of error handling.



 If I want to handle errors, in perl code which is making connections with
 database and fetching and inserting rows, which error handling method will
 be best.

 1.   Checking execution status and then hadling error case to case.

 a.   using die

 b.   using warn

 c.   using carp

 d.   OR usning try-catch metod



 I have been handling errors like,



 $stmt_base=$dbh-prepare($stmt) || log_err(PIE, Could not
 execute $stmt and the oracle error was $DBI::errstr\n\n) ;



 And then in log_err routine,



 Printing error sentence in log

 Disconnecting from databse

 Clearing file handles

 And exiting



 Now, want to switch over to try-catch method, so want to be sure,
 if I it's
 a good alternative.



 Thanks  Regards,

 NP

I am NOT an expert, so please do not treat my reply as an expert opinion.
However, I personally don't like to just 'die', so I use eval. I can handle
the error any way I choose in this capacity and it operates much like
try/catch and .  But then, I'm from a C++ background initially.  I would do
something like -

eval {$stmt_base=$dbh-prepare($stmt);};
log_err(PIE, Could not execute $stmt and the oracle error was
$DBI::errstr\n\n) if $@;

Peace -
Ron



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




RE: Spam:Re: using $! for die()ing with Package function

2004-12-02 Thread Ron Goral


 -Original Message-
 From: Michael Kraus [mailto:[EMAIL PROTECTED]
 Sent: Thursday, December 02, 2004 6:43 PM
 To: [EMAIL PROTECTED]; JupiterHost.Net;
 [EMAIL PROTECTED]
 Subject: RE: Spam:Re: using $! for die()ing with Package function


 G'day...

  Return undef or 0, just like you are doing.  Both your calls
  to baz have an argument, so 1 is returned both times.  I
  prefer undef for false.

 Ahh... But how do you set $! in the enclosing scope?


I don't think you can't set $! since it is a system var.  Perhaps you could
do something like:

my $err_text;

die $err_text if !Foo();

sub Foo_baz
{
return 1 if shift;
$err_text = Your error message.
return 0;
}

Peace -
Ron



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




RE: Spam:Re: using $! for die()ing with Package function

2004-12-02 Thread Ron Goral


 -Original Message-
 From: JupiterHost.Net [mailto:[EMAIL PROTECTED]
 Sent: Thursday, December 02, 2004 7:06 PM
 To: [EMAIL PROTECTED]
 Subject: Re: Spam:Re: using $! for die()ing with Package function


  I don't think you can't set $! since it is a system var.
 Perhaps you could
  do something like:
 
  my $err_text;
 
  die $err_text if !Foo();
 
  sub Foo_baz
  {
  return 1 if shift;
  $err_text = Your error message.
  return 0;
  }

 Thanks Ron, yeah if I want to I'll have to probabblly use the old error
 var route. I just wanted to avoid having a special error var tokeep
 track of and die()ing in the function itself. (IE let them kill
 themselves not have me do it :)

NP Jupiter.  Something I do is use the __DATA__ to store error numbers and
messages. I parse it to find the error number and return the text.  'Course,
that means you have to try to anticipate the trouble your users could get
themselves intoAlways an impossible task.  But, you could catch general
errors and at least give them some place to start looking for their issues.



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




RE: using $! for die()ing with Package function

2004-12-02 Thread Ron Goral


 -Original Message-
 From: JupiterHost.Net [mailto:[EMAIL PROTECTED]
 Sent: Thursday, December 02, 2004 7:15 PM
 To: [EMAIL PROTECTED]
 Subject: Re: using $! for die()ing with Package function




 Paul Johnson wrote:

  On Thu, Dec 02, 2004 at 05:59:49PM -0600, JupiterHost.Net wrote:
 
 
 if I make a module, say Foobar.pm how do you make it so if a function
 returns false you can die $!; ?
 
 
  You can't.  Or at least not in the sense you want.
 
  $! is linked to the current value of errno, which will be set in the
  underlying C libraries.  Its value is undefined except for just after an
  error has occurred.  errno is an int (or it can be thought of as one).
  When you use $! in a numeric context you get the value of errno.  When
  you use $! in a string context you get the text associated with that
  error number.
 
  It is possible to assign a numeric value to $!, after which $! in a
  string context will return the text for the error number you assigned,
  but this is rarely useful, and certainly not the general way you are
  looking for.
 
  Unfortunately perl doesn't have a standard way of coping with this other
  than using die, eval {} and $@, which might be seen as overkill in some
  situations.
 
  Take a look at $! in perldoc perlvar.

 Will do thanks for the info ;p

 I think as long as a failed open() or mkdir() (IE a system function that
 does $! sets it already) then that is all I need for this project:

 sub baz {
 mkdir '/dir/I/cant/make' or return;
 }

 will do what i need:

   baz or die $!;

Actually mkdir returns true or false -

sub baz{return mkdir '/dir/I/cant/make';}

would do the same without any evaluation.



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




RE: Append on top (easy sollution)

2004-11-15 Thread Ron Goral


 -Original Message-
 From: Gary Stainburn [mailto:[EMAIL PROTECTED]
 Sent: Monday, November 15, 2004 7:25 AM
 To: [EMAIL PROTECTED]
 Subject: Re: Append on top (easy sollution)


 On Monday 15 November 2004 3:02 am, K-sPecial wrote:
  Rajesh Dorairajan wrote:
   Does anyone know of a way to open a file in append mode and append
   on top of the file?
  
   Thanks in Advance,
  
   --Rajesh
 
  I don't know why people are having a problem with this sollution,
  simply open in append mode so open doesn't clobber the file, then use
  seek() to move to the beginning of the file. Done :)
 

 The problem is that if you do that, you're going to overwrite the
 existing data with every write you do. What is required when appending
 to the front (oxymoron as append means to stick on the end), is that
 the existing data is shuffled down when you write.

 To clarify.

 if you had

 a
 b
 c
 d

 and did as you suggested to write 'f' you would end up with

 f
 b
 c
 d

 See?

  --K-sPecial
 
  [ http://xzziroz.freeshell.org
 irc://xzziroz.dtdns.net   ]

 --
 Gary Stainburn

 This email does not contain private or confidential material as it
 may be snooped on by interested government parties for unknown
 and undisclosed purposes - Regulation of Investigatory Powers
 Act, 2000

Perl FAQ 5 talks about this in the subsection entitled How do I change one
line in a file/delete a line in a file/insert a line in the middle of a
file/append to the beginning of a file?

Peace -
Ron Goral



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




RE: Variable scope in wanted function

2004-10-12 Thread Ron Goral


 -Original Message-
 From: Jenda Krynicky [mailto:[EMAIL PROTECTED]
 Sent: Monday, October 11, 2004 10:39 AM
 To: [EMAIL PROTECTED]
 Subject: Re: Variable scope in wanted function


 From: Gunnar Hjalmarsson [EMAIL PROTECTED]
  Ron Goral wrote:
   I am having some difficulty with a module that is using File::Find.
   The method is below.
  
   The idea is to enter this method feeding it a file name and
   beginning directory and then looking for all occasions of
   $file_name and push those addresses into @a_files.  This works fine
   until I need to use FindPath again during the same session.  What
   I'm finding is that while @a_files looses scope within FindPath
   itself, it does not in ProcessFile.  In other words, when I exit
   FindPath and come back into it later, @a_files is an uninitiated
   array.  However when ProcessFile is called, @a_files has retained
   the values it had from the last call to FindPath.
  
   Am I making sense?
 
  Yes. But you are apparently running the code without warnings enabled,
  or else Perl would have indicated the reason for this problem.
 
   sub FindPath
   {
   #- Var Declaration And Initialization
   my ($hr_self, $file_name, $file_path) = @_;
   # Array to fill with file paths
   my @a_files = ();
  
   # Search file_path for the file
   find(\ProcessFile, $file_path);
  
   #- The Subroutine To Process Files And Directories
   sub ProcessFile
   {if ($_ eq $file_name){push (@a_files, $File::Find::name);}}
  
   # Return the paths found
   return @a_files;
   }   # end FindPath
 
  One possible solution is to move the ProcessFile() function out from
  FindPath(), so the former is no longer a nested sub:
 
   sub ProcessFile {
   my ($a_files, $file_name) = @_;
   push @$a_files, $File::Find::name if $_ eq $file_name;
   }
 
  and call ProcessFile() from FindPath() with arguments:
 
   find( \ProcessFile( [EMAIL PROTECTED], $file_name ), $file_path );

 You can't do that. You'd have to write it like this:

   find( sub {ProcessFile( [EMAIL PROTECTED], $file_name )}, $file_path );

 Another option would be to use an unnamed subroutine like this:

 sub FindPath
 {
 #- Var Declaration And Initialization
 my ($hr_self, $file_name, $file_path) = @_;
 # Array to fill with file paths
 my @a_files = ();

 # Search file_path for the file
 find(sub {
   if ($_ eq $file_name){push (@a_files, $File::Find::name);}
   }, $file_path);

 # Return the paths found
 return @a_files;
 }   # end FindPath


 Or (which might very well be fastest) you'd declare the $file_name
 and @a_files outside the FindPath and ProcessFile:

 {
   my ($file_name, @a_files);

   sub FindPath
 {
 #- Var Declaration And Initialization
   my ($hr_self, $file_path);
 ($hr_self, $file_name, $file_path) = @_;
 # Array to fill with file paths
 @a_files = ();

 # Search file_path for the file
 find(\ProcessFile, $file_path);

 # Return the paths found
 return @a_files;
   }   # end FindPath

   #- The Subroutine To Process Files And Directories
   sub ProcessFile {
 if ($_ eq $file_name){push (@a_files, $File::Find::name);}
   }
 }

 HTH, Jenda
 = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
 When it comes to wine, women and song, wizards are allowed
 to get drunk and croon as much as they like.
   -- Terry Pratchett in Sourcery



Thanks to everyone who replied to this problem.

I discovered that what I had done, inadvertantly, was created a closure with
the ProcessFile function.  The closure will act on 'my' vars that are
created outside of its own scope, however, it will retain the values it
assigned to the var.  There is a much better explanation in Perl FAQ 7
(http://www.perldoc.com/perl5.8.4/pod/perlfaq7.html#What's-a-closure-).

This is how I ended up solving the issue:

sub FindPath
{
#- Var Declaration And Initialization
my ($hr_self, $file_name, $file_path) = @_;
#- Array to fill with file paths
my @a_files = ();

#- The Subroutine To Process Files And Directories
my $process_file = sub
{push (@a_files, $File::Find::name) if $_ eq $file_name;return;};

#- Search file_path Looking For This File
find(\$process_file, $file_path);

return @a_files;
}   # end FindPath

Now, the var $process_file is a coderef.  While having stumbled on this
closure business was pretty baffling, I'm glad I did.  It's an interesting
concept that I might could use advantageously in the future.

Thanks again -
Ron Goral



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




RE: Variable scope in wanted function

2004-10-11 Thread Ron Goral


 -Original Message-
 From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED]
 Sent: Sunday, October 10, 2004 6:32 PM
 To: [EMAIL PROTECTED]
 Subject: Re: Variable scope in wanted function


 Ron Goral wrote:
  I am having some difficulty with a module that is using File::Find.
  The method is below.
 
  The idea is to enter this method feeding it a file name and
  beginning directory and then looking for all occasions of
  $file_name and push those addresses into @a_files.  This works fine
  until I need to use FindPath again during the same session.  What
  I'm finding is that while @a_files looses scope within FindPath
  itself, it does not in ProcessFile.  In other words, when I exit
  FindPath and come back into it later, @a_files is an uninitiated
  array.  However when ProcessFile is called, @a_files has retained
  the values it had from the last call to FindPath.
 
  Am I making sense?

 Yes. But you are apparently running the code without warnings enabled,
 or else Perl would have indicated the reason for this problem.

  sub FindPath
  {
  #- Var Declaration And Initialization
  my ($hr_self, $file_name, $file_path) = @_;
  # Array to fill with file paths
  my @a_files = ();
 
  # Search file_path for the file
  find(\ProcessFile, $file_path);
 
  #- The Subroutine To Process Files And Directories
  sub ProcessFile
  {if ($_ eq $file_name){push (@a_files, $File::Find::name);}}
 
  # Return the paths found
  return @a_files;
  }   # end FindPath

 One possible solution is to move the ProcessFile() function out from
 FindPath(), so the former is no longer a nested sub:

  sub ProcessFile {
  my ($a_files, $file_name) = @_;
  push @$a_files, $File::Find::name if $_ eq $file_name;
  }

 and call ProcessFile() from FindPath() with arguments:

  find( \ProcessFile( [EMAIL PROTECTED], $file_name ), $file_path );

 And last but not least:

  use warnings;

 ;-)

 --
 Gunnar Hjalmarsson
 Email: http://www.gunnar.cc/cgi-bin/contact.pl

Actually, I am using warnings. However, in the 'real' code, I have placed
the the call to 'find' within an eval block so that I can manage the errors.
Is this why I did not receive any warnings? The difficulties with moving
ProcessFile out of FindPath is that any return values ProcessFile might have
are ignored and it can take no arguments (this is from
http://search.cpan.org/~nwclark/perl-5.8.5/lib/File/Find.pm#The_wanted_funct
ion).

I've setting up a global variable like $hr_self-{a_files}, where $hr_self
is an object ref to the module.  This requires calling ProcessFile like so:

find(\$hr_self-ProcessFile, $file_path);
or
find(\ProcessFile($hr_self), $file_path);

File::Find dies here with the complaint invalid top directory at
/usr/lib/perl5/5.6.1/File/Find.pm line 295, line 36.  I'm fairly certain
this is because of the '$hr_self-'.  I'm also completely out of ideas for
this.  At least when ProcessFile is defined within FindPath, the only
variable trouble I had was with @a_files.

There is a light, however.  If ProcessFile is actually an anonymous sub and
called this way:

my $processfile = sub {if ($_ eq $file_name){push (@a_files,
$File::Find::name);}};

find(\$processfile, $file_path);

There are no errors and @a_files is populated (and depopulated) as it should
be.

Thanks for taking the time to check this out and to write an answer.



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




Variable scope in wanted function

2004-10-10 Thread Ron Goral
Greetings All -

I am having some difficulty with a module that is using File::Find.  The
method is below.

The idea is to enter this method feeding it a file name and beginning
directory and then looking for all occasions of $file_name and push those
addresses into @a_files.  This works fine until I need to use FindPath again
during the same session.  What I'm finding is that while @a_files looses
scope within FindPath itself, it does not in ProcessFile.  In other words,
when I exit FindPath and come back into it later, @a_files is an uninitiated
array.  However when ProcessFile is called, @a_files has retained the values
it had from the last call to FindPath.

Am I making sense?


sub FindPath
{
#- Var Declaration And Initialization
my ($hr_self, $file_name, $file_path) = @_;
# Array to fill with file paths
my @a_files = ();

# Search file_path for the file
find(\ProcessFile, $file_path);

#- The Subroutine To Process Files And Directories
sub ProcessFile
{if ($_ eq $file_name){push (@a_files, $File::Find::name);}}

# Return the paths found
return @a_files;
}   # end FindPath

Peace -
Ron Goral



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




Need some help using lib to add custom directories to @INC

2004-09-16 Thread Ron Goral
Can anyone tell me why this code fails when trying to load
Some_Module_In_lib_Dir-
==
my $file_path =
substr($ENV{SCRIPT_FILENAME},0,index($ENV{SCRIPT_FILENAME},'/test.cgi'));
use lib $file_path/../lib;
use Some_Module_In_lib_Dir;

==
And this code does not -
==
use FindBin qw($Bin);
use lib $Bin/../lib;
use Some_Module_In_lib_Dir;

==
And this code does not -
==
use lib '/home/user/domain-www/cgi-bin/some_dir/test/../lib'
use Some_Module_In_lib_Dir;

==
And this code does not -
==
use lib
substr($ENV{SCRIPT_FILENAME},0,index($ENV{SCRIPT_FILENAME},'/test.cgi')) .
/../lib;
use Some_Module_In_lib_Dir;


If $Bin and $file_path are printed to screen, they show values identical to
the path used in the third example and that one derived in the fourth
example. So, why does $Bin get added to @INC before the program tries to
load Some_Module_In_lib_Dir, and $file_path does not?


Up On The Mountain Design Group

Custom solutions for your database driven web site.


Ron Goral
[EMAIL PROTECTED]
Tel  1 (920) 356 0239
Fax  1 (928) 752 6629
www.uponthemountain.com



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




RE: Need some help using lib to add custom directories to @INC

2004-09-16 Thread Ron Goral


 -Original Message-
 From: Wiggins d Anconia [mailto:[EMAIL PROTECTED]
 Sent: Thursday, September 16, 2004 9:03 AM
 To: Ron Goral; Perl Beginners; [EMAIL PROTECTED]
 Subject: Re: Need some help using lib to add custom directories to @INC


 Please only post to one group, if that group does not yield a good
 answer, then try a different one. Especially since this has nothing to
 do with CGI.


Actually, for me this has quite a lot to do with cgi as I am using this bit
of code to load various custom modules to process choices submitted via
forms on a web site.  This is especially necessary when the website does not
have it's own secure server certificate and is using a generic one owned by
the hosting company.  In such a case, when the script is called via SSL,
FindBin fails to produce a relative path to the lib directory and loading
the custom module fails miserably.  The use lib substr() concoction works.
I just need to know why for future use.


  Can anyone tell me why this code fails when trying to load
  Some_Module_In_lib_Dir-
  ==
  my $file_path =
 
 substr($ENV{SCRIPT_FILENAME},0,index($ENV{SCRIPT_FILENAME},'/test.cgi'));

 The above happens at runtime,

  use lib $file_path/../lib;

 The above happens at compile time, so $file_path is empty (at least I
 suspect).

  use Some_Module_In_lib_Dir;
 
  ==
  And this code does not -
  ==
  use FindBin qw($Bin);

 This is loaded at compile time and I suspect it sets $Bin at compile time,

  use lib $Bin/../lib;

 This is then loaded at compile time with $Bin already having been set.

  use Some_Module_In_lib_Dir;
 
  ==
  And this code does not -
  ==
  use lib '/home/user/domain-www/cgi-bin/some_dir/test/../lib'

 Obviously this is hardcoded and loaded at compile time. Since it is just
 a string it works.

  use Some_Module_In_lib_Dir;
 
  ==
  And this code does not -
  ==
  use lib
 
 substr($ENV{SCRIPT_FILENAME},0,index($ENV{SCRIPT_FILENAME},'/test.cgi')) .
  /../lib;

 This is impressive, but I suspect Perl is loading the whole statement at
 compile time, and since the %ENV is already established it works. I am
 impressed (but not terribly surprised, Perl is so cool) that it knows to
 compile and execute the whole line.

  use Some_Module_In_lib_Dir;
 
 
  If $Bin and $file_path are printed to screen, they show values
 identical to
  the path used in the third example and that one derived in the fourth
  example. So, why does $Bin get added to @INC before the program tries to
  load Some_Module_In_lib_Dir, and $file_path does not?

 Printing happens at runtime, but the 'use' happens at compile time, as
 do the setting of variables, *unless* they specifically happened at
 compile time for some reason.

 You can use CBEGIN blocks to when items are executed, aka if you want
 them to be run during compile time.

 HTH,

 http://danconia.org



This helps quite a bit.  THANKS!! =)  I did not know, though I suspected,
that $Bin would be set at compile time.  I had noticed as I printed out the
elements of @INC the path was listed using FindBin even if I printed
before I did the FindBin stuff in code.  It makes sense that FindBin does
it's stuff before run time.  I am curious though why substr() executes at
compile time and not at runtime.  Is it because it is a builtin perl
function?

Thanks again.



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




Need some help using lib to add custom directories to @INC

2004-09-16 Thread Ron Goral
Can anyone tell me why this code fails when trying to load
Some_Module_In_lib_Dir-
==
my $file_path =
substr($ENV{SCRIPT_FILENAME},0,index($ENV{SCRIPT_FILENAME},'/test.cgi'));
use lib $file_path/../lib;
use Some_Module_In_lib_Dir;

==
And this code does not -
==
use FindBin qw($Bin);
use lib $Bin/../lib;
use Some_Module_In_lib_Dir;

==
And this code does not -
==
use lib '/home/user/domain-www/cgi-bin/some_dir/test/../lib'
use Some_Module_In_lib_Dir;

==
And this code does not -
==
use lib
substr($ENV{SCRIPT_FILENAME},0,index($ENV{SCRIPT_FILENAME},'/test.cgi')) .
/../lib;
use Some_Module_In_lib_Dir;


If $Bin and $file_path are printed to screen, they show values identical to
the path used in the third example and that one derived in the fourth
example. So, why does $Bin get added to @INC before the program tries to
load Some_Module_In_lib_Dir, and $file_path does not?


Up On The Mountain Design Group

Custom solutions for your database driven web site.


Ron Goral
[EMAIL PROTECTED]
Tel  1 (920) 356 0239
Fax  1 (928) 752 6629
www.uponthemountain.com



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




RE: Need some help using lib to add custom directories to @INC

2004-09-16 Thread Ron Goral


 -Original Message-
 From: Wiggins d Anconia [mailto:[EMAIL PROTECTED]
 Sent: Thursday, September 16, 2004 9:03 AM
 To: Ron Goral; Perl Beginners; [EMAIL PROTECTED]
 Subject: Re: Need some help using lib to add custom directories to @INC


 Please only post to one group, if that group does not yield a good
 answer, then try a different one. Especially since this has nothing to
 do with CGI.


Actually, for me this has quite a lot to do with cgi as I am using this bit
of code to load various custom modules to process choices submitted via
forms on a web site.  This is especially necessary when the website does not
have it's own secure server certificate and is using a generic one owned by
the hosting company.  In such a case, when the script is called via SSL,
FindBin fails to produce a relative path to the lib directory and loading
the custom module fails miserably.  The use lib substr() concoction works.
I just need to know why for future use.


  Can anyone tell me why this code fails when trying to load
  Some_Module_In_lib_Dir-
  ==
  my $file_path =
 
 substr($ENV{SCRIPT_FILENAME},0,index($ENV{SCRIPT_FILENAME},'/test.cgi'));

 The above happens at runtime,

  use lib $file_path/../lib;

 The above happens at compile time, so $file_path is empty (at least I
 suspect).

  use Some_Module_In_lib_Dir;
 
  ==
  And this code does not -
  ==
  use FindBin qw($Bin);

 This is loaded at compile time and I suspect it sets $Bin at compile time,

  use lib $Bin/../lib;

 This is then loaded at compile time with $Bin already having been set.

  use Some_Module_In_lib_Dir;
 
  ==
  And this code does not -
  ==
  use lib '/home/user/domain-www/cgi-bin/some_dir/test/../lib'

 Obviously this is hardcoded and loaded at compile time. Since it is just
 a string it works.

  use Some_Module_In_lib_Dir;
 
  ==
  And this code does not -
  ==
  use lib
 
 substr($ENV{SCRIPT_FILENAME},0,index($ENV{SCRIPT_FILENAME},'/test.cgi')) .
  /../lib;

 This is impressive, but I suspect Perl is loading the whole statement at
 compile time, and since the %ENV is already established it works. I am
 impressed (but not terribly surprised, Perl is so cool) that it knows to
 compile and execute the whole line.

  use Some_Module_In_lib_Dir;
 
 
  If $Bin and $file_path are printed to screen, they show values
 identical to
  the path used in the third example and that one derived in the fourth
  example. So, why does $Bin get added to @INC before the program tries to
  load Some_Module_In_lib_Dir, and $file_path does not?

 Printing happens at runtime, but the 'use' happens at compile time, as
 do the setting of variables, *unless* they specifically happened at
 compile time for some reason.

 You can use CBEGIN blocks to when items are executed, aka if you want
 them to be run during compile time.

 HTH,

 http://danconia.org



This helps quite a bit.  THANKS!! =)  I did not know, though I suspected,
that $Bin would be set at compile time.  I had noticed as I printed out the
elements of @INC the path was listed using FindBin even if I printed
before I did the FindBin stuff in code.  It makes sense that FindBin does
it's stuff before run time.  I am curious though why substr() executes at
compile time and not at runtime.  Is it because it is a builtin perl
function?

Thanks again.



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




HELLLLLP! COOKIES ARE DRIVING ME INSAAAAAAAAAAANE!

2004-09-07 Thread Ron Goral
Howdy -

I'm having some trouble deleting a cookie using CGI::Cookie.  Here is the
code I'm using to do this.  Note this is in a module, so I have written
wrappers for the CGI::Cookie Set/Get functionality.  However, this is test
code, so it's being accessed in it's own namespace.  I know that this code
writes cookies.  But, I cannot seem to modify the properties of an existing
cookie.

use strict;
use CGI qw/:standard/;
use CGI::Cookie;

my $name = 'Johnny';
my $cookie = GetCookie($name);

if ($cookie)
{
# Set the 'expires' attribute to -1M
$cookie = DeleteCookie($name);
# If the cookie object is returned, print its new properties
if ($cookie)
{
print $h_self{cgi}-header(-cookie=$cookie);

print qq[Just set the cookie to be deleted.  These are the
properties:br /];

print -name is . $cookie-name .br /;
print -value is . $cookie-value .br /;
print -expires is . $cookie-expires .br /;
print -path is . $cookie-path .br /;
print -domain is . $cookie-domain .br /;
print -secure is . $cookie-secure .br /;

print qq[Close the browser and look in the cookies folderbr /];
}
# If the cookie was not returned, there was a problem.
else
{
print $h_self{cgi}-header;
print qq[Something has gone completely wrong here!];
}
}

sub GetCookie
{
my ($name) = @_;
my %h_cookies = fetch CGI::Cookie();
(exists $h_cookies{$name})?return $h_cookies{$name}:return 0;
}

sub DeleteCookie
{
my ($name) = @_;
# Get the cookie
my $cookie = GetCookie($name);
# Set the expiration date to delete cookie
$cookie = SetCookieProp($name,'expires','-1M');
($cookie)?return $cookie:return 0;
}

sub SetCookieProp
{
my ($name, $prop, $value) = @_;
# Get the cookie
my $cookie = $hr_self-GetCookie($name);
# Set the named property to the new value
$cookie-$prop($value);
($cookie)?return $cookie:return 0;
}


Ron Goral
Up On The Mountain Design Group
Custom solutions for your database driven web site.



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




RE: ODBC

2004-09-03 Thread Ron Goral


 -Original Message-
 From: Wiggins d Anconia [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, September 01, 2004 8:33 AM
 To: Rearick, Kenneth N.; '[EMAIL PROTECTED]'
 Subject: Re: ODBC


 
 
 
  I have a CGI program in which I am trying to access a database. When I
 run the code in active state feeding it the input from the form it runs
 fine. When I try to run it as a cgi from IE using Apache web server the
 data from the form comes in fine but it can not seem to attach to the
 database.
 
  Is there anyway to see the errors that the DBI:ODBC is generating when
 the application is being run from the server? Any ideas why the ODBC
 connect is failing?
 

 You can use CGI::Carp and 'fatalsToBrowser' to have fatal messages
 thrown to the browser, alternatively error messages are generally sent
 to the Apache error log.  Check there for what they have to say. You
 could also turn off DBI's automatic exceptions and catch them yourself,
 but this is a fair amount more work (at least while prototyping).

  $dbh = DBI-connect(DBI:ODBC:$SERVER, $USER, $PASSWORD);
 
 

 Sorry can't help with the connect issue, I suspect if you can find the
 error output it will.  If not you might try the dbi-users group or maybe
 someone else with ODBC experience will chime in.

 http://danconia.org


CGI::Carp may not capture errors that occur in the DBI module. However, DBI
has a built in logging functionality called trace which allows you to
specify the level of detail you want to see as well as specify where you
want the trace output stored.  Note that trace will log everything that is
being done in the name of DBI, so be prepared to wade through alot of info.
Though I would recommend reading the entire documentation, atleast go to
this address and check out this function:

http://search.cpan.org/~timb/DBI-1.43/DBI.pm#TRACING

HTH,
Peace in Christ -
Ron Goral



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




Locating the root directory to find files on a web site

2004-07-21 Thread Ron Goral
Howdy -

I have a module that needs to locate the root directory in order to search
for files or directories on a web site.  The difficulty is that I cannot be
certain of a couple things -

1.  I don't know where the script will be installed except that it will be
in the cgi-bin
2.  I don't know where the file or directory to be located will be relative
to the script
3.  It is possible that the script could be called using SSL or not.
4.  It is possible that the SSL could be a site certificate or a shared
server certificate.

I know that I can use File::Find as such -

find(\wanted, $root_dir);

But how do I find $root_dir reliably?

Any help in this matter will be greatly appreciated.

Peace -
Ron Goral



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




RE: Write to file with shared server certificate

2004-07-09 Thread Ron Goral


 -Original Message-
 From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED]
 Sent: Thursday, July 08, 2004 8:58 PM
 To: [EMAIL PROTECTED]
 Subject: Re: Write to file with shared server certificate


 Ron Goral wrote:
  If I try to create the file using open(LOG,+$logfile), the error
  is:
 
  No such file or directory at
  /usr/wwws/htdocs/mydomain/cgi-bin/test.cgi line 35.

 You must not include the '+' character when creating a file.

  perldoc perlopentut

 Try:

  open LOG,  $logfile or die $!;

 That presupposes of course that you remove the existing log file first.

 --
 Gunnar Hjalmarsson
 Email: http://www.gunnar.cc/cgi-bin/contact.pl


Thanks again for the replies.  I contacted my host and the shared SSL does
indeed operate under its own name which is different from mine.  It is
possible to create files under such circumstances, but they must be created
in a folder that is 0777.  I'm not crazy about having a folder set to 0777
full of files set to 0666.  =)

As for creating the file with '+', this would allow for read and append
ops on the file.  In the original function, if the log file existed, it was
to be searched for particular input and then written to.  If it did not
exist, it was to be created and then written to.

I appreciate the help and the pointers.

I apologize again for the off-topic nature of these postings.

Peace -
Ron Goral



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




Write to file with shared server certificate

2004-07-08 Thread Ron Goral
Greetings -

I need to write to a log file to record things happening in a cgi script.
The environment is secured using a server-wide, shared certificate.  I
cannot write to the file and get an error telling me I do not have the
proper permissions to do so.  The log file is in my web's directory, but
using the shared cert. requires a path like so:

https://secure.hostname.com/mydomain/cgi-bin/logs/logfile.log
rather than:
https://www.mydomain.com/cgi-bin/logs/logfile.log

Is there any way to overcome this short of owning the server or my own
certificate?

Thank you in advance -
Ron Goral



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




RE: Write to file with shared server certificate

2004-07-08 Thread Ron Goral
 -Original Message-
 From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED]
 Sent: Thursday, July 08, 2004 9:19 AM
 To: [EMAIL PROTECTED]
 Subject: Re: Write to file with shared server certificate


 Ron Goral wrote:
  I need to write to a log file to record things happening in a cgi
  script. The environment is secured using a server-wide, shared
  certificate.  I cannot write to the file and get an error telling
  me I do not have the proper permissions to do so.

 So, why don't you change the file permissions? Maybe it's 644 right
 now, and it's likely that 666 is needed since it's a CGI script.

  The log file is in my web's directory, but using the shared cert.
  requires a path like so:
 
  https://secure.hostname.com/mydomain/cgi-bin/logs/logfile.log
  rather than:
  https://www.mydomain.com/cgi-bin/logs/logfile.log

 Those are not paths on the file system, they are two different URLs
 that happen to be mapped to the same file. It has nothing to do with
 the problem to write to the log file.

 --
 Gunnar Hjalmarsson
 Email: http://www.gunnar.cc/cgi-bin/contact.pl


Gunnar -

chmod 0666 is the right thing.  Thank you.  However, I am not able to do
that programmatically when the script is running in secure mode. The
following dies:

$file_path = qq[/usr/wwws/htdocs/mydomain/cgi-bin/logs/errs.log];
chmod 0666,$file_path or die Cannot chmod $file_path - $!;

However, in unsecure mode, this succeeds:

$file_path = qq[/home/username/mydomain-www/cgi-bin/logs/errs.log];
chmod 0666,$file_path or die Cannot chmod $file_path - $!;

Thanks for the help -
Ron Goral



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




RE: Write to file with shared server certificate

2004-07-08 Thread Ron Goral

 -Original Message-
 From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED]
 Sent: Thursday, July 08, 2004 3:25 PM
 To: [EMAIL PROTECTED]
 Subject: Re: Write to file with shared server certificate


 Ron Goral wrote:
  chmod 0666 is the right thing.  Thank you.  However, I am not able
  to do that programmatically when the script is running in secure
  mode. The following dies:
 
  $file_path = qq[/usr/wwws/htdocs/mydomain/cgi-bin/logs/errs.log];
  chmod 0666,$file_path or die Cannot chmod $file_path - $!;
 
  However, in unsecure mode, this succeeds:
 
  $file_path = qq[/home/username/mydomain-www/cgi-bin/logs/errs.log];
  chmod 0666,$file_path or die Cannot chmod $file_path - $!;

 That's another problem. Note that this is getting rather off topic for
 a Perl list.

 I was assuming that you simply could change the permissions when
 logged in via FTP or SSH. To do it via a CGI script, the file must be
 owned by the user CGI is run as, i.e. the file typically needs to have
 been created by the script. Is that the case?

 Still assuming that we are talking about 'physically' the same file,
 i.e. that /usr/wwws/htdocs/mydomain is a symlink to
 /home/username/mydomain-www, I really don't know why the first example
 above dies. What does the error log say?

 Can it possibly be that CGI is running as a different user under HTTPS
 compared to HTTP?

 But again, this is *very* off topic here.

 --
 Gunnar Hjalmarsson
 Email: http://www.gunnar.cc/cgi-bin/contact.pl


Sorry for the off-topic.  I had not meant to do that.  But.

When trying to chmod, the error message is:

Operation not permitted at /usr/wwws/htdocs/mydomain/cgi-bin/test.cgi line
34.

If I try to create the file using open(LOG,+$logfile), the error is:

No such file or directory at /usr/wwws/htdocs/mydomain/cgi-bin/test.cgi line
35.

I am unable to raise the $ENV{USER_NAME} in this environment.  However,
given that this is a shared server certificate and mine is not the only
website on the server, it probably is the case that it is a different user.
I will have to contact my host and determine what, if anything, I can do
about that.

Again, I apologize for posting off topic.

Ron Goral





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




Trying to locate module in parallel directory

2004-07-07 Thread Ron Goral
Greetings -

I am having trouble locating and using modules that are not in the current
directory of a cgi script.  For this test, I know the directory structure
looks like this:

cgi-bin/test/test.cgi
cgi-bin/lib/DGStanLib.pm

However, this script and the required modules may be used by others and I
cannot guarantee its location. As such, I want to locate a module located in
cgi-bin/lib to be used by a cgi script in cgi-bin/test.  Below are three
methods I've tried for doing this.  The first, of course, explicitly names
the path to the module. This will not be possible to do. Mainly because I
cannot be sure of the path. In the second, I am trying to locate the cgi-bin
directory and build the path from there.  use lib, however, does not
expand variables, so the value of $mod_path is not being added to @INC. In
the third method, I've added FindBin.  However, it is only going to locate
directories in cgi-bin/test. Again, though, even $Bin is not added to @INC.
Please help.  This is very frustrating.

#- 1st Method -#
use lib qw(/usr/www/htdocs/domain-name/cgi-bin/lib);
use DGStanLib;

#- 2d Method -#
use File::Find;
my $index = index($ENV{SCRIPT_FILENAME},'cgi-bin/');
my $cgi_path = substr($ENV{SCRIPT_FILENAME},0,$index+8);
my $mod_path;
find (\wanted, $cgi_path);
sub wanted
{
if (!-d  $File::Find::name =~ m/DGStanLib\.pm/)
{$mod_path = $File::Find::dir;}
}

use lib $mod_path;
use DGStanLib;

#- 3d Method -#
use File::Find;
my $index = index($ENV{SCRIPT_FILENAME},'cgi-bin/');
my $cgi_path = substr($ENV{SCRIPT_FILENAME},0,$index+8);
my $mod_path;
find (\wanted, $cgi_path);
sub wanted
{
if (!-d  $File::Find::name =~ m/DGStanLib\.pm/)
{$mod_path = $File::Find::dir;}
}

use FindBin qw($Bin);
$Bin .= $mod_path;
use lib $Bin;
use DGStanLib;

Ron Goral



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




RE: Trying to locate module in parallel directory

2004-07-07 Thread Ron Goral

 Ron Goral wrote:
  Greetings -
 
  I am having trouble locating and using modules that are not in the
  current directory of a cgi script.  For this test, I know the
  directory structure looks like this:
 
  cgi-bin/test/test.cgi
  cgi-bin/lib/DGStanLib.pm

 From: Bob Showalter [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, July 07, 2004 10:39 AM
 To: 'Ron Goral'; Perl Beginners
 Subject: RE: Trying to locate module in parallel directory



 Why not the straightforward:

use FindBin;
use lib $FindBin::Bin/../lib;

 (lifted directly from the FindBin docs)

 Or why not allow the sysadmin to place the libs wherever he wants
 and use a
 SetEnv directive in the web server config to pass PERL5LIB to the CGI
 scripts and forego use lib altogether?


This is obviously a case of me trying to make this too complex.  Thank you
Bob for showing me that simpler is always better.  My assumption was that
$FindBin::Bin was going to locate a directory BELOW cgi-bin/test.  The
straight forward method worked just fine.

Thank you.



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




RE: help with adjusting log file data?

2004-06-11 Thread Ron Goral


 -Original Message-
 From: Charles K. Clarkson [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, June 09, 2004 9:19 PM
 To: 'Catriona Pure Scents'; [EMAIL PROTECTED]
 Subject: RE: help with adjusting log file data?


 From: Catriona Pure Scents mailto:[EMAIL PROTECTED] wrote:

 : Hi Charles,
 :
 : thanks immensely.  As you can probably tell I am one of those
 : people who pulled some scripts off the net to get me going,
 : and insists on making alterations.

 There is nothing wrong with that. Many people run very
 successful sites using that plan. CREOnline.com is easily
 the most visited RE site on line and they use an old Matt's
 Script called WWW Board. It's old, its clunky, and hundreds
 of posters a day don't seem to mind.


 : Yes the script I am attempting to alter in this instance I
 : located back in 1998.  I have made heaps of other
 : alterations so it wouldn't be simple to go get the latest
 : version.  :-((

 I got that impression, but I am obligated to point out
 the merits of warnings and strictures. I think others on this
 list would be disappointed if I didn't at least nudge you a
 little.


 : By warnings I am presuming that you mean use strict etc...
 : I have been asking on this list if someone can refer me to
 : sites that have details on how to convert my current scripts
 : and update them, it seems so totally different the way that
 : scripts are written with the warnings.  any good books or
 : sites that you can recommend?

There's a book about this mentioned a few months ago on a
 perl beginner list, but I can't find the post. Perhaps
 someone else remembers the post or the book. I seem to recall
 something about creating subs for each global variable.

 You may be looking at diminishing returns. Many slower
 sites are less likely to be affected by security problems.
 Hackers seem to like bigger fish. Putting a lot of effort
 into converting an old script might not be worth your time.
 Unless you think the experience will help in the long run.


 : I looked through the perl docs about that and couldn't find
 : anything.  I haven't looked through about perl join though.

 It sounds like you need to learn more of the basics before
 you start converting a large script. If you have the time, try
 to solve some of the problems asked on these perl beginner
 lists and compare your answers with those given by the more
 experienced contributors.


 : I need to set up my old pc for that.  The site I have is run
 : on Unix so I have a friend who is setting up the old pc for
 : unix, perl php etc so that I can just go ballistic and test
 : everything offline, make mistakes, try things, but at the
 : moment I don't have that luxury while they have my old pc.

 I do something similar, but with Apache on Windows XP.


 : Theoretically if the site stats can tell where someone came
 : from...then http_ referer would be env_var.  So why wouldn't
 : it work throughout the site itself?

 I'm not sure I understand your question. What do you mean
 by work throughout the site itself?

 HTH,

 Charles K. Clarkson
 --
 Mobile Homes Specialist
 254 968-8328



Howdy Guys -

Don't mean to butt in, but there are definite problems when relying on
HTTP_REFERER for anything except an informational item.  I learned this the
hard way while writing a shopping cart script.  I wanted to track users
through the site using HTTP_REFERER so that I would not have to rely on
cookies or javascripting.  I discovered a couple things.  Most notably, if
the user is behind a firewall, chances are HTTP_REFERER will not show up in
%ENV.  If the browser does not supply that information, and it is a browser
specific thing, then HTTP_REFERER will not be in the %ENV hash.  It won't
even be an empty value.  Please do not rely on HTTP_REFERER for any kind of
functionality in your code.  It is certain to fail at some point.

As for hackers and your site, they are a rabid pack of cannibals who don't
care what they use to get what they want.  I have a site that gets less than
5 hits a day.  I use it mostly for development.  I thought I was safe.  Yet,
some cretin began using a form of mine for his spamming campaign.  Don't
feel safe because you are obscure.  In fact, to quote an anonymous person,
Security through obscurity is not secure at all.  This applies to
scripting techniques as well.

By the way, this is a very simple version of getting/printing %ENV
variables -

#!/usr/bin/perl

use strict;
use CGI;
my $q = new CGI;

print $q-header;
for my $key(sort keys %ENV){print qq[b$key is /b$ENV{$key}br /];}

HTH -
Peace in Christ -

Ron Goral



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




RE: Locatiing Self-Installed Modules

2004-03-24 Thread Ron Goral


 -Original Message-
 From: Bob Showalter [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, March 23, 2004 10:03 AM
 To: 'Ron Goral'; Perl Beginners
 Subject: RE: Locatiing Self-Installed Modules


 Ron Goral wrote:
  Sorry, not sure what bottom post means.

 It means posting your new material below that which you are responding to,
 rather than at the top of the message. Lots of folks (me
 included) find this
 makes the thread easier to follow. Others disagree.

 If you use Outlook or Outlook Express, there's a nice tool that helps with
 quoting and replying:

   http://flash.to/outlook-quotefix/
   http://flash.to/oe-quotefix/


Thanks Bob.  I'll follow this form.  =)



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




RE: Locatiing Self-Installed Modules

2004-03-23 Thread Ron Goral
Hmm.  Thank you.  I did not make it clear that if this is installed on
another domain, I will not know exactly where the modules are installed,
except that they will be in the cgi-bin.  Outside of that, I cannot be
certain of where they are.  Hence, I thought, the need for the functionality
of something like FindBin.  Is there an alternative to this?

Thanks again -
Ron Goral

 -Original Message-
 From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
 Sent: Monday, March 22, 2004 7:10 PM
 To: Ron Goral
 Cc: Perl Beginners
 Subject: Re: Locatiing Self-Installed Modules


 Ron Goral wrote:
  Hello -
 
  I have a series of scripts and modules that I will self
 install, creating
  directories within the cgi-bin directory.  The structure looks
 like this:
 
 |-- Base
  cgi-bin -- DsgnGrp --|
 |-- Utilities
 
  DsgnGrp contains the scripts that call modules in Base and
 Utilities.  Base
  contains modules that fulfill basic functions like database access, file
  management, etc.  Utilities contains modules that do more
 specific things
  like validate email addresses, validate credit cards, validate form
  submissions, etc.  The problem I'm having is in getting modules
 in Utilities
  to find modules in Base.  I've tried this in a Utilities module:
 

 I am wondering if this is so complicated because of a poor design
 decision.  For me it doesn't make sense for a module to know anything
 about where it is installed or where any other modules are installed,
 just that they are installed and callable.  Otherwise encapsulation and
 modularization break down.  I would re-think the module layout and
 update the scripts so that they determine where a Perl module is
 installed, then you can move your FindBin code into the script and
 include as many 'use lib' lines as you wish.  This may also help your
 development cycle, including testing and development vs. production
 environments.

  use strict;
  use FindBin qw($Bin);   # Locate the path to this script
  use lib $Bin/../Base; # Set the path to the Base
 directory in the @INC
  use DGObjectManager;# Creates and validates new objects
 
  and that works for that module.  The problem arises when I try
 to use two
  modules out of Utilities in the same script call.  For
 instance, if I need
  to validate an email address and a credit card number.  According to the
  Perl 5.8 documentation for FindBin on CPAN:
 
  If there are two modules using FindBin from different
 directories under the
  same interpreter, this won't work. Since FindBin uses BEGIN
 block, it'll be
  executed only once, and only the first caller will get it
 right. This is a
  problem under mod_perl and other persistent Perl environments, where you
  shouldn't use this module. Which also means that you should avoid using
  FindBin in modules that you plan to put on CPAN. The only way
 to make sure
  that FindBin will work is to force the BEGIN block to be executed again:
 
  delete $INC{'FindBin.pm'};
  require FindBin;
 
  This form of the call:
 
  use strict;
  delete $INC{'FindBin.pm'};
  require FindBin;
  use lib $FindBin::Bin/../Base; # Set the path to the Base
 directory in
  the @INC
  use DGObjectManager;# Creates and validates new objects
 
  fails in Perl 5.6 with the error:
 
  Can't locate DGObjectManager.pm in @INC (@INC contains: /../Base
  /usr/lib/perl5/5.6.1/i686-linux /usr/lib/perl5/5.6.1
  /usr/lib/perl5/site_perl/5.6.1/i686-linux /usr/lib/perl5/site_perl/5.6.1
  /usr/lib/perl5/site_perl .)
 
  You can see that the Base directory is there, but the form is
 different from
  the use call which takes the form:
 
  /home/rongoral/uponthemountain-www/cgi-bin/DsgnGrp/Utilities/../Base
 
  Modifying the calls to DGObjectManager to
 DsgnGrp/Base/DGObjectManager or
  Base/DGObjectManager does not alleviate the issue.
 
  I am getting hopelessly confused here.  Any help would be greatly
  appreciated.
 

 I would re-think your structure, this is very non-standard and as the
 docs indicate, probably not for the faint of heart.  As a suggestion you
 might consider setting up a single directory where your home grown Base
 and Utilities modules live, then just call them by name under that
 single directory, for instance:

 /www/cgi-bin/lib/DsgnGroup/Base/ObjectMgr.pm
 /www/cgi-bin/lib/DsgnGroup/Utilities/DB.pm

 Then in your scripts you have,

 use lib qw( /www/cgi-bin/lib );
 use DsgnGroup::Base::ObjectMgr;
 use DsgnGroup::Utilities::DB;

 Alternatively you could boil down to a single 'use' that pulls in the
 various sub-modules.

 What I am prone to do these days is have the following:

 /httpd/domains/lib
 /httpd/domains/danconia/lib
 /httpd/domains/danconia/cgi-bin
 /httpd/domains/domain2/lib
 /httpd/domains/domain2/cgi-bin

 Then within a script in either cgi-bin I have the following:

 use FindBin;
 use lib $FindBin::Bin/../../lib;
 use lib $FindBin::Bin/../lib;

 Each site can then use any libraries

RE: Locatiing Self-Installed Modules

2004-03-23 Thread Ron Goral
Sorry, not sure what bottom post means.

 -Original Message-
 From: Wiggins d Anconia [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, March 23, 2004 9:05 AM
 To: Ron Goral; Perl Beginners
 Subject: RE: Locatiing Self-Installed Modules


 Please bottom post...

  Hmm.  Thank you.  I did not make it clear that if this is installed on
  another domain, I will not know exactly where the modules are installed,
  except that they will be in the cgi-bin.  Outside of that, I cannot be
  certain of where they are.  Hence, I thought, the need for the
 functionality
  of something like FindBin.  Is there an alternative to this?
 
  Thanks again -
  Ron Goral

 Couple of steps back, so you have a set of modules that will be
 installed on multiple servers, which may have different paths to the
 Perl module repositories?  And/or the modules will always be installed
 with the same set of CGI scripts?  Or the CGI scripts are considered
 independent and just need to rely on the fact that the modules will be
 installed somewhere on the system?

Yes.  Yes.  And yes.

 If they are really independent, and the modules don't know where they
 are installed, and more importantly the CGI scripts don't know they are
 installed in a particular relative location (as I described), I would
 leave all of the FindBin stuff out completely and allow the standard
 Perl search locations to take over.  In other words @INC will contain

I would love to do this, except that if the modules are installed in
parallel directories (same-level subdirectories in DsgnGrp), @INC will not
find the other directory since it is not in the parent path of the calling
module.

 Perl search locations to take over.  In other words @INC will contain
 the locations of the normal module installation locations which some
 users with root access may be using to install your modules. For other
 users they can use the PERL5LIB env variable, which can usually be set
 in the web server's configuration and will then be passed to the CGI.
 They would set that variable to whatever the location of their
 installation is.  Essentially I am trying to steer you clear of using

It is not necessarily the case that the user will have access to root or
have the ability to modify server configurations.  It could be that the user
is on a commercial server, just renting space.

 installation is.  Essentially I am trying to steer you clear of using
 paths within the module source...

Three cheers for non-hard coded paths.


 Does this make sense, help?

 http://danconia.org


 
   -Original Message-
   From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
   Sent: Monday, March 22, 2004 7:10 PM
   To: Ron Goral
   Cc: Perl Beginners
   Subject: Re: Locatiing Self-Installed Modules
  
  
   Ron Goral wrote:
Hello -
   
I have a series of scripts and modules that I will self
   install, creating
directories within the cgi-bin directory.  The structure looks
   like this:
   
   |-- Base
cgi-bin -- DsgnGrp --|
   |-- Utilities
   
DsgnGrp contains the scripts that call modules in Base and
   Utilities.  Base
contains modules that fulfill basic functions like database
 access, file
management, etc.  Utilities contains modules that do more
   specific things
like validate email addresses, validate credit cards, validate form
submissions, etc.  The problem I'm having is in getting modules
   in Utilities
to find modules in Base.  I've tried this in a Utilities module:
   
  
   I am wondering if this is so complicated because of a poor design
   decision.  For me it doesn't make sense for a module to know anything
   about where it is installed or where any other modules are installed,
   just that they are installed and callable.  Otherwise
 encapsulation and
   modularization break down.  I would re-think the module layout and
   update the scripts so that they determine where a Perl module is
   installed, then you can move your FindBin code into the script and
   include as many 'use lib' lines as you wish.  This may also help your
   development cycle, including testing and development vs. production
   environments.
  
use strict;
use FindBin qw($Bin);   # Locate the path to this script
use lib $Bin/../Base; # Set the path to the Base
   directory in the @INC
use DGObjectManager;# Creates and validates new objects
   
and that works for that module.  The problem arises when I try
   to use two
modules out of Utilities in the same script call.  For
   instance, if I need
to validate an email address and a credit card number.  According
 to the
Perl 5.8 documentation for FindBin on CPAN:
   
If there are two modules using FindBin from different
   directories under the
same interpreter, this won't work. Since FindBin uses BEGIN
   block, it'll be
executed only once, and only the first caller will get it
   right

Locatiing Self-Installed Modules

2004-03-22 Thread Ron Goral
Hello -

I have a series of scripts and modules that I will self install, creating
directories within the cgi-bin directory.  The structure looks like this:

   |-- Base
cgi-bin -- DsgnGrp --|
   |-- Utilities

DsgnGrp contains the scripts that call modules in Base and Utilities.  Base
contains modules that fulfill basic functions like database access, file
management, etc.  Utilities contains modules that do more specific things
like validate email addresses, validate credit cards, validate form
submissions, etc.  The problem I'm having is in getting modules in Utilities
to find modules in Base.  I've tried this in a Utilities module:

use strict;
use FindBin qw($Bin);   # Locate the path to this script
use lib $Bin/../Base; # Set the path to the Base directory in the @INC
use DGObjectManager;# Creates and validates new objects

and that works for that module.  The problem arises when I try to use two
modules out of Utilities in the same script call.  For instance, if I need
to validate an email address and a credit card number.  According to the
Perl 5.8 documentation for FindBin on CPAN:

If there are two modules using FindBin from different directories under the
same interpreter, this won't work. Since FindBin uses BEGIN block, it'll be
executed only once, and only the first caller will get it right. This is a
problem under mod_perl and other persistent Perl environments, where you
shouldn't use this module. Which also means that you should avoid using
FindBin in modules that you plan to put on CPAN. The only way to make sure
that FindBin will work is to force the BEGIN block to be executed again:

delete $INC{'FindBin.pm'};
require FindBin;

This form of the call:

use strict;
delete $INC{'FindBin.pm'};
require FindBin;
use lib $FindBin::Bin/../Base; # Set the path to the Base directory in
the @INC
use DGObjectManager;# Creates and validates new objects

fails in Perl 5.6 with the error:

Can't locate DGObjectManager.pm in @INC (@INC contains: /../Base
/usr/lib/perl5/5.6.1/i686-linux /usr/lib/perl5/5.6.1
/usr/lib/perl5/site_perl/5.6.1/i686-linux /usr/lib/perl5/site_perl/5.6.1
/usr/lib/perl5/site_perl .)

You can see that the Base directory is there, but the form is different from
the use call which takes the form:

/home/rongoral/uponthemountain-www/cgi-bin/DsgnGrp/Utilities/../Base

Modifying the calls to DGObjectManager to DsgnGrp/Base/DGObjectManager or
Base/DGObjectManager does not alleviate the issue.

I am getting hopelessly confused here.  Any help would be greatly
appreciated.

Thanks in advance -
Ron Goral






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




RE: error msg : can't use string as an ARRAY ref

2004-02-23 Thread Ron Goral
 -Original Message-
 From: Joseph Paish [mailto:[EMAIL PROTECTED]
 Sent: Monday, February 23, 2004 9:18 AM
 To: perl_beginner
 Subject: error msg : can't use string as an ARRAY ref

SNIP MESSAGE

 while (fh1) {
 push (@all_of_them, $_ ) ;  # an array of all the records in the file

Since you are not splitting $_, @all_of_them is a single-dimension array.

 my @single_line = split/ /, $_;
 push (@temp_array, $single_line[3]) ; # a list of all the
 part numbers,
 including duplicates
 }

SNIP MESSAGE

 foreach $temp1 (@unique_part_nbrs) {
 for ($ctr = 0 ; $ctr  (scalar(@all_of_them)) ; $ctr++) {
   print if ($all_of_them[$ctr][3] eq $temp1) ;

Here you are treating @all_of_them as a multi-dimensional array, and this is
where the error occurs.  Solve this by -

a) Splitting the array element here print if (split / /,
$all_of_them[$ctr] eq $temp1) ; 
b) Splitting $_ when you push the data into @all_of_them  push
(@all_of_them, split / /, $_) ; 
c) Just push the part number into @all_of_them and don't worry about
accessing a multi-dimensional array.


HTH -

Ron Goral



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




fetchall_hashref error: invalid number of parameters?

2004-01-03 Thread Ron Goral
Howdy all -

I am trying to hit a MySQL database using DBI::mysql.  I am trying to get
table information using the SQL - SHOW TABLE STATUS.

The statement handle prepares and then executes as it should, but when I try
to get the info via $sth-fetchall_hashref, I get the following error:

=
DBI fetchall_hashref: invalid number of parameters: handle + 0 Usage:
$h-fetchall_hashref()
=

I'm not sure what form the data will be in when this statement is executed,
but the hashref is a hopeful thing.

Here is the code after a good connection to the database -

=
eval{$sth = $dbh-prepare(SHOW TABLE STATUS);};
print qq[Error - $@ br /] if $@; # No error here

eval{$sth-execute();};
print qq[Error - $@ br /] if $@; # No error here

my $ar_TableInfo;
eval{$ar_TableInfo = $sth-fetchall_hashref;};
print qq[Error - $@ br /] if $@; # Error occurs here

print qq[About to iterate the array of hashrefs.br /];
foreach my $hr_TableInfo (@$ar_TableInfo)
{
foreach my $key (keys %{$hr_TableInfo})
{print qq[$key is $hr_TableInfo-{$key}br /];}
}
=


Any help here would be greatly appreciated.

Peace -
Ron



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




RE: fetchall_hashref error: invalid number of parameters?

2004-01-03 Thread Ron Goral
Hey Rob -

fetchall_hashref is an array ref of hash refs (one hash ref per row
contained in an array ref), so I have to dereference and iterate the array
ref to get to the hash refs underneath. The DBI Manpage says:

It returns a reference to an array that contains one hash of field name and
value pairs per row.

Specifying column names is, unfortunately, an optional parameter for
fetchall_arrayref not fetchall_hashref.  =(

Peace -
Ron

-Original Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED]
Sent: Saturday, January 03, 2004 9:51 AM
To: [EMAIL PROTECTED]
Subject: Re: fetchall_hashref error: invalid number of parameters?


Ron Goral wrote:

 I am trying to hit a MySQL database using DBI::mysql.  I am trying to get
 table information using the SQL - SHOW TABLE STATUS.

 The statement handle prepares and then executes as it should, but when I
try
 to get the info via $sth-fetchall_hashref, I get the following error:

 =
 DBI fetchall_hashref: invalid number of parameters: handle + 0 Usage:
 $h-fetchall_hashref()
 =

 I'm not sure what form the data will be in when this statement is
executed,
 but the hashref is a hopeful thing.

 Here is the code after a good connection to the database -

 =
 eval{$sth = $dbh-prepare(SHOW TABLE STATUS);};
 print qq[Error - $@ br /] if $@; # No error here

 eval{$sth-execute();};
 print qq[Error - $@ br /] if $@; # No error here

 my $ar_TableInfo;
 eval{$ar_TableInfo = $sth-fetchall_hashref;};
 print qq[Error - $@ br /] if $@; # Error occurs here

 print qq[About to iterate the array of hashrefs.br /];
 foreach my $hr_TableInfo (@$ar_TableInfo)

You're getting confused here. $ar_TableInfo is a hashref
so you can't dereference it as an array.

 {
 foreach my $key (keys %{$hr_TableInfo})
 {print qq[$key is $hr_TableInfo-{$key}br /];}
 }
 =

Hi Ron.

Like it says, you've supplied the wrong number of parameters
to the fetchall_hashref method. You need to pass a single
parameter saying which of the columns you want to use as the
keys of the returned hash. In this case it makes little sense
to use anything but the 'Name' column of the results, so you
could write something like:

  my $hr_TableInfo = $sth-fetchall_hashref('Name');

  foreach my $name (keys %{$hr_TableInfo}) {
my $rows = $hr_TableInfo-{$name}{Rows};
my $update_time = $hr_TableInfo-{$name}{Update_time};
  }

depending on what information you need from the results.

HTH,

Rob







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




RE: fetchall_hashref error: invalid number of parameters?

2004-01-03 Thread Ron Goral
Thanks Rob -

There is a difference between what is on CPAN and what is at perldoc.com.
The CPAN manpage shows that fetchall_hashref will return only a single field
so it is $sth-fetchall_hashref($keyfield) as you pointed out.  The method
to use for what I want to do is to use $sth-fetchall_arrayref({}) which
does what fetchall_hashref used to do: return an array ref of hash refs
containing all fields.  So, my code should be:

=
eval{$sth = $dbh-prepare(SHOW TABLE STATUS);};
print qq[Error - $@ br /] if $@; # No error here

eval{$sth-execute();};
print qq[Error - $@ br /] if $@;

my $ar_TableInfo;
eval{$ar_TableInfo = $sth-fetchall_arrayref;};  # Change to
fetchall_arrayref
print qq[Error - $@ br /] if $@;

print qq[About to iterate the array of hashrefs.br /];
foreach my $hr_TableInfo (@$ar_TableInfo)
{
foreach my $key (keys %{$hr_TableInfo})
{print qq[$key is $hr_TableInfo-{$key}br /];}
}
=

Thanks for your help.  This part of this is solved.  =)

Peace -
Ron

-Original Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED]
Sent: Saturday, January 03, 2004 5:19 PM
To: Ron Goral; Perl Beginners
Subject: Re: fetchall_hashref error: invalid number of parameters?


Ron Goral wrote:

 From: Rob Dixon [mailto:[EMAIL PROTECTED]
 Sent: Saturday, January 03, 2004 9:51 AM
 To: [EMAIL PROTECTED]
 Subject: Re: fetchall_hashref error: invalid number of parameters?
 
 
  Ron Goral wrote:
  
   I am trying to hit a MySQL database using DBI::mysql.  I am trying to
get
   table information using the SQL - SHOW TABLE STATUS.
  
   The statement handle prepares and then executes as it should, but when
I
  try
   to get the info via $sth-fetchall_hashref, I get the following error:
  
   =
   DBI fetchall_hashref: invalid number of parameters: handle + 0 Usage:
   $h-fetchall_hashref()
   =
  
   I'm not sure what form the data will be in when this statement is
  executed,
   but the hashref is a hopeful thing.
  
   Here is the code after a good connection to the database -
  
   =
   eval{$sth = $dbh-prepare(SHOW TABLE STATUS);};
   print qq[Error - $@ br /] if $@; # No error here
  
   eval{$sth-execute();};
   print qq[Error - $@ br /] if $@; # No error here
  
   my $ar_TableInfo;
   eval{$ar_TableInfo = $sth-fetchall_hashref;};
   print qq[Error - $@ br /] if $@; # Error occurs here
  
   print qq[About to iterate the array of hashrefs.br /];
   foreach my $hr_TableInfo (@$ar_TableInfo)
 
  You're getting confused here. $ar_TableInfo is a hashref
  so you can't dereference it as an array.
 
   {
   foreach my $key (keys %{$hr_TableInfo})
   {print qq[$key is $hr_TableInfo-{$key}br /];}
   }
   =
 
  Like it says, you've supplied the wrong number of parameters
  to the fetchall_hashref method. You need to pass a single
  parameter saying which of the columns you want to use as the
  keys of the returned hash. In this case it makes little sense
  to use anything but the 'Name' column of the results, so you
  could write something like:
 
my $hr_TableInfo = $sth-fetchall_hashref('Name');
 
foreach my $name (keys %{$hr_TableInfo}) {
  my $rows = $hr_TableInfo-{$name}{Rows};
  my $update_time = $hr_TableInfo-{$name}{Update_time};
}
 
  depending on what information you need from the results.

 fetchall_hashref is an array ref of hash refs (one hash ref per row
 contained in an array ref), so I have to dereference and iterate the array
 ref to get to the hash refs underneath. The DBI Manpage says:

 It returns a reference to an array that contains one hash of field name
and
 value pairs per row.

 Specifying column names is, unfortunately, an optional parameter for
 fetchall_arrayref not fetchall_hashref.  =(

Hi Ron.

There's something odd somewhere. This is straight from

  perldoc DBI

  fetchall_hashref
$hash_ref = $sth-fetchall_hashref($key_field);

  The fetchall_hashref method can be used to fetch all the data to
  be returned from a prepared and executed statement handle. It
  returns a reference to a hash that contains, at most, one entry per
  row.

Try running:

  use DBI;
  print $DBI::VERSION, \n;

I'm running DBI version 1.37 (But the POD in the DBI.pm source file claims
that it's for version 1.34!!)

I can't really help any further :-/

Rob




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




RE: @INC paths on an IIS server

2003-12-09 Thread Ron Goral


-Original Message-
From: R. Joseph Newton [mailto:[EMAIL PROTECTED]
Sent: Monday, December 08, 2003 8:42 PM
To: Ron Goral
Cc: Perl Beginners
Subject: Re: @INC paths on an IIS server

This strikes me as strange, because I have never had any problems using
module
placed correctly in relative paths, and I've never had to modify @INC to do
so.
This includes working with IIS.  Are you sure that the filename is an exact
case-sensitive match for the class name?  Windows doesn't care, but Perl
does.


Yes, I am ensuring the case of the file names called.


Have you telnetted into the directory to see what the view looks like from
there?  It should work.  Hmmm, what version of Windows and Perl is running
on
the server?


The box is mine at home.  I am operating Windows 2000 Pro with IIS
installed.  The Perl version is 5.61.


Joseph




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




@INC paths on an IIS server

2003-12-08 Thread Ron Goral
I am testing some scripts on an IIS server and receive the following error
when I attempt to use a module:

Can't locate DG_DatabaseManager.pm in @INC (@INC contains: C:/Perl/lib
C:/Perl/site/lib .) at c:\inetpub\wwwroot\cgi-bin\develop\shp_crt\test.cgi
line 9.
BEGIN failed--compilation aborted at
c:\inetpub\wwwroot\cgi-bin\develop\shp_crt\test.cgi line 9.

Do I have to modify %INC for IIS to find a non-standard module?  It appears
that the . directory is in @INC, but the script cannot find it even though
DG_DatabaseManager.pm is in the same directory as test.cgi.  Am I wrong in
thinking that . represents the
c:\inetpub\wwwroot\cgi-bin\develop\shp_crt directory when that is where
test.cgi is located?

Ahead of time, I have this directory's permissions up to execute both
scripts and executables and, for now, it is operating under the
administrator's account so there are no issues with permissions.

Thanks -
Ron Goral


Browser wants to do a file download on a CGI script

2003-09-13 Thread Ron Goral
Can anyone please tell me why my browser wants to do a file download on a
CGI script?

Ron Goral


RE: Browser wants to do a file download on a CGI script

2003-09-13 Thread Ron Goral
The file name is dgConfigAdmin.cgi.  I have explicitly configured the server
to execute .cgi as .pl scripts.  In fact, this script works properly and the
error does not occur until the script calls itself to save some settings to
a database.  When I open or save the file that is being downloaded, it is
the HTML that is supposed to display in the next step of the script.

I've tried to put an implicit  print qq[Content-Type: text/html\n\n]; just
prior to the here document that displays the HTML (that gets downloaded),
but that does not help.

-Original Message-
From: Charles K. Clarkson [mailto:[EMAIL PROTECTED]
Sent: Saturday, September 13, 2003 7:17 PM
To: 'Ron Goral'; 'Perl Beginners'
Subject: RE: Browser wants to do a file download on a CGI script


Ron Goral [EMAIL PROTECTED] wrote:
:
: Can anyone please tell me why my browser wants to do
: a file download on a CGI script?

For some reason, your server doesn't know that
it is supposed to execute the file. What is the file
name? What extension is on the file? Where is it
located? Do other cgi scripts run okay?


HTH,

Charles K. Clarkson
--
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328



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



RE: Browser wants to do a file download on a CGI script

2003-09-13 Thread Ron Goral
{form_name} = 'form_sc_edit_gateway_config';
GetConfigTableInfo();
$content = GetConfigEditScreen($heading);
}
elsif ($FORM{cmd} eq 'confirm_config_changes')
{
$heading = qq[Configuration Changes Confirmation];
$content = GetConfirmConfigScreen();
}

#WHEN THE CONFIGURATION CHANGES ARE SAVED, THE DATA IS SAVED TO THE
DATABASE.
#HOWEVER, THIS HERE DOCUMENT DOES NOT PRINT TO SCREEN.  INSTEAD, THE USER
#IS PROMPTED TO EITHER SAVE OR OPEN A FILE DOWNLOAD OF THE .CGI SCRIPT.  IF
#THE FILE IS SAVED, IT DOES CREATE THE HTML, BUT IT IS IN A FILE NAMED
#dgCartAdmin.cgi.  THE STRANGE THING IS THAT IF ONE OF THE OTHER COMMANDS
ARE
#SENT IN THE SCRIPT, THIS HERE DOCUMENT PRINTS EXACTLY AS IT SHOULD.
printHTML;
html
head
title$title$heading/title
meta http-equiv=content-Type content=text/html; charset=iso-8859-1
meta http-equiv=content-language content=en-US
link rel=stylesheet type=text/css
href=$h_self{cfg_sc_web_dir_unsec}stylesheets/styles.css
script src=$h_self{cfg_sc_web_dir_unsec}scripts/dgWindowManager.js
language=JavaScript/script
script src=$h_self{cfg_sc_web_dir_unsec}scripts/dgImageManager.js
language=JavaScript/script
style
#hidden_cmd {width:1px;height:1px;}
/style
script language=javascript
!-- Hide from older browsers
var cmd;

function setCmd(cmd)
{
document.all.hidden_cmd.innerHTML='input type=hidden name=cmd
value=' + cmd + '';
}
// Stop Hiding --
/script
/head

body
center

a name=top/a

table name=Header width=755 height=100 cellpadding=1
cellspacing=1 bgcolor=skyblue class=thinborder_red
tr valign=middle
td height=100 width=149 align=center
a href=http://www.uponthemountain.com; target=_top
class=img_lnkimg src=$h_self{cfg_sc_web_dir_unsec}images/logo.gif
height=75 width=75 alt=Up On The Moutain Design Group border=0/a
/td
td width=450 align=center
span style=font-family:'Times New
Roman';font-size:20pt;font-weight:bold;color:darkslategray;Up On The
Mountain Design Groupbr /Shopping Cart Administrator/span
/td
td width=149 align=center valign=middlenbsp;/td
/tr
/table

table width=755 cellpadding=1 cellspacing=0 border=0
bgcolor=azure class=rl_thinborder_red
tr
td width=150 align=center valign=top
class=r_thinborder_red
!-- Begin Left Nav
Section 
table width=148 cellpadding=1 cellspacing=0 border=0
bgcolor=azure 
trtd width=148 height=5/td/tr
trtd align=center valign=middle
background=$h_self{cfg_sc_web_dir_unsec}images/button.gif height=25a
href=$h_self{cfg_sc_cgi_dir_unsec}dgCartAdmin.cgi?cmd=config_manager
class=navConfiguration Manager/a/td/tr
trtd height=5/td/tr
trtd align=center valign=middle
background=$h_self{cfg_sc_web_dir_unsec}images/button.gif height=25a
href=$h_self{cfg_sc_cgi_dir_unsec}dgCartAdmin.cgi?cmd=account_manager
class=navAccount Manager/a/td/tr
trtd height=5/td/tr
trtd align=center valign=middle
background=$h_self{cfg_sc_web_dir_unsec}images/button.gif height=25a
href=$h_self{cfg_sc_cgi_dir_unsec}dgCartAdmin.cgi?cmd=item_manager
class=navItem Manager/a/td/tr
trtd height=5/td/tr
trtd align=center valign=middle
background=$h_self{cfg_sc_web_dir_unsec}images/button.gif height=25a
href=$h_self{cfg_sc_cgi_dir_unsec}dgCartAdmin.cgi?cmd=template_manager
class=navTemplate Manager/a/td/tr
trtd height=5/td/tr
trtd align=center valign=middle
background=$h_self{cfg_sc_web_dir_unsec}images/button.gif height=25a
href=$h_self{cfg_sc_cgi_dir_unsec}dgCartAdmin.cgi?cmd=this
class=navThis/a/td/tr
 /table
!-- End Left Nav
Section --
/td
td width=600 height=400 valign=top align=center
form name=$FORM{form_name}
action=$h_self{cfg_sc_cgi_dir_unsec}dgCartAdmin.cgi method=POST
input type=hidden name=form_name value=$FORM{form_name}
input type=hidden name=referer value=$FORM{referer}
$content
span id=hidden_cmd/span
/form
/td
/tr
/table

!-- Begin Footer
Section --
table width=755 cellpadding=1 cellspacing=0 border=0
bgcolor=black class=thinborder_red
tr
td width=750 align=center class=centerfooter
copy;nbsp;2000 Up On The Mountain Design Groupbr
a href=mailto:$h_self{cfg_email_web_err};
class=footer$h_self{cfg_email_web_err}/a
/td
/tr
/table
!-- End Footer
Section 

/center
/body
/html
HTML
}

-Original Message-
From: Charles K. Clarkson [mailto:[EMAIL PROTECTED]
Sent: Saturday, September 13, 2003 8:00 PM
To: 'Ron Goral'; 'Perl Beginners'
Subject: RE: Browser wants to do a file download on a CGI script


Ron Goral [EMAIL PROTECTED

RE: Browser wants to do a file download on a CGI script

2003-09-13 Thread Ron Goral
Please do not bother to read that obnoxious amount of code.  I found my
error:

print qq[dgCartAdmin::SaveChanges - $h_self{sqlstmt}br /];# if
$h_self{debug};

rather than

print qq[dgCartAdmin::SaveChanges - $h_self{sqlstmt}br /] if
$h_self{debug};

This print statement was happening before the HTML page header information
was being printed.  Curious that the internal server error did not rear it's
ugly head.

Anyway, thanx for any efforts you may have put forth in this issue.

Ron Goral
self chastened and remorseful

-Original Message-
From: Charles K. Clarkson [mailto:[EMAIL PROTECTED]
Sent: Saturday, September 13, 2003 8:00 PM
To: 'Ron Goral'; 'Perl Beginners'
Subject: RE: Browser wants to do a file download on a CGI script


Ron Goral [EMAIL PROTECTED] wrote:

: the error does not occur until the script calls itself
: to save some settings to a database.  When I open or
: save the file that is being downloaded, it is the HTML
: that is supposed to display in the next step of the
: script.

Sounds like we'll need to see the code to provide
assistance.


Charles K. Clarkson
--
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328




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



RE: Browser wants to do a file download on a CGI script

2003-09-13 Thread Ron Goral
Thank you for the answer Joseph.  Sorry, I was not trying to shout with the
caps, merely attempting to set those comments apart from the other comments
in the code.

I had sent out another email to the list stating that I found the problem
and that it existed in the SaveChanges function.  I was printing a debug
string before printing the HTML page header.  It was very difficult to track
down as I had placed the line to print the page header in places I thought
were key in an attempt to trap the error.  But, of course, the error was not
where I thought it should be.  =)

As with the other email I'd sent to the list, I apologize for making the
inquiry before I had thoroughly checked my own code.

Ron Goral

-Original Message-
From: R. Joseph Newton [mailto:[EMAIL PROTECTED]
Sent: Sunday, September 14, 2003 12:17 AM
To: Ron Goral
Cc: Charles K. Clarkson; 'Perl Beginners'
Subject: Re: Browser wants to do a file download on a CGI script


Ron Goral wrote:



 sub main
 {
 #

Debugging #
 print $h_self{page_header} if $h_self{debug};


#---
 #

 # Create objects
 CreateObjects();# THIS EXECUTES

 # Create the database connection. Will exit if there is an error.
 CreateDatabaseConnection(); # THIS EXECUTES

 # Get configuration data.
 GetConfigData('dg_sc_config');  # THIS EXECUTES

 # Get the form data
 GetFormVars();  # THIS EXECUTES

 # Branch based on cmd
 # THIS BLOCK EXECUTES
 if ($FORM{cmd} eq 'login')
 {
 if (ValidateForm())
 {
 if (DoLogin())
 {
 SetLoginCookie();
 $FORM{cmd} = 'config_manager';
 }
 else{$FORM{cmd} = '';}
 }
 else{$FORM{cmd} = '';}
 }

 # THIS BLOCK EXECUTES
 if (!$LOGIN{auth_level}){GetLoginCookie();}

 # Check for authorization level and branch based on command
 # THIS BLOCK EXECUTES
 if ($LOGIN{auth_level})
 {
 my $auth = $LOGIN{auth_level};
 # Administrators
 if ($auth = 10)
 {
 if ($FORM{cmd} eq 'config_manager'){;}
 # Save changes to configuration settings
 elsif ($FORM{cmd} eq 'save_changes'  $FORM{form_name} =~
 m/config/)
 {if (SaveChanges()){$FORM{cmd} =
'confirm_config_changes';}}
 }
 else {$LOGIN{auth_level} = 0;}
 }
 else {$LOGIN{auth_level} = 0;}

 PrintAdminPage();
 }   #end main

 # Various methods defined here

Except the one we need to see.
Where is GetConfirmConfigScreen() defined?



 #WHEN THE CONFIGURATION CHANGES ARE SAVED, THE DATA IS SAVED TO THE
 DATABASE.

This comment is outside of any execution block.  Does the problem occur in
all.
On the assumption that you mean this occurs only in the confirmation branch,
I
would recommend that you look at the GetConfirmConfigScreen() function.


 #HOWEVER, THIS HERE DOCUMENT DOES NOT PRINT TO SCREEN.  INSTEAD, THE
USER

Please!  You can have our attention without shouting.


 #IS PROMPTED TO EITHER SAVE OR OPEN A FILE DOWNLOAD OF THE .CGI SCRIPT.
IF
 #THE FILE IS SAVED, IT DOES CREATE THE HTML, BUT IT IS IN A FILE NAMED
 #dgCartAdmin.cgi.  THE STRANGE THING IS THAT IF ONE OF THE OTHER COMMANDS
 ARE
 #SENT IN THE SCRIPT, THIS HERE DOCUMENT PRINTS EXACTLY AS IT SHOULD.
 printHTML;
 html
 head
 title$title$heading/title
 meta http-equiv=content-Type content=text/html; charset=iso-8859-1
 meta http-equiv=content-language content=en-US


The vast vajoprity of the content of the page itself is not relevant to the
question.  All code in the chain of execution is.  Please try to trace the
chain
of execution where the problem occurs, and send the definitions of all
subroutines called.

Joseph




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



RE: AOL and IP Address Changes

2003-08-14 Thread Ron Goral
Original -

I am writing a script that relies on retrieving the $ENV{REMOTE_ADDR} from
the user's browser. I'm depending on this for database information retrieval
rather than cookies or some type of javascripting since one cannot depend on
a user having either cookies or javascripting enabled in his browser. I've
run across an issue with an AOL user and am curious if this is a universal
problem with the AOL browser or just this person's particular browser
configurations. My script is handing the user off to a VeriSign secure
server. Sometime between when the user is handed off to the VeriSign server
and he is returned to my unsecured server, his IP address changes. Has
anyone encountered this? If so, what solution can you suggest.

Bob Showalter Replied -

You can't use REMOTE_ADDR for this purpose. His IP is being dynamically
assigned from a pool that any number of users will share over time. If you
don't want to use cookies (easiest approach, IMO), you can use a session ID
in your URL's. Javascript is necessary in either case.

My Reply -

The problem is manifest when I give up control of the user's browser to a
secure VeriSign server.  I cannot use a session ID in the URL since the
VeriSign server redirects to a specific URL and I cannot specify a dynamic
value for the URL.  I would like to do this with cookies, but as I stated
before, I cannot be dependent on the user's allowing cookies to be planted
in his browser.  Way too much paranoia out there.

I can figure a way to react to a changed IP, but my curiosity runs more
toward why this AOL browser is switching IPs during a session.  I could
understand if the user were to disconnect then reconnect his internet, but
this is just a change of web pages basically.  Perhaps this is just another
reason to avoid using AOL, but I'd like to discover a reason for this
seemingly arbitrary behavior.

Peace in Christ -
Ron Goral
[EMAIL PROTECTED]



AOL and IP Address Changes

2003-08-14 Thread Ron Goral
I am writing a script that relies on retrieving the $ENV{REMOTE_ADDR} from
the user's browser.  I'm depending on this for database information
retrieval rather than cookies or some type of javascripting since one cannot
depend on a user having either cookies or javascripting enabled in his
browser.  I've run across an issue with an AOL user and am curious if this
is a universal problem with the AOL browser or just this person's particular
browser configurations.  My script is handing the user off to a VeriSign
secure server.  Sometime between when the user is handed off to the VeriSign
server and he is returned to my unsecured server, his IP address changes.
Has anyone encountered this?  If so, what solution can you suggest.
Peace in Christ -
Ron Goral
[EMAIL PROTECTED]



RE: AOL and IP Address Changes

2003-08-14 Thread Ron Goral
Ah, I was under the impression that the IP would be changed if the internet
connection was broken, not between page requests.  Since VeriSign will not
produce a dynamic URL (one containing some sort of session or identification
information), I will probably have to fall back on user input if the ip is
new and/or not recognized.

Thanks for the input Bob.

Peace in Christ -
Ron Goral
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


-Original Message-
From: Bob Showalter [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 13, 2003 11:05 AM
To: 'Ron Goral'; Perl Beginners
Subject: RE: AOL and IP Address Changes


Ron Goral wrote:
 ...
 I can figure a way to react to a changed IP, but my curiosity runs
 more toward why this AOL browser is switching IPs during a session.
 I could understand if the user were to disconnect then reconnect his
 internet, but this is just a change of web pages basically.  Perhaps
 this is just another reason to avoid using AOL, but I'd like to
 discover a reason for this seemingly arbitrary behavior.

I don't really know the answer, but HTTP is not a session-oriented protocol.
Each request is independent of all other requests (HTTP 1.1 allows reusing
connections to a certain extent, but not for the purposes of maintaining a
session). Between a change of pages, the TCP connection is torn down and
built back up, so the IP is subject to change. AOL may be using a pool of
proxies and handing his requests off to different proxies in a
load-balancing scheme. The point is, you can't reliably use REMOTE_ADDR for
session management. You've got to pass some kind of data back and forth in
the request and response themselves.




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



RE: AOL and IP Address Changes

2003-08-14 Thread Ron Goral
Its a good thing I posted this question.  Folks are pointing the errors of
my ways.  Better to find out here than when things are live.  Good points
Jenda.  I think I'm going back to the drawing board and reconsider the
methods I am using.

Peace in Christ -
Ron Goral
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]



-Original Message-
From: Jenda Krynicky [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 13, 2003 12:53 PM
To: [EMAIL PROTECTED]
Subject: Re: AOL and IP Address Changes


From: [EMAIL PROTECTED]
 In a message dated 8/13/03 9:46:29 AM Pacific Daylight Time,
 [EMAIL PROTECTED] writes:

 I see,  you have no control of over the redirect.  Use  the IP address
 first and if it returns no match check for cookies. If the cookie
 returns nothing then create an popup input box with javascript.

I believe you should not be using the IP address at all.
What do you do if two users using the same proxy (and therefore IP
address) come to your pages at about the same time? Overwrite each
others data? What if user A comes, fills in some data, you redirect
him to VeriSign, some other user with the same IP comes, fills in
another data, you redirect him to VeriSign as well and then they come
back in any random order? If you use the IP address at least one of
them has the wrong data.

The IP may be useable on an intranet if you know the topology, but
otherwise it's just an aproximate note in the logs.

I would personaly insist on using cookies ... the number of people
that are paranoid enough to turn them off completely is not that big
and they usualy know what to do if you tell them that you need
session cookies. And if the cookie is well formated, local to the
server and doesn't try to get stored on disk there is no reason to
block it.

The only other solution I can think of is to use frames and
JavaScript. That is you create a frameset (possibly completely
invisible), store the session id the static frame, redirect in the
other and when the user comes back to your pages you fetch the
session from the static frame. The problem is that the people who
turned of session cookies are the same ones who will turn of
JavaScript.

Jenda
P.S.: It really surprises me that VeriSign doesn't let you attach a
session id to their URL that would then be attached back to the
return URL.
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery




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



RE: AOL and IP Address Changes

2003-08-14 Thread Ron Goral
Ah again.  I am not thinking on a large enough scale.  Thanks Bob, you've
been very helpful.

Peace in Christ -
Ron Goral
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]



-Original Message-
From: Bob Showalter [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 13, 2003 11:11 AM
To: 'Ron Goral'; Perl Beginners
Subject: RE: AOL and IP Address Changes


Bob Showalter wrote:
 ... AOL
 may be using a pool of proxies and handing his requests off to
 different proxies in a load-balancing scheme.

This in fact seems to be the case. cf:

   http://webmaster.info.aol.com/proxyinfo.html

Which contains this statement:

...When a member requests multiple documents for multiple URLs, each
request may come from a different proxy server.




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



RE: Improving the Quality of Our Beginners was Re: Write permissions and other rights

2002-04-25 Thread Ron Goral

Sorry Michael.  I was not clear there.  I was not saying that *you* flamed
*me*.  That did not happen.  I was speaking in a general sense to the
flamers on this board.  Please accept my apology for creating this
misconception.

As for Unix file permissions, have a look at the cover of Learning Perl.
At the top of mine it says UNIX Programming.  I do agree that the
mysteries of the *NIX OS should not be covered in a list like this, but some
issues (like having to set the proper permissions to enable a script to run
and security concerns as regards .htaccess/.htpasswd files and proper
directory formation) do need to be discussed with on a beginner's list.  If
nothing else, to provide that beginner with a springboard to find the more
in depth documentation he/she will need to be an effective programmer.

However, the point of this response is, again, to apologize to you, Michael,
for inadvertently implying that you had flamed me and I had words for you.
This was not the case at all.

Peace In Christ -
Ron Goral
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


 -Original Message-
 From: Michael Lamertz [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, April 25, 2002 5:52 AM
 To: Ron Goral
 Cc: Michael Lamertz
 Subject: Re: Improving the Quality of Our Beginners was Re: Write
 permissions and other rights


 Aye,

 Sorry, I'll reverse your quotes, because the following sentence struck
 me:

  If my questions are too remedial, then ignore
  them.  But don't open fire on me simply because I've asked a question.

 Where have I flamed you?  My response was completely *pro* your
 request.  %-)

 Let me quote the two last paragraphs of my own mail to you:

 -- snip --
 However, an appropriate answer on *this* *list* should have been a
 pointer to at least one or two introductory Unix books and
 perhaps some
 webpages (and although I dare to post this long rand I'm actually not
 able to provide you with any one, since I never read one %-)

 It's always hard to bootstrap oneself on a new platform, to get a grip
 on the system and a feeling for where to look for more information...
 Keep going, and keep on posting stuff here, you'll see, it'll get
 better, and you most probably wont get flamed by a kid with too much
 thestosterone everyday...
 -- snip --

 The only thing I didn't agree with was that topics like Unix file
 permissions should be covered in the perl documentation.  I explained my
 reasons for that at length, and I think they stand.

 But then again I agreed with you that the request *IS* valid for the
 beginners list, and that somebody who had good information on the topic
 should have replied to it instead of some zealot flaming around.

 We're completely in line I think.

 On Wed, Apr 24, 2002 at 08:28:08PM -0500, Ron Goral wrote:
  Well, I didn't get flamed, another potential coder did.  For
 the sake of
  brevity, the point of my message was simply this:  A beginner's
 list is for
  beginners.  Not folks with an intermediate knowledge of the
 subject.  It is
  for those of us who do not know what we are doing.  This is the place we
  should be able to go and ask the stupid questions and hope
 for an answer.

 Yepp, I completely agree, although I'm not for cutting out the
 intermediate level questions to another list.  Where will you draw the
 line between a beginner and an intermediate?

 If you fragment the lists you also fragment the community and eventually
 the more advanced users will stay away from the absolute-beginners list
 since they don't find it interesting or challenging enough.

  It is an incredible bonus that more knowledgeable coders
 actually take the
  time to patiently answer our questions.

 But don't you underestimate the value that these questions have for us
 who answer.  This is both give and take!  I'm programming perl since
 about 1994 or 1995, but *explaining* stuff to other folks makes me think
 not twice but trice about topics that I thought I had fully grasped
 years ago, and quite often I get a new insight by that process.

 I like that, and that's why I lurk on the list!

  But when the knowledgeable can no
  longer be patient, then they need to move on to a place where they are
  behind the curve and leave us alone.

 Agreed, and in that next sentence...

  I'm not on this list so that some kid
  can look down his nose at me.

 ...You describe exactly what kind of person we're talking about here.
 Don't take these kids serious, although they can be annoying some times,
 they tend to get bored and go away, but there will always be others who
 answer appropriately.

  Well, I'm getting long winded again and ya'll have better
 things to do than
  listen to me rant...again.

 Actually, yes and no.  I may be busy, but this topic is interesting and
 important, so keep on talking ...

 --
  If we fail, we will lose the war.

 Michael Lamertz|  +49 221

RE: Improving the Quality of Our Beginners was Re: Write permissions and other rights

2002-04-24 Thread Ron Goral

I have only recently started using Perl and the *NIX environment.  I am
grounded in C++ using MFC in a Windows NT environment.  Up until a few weeks
ago, the idea of having to set file permissions in order to execute a bit 'o
code was foreign to me as well.  In fact, there are many aspects of Perl
coding (whether for cgi or whatever) that just do not strike me in a
natural way.  I have not been raised on *NIX, therefore I don't know how
*NIX operates.

Yes, I can read the perldocs and the manpages, but, incredibly, these are
written with the notion that I have a half a clue about how to interpret
what chmod means.  And yes, yes, yes, reading more and more documents
means that eventually, you will come to understand a word or two here or
there.  However, the plain and simple fact is that until there is a document
written that assumes the reader knows NOTHING AT ALL about the *NIX
environment or what an awk is (yes, I finally know that awk is a shell
language), there is an incredible need for a forum where a potential coder
can come ask the obvious.  Since this list is called Beginners and not
Intermediate or Have half a clue, this is as good a place as any to ask
those kind of questions.  If it bothers you to see those kind of questions,
then move up the food chain and find a more advanced list.  If it bothers
you to answer those questions, then don't!!!

Notice the word potential above.  That is important.  Most of us reading
and writing to this list are beginners.  We are therefore potential
coders.  If the Perl community is such that it will flame a FNG for asking a
question, then I'd rather spend my time learning VB.  I can certainly make
more money and there is a very good IDE for it.

Besides, we all know the adage, Give a man a fish and you feed him for the
day.  Teach him to fish and you feed him for life.  They always leave off
the part that says But, smack him upside the head for asking a stupid
question and the world will loose a potential fisherman.  And you will gain
a potential enemy.

Well, I've said more than enough and I have better things to do.  Kudos to
drieux and those like him who know better than most of us here and take the
time to explain how and why.

BTB drieux, I was one of those 90 day wonders who was lucky enough to have
had excellent NCOs to teach me what life was really like.  I should write a
book entitled All I Really Needed To Know I Learned From My Platoon
Sergeant.

Peace In Christ -
Ron Goral
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]



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




RE: RegEx question

2002-04-24 Thread Ron Goral

You can also say:

use strict; # Always use strict =)
use CGI;
use CGI::Carp qw(fatalsToBrowser);  # Great for debugging
my $q = new CGI;# Create a new CGI object that will parse both POST and
GET methods

# Now to access those parameters use one of the following methods

# This requires Perl 5.06, but is very useful
my %PARAMS = $q-Vars;
# -- or -- #
# Now all the element names are in @PARAMS
my @PARAMS = $q-param;
# -- or -- #
# Accessing individual form elements based on
#   the name of the element.  Works well when
#   used in conjunction with an array of
#   element names
print qq[This is the value of SomeFormElement -
$q-param('SomeFormElement')];

As for the original question, the reason the transliteration operator was
being used to begin with is that when a URL is sent  to your script, it is
encoded and the + sign is used to encode a   (space).  So, the form
element value My Home Page gets sent as My+Home+Page.  Using the code
above, in any of its forms, is cleaner and more efficient.

Peace In Christ -
Ron Goral
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


 -Original Message-
 From: Shaun Fryer [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, April 23, 2002 5:49 PM
 To: Perl Beginners
 Subject: Re: RegEx question


   I have been using the below subroutine for Parsing my data from forms.

 Up until recently I was using cgi-lib.pl's ReadParse routine to do the
 same thing. Since the one you are using is quite similar you can
 easily port existing scripts using the following in place of that
 subroutine.

 use CGI;
 CGI::ReadParse(*formdata);

 ===
  Shaun Fryer
 ===
  London Webmasters
  http://LWEB.NET
  PH:  519-858-9660
  FX:  519-858-9024
 ===






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




RE: browsing html pages

2002-04-21 Thread Ron Goral

I have recently taken a stab at this myself.  There is probably an easier
way, but I could not make ::TreeBuilder respond well.  I had to sub-class
it.  I'm sure that drieux has some wisdom about this and how to do it more
easily.  =)

Peace In Christ -
Ron Goral
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


 -Original Message-
 From: drieux [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, April 20, 2002 10:03 AM
 To: [EMAIL PROTECTED]
 Subject: Re: browsing html pages



 On Friday, April 19, 2002, at 01:22 , Martin wrote:

  Hi Yo!
 
  As a Perl rookie I've got a serious problem trying to find out how to
  write
  a code which should do the following stuff: connect to
 specified URL using
  HTTP, send GET / PUT messages and process the output (web page) from the
  server. I went throug my Perl guidebook but found nothing according to
  this
  subject. Can anybody give me a hint (and/or suggest a good
 reference guide
  for
  Perl on the internet) ?

 while Not A Good Illustration but one that I know works

 http://www.wetware.com/drieux/src/unix/perl/UglyCode.txt

 my Illustration of how to do this for a friend is:

 http://www.wetware.com/drieux/CS/lang/Perl/Beginners/for_thog.txt


 The Funk is in 'parsing the webPage' - and for that I
 have found that having HTML::TreeBuilder is OBLIGATORY
 unless you want to do all the heavy lifting on your own.



 ciao
 drieux

 ---





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




RE: Perl CGI with ISP - advice?

2002-04-16 Thread Ron Goral

These modules you mention, except AnyData::CSV, are in a standard Perl
install.  As such, if the ISP has Perl installed, they will be there. Go to
http://www.scriptsolutions.com/programs/free/perldiver/ and download
perldiver.  It is free.  Place it in the cgi-bin directory (or where ever
you plan to run your scripts from) and then just enter its address in the
address bar of your browser.  It will give you all sorts of good information
including a list of all the modules installed on the server.  Another good
source for a script that does a similar thing is
http://www.groundbreak.com/cgiperl/helper.zip.  This one will produce links
to the CPAN modules associated with the installed modules.  In my mind, it
is better.

Peace In Christ -
Ron Goral
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


 -Original Message-
 From: John Brooking [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, April 16, 2002 3:18 PM
 To: Beginners CGI
 Subject: Perl CGI with ISP - advice?



 Hi,

I'm writing a Perl-based system to allow simple site content
 management through web forms. I'm a relative beginner to both
 Perl and CGI, although I have much experience with C, Visual
 Basic, and relational database programming. The system I'm
 writing is targeted to non-profits and small businesses, the
 kinds of outfits which typically will have sites hosted by an
 ISP, not on their own hardware with their own people to
 administer it. So my software will need to be (1) small, and (2)
 installable to a virtual domain cgi-bin path by FTP with normal
 owner permissions, not system admin and/or shell access. I've
 found that this cuts down on available technology quite dramatically.

One hesitation I have is that most Perl modules assume that
 you can run an install procedure to install the module in your
 system. If an outfit has only FTP access to its virtual domain,
 not shell access or sysadm privilege, the only thing you can do
 is copy the module's files over from some other place you've
 installed them (such as my PC's hard drive). This seems to be
 working with two of the modules I've used so far (HTML::Template
 and AnyData::CSV), but I'm hesitant to rely too much on a lot of
 them. Obviously, you run a risk if a module has platform-specific
 functionality. I'm particularly shy of CGI.pm, both due to size
 and also uncertainty of if it can be installed by a simple file copy.

I'd appreciate any advice anyone could give on the
 difficulties I might encounter in this endeavor, in particular
 module size and ability to install on an ISP-hosted virtual
 domain by FTP alone. Should I be convincing the ISP to install
 the modules in their /site/lib instead, rather than us putting
 them in our virtual domain? Is CGI.pm recommended in this
 situation? Any other issues you would foresee me having? (I
 already know I'll have to think through security at some point.)
 Thanks in advance for any replies.

 - John Brooking



 -
 Do You Yahoo!?
 Yahoo! Tax Center - online filing with TurboTax



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




How to do a cron job?

2002-04-15 Thread Ron Goral

Can someone point me toward resources on how to conduct a cron job in script? I
have no access to the server via telnet, so this would have to be script based. I
am using the Perl command sleep $sec now, but there may be some issues with
that. Self perpetuation can be a bad thing for system resources.

Peace In Christ -
Ron Goral
[EMAIL PROTECTED]





RE: How to do a cron job?

2002-04-15 Thread Ron Goral

It is a Linux server.  Sorry I didn't make it more clear, not only do I not
have telnet access, neither do I have command line access.  As for the man
on crontab, I could not locate that nor is it covered at www.Perl.org.
However, there is a nice little tutorial at
http://www.superscripts.com/tutorial/crontab.html.  (Should have done a web
search first before bothering you good people.)

Peace In Christ -
Ron Goral
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


-Original Message-
From: Nag, Somnath, ALINF [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 15, 2002 10:33 AM
To: [EMAIL PROTECTED]
Subject: RE: How to do a cron job?


Ron :

What is the operating system you R using ?
If its Unix then you can use crontab.
Do a man on crontab and it can guide you.

Let me know.
Somnath

-Original Message-
From: Ron Goral [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 15, 2002 11:27 AM
To: [EMAIL PROTECTED]
Subject: How to do a cron job?


Can someone point me toward resources on how to conduct a cron job in
script? I
have no access to the server via telnet, so this would have to be script
based. I
am using the Perl command sleep $sec now, but there may be some issues
with
that. Self perpetuation can be a bad thing for system resources.

Peace In Christ -
Ron Goral
[EMAIL PROTECTED]



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




RE: How to do a cron job?

2002-04-15 Thread Ron Goral

Yes, I want to be able to check mailboxes; this is a script to create and
manage mailing lists.  So, I want to be able to collect and distribute
emails sent to a list, respond to subscriptions/unsubscriptions, requests
for help, etc. without having to have a human monitor the mailboxes all the
time.

My reasons for not having telnet access is that the hosting company wisely
requires a secure telnet connection with a program capable of generating RAS
keys.  They've recommended Van Dyke's SecureCRT, but that is $99 program.
Not really in the budget.  I've looked at some others, but they don't seem
to be as capable as SecureCRT, nor do most of them generate keys.  The price
would be worth it, I think, if I had the bucks. =)  A common dilemma.

Peace In Christ -
Ron Goral
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


-Original Message-
From: drieux [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 15, 2002 11:16 AM
To: [EMAIL PROTECTED]
Subject: Re: How to do a cron job?



On Monday, April 15, 2002, at 08:52 , Ron Goral wrote:

 It is a Linux server.  Sorry I didn't make it more clear, not only do I
 not
 have telnet access, neither do I have command line access.  As for the man
 on crontab, I could not locate that nor is it covered at www.Perl.org.
 However, there is a nice little tutorial at
 http://www.superscripts.com/tutorial/crontab.html.  (Should have done a
 web
 search first before bothering you good people.)

This sounds a bit like 'cogito ergo pallamino'
- getting de carte before de horse -

p0: For cron to 'run' a job - it will need to be installed
in some users account - hence if you can not login
and get a 'command line'/'shell' - then cron would not
be able to run the 'job' as you.

what happens when you 'create a cron job' is that a file on the
unix box on a 'per user' basis is put into /var/spool/cron/user
and will generically look like say:

[root@disky cron]# cat root
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.2437 installed on Wed Mar 20 14:56:56 2002)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
0 0 * * * /usr/local/lib/smail/savelog -c 30 /var/smail/log/logfile
0 0 * * 1 /home/lyris/bin/lyris dbpack
0 3 * * * cd /backups/dumps ; /backups/dumps/bin/do_dump
[root@disky cron]#

this 'per user' approach also means that when cron runs the job,
it will generate email to that user.

 Subject: How to do a cron job?

 Can someone point me toward resources on how to conduct a cron job in
 script? I have no access to the server via telnet, so this would have to
 be script based. I am using the Perl command sleep $sec now, but there
 may be some issues with
 that. Self perpetuation can be a bad thing for system resources.

So you might want to re-think the problem

Cron is more for problems like,

I want to run this script every day, week, month

where you know that any given run of the script will finish before
there is any chance of the next run. { I get concerned about using
cron to run jobs any faster than once an hour that way can lead
to the need to get into processes lock outs - so that the new one will
not start if another one is still running... }

If your script 'works' each time - and you want to make sure that it
will always be run once a 'reasonably large interval' - then you need
to get it installed on the 'server' and have an account on the server
so that you can do the 'crontab -e' to edit your crontab file and
put in your iterator like above.

0 3 * * * MyCoolScript

and it will run at 3am each day

So we are back to the problem -

why are you in a 'sleep' cycle in your script?

Is it a matter that it needs to be continuosly running?


ciao
drieux

---




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




Trouble with HTML::Parser

2002-03-29 Thread Ron Goral

Would someone be kind enough to tell me why the code below does not work?
It is a library of sorts and resides in a file separate from the main cgi
(hence the 1; at the end).  It is activated with the call
MapFormData($fileName).  The print statements in MapFormData print to the
screen as I want and there are no errors either printed to the log file or
that kill the script.  However, neither the procStart subroutine nor the
procEnd subroutine are invoked.  I am not able to determine what the problem
is.

## CODE SAMPLE FOLLOWS ##

use strict;
use HTML::Parser;
use HTML::Entities qw(decode_entities);
require dgcommon.cgi;

open(STDERR,dglogs/dgformapper.log)
or die(Could not open or create dgformapper.log: $!);
chmod 0666, dglogs/dgformapper.log;

sub procStart
{
my ($tagname,$attr,$attrseq) = @_;
print qq[bi$tagname -/i/bbr];
for my $i(0..@$attrseq)
{
print qq[@$attrseq[$i] is %$attr-{@$attrseq[$i]}br];
}
}   # end procStart

sub procEnd
{
my ($tagname) = @_;
print qq[End $tagnamebr==brbr];
}   # end procEnd

sub MapFormData
{
my @formTags = qw(form input textarea button select option);

print qq[Entering MapFormDatabr];

my ($formUrl) = shift;

print qq[Just got $formUrlbr];

open(FORMFILE,$formUrl)?
print qq[Just opened $formUrlbr]:
LogEntry(\*STDERR,dgformapper,MapFormData,
Could not open $formUrl,$!);

my $p = HTML::Parser-new (api_version = 3,
start_h = [\procStart, tagname,attr,attrseq],
end_h = [\procEnd, tagname],
report_tags = [\@formTags ],
);

print qq[Created new HTML::Parser objectbr];

my $retVal = $p-parse_file(\*FORMFILE);

ref($retVal)?
print qq[Parsed the filebr]:
LogEntry(\*STDERR,dgformapper,MapFormData,
Could not parse file $formUrl,$!);
}

1;

## END OF CODE SAMPLE ###

Thanks in advance -
Peace In Christ -
Ron Goral
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


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




RE: Making my own error.logs

2002-03-21 Thread Ron Goral

You can very easily create your own error logs.

my $errLog = qq[logs/errorLog.log];
open(STDERR, $errLog)?LogEntry(\*STDERR,Opened error log $errLog):die
(Could not open $errLog. Reason: $!);
my $number = 10;
$number eq 50?LogEntry(\*STDERR,$number equals
50.):LogEntry(\*STDERR,$number does not equal 50 you silly person.,$!);

#--#
# LogEntry is a subfunction that makes log entries.
#--#
sub LogEntry
{
my ($FH,$message,$error) = @_;
my $date = `date`;
chomp($date);
print $FH Date: $date\nMessage: $message\nReason: $error\n\n or
die(Could not make a log entry.\nReason:\n$!\n);
}   #end LogEntry


Use STDERR for your error log file handles so that you will catch all
errors.  Useful when your script runs with the -w switch.  Chomp the date
because the system date function returns a string with a \n on the end of
it.  The rest is just formatting.  If you use a consistent format for your
error logs, then you can build a viewer to view your logs.  Just something
that makes reading about errors easier.  Also with this kind of setup, you
can make entries for anything you want.  Notice I made a log entry right
away to let myself know that the error log was opened successfully.

HTH -
Peace In Christ -
Ron Goral
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


-Original Message-
From: Elaine -HFB- Ashton [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 20, 2002 6:24 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: Making my own error.logs


[EMAIL PROTECTED] [[EMAIL PROTECTED]] quoth:
*My new web hosting service at oneononeinternet.com doesn't have error logs
*for each site. What do I do?
*
*Is there a way for me to create my own logs for my perl files?

You probably would benefit from buying
http://www.amazon.com/exec/obidos/ASIN/1565926471/

e.


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




Commonality of module installation

2002-03-06 Thread Ron Goral

I am working with some hashes and found that you can maintain an ordered hash
using Tie::IxHash.  The server my site lives on does not have this module
installed.  Is this module commonly installed on machines? In other words, can I
count on this module being present on some user's server or would I need to
stipulate that as a requirement for using the script?

Thanks in advance -
Peace in Christ -
Ron Goral



arrays and refs...argh!

2002-02-15 Thread Ron Goral

Can someone please tell me why the following code only returns the last
element in the referenced array?  If I put the foreach routine inside the
while loop, I get a printout of each element in both the $sqlRes reference
and the $colNames reference.  But, if I print outside the while loop, I only
get the last reference put in the $sqlRes reference.  Please help.

# Reference to a set of references
my $sqlRes;

# Fetch each row of data, put into an array ref and push into the main array
ref.
while (my $colNames = $sth-fetchrow_arrayref)
{
push(@{$sqlRes},$colNames);
}

foreach my $arrayRef(@{$sqlRes})
{
foreach my $refRef(@{$arrayRef})
{
print $refRef;
print qq[br];
}
}


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




Open a brand new browser window with Perl

2002-02-07 Thread Ron Goral

Is it possible to open a brand new browser window and set it's size,
location and characteristics (no menu bar, no status bar, etc.) using Perl
or is it necessary to always use the same window that has called the script?


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




RE: Open a brand new browser window with Perl

2002-02-07 Thread Ron Goral



I hate it when I make a post and then answer my own questions, but Morbus
made me recall the window resizing and moving methods useable via
JavaScript.  If I were to print the new page with an onLoad event that
called the resizeTo and moveTo methods, I can resize and move my windows
anywhere I wish.  It's not a new window, but it sure walks and talks like
one.  The same is true of all the window properties.

Sorry 'bout the bad post guys.

Ron

 Is it possible to open a brand new browser window and set it's size,
 location and characteristics (no menu bar, no status bar, etc.) using Perl
 or is it necessary to always use the same window that has called the
script?

With Perl, no. But you can certainly tell Perl to send some javascript that
does what you want to the browser. Have Perl spit out something like this
to the browser window:

  html
  head
 SCRIPT LANGUAGE = Javascript TYPE=text/javascript!--
 function open() { window.open('/path/to/file.shtml', 'Your New Window',
 'height=125,width=360,toolbar=no,scrollbars=no,menubar=no,location=no,
 directories=0,status=no,resizable=0'); }
 //--/SCRIPT
 titleSee Other Window/title
  /head
  body onLoad=open()

   h1Please See The Other Window/h1

  /body
  /html



--
Morbus Iff ( softcore vulcan pr0n rulez )
http://www.disobey.com/  http://www.gamegrene.com/
please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus


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




UFO (Unidentified Formatting Observation) on the web....

2002-02-01 Thread Ron Goral

I have a very beginner's question.  I've just been looking at the code for a
library file and noticed some, to me, very peculiar things.  First, there is
text that is not commented, it is just typed in place.  Why does this not
interfere with the script?  Second, there are expressions like =pod and
=cut and =head1.  What do these mean?  Third, there is a 1; at the
very end of the file.  I've seen that before, but what is the purpose?
Fourth, there is text like Idelete_cookie blah blah and BMUST (I
assume that this last is a comment on text decoration).  Can anyone tell me
what these mean?  Is there a difference in a library file and a regular
script file that allows for this?   Is there some tutorial or documentation
about the differences in writing a library/module versus a normal script
file?


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