Re: New Website for Perl Beginners: perlmeme.org

2005-10-03 Thread Rob Bryant
On 10/2/05, Ovid <[EMAIL PROTECTED]> wrote:

> There's more and nitpicking seems petty 

Yep, you're right on the money with that. It does indeed seem petty.
So did Randal "I am Unhealthily Obsessed With The Flinstones"
Schwartz's earlier post. One would assume (apparently erroneously,
however) that the "perl community" would generally be more
enncouraging than discouraging the kind of effort the original poster
put forth.

Anyway, this thread wasn't a complete waste. Now I remember why I
always start to use Perl but then abandon it-- great tool, crappy
community.

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




RE: HTML::Template is choking

2004-09-28 Thread Hanson, Rob
> The nested quotes in my attempt to put TMPL_VARs
> into the value field make me suspicious that I 
> am misusing HTML::Template

It may look odd, but the nested quotes are fine.

If I had to guess I would say it is because there is a newline within the
tag (as it seems to be in your example).  I tried it on my installation and
*did not* get an error.  I am running version 2.7.

Looking at the change log this was something that was added in version 2.3.
So if you are running anything older than 2.3 it may be time for an upgrade.

[From: http://search.cpan.org/src/SAMTREGAR/HTML-Template-2.7/Changes]
2.3 Thu June 28 12:00:00 2001
   - New Feature: template tags can now span lines.  (Roland Giersig)

Rob

-Original Message-
From: Rick Triplett [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 28, 2004 2:39 PM
To: [EMAIL PROTECTED]
Subject: HTML::Template is choking


HTML::Template is choking with the complaint ...

HTML::Template->new() : Syntax error in  tag at /XXX[here I'm 
ommiting the path]/data/templates/student_info.tmpl : 13. at 
/usr/local/lib/perl5/site_perl/5.005/HTML/Template.pm line 2243.

This is a typical line from my template ...

" size="40" maxlength="40">

This isn't much code to look at, but I'm hoping my blunder will be 
obvious to someone with more experience. The nested quotes in my 
attempt to put TMPL_VARs into the value field make me suspicious that I 
am misusing HTML::Template. Anyone have some words of wisdom for me?
Rick T.


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


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




RE: image manipulation (scaling)

2004-09-17 Thread Hanson, Rob
The best module that I know of for scaling is Image::Magick.  I didn't find
the docs very easy to navigate, but it does a very good job.

[Very light documentation]
http://search.cpan.org/~jcristy/PerlMagick-6.02/Magick.pm

[Additional docs]
http://www.imagemagick.org/www/perl.html

The code you want would be something like this:

use Image::Magick;

my $image = Image::Magick->new;
$image->Read('logo.jpg');
$image->Crop(geometry=>'100x100"+100"+100');
$image->Write('x.jpg');


Rob

-Original Message-
From: Ingo Weiss [mailto:[EMAIL PROTECTED]
Sent: Friday, September 17, 2004 12:19 PM
To: [EMAIL PROTECTED]
Subject: image manipulation (scaling)


Hi all,

I need have my CGI scale images on the server, and I was wondering
whether there is a "standard" perl module that can do that (and possibly
other image manipulation tasks). I am looking for one that:

- is easy to understand and use
- is likely to be already installed on the server or so well known that
my hosting provider is likely to agree to install it for me.


Thanks for any hint!

Ingo

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


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




RE: PHPerl

2004-09-08 Thread Hanson, Rob

There is embperl like was mentioned.  Also Mason is very popular and well
documented.

Rob

-Original Message-
From: Octavian Rasnita [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 08, 2004 11:57 AM
To: [EMAIL PROTECTED]
Subject: PHPerl


Hi all,

Is there a way to embed Perl programs in html like PHP can do?
I heard that Perl can be used in ASP files, but I am wondering if there is
an Apache module for that task.

It would be cool to exist such a thing...

Thanks.

Teddy


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


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




RE: Month-Year Links....

2004-09-07 Thread Hanson, Rob
One note... if you have a daylight savings time that takes effect between
11pm and 1am this won't work.  In the US DST is 2am, so it is safe.

Also, this might be a prettier solution...

use Time::Local;
use constant DAY => 86_400;

$current = time;
$previous = subtract_month(time, 1);
$current_2 = subtract_month(time, 2);

print get_date($current), "\n";
print get_date($previous), "\n";
print get_date($current_2), "\n";

sub subtract_month
{
  my $time = shift;
  my $months = shift;

  if ($months) {
$time = subtract_month(first_day($time) - DAY, --$months)
  }

  return $time;
}

sub first_day
{
  my $time = shift;
  my @time = localtime($time);
  $time[3] = 1;
  return timelocal(@time);
}

sub get_date
{
  my $time = shift;
  my @time = localtime($time);
  return sprintf('%02d-%04d', $time[4]+1, $time[5]+1900);
}




-Original Message-
From: Hanson, Rob 
Sent: Tuesday, September 07, 2004 6:33 PM
To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
Subject: RE: Month-Year Links


The trick is to use Time::Local to find the first day of the month, then
subtract 1 day.

This prints:
09-2004
08-2004
07-2004

###
use Time::Local;
use constant DAY => 86_400;

$current = time;
$previous = first_day($current) - DAY;
$current_2 = first_day($previous) - DAY;

print get_date($current), "\n";
print get_date($previous), "\n";
print get_date($current_2), "\n";

sub first_day
{
  my $time = shift;
  my @time = localtime($time);
  $time[3] = 1;
  return timelocal(@time);
}

sub get_date
{
  my $time = shift;
  my @time = localtime($time);
  return sprintf('%02d-%04d', $time[4]+1, $time[5]+1900);
}



-Original Message-
From: Greg Schiedler [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 07, 2004 5:01 PM
To: [EMAIL PROTECTED]
Subject: Month-Year Links


Perl v5.6.1

Trying to easily create some variable based on the current month and links
to the two
previous months.  The filename(s) are based on two digit months
MM--Filename.  I have the
filename part working but I need some guidancd on creating the MM-.  I
have seen many
perl modules that I could install to implement a solution but I think that
is an overkill
just to make create a current month, previous month and two months ago
variables.

RedHat ish OS Cobalt RaQ4i to be specific

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

Ie.
$current = "09-2004-Filename"
$previous = "08-2004-Filename"
$current_2 = "07-2004-Filename"

Does anyone have a simple solution?

Greg





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


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


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




RE: Month-Year Links....

2004-09-07 Thread Hanson, Rob
The trick is to use Time::Local to find the first day of the month, then
subtract 1 day.

This prints:
09-2004
08-2004
07-2004

###
use Time::Local;
use constant DAY => 86_400;

$current = time;
$previous = first_day($current) - DAY;
$current_2 = first_day($previous) - DAY;

print get_date($current), "\n";
print get_date($previous), "\n";
print get_date($current_2), "\n";

sub first_day
{
  my $time = shift;
  my @time = localtime($time);
  $time[3] = 1;
  return timelocal(@time);
}

sub get_date
{
  my $time = shift;
  my @time = localtime($time);
  return sprintf('%02d-%04d', $time[4]+1, $time[5]+1900);
}



-Original Message-
From: Greg Schiedler [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 07, 2004 5:01 PM
To: [EMAIL PROTECTED]
Subject: Month-Year Links


Perl v5.6.1

Trying to easily create some variable based on the current month and links
to the two
previous months.  The filename(s) are based on two digit months
MM--Filename.  I have the
filename part working but I need some guidancd on creating the MM-.  I
have seen many
perl modules that I could install to implement a solution but I think that
is an overkill
just to make create a current month, previous month and two months ago
variables.

RedHat ish OS Cobalt RaQ4i to be specific

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

Ie.
$current = "09-2004-Filename"
$previous = "08-2004-Filename"
$current_2 = "07-2004-Filename"

Does anyone have a simple solution?

Greg





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


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




interactive perl programing

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

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

--
[EMAIL PROTECTED]


 The trouble with the rat-race is that even if you win
 you'r still a rat.
 Lily Tomlin


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



Active 'back' buttons

2004-03-29 Thread Rob Dixon
Hi guys.

What's the 'usual' way (if there is one) of implementing an 'active' back
button (which does the equivalent of the browser's back button but is
implemented in CGI code)?

If, say, I'm doing a database search and come up with a list of records,
each of which can be clicked on to provide the complete data for the single
record, how do I get back to the page with the list of records?

Obviously I can pass all the search criteria to the detail script and have
it pass them back again to repeat the search. But I know there must be a
better way to do it.

Thanks for any help.

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: quote marks in DBM

2004-02-08 Thread Hanson, Rob
> Must I abandon trying to get double-quote marks
> into my hash element?

No, it would be silly if the language didn't support that.  And I want to
apologize for my long winded answer that is to follow... I guess I just felt
like typing.

...

As for an answer I think some explanation is needed, otherwise it won't help
much the next time you have a problem.

The hash value is just a scalar value, and a scalar can hold ANY type of
data... even binary.

There are several ways to quote a scalar value...

Single-quotes: 'Hello World'

The value in the quotes is NOT interpolated (meaning it won't look for
variables in the value), and the single-quote (') must be escaped with a
backslash if you want to have one in the string (e.g. 'The\'re here').

Double quotes: "Hello World"

The value in the quotes IS interpolated (meaning variables in the value are
converted to their string value), and double-quotes(") must be escaped with
a backslash if you want to have one in the string (e.g. "Robert \"The
Hacker\" Hanson").

The q() operator: q(Hello World)

The value is treated like a single-quoted string, EXCEPT that the delimiter
is not a single-quote('), it is the character following the "q".  The end
delimiter is either the closing brace/bracket/paren OR the same character as
the opening delimiter.  Some examples: q|Hello World|, q{Hello World},
q*Hello World*.

The qq() operator: qq(Hello World)

Same as the q() operator, but acts like the double-quotes because it does
interpolate.

Anyway, there are several solutions to your problem, which can be handled
however you like best (1 uses the escape (\), the others use a different
delimiter)...

%database = (
...
q_1 => "\"Excretion" is getting rid of __ material.",
q_2 => '"Excretion" is getting rid of __ material.',
q_3 => q{"Excretion" is getting rid of __ material.},
q_4 => qq|"Excretion" is getting rid of __ material.|,
...
);

BTW - I unquoted the hash keys.  They only need to be quoted if there are
spaces or special characters in them.  In this case they will automatically
be treated as single quoted strings without having to actually use quotes
around them.  It's really a matter of preference on if you want to
explicitly quote them, I tend to prefer not to (less quotes = less clutter).

Rob

-Original Message-
From: Rick Triplett [mailto:[EMAIL PROTECTED] 
Sent: Sunday, February 08, 2004 5:26 PM
To: [EMAIL PROTECTED]
Subject: quote marks in DBM

The following snippet of code is from "Programming the Perl DBI" and 
shows the storing of a hash element that contains both a comma and a 
sort-of double quote. (In the book, double quotes are shown; in the 
book-file, it looks like back tics and single quotes.)

...
### Insert some data rows
$database{'Callanish I'} =
 "This site, commonly known as the ``Stonehenge of the North'' is in 
the
form of a buckled Celtic cross.";
...

The next snippet is from code I wrote which didn't compile (choked on 
the repeated double quote marks as I attempted to put the word 
"Excretion" in quotes.

%database = (
...
"a4_2" => "releasing energy from food",
"q_3"  => ""Excretion" is getting rid of __ material.",
"a1_3" => "excess",
...
);

Must I abandon trying to get double-quote marks into my hash element 
for later printing to the screen? I can live with single-quotes if I 
must.


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


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




RE: Hidden field on a form in perl

2003-11-21 Thread Hanson, Rob
I'll see if I can explain it gently as you seem to be a gov't worker ;)

There is no "perl" translation... you just aren't thinking about it in a
web-app type of way.  The sequence would look like this...

1. display page "A" to user
2. user submits page "A" with hidden form field
3. perl script process input from page "A"
4. perl script prints new form page, creating a new hidden input field that
has the value that the script recieved from step 3.

If that makes sense, then the rest is easy... but I am sure something there
won't make sense.  So you might need to ask a more detailed question.

BTW - for step #3 you would probably use the CGI module to extract the form
data from the input to the script.  The code for steps #3 and #4 might look
like this...

use CGI qw(:cgi);

my $hidden_val = param('name_of_hidden_field');

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


 
 
 



EOF



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Friday, November 21, 2003 2:21 PM
To: [EMAIL PROTECTED]
Subject: Hidden field on a form in perl


I was wondering if anyone knows how to hide a field in a form so that it 
can be passed on to other forms, mainly for version number and some other 
information that i wish the user not to see and/or change. I know in HTML 
i could simply  yet I've 
looked through the manpages and a few books and can't seem to find the 
translation for this in perl. I will say I've only been using perl for 
maybe 3 weeks, so if your response is RTFM... i ask that you refer me to 
what section of the FM i should look to.

Thank you for any and all assistance.

Derrick 

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



RE: quotes problem

2003-10-20 Thread Hanson, Rob
I'm not sure if John or Greg from the previous answers understand the
question... or maybe it is me that is misunderstanding it.

You are receiving a string from the query string that includes quotes, but
it isn't printing the whole value.  Correct?

If that is the case, I am not sure I know where the problem is, even though
you say you do.

For example, this works fine:

my $x = 'This is the string "which" contains the quotes';
print $x, "\n";
print qq|
$x
|;

Once the quote is inside the variable you don't need to do anything special
to print it.

If you could give us an example of the query string, maybe that would help.
My guess would be that the query string is malformed.

Rob


-Original Message-
From: Sara [mailto:[EMAIL PROTECTED]
Sent: Sunday, October 19, 2003 6:56 PM
To: beginners-cgi
Subject: quotes problem


##
use CGI;

$q = new CGI;

my $field = $q->param('field');

print qq|
$field
|;
#

# Lets Suppose the form Input contains the quotes in the string e.g.

$field = "This is the string "which" contains the quotes";

The script stops printing everything after first quote ("), I KNOW where the
problem is but at a loss to prevent it as I have tried all the options

Any help!!!.

thanks,

Sara.

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



RE: Where is Apache::Session

2003-10-20 Thread Hanson, Rob
On CPAN.

http://search.cpan.org/~jbaker/Apache-Session-1.54/

Rob

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, October 20, 2003 6:15 PM
To: [EMAIL PROTECTED]
Subject: Where is Apache::Session


I'm looking for the download of Apache::Session.
There is a lot of docs on it but where is the download?

thanks


-
eMail solutions by 
http://www.swanmail.com

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

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



Re: Laying Out HTML Forms

2003-10-16 Thread Rob Dixon
Casey West wrote:
>
> It was Wednesday, October 15, 2003 when Rob Dixon took the soap box, saying:
> : Does anyone know of a tidy way to go about the tedious
> : business of laying out HTML forms using enclosing 
> : tags?
>
> I admit that the internals of CGI::FormBuilder are less than
> desirable, it does a good job of taking the load off.  I'd take a look
> there first.

Thanks Casey. I hadn't played with this (huge!) module before, but it
looks like yours is the only answer I'm going to get.

I'd better start reading!

Cheers,

Rob



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



Laying Out HTML Forms

2003-10-15 Thread Rob Dixon
Does anyone know of a tidy way to go about the tedious
business of laying out HTML forms using enclosing 
tags?

Thanks,

Rob



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



Re: Date to seconds

2003-09-17 Thread Rob Dixon

Kit-Wing Li wrote:
>
> Does anybody know of a quick method in perl to turn a date string into its
> equivalent in seconds, include milliseconds if possible?  Ex: 20030910
> 13:50:25.6 to 1063202644.  Thanks much!

The Date::Manip module will do it for you easily, as long as you're
not worried about size or performance. See below.

HTH,

Rob


use strict;
use warnings;

use Date::Manip;

my $date = ParseDate('20030910 13:50:25.6');
my $seconds = UnixDate($date, '%s');

print $seconds, "\n";

** OUTPUT **

1063230625






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



RE: accessing a hash map...

2003-09-09 Thread Hanson, Rob
You have it slightly wrong...

print $hashref{'disks'}->{'io'};

...And the quotes are optional (usually)...

print $hashref{disks}->{io};

> Is there a more generic mailing list
> for the different perl modules?

Thare are other lists/newsgroups, but most are geared to specific port
(ActiveState), or modules (Tk).  This is a good list for any beginner(ish)
question, no matter the subject... just as long as it is a Perl question.

Rob

-Original Message-
From: Li, Kit-Wing [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 09, 2003 2:40 PM
To: cgi cgi-list
Subject: accessing a hash map...


This may not be the right thread but I'd like to see if someone could point
me to the right direction.  I'm writing a CGI script to show current
performance of the Apache server and I'm using Linux::stat to get the disk
IO for example.  I can seem to access the value of the hash reference(see
below).  Does anybody have any thoughts?  Is there a more generic mailing
list for the different perl modules?  I know there's the mod_perl thread but
its more for Apache.  Any help will be greatly appreciated.  Thanks!

use Data::VarPrint;
use Linux::stat;

my $stat = Linux::stat->new( [ stat => "path to /proc/stat" ] );
my $hashref = $stat->stat();

print $hashref{'disks'}=>{'io'};




--
This message is intended only for the personal and confidential use of the
designated recipient(s) named above.  If you are not the intended recipient
of
this message you are hereby notified that any review, dissemination,
distribution or copying of this message is strictly prohibited.  This
communication is for information purposes only and should not be regarded as
an offer to sell or as a solicitation of an offer to buy any financial
product, an official confirmation of any transaction, or as an official
statement of Lehman Brothers.  Email transmission cannot be guaranteed to be
secure or error-free.  Therefore, we do not represent that this information
is
complete or accurate and it should not be relied upon as such.  All
information is subject to change without notice.


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

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



RE: File existence under Microsoft IIS

2003-09-05 Thread Hanson, Rob
The -e test does work on MS-Win, not sure what the problem might be.  One
thing I can think of is that you should avoid relative paths because IIS
will set the current directory to C: (if I remember correctly).

These work for me on Win2K:

print -e 'C:/Perl';
print -e 'C:/Perl/bin/perl.exe';
print -e 'C:/Program Files';
print -e 'C:/Program Files/WinZip';

Rob


-Original Message-
From: Mike [mailto:[EMAIL PROTECTED]
Sent: Friday, September 05, 2003 9:13 PM
To: [EMAIL PROTECTED]
Subject: File existence under Microsoft IIS


Hello,

I have been trying a number of ways to determine whether a file exists in a
particular directory, but to no avail.
The perl books I have (and many web sites/forums I have checked) mention the
'-e' test on a filehandle or filename, but it returns false (the file does
not exist) even if it does.  I have used code such as:

if (-e 'filepath/filename') { # using absolute naming with full pathname
etc.
  # display the file (image) in the HTML output
}

and

if (-e "$filepath/$filename") { # using variables as the path and name
information
  # display the file
}

and

if (open(TMP, "<$filepath/$filename")) { # to test whether the file can be
opened
# I would expect a false (or undef) if the file did not exist
  # display the file
}

I commented out the if statement (and closing brace '}' ), and manually set
the file to be displayed, and it worked.  That was to check that the path &
filename were correct.  I would like to be able to display the image if it
exists, or display another 'image does not exist' image if the image file
does not exist.

I have even tried the 'use File::stat' module methods.

I do not get any fatal errors - the rest of the HTML output works fine -
just no image displayed even though I know the filepath & name do indeed
exist.  Am I missing something obvious?  The only thing I can think of at
this stage is that the -e test (and related file tests) are for Unix-based
servers and I am running from a MS IIS-based server.  But if that were the
case, wouldn't the server spit out an error that it didn't understand -e?
Are there similar (but different) file tests for IIS?

Thanks in advance,
Mike.



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



RE: Stripping HTML from a text file.

2003-09-04 Thread Hanson, Rob
> Or maybe I misunderstood the question

Or maybe I did :)

> HTML::TokeParser::Simple

I agree... but only if you are looking for a strong permanant solution.  The
regex way is good for quick and dirty HTML work.

Sara, if you need to keep the  tags, then you could use this modified
version...

# untested
$text = "...";
$text =~ s|().*?()|$1$2|s;

...Or if you wanted to keep the  tag...

# untested
$text = "...";
$text =~ s|().*?.*?.*?()|$1$2$3|s;

Rob

-Original Message-
From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 04, 2003 8:48 PM
To: 'Sara'
Cc: beginperl
Subject: Re: Stripping HTML from a text file.


Won't this remove *everything* between the given tags? Or maybe I 
misunderstood the question, I thought she wanted to remove the "code" 
from all of the contents between two tags?

Because of the complexity and variety of HTML code, the number of 
different tags, etc. I would suggest using an HTML parsing module for 
this task. HTML::TokeParser::Simple has worked very well for me in the 
past.  There are a number of examples available. If this is what you 
want and you get stuck on the module then come back with questions. 
There are also the base modules such as HTML::Parser, etc. that the one 
previously mentioned builds on, among others check CPAN.

http://danconia.org

Hanson, Rob wrote:
> A simple regex will do the trick...
> 
> # untested
> $text = "...";
> $text =~ s|.*?||s;
> 
> Or something more generic...
> 
> # untested
> $tag = "head";
> $text =~ s|<$tag[^>]*?>.*?||s;
> 
> This second one also allows for possible attributes in the start tag.  You
> may need more than this if the HTML isn't well formed, or if there are
extra
> spaces in your tags.
> 
> If you want something for the command line you could do this...
> 
> (Note: for *nix, needs modification for Win [untested])
> perl -e '$x=join("",<>);$x=~s|.*?||s' myfile.html >
> newfile.html
> 
> Rob
> 
> 
> -Original Message-
> From: Sara [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, September 03, 2003 6:32 AM
> To: beginperl
> Subject: Stripping HTML from a text file.
> 
> 
> I have a couple of text files with html code in them.. e.g.
> 
> -- Text File --
> 
> 
> This is Test File
> 
> 
> This is the test file contents
> 
> blah blah blah.
> 
> 
> 
> -
> 
> What I want to do is to remove/delete HTML code from the text file from a
> certain tag upto certain tag.
> 
> For example; I want to delete the code completely that comes in between
>  and  (including any style tags and embedded javascripts etc)
> 
> Any ideas?
> 
> Thanks in advance.
> 
> Sara.
> 


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

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



RE: Stripping HTML from a text file.

2003-09-04 Thread Hanson, Rob
A simple regex will do the trick...

# untested
$text = "...";
$text =~ s|.*?||s;

Or something more generic...

# untested
$tag = "head";
$text =~ s|<$tag[^>]*?>.*?||s;

This second one also allows for possible attributes in the start tag.  You
may need more than this if the HTML isn't well formed, or if there are extra
spaces in your tags.

If you want something for the command line you could do this...

(Note: for *nix, needs modification for Win [untested])
perl -e '$x=join("",<>);$x=~s|.*?||s' myfile.html >
newfile.html

Rob


-Original Message-
From: Sara [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 03, 2003 6:32 AM
To: beginperl
Subject: Stripping HTML from a text file.


I have a couple of text files with html code in them.. e.g.

-- Text File --


This is Test File


This is the test file contents

blah blah blah.



-

What I want to do is to remove/delete HTML code from the text file from a
certain tag upto certain tag.

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

Any ideas?

Thanks in advance.

Sara.

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



RE: cgi error

2003-08-15 Thread Hanson, Rob
The message you see in the browser usually means very little, and doesn't
help much.  Check your web server's error logs to see the real error.

If you are getting that error you can be pretty sure that your web server is
at least trying to execute the script.  So after checking your logs, I would
check the following in this order:

1. Is the script executable (chmod +x)
2. Can your web server user execute perl.
3. Can your web server user read and exec your script.

If you have root access you can try su'ing to that user and attempt to run
the script.  That would eliminate all of the above.

Rob

-Original Message-
From: David Glucksman [mailto:[EMAIL PROTECTED]
Sent: Friday, August 15, 2003 1:26 PM
To: [EMAIL PROTECTED]
Subject: cgi error


Hello everyone,

I am new to Perl and CGI so I need some help. I have a
simple cgi script:

#!/usr/bin/perl

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

print "This is my first CGI application";


I save the script using the .cgi nameing convention. I
can run the script from unix with no errors but when I
try to run it in a browser I get:

Internal Server Error
The server encountered an internal error or
misconfiguration and was unable to complete your
request.

I must be missing something obvious.
Any suggestions?
Thanks
David



__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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

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



RE: .htaccess

2003-07-24 Thread Hanson, Rob
This is really an Apache question, not Perl.  Most things that can be done
in the Apache config can be done in a .htaccess file, assuming the main
Apache config file allows you to do so.  You might want to check out the
Apache docs at http://httpd.apache.org.

Rob

-Original Message-
From: awarsd [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 24, 2003 4:28 PM
To: [EMAIL PROTECTED]
Subject: .htaccess


Hello,

I'm curious i read somewhere with .htaccess we can block user to do hotlinks
in both ways etc...
But my question is a bit different it is possible with .htaccess to forbid
forms that comes from a different domain? so no hacking


Thank You



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

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



Re: look arounds

2003-07-07 Thread Rob Dixon
Steve Grazzini wrote:
> On Sun, Jul 06, 2003 at 11:20:03AM -, mark  sony wrote:
> > $_ = "The brown fox jumps over the lazy dog";
> >   /the (\S+)(?{ $color = $^N }) (\S+)(?{ $animal = $^N })/i;
> >   print "color = $color, animal = $animal\n";
> >
> > When I run the program it gives :color = , animal =
> >
> > I took it from this link :
> > http://www.perldoc.com/perl5.8.0/pod/perlre.html
>  ^
> $^N is new in 5.8.0.
>
> In general, it's less frustrating to read the documentation
> that comes with *your* version of Perl.
>
> % perl -v
> % perldoc perlre
> % perldoc perlvar
>
> In this case you can probably use $+ instead.

$+ will return only the last captured string so you would need to
process your text in two passes to get this result. For versions < 5.8
this will do what you want:

my ($color, $animal) = /the (\w+) (\w+)/i;


which, to my mind, is a lot neater anyway.

Rob




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



RE: Running process in background?

2003-07-03 Thread Hanson, Rob
> How would a cron know by looking at a text
> file or DB entry when it was supposed to
> send the mail?

The cron doesn't look at the DB... your scheduler script does (which is
started by cron).  The scheduler might do something like this:

1. open the database
2. search for records with a "to_send_date" that
  has past AND has not yet been sent.
3. loop over each search result, sending the mail
  and marking it as having been sent.
4. close the database
5. the script exits.

Cron would run this script every hour.

I have done this in the past for eCard systems and such, but none of it is
code that I can pass around.  It's hard to come up with a sample as well
because it depends on the technologies you want to use for your schedule
storage.  I recommend a real database (MySQL, Oracle, etc) as opposed to a
text or csv file... but it all depends on what your client it running.

Using a DB to do this is straight-forward since all you need to do is query
the DB that have a "send_date" column that is older than the current time,
and send those records.  If you use a text file you need to worry about
parsing, updating, locking, and everything else the DB engine handles for
you.

Rob


-Original Message-
From: Scot Robnett [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 03, 2003 2:39 PM
To: Hanson, Rob; [EMAIL PROTECTED]
Subject: RE: Running process in background?


I sort of follow you, but I'm not exactly sure how to implement something
like that. How would a cron know by looking at a text file or DB entry when
it was supposed to send the mail? Has anyone done anything like this, and
are there code samples available somewhere that I can review?

-
Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]



-Original Message-
From: Hanson, Rob [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 03, 2003 1:20 PM
To: 'Scot Robnett'; [EMAIL PROTECTED]
Subject: RE: Running process in background?


Your first solution is prone to memory leaks and your second is just a pain
(INHO).

> Is there a third alternative?

Sure.  Create a cron that runs every hour (or less) and checks for scheduled
mail to send.  All you need to do is have some sort of persistant storage
(file or preferably a DB) to store your schedule.  Each hour a cron launches
your send script which queries the schedule (On Oracle: Select * from
schedule where send_time > Sysdate), then iterates through each sending a
mail.

Rob

-Original Message-
From: Scot Robnett [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 03, 2003 1:50 PM
To: [EMAIL PROTECTED]
Subject: Running process in background?


I'm setting up a mailing subroutine for one of my customers that will send
mail based upon a delay of X amount of hours (selected via web form).

If I use something like:

  sub send_on_schedule {
   my $hours = $q->param('delay');
   my $sleeptime = $hours * 3600; # how many seconds?
   my @addresses = ('[EMAIL PROTECTED]','[EMAIL PROTECTED]'); # from a DB
   sleep $sleeptime;
   foreach my $address(@addresses) {
some_mail_sending_routine($address);
   }
  }

then my script/process could technically be running for 24 hours before
sending the mail. I want to allow the delay, but I don't think it's a good
idea for that process to be running the entire time.

I gave some thought to using a cron job, but basically what would have to
happen is that in every instance, I'd have to create a crontab, run the
cron, then destroy it again. Still, this might be better.

Is there a third alternative? Suggestions please? Thanks.

-
Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]


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

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

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



RE: Running process in background?

2003-07-03 Thread Hanson, Rob
Your first solution is prone to memory leaks and your second is just a pain
(INHO).

> Is there a third alternative?

Sure.  Create a cron that runs every hour (or less) and checks for scheduled
mail to send.  All you need to do is have some sort of persistant storage
(file or preferably a DB) to store your schedule.  Each hour a cron launches
your send script which queries the schedule (On Oracle: Select * from
schedule where send_time > Sysdate), then iterates through each sending a
mail.

Rob

-Original Message-
From: Scot Robnett [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 03, 2003 1:50 PM
To: [EMAIL PROTECTED]
Subject: Running process in background?


I'm setting up a mailing subroutine for one of my customers that will send
mail based upon a delay of X amount of hours (selected via web form).

If I use something like:

  sub send_on_schedule {
   my $hours = $q->param('delay');
   my $sleeptime = $hours * 3600; # how many seconds?
   my @addresses = ('[EMAIL PROTECTED]','[EMAIL PROTECTED]'); # from a DB
   sleep $sleeptime;
   foreach my $address(@addresses) {
some_mail_sending_routine($address);
   }
  }

then my script/process could technically be running for 24 hours before
sending the mail. I want to allow the delay, but I don't think it's a good
idea for that process to be running the entire time.

I gave some thought to using a cron job, but basically what would have to
happen is that in every instance, I'd have to create a crontab, run the
cron, then destroy it again. Still, this might be better.

Is there a third alternative? Suggestions please? Thanks.

-
Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]


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

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



Clearing Printers w/CGI

2003-06-26 Thread Rob
Hello, I've been trying to write a cgi script that will clear and restart
the printers on our server.  We have 3 printers that just give me fits
running through a Linux server.  I have no problem getting everything back
up and running on the command line but when I go on vacation the office
staff wont leave me alone and I have to log into the server from where
ever I'm at and clear them.  The steps that I've been trying to take are
to move the print jobs to another directory on the server, then restart
lpd.  I'm using the file copy module but when it gets to this line it
fails with the following error message in the log:

Insecure dependency in rename while running setuid at
/usr/lib/perl5/5.00503/File/Copy.pm line 156.

The line in the script that causes this is:
move("/var/spool/lpd/$printer/[cd]f*", "$printer");

The permissions on the script are:
-rwsr-xr-x   1 root root 1312 Jun 26 08:21 clearpq.cgi

I know it's probably not good to run a cgi script with suid root but I
think that would be better then giving the Secretarys root access to the
server and having them delete files.  The server is not connected to the
Internet but is an internal machine.

Any help on solving this problem would sure make my upcoming vacation much
nicer ;^)

--
Rob

Do not meddle in the affairs of wizards,
for they are subtle and quick to anger.


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



Re: More subroutine confusion

2003-06-08 Thread Rob Dixon
Rob Richardson wrote:
> Dave,
>
> Your response dovetails nicely with my next question.

I don't think the list has a response from Dave at the time of writing?

> The module I'm working in begins as follows:
>
> use warnings;
> use strict;
> use CGI qw/:standard center strong *big delete_all/;

'strong' and 'big' are exported by default as part of ':standard'.
'center' has to be imported explicitly.

> After putting parentheses after my calls to "br", the program compiled
> and started running.

Calls to 'br' shouldn't need parentheses. The subroutine is prototyped
and Perl knows what it is before you use it.

> It barfed, though, at the following line:
>
> $htmlString = p(center(strong("There are not any trains running on this
> day.Use the date dropdowns above to select a different day.")));
>
> It complained that $Schedule::strong was undefined.  As you
> illustrated, changing "strong" to "CGI::strong" fixed that problem, and
> it proceeded to complain about "$Schedule::center" being undefined.

So after the code you show, you have a 'package Schedule'.

> I had thought that the "use CGI" line would tell Perl enough about
> those functions that I wouldn't have to qualify them.

Chris's response to your previous thread explained this. Your call to
'use CGI' imports the nmaes into 'main' - the default package before
you declare anything different. You then have '$CGI::strong' and
'$main::strong' as synonyms for the same subroutine. There is still,
however, no 'Schedule::strong'.

> What do I have
> to do to avoid putting the package name before every subroutine that
> doesn't come from the package I'm developing?  For a complicated
> program, I would imagine qualifying every subroutine call would get
> very cumbersome!

  use strict;
  use warnings;

  package Schedule;

  use CGI qw/:standard center delete_all/;

  my $htmlString = p( center( strong(
  'There are not any trains running on this day.', br,
      'Use the date dropdowns above to select a different day.' )));

> P.S.  In the little test program, if I leave the semicolon off the last
> line, it compiles.  If I put it on, it complains about the "br"
> bareword.  I'm using IndigoPerl.

May we see your little test program?

Cheers,

Rob




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



More subroutine confusion

2003-06-07 Thread Rob Richardson
Dave,

Your response dovetails nicely with my next question.  The module I'm
working in begins as follows:

use warnings;
use strict;
use CGI qw/:standard center strong *big delete_all/;

After putting parentheses after my calls to "br", the program compiled
and started running.  It barfed, though, at the following line:

$htmlString = p(center(strong("There are not any trains running on this
day.Use the date dropdowns above to select a different day.")));

It complained that $Schedule::strong was undefined.  As you
illustrated, changing "strong" to "CGI::strong" fixed that problem, and
it proceeded to complain about "$Schedule::center" being undefined.  

I had thought that the "use CGI" line would tell Perl enough about
those functions that I wouldn't have to qualify them.  What do I have
to do to avoid putting the package name before every subroutine that
doesn't come from the package I'm developing?  For a complicated
program, I would imagine qualifying every subroutine call would get
very cumbersome!

Thanks once again!

RobR

P.S.  In the little test program, if I leave the semicolon off the last
line, it compiles.  If I put it on, it complains about the "br"
bareword.  I'm using IndigoPerl.

__
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

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



Re: br -- problem caused by "Package"? -- my bad

2003-06-07 Thread Rob Richardson
Greetings again!

I could of course be wrong...

I just found that I had "use warnings" and "use strict" commented out
in the module that compiled!

Excuse me for a while while I track down a hundred or so violations
that uncommenting them uncovered.

RobR

--- Rob Richardson <[EMAIL PROTECTED]> wrote:
> Kristofer and everybody else,
> 
> "br" is successfully used without parentheses in the first snippet I
> posted.  I don't believe that parentheses are required for subroutine
> calls that don't have arguments, although I suppose I should use them
> since I'm mainly a C++ programmer and so I should be as consistent as
> possible between the two languages.


__
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

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



Re: br -- problem caused by "Package"?

2003-06-07 Thread Rob Richardson
Kristofer and everybody else,

"br" is successfully used without parentheses in the first snippet I
posted.  I don't believe that parentheses are required for subroutine
calls that don't have arguments, although I suppose I should use them
since I'm mainly a C++ programmer and so I should be as consistent as
possible between the two languages.

I tried another program to illustrate the "br" problem.  Here is the
entire program:

#!/usr/bin/perl

use warnings;
use strict;
use CGI qw/:standard center *big delete_all/;

use ScheduleDay;
use Train;

package Brtest;

my $testString = br;


When I compile this, I get the following error:

Bareword "br" not allowed while "strict subs" in use at brtest.pm line
12.

When I comment the "package Brtest;" line, I don't get the error.

What is happening?

Thanks again!

Rob

P.S.  I am cross-posting this to the [EMAIL PROTECTED] list because
this is looking as though it's not a CGI issue.

P.P.S. to any list administrator who may read this:  Whenever I click
"Reply", the original sender is automatically put into my "To:" box,
but "[EMAIL PROTECTED]" is not.  The same is true for the
"[EMAIL PROTECTED]" list.  Can that be changed?


__
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

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



br

2003-06-07 Thread Rob Richardson
Greetings!

I am attempting to use objects to organize a program somewheat
intelligently.  I am running into a problem using the CGI method "br".

My main routine has the following use statements:

use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard center *big delete_all/;

It begins writing HTML with the following code:

print 
header(-type=>'text/html',-expires=>'-1d'),
start_html(-title=>'Volunteer Scheduling System',-vlink=>'blue'),
center(p(img({-src=>'cvsr.gif'}),br,strong("Welcome to the Volunteer
Scheduling System $usrvals[1] $usrvals[3]."),br,


There is no problem with this statement.  Note that the CGI method "br"
was used twice.  (At least I think that's what "br" is here.)


In a new module that I wrote, I have the following use statement:

use CGI qw/:standard center *big delete_all *br/;

This module defines an object that knows how to build an HTML string. 
It has a GetHTML() method that returns a string, and it's the
responsibility of the calling routine to send that string to standard
output to build the web page.  The GetHTML() routine uses the following
code to build a string:

$htmlString = p
  (
center
(
  strong
  (
"Train(s) and positions for the day you have selected."
  ) . 
  br . 
  "Click the position you would like to volunteer for." . 
  br . 
  "Positions that are already taken cannot be clicked." . 
  br . 
  "Use the date dropdowns above to change to a different day."
)
  ) . 
  br . 
  "";

In this instance, Perl is complaining that the bareword "br" is not
allowed when "strict subs" is in use.  I don't understand why it's not
allowed here but it is allowed in the other module.  Can somebody
please explain this?

Thanks very much!

RobR


__
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

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



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

2003-06-06 Thread Hanson, Rob
Right, Apache 2.0 supports this with filters.

Rob


-Original Message-
From: Octavian Rasnita [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 05, 2003 5:32 PM
To: Edson Manners; [EMAIL PROTECTED]
Subject: Re: I am having trouble using SSI(Server side includes) from cgi
using perl


CGI is handled by another web server module than Server Side Includes, so
they can't work together.
I heard that in the latest version of Apache (or only a future one, I don't
know), they will make possible to feed the results of a CGI program to the
server side includes parser.

Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]

- Original Message -
From: "Edson Manners" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 05, 2003 8:41 PM
Subject: I am having trouble using SSI(Server side includes) from cgi using
perl


I am making a cgi script that prints a web page with SSIs in it. When I
put SSI code in my cgi which is output to STDOUT the webserver gets no
chance to parse the SSI and put the HTML code in in place of the SSI
statements. Does anyone know how to do this.
--
Law of inverse proportionality - The less you really
know the more you think you know. - Edson Manners.

Academic Computing and Network Systems
Florida State University
Phone: (850)644-2591 ext 125

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




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

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



RE: Problems getting a simple form to work.

2003-04-04 Thread Rob Benton
It's OK, my feelings aren't hurt :)

On Fri, 2003-04-04 at 15:45, Hughes, Andrew wrote:
> I think you meant, "Thanks, Rob."
> 
> Andrew
> 
> -Original Message-
> From: Mike Butler [mailto:[EMAIL PROTECTED]
> Sent: Friday, April 04, 2003 4:45 PM
> To: Rob Benton
> Cc: Hughes, Andrew; [EMAIL PROTECTED]
> Subject: RE: Problems getting a simple form to work.
> 
> 
> Thanks, Andrew. That did it. It's working now. :) :) :)
> 
> Thanks everyone for all your help.
> 
>   - Mike
> 
> -Original Message-
> From: Rob Benton [mailto:[EMAIL PROTECTED]
> Sent: Friday, April 04, 2003 4:38 PM
> To: Mike Butler
> Cc: Hughes, Andrew; [EMAIL PROTECTED]
> Subject: RE: Problems getting a simple form to work.
> 
> 
> Give this a shot and see if it errors:
> 
> use CGI;
> my $query = new CGI;
> my %params = $query->Vars;
> 
> my $username = $params{'username'};
> 
> 
> 
> On Fri, 2003-04-04 at 15:29, Mike Butler wrote:
> > Thanks, Andrew. I added CGI::Carp qw(fatalsToBrowser); to the script.
> That's
> > a big help. The error message that I get now is:
> > Software error:
> > Undefined subroutine &main::param called at simpleform.cgi line 6.
> >
> > Line 6 is my $username = param('username');
> >
> > Any idea why param is undefined?
> >
> > Thanks,
> >
> >   - Mike
> >
> >
> > -Original Message-
> > From: Hughes, Andrew [mailto:[EMAIL PROTECTED]
> > Sent: Friday, April 04, 2003 3:09 PM
> > To: [EMAIL PROTECTED]
> > Subject: RE: Problems getting a simple form to work.
> >
> >
> > I would also add
> >
> > use CGI::Carp qw(fatalsToBrowser);
> >
> > along with
> >
> > use CGI;
> > use strict;
> >
> > This way your errors will get displayed in your browser.
> >
> > Also, check with your hosting company to make sure that your path to perl
> is
> > correct (ex. is it #!/usr/local/bin/perl -wT vs. #!/usr/bin/perl -wT)
> >
> > Andrew
> >
> > -Original Message-
> > From: Li Ngok Lam [mailto:[EMAIL PROTECTED]
> > Sent: Friday, April 04, 2003 2:37 PM
> > To: Mike Butler; [EMAIL PROTECTED]
> > Subject: Re: Problems getting a simple form to work.
> >
> >
> > [..]
> > > #!/usr/local/bin/perl -wT
> > > use CGI;
> > > use strict;
> > >
> > > $username = param('username');
> >
> > should be :
> > my $username = param('username');
> >
> > because you've using strict;
> >
> > >
> > > print "Content-type: text/plain\n\n";
> > For what I know, I would write as "Content-type: text/html\n\n";
> >
> > > print "You entered: $username\n";
> > >
> > > The permissions look like this:
> > >
> > > Permissions for cgi-bin: rwxr-xr-x
> > > Permissions for simpleform.cgi rwxr-xr-x
> > > Permissions for simpleform.htm: rwxr-xr-x
> > >
> > > I have changed  to
> > >  action="http://www.mikyo.com/cgi-bin/simpleform.cgi";>.
> > >
> >
> > 2 suggestion here :
> >
> > 1. use CGI::Carp 'fatalsToBrowser'; # the die message will goto your
> > browser.
> > 2. Try simpler script, so you will know if your form is going to a right
> > place :
> >
> > #!/usr/bin/perl
> > print "Content-type: text/html\n\n";
> > print "Hello world";
> >
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


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



RE: Problems getting a simple form to work.

2003-04-04 Thread Rob Benton
Give this a shot and see if it errors:

use CGI;
my $query = new CGI;
my %params = $query->Vars;

my $username = $params{'username'};



On Fri, 2003-04-04 at 15:29, Mike Butler wrote:
> Thanks, Andrew. I added CGI::Carp qw(fatalsToBrowser); to the script. That's
> a big help. The error message that I get now is:
> Software error:
> Undefined subroutine &main::param called at simpleform.cgi line 6.
> 
> Line 6 is my $username = param('username');
> 
> Any idea why param is undefined?
> 
> Thanks,
> 
>   - Mike
> 
> 
> -Original Message-
> From: Hughes, Andrew [mailto:[EMAIL PROTECTED]
> Sent: Friday, April 04, 2003 3:09 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Problems getting a simple form to work.
> 
> 
> I would also add
> 
> use CGI::Carp qw(fatalsToBrowser);
> 
> along with
> 
> use CGI;
> use strict;
> 
> This way your errors will get displayed in your browser.
> 
> Also, check with your hosting company to make sure that your path to perl is
> correct (ex. is it #!/usr/local/bin/perl -wT vs. #!/usr/bin/perl -wT)
> 
> Andrew
> 
> -Original Message-
> From: Li Ngok Lam [mailto:[EMAIL PROTECTED]
> Sent: Friday, April 04, 2003 2:37 PM
> To: Mike Butler; [EMAIL PROTECTED]
> Subject: Re: Problems getting a simple form to work.
> 
> 
> [..]
> > #!/usr/local/bin/perl -wT
> > use CGI;
> > use strict;
> >
> > $username = param('username');
> 
> should be :
> my $username = param('username');
> 
> because you've using strict;
> 
> >
> > print "Content-type: text/plain\n\n";
> For what I know, I would write as "Content-type: text/html\n\n";
> 
> > print "You entered: $username\n";
> >
> > The permissions look like this:
> >
> > Permissions for cgi-bin: rwxr-xr-x
> > Permissions for simpleform.cgi rwxr-xr-x
> > Permissions for simpleform.htm: rwxr-xr-x
> >
> > I have changed  to
> > http://www.mikyo.com/cgi-bin/simpleform.cgi";>.
> >
> 
> 2 suggestion here :
> 
> 1. use CGI::Carp 'fatalsToBrowser'; # the die message will goto your
> browser.
> 2. Try simpler script, so you will know if your form is going to a right
> place :
> 
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> print "Hello world";
> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


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



Re: File::Find

2003-04-03 Thread Rob Dixon
Hi Jeff

Jeff wrote:
> I am attempting to use the File::Find module to go through all directories and 
> subdirectories
> and preform a search and replace function.  I am simply opening each file and line 
> by line
> comparing to an input string parameter.  If I find it, I replace with the input 
> replace
> string, and keep on going, one file at a time, one line at a time. 1) Why does the 
> opening
> and reading of image file mess up the files if nothing more is done to them then 
> opening and
> reading line by line?

It can't. Are you sure it's your program that damaging the file? If you have no output
statements at all then there's no way you can be altering the file. If you post the 
code
we should be able to see the problem. You could use the -T file test to ignore non-text
files, but I'd like to know what your problem really is.

> 2) Does anyone know of a module out there that does global search and replace on 
> whole
> directories and all subdirectories?

You could take a look at File::Searcher, but it shouldn't be too difficult going the
way you are.

Cheers,

Rob




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



Forcing a refresh from within a CGI script

2003-04-02 Thread Rob Dixon
Hi all.

I'm in the process of modifying an existing CGI script. There is a page of
HTML which has an anchor to the script which, when run, modifies the
HTML file which linked to it and redisplays it. At present this is done by
returning just the header line

Location: http://www.domain.com/referrer.htm

to the client after modifying the file.

Firstly, I'm not at all sure if this is the preferred way to force a refresh,
and secondly it doesn't always work as the client browser believes it has
a valid cached copy of the page and refuses to reload it.

Can someone help me towards a better solution?

Thanks,

Rob




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



Re: mysterious blank space in variable

2003-04-01 Thread Rob Anderson
Luke,

It's impossible to say without knowing what your data looks like (what's the
value being returned by $FORM::F_totalsum)

If you can't rely on your data, you could have a look at this regex. It's in
it's own test suite for you :-).


#!perl -w
use strict;

foreach my $string ("123.23", "123  ", "123.23", "234.234", "  2 ", " .3
"," 12. ") {
if ($string =~ m/(\d+?\.\d*|\.?\d+)/) {
my $num = $1;
print ">>$num<<\n";
} else {
print "unknown format\n";
}
}

HTH

Rob


"Cool Hand Luke" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Ahoy, hoy.
> I am having problems with this script, it keeps adding 6 blank spaces in
> front of a variable when it calculates it. I can't see why it's doing so.
> The variable in question is the $x_amount. Can anybody see where I'm going
> wrong, or alternately is there a quick way to strip a variable down to
just
> numbers and "."s? Just one line I could add maybe at the end that would
> strip it of these 6 blank spaces?
> Any help is appreciated.
> Thanks,
> Luke
>
>  if ($FORM::F_totalsum) {
> @sumvars=split(/,/,$FORM::F_totalsum);
> $x_amount=0;
> foreach $i (@sumvars) {
>   if ($i eq "F_subtotal") {
>  $x_amount+=$subtotal;
>   } elsif ($i eq "F_tax") {
>  $x_amount+=$tax;
>   } elsif ($var_set{$i}) {
>  $x_amount+=$req->param($i);
>   } else {
>  &err("$i is not defined");
>   }
> }
> $x_amount=¤cy($x_amount);
>   }
>



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



Re: Problems with html output

2003-03-27 Thread Rob Anderson
Your logic looks find, and works on my machine (although I made it command
line)

Try switching on warnings  (#!/usr/local/bin/perl -w) and use strict (use
strict;)

Probably most likely is that you script can't read the file. You should
really always check if a file has been opened successfully you've done that
in your first example, but not the CGI example.

But if you file is in the format that you describe, your code should be
working


"Jonathan Musto" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have a simple perl script as follows which gets a users id number by
> looking in a file.  It already knows the username and uses this to
reference
> to the id.
> The file is in the format:
>
> jbloggs,101
> jdoe,103
> msmith,111
> etc...
>
> The code i'm using is:
>
> #!/usr/local/bin/perl
>
> my $hashfile = "/opt/netcool/webtop/config/cgi-bin/hl_of_user.txt";
> my $username = 'mustoj';
>
> open (USERFILE, $hashfile) || die "Couldn't open hash file: $!\n";
>
> while()
> {
> chomp;
> ($key, $data) = split /,/, $_; # or whatever you have to split on
> $userlookup{$key} = $data;
> }
>
> my $usernum = $userlookup{$username};
>
> print "User Name = $username\nUserID = $usernum\n";
> Now this works fine as a perl script, but when i put this in a perl cgi
> script and try to output the values in html the user id is blank.
> I get the output:
> User Name = mustoj User ID =
>
> Does anyone have any idea's on what could be causing this, or can anyone
> think of a more efficient way of looking up the user id from this file??
> Any help would be much appreciated, i've included the cgi script below.
>
> the url is /cgi-bin/sis_home.cgi?un=mustoj, which is how i'm passing the
> username in.
>
> #!/usr/local/bin/perl
> #
> # script name: sis_home.cgi
> #
>
>
> use CGI qw(:standard);
>
>
> my $q = new CGI;
> my $username = $q->param("un");
> open (FH,"
>
> while()
> {
> chomp;
> ($key, $data) = split /,/, $_; # or whatever you have to split on
> $userlookup{$key} = $data;
> }
> my $usernum = $userlookup{$username};
>
> #print the html
> print "Content-type: text/html\n\n";
> print <<__HTML__;
> 
> 
> 
> Simple Program
> 
> 
> 
> User Name = $username UserID = $usernum
> __HTML__
> print <<__HTML__;
> 
> 
> __HTML__
>
>
>
> Jonathan Musto
>
>
>
> BT Ignite Solutions
> Telephone - 0113 237 3277
> Fax - 0113 244 1413
> E-mail - [EMAIL PROTECTED]
> http://www.technet.bt.com/sit/public

>
>
> British Telecommunications plc
> Registered office: 81 Newgate Street London EC1A 7AJ
> Registered in England no. 180
> This electronic message contains information from British
Telecommunications
> plc which may be privileged or  confidential. The information is intended
to
> be for the use of the individual(s) or entity named above. If you  are not
> the intended recipient be aware that any disclosure, copying, distribution
> or use of the contents of  this information is prohibited. If you have
> received this electronic message in error, please notify us by  telephone
or
> email (to the numbers or address above) immediately.
>
>



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



RE: Problem with regular expressions!!!

2003-03-19 Thread Hanson, Rob
*? = 0 or more, non-greedy.  Non-greeday meaning "as few as possible".

$test = 'foobar foobar';

# matches "foobar foobar", as many of "." as possible.
$test =~ /foo.*bar/;

# matches "foobar", as few of "." as possible (in this case, none).
$test =~ /foo.*?bar/;

Also...

+ = 1 or more (greedy)
+? = 1 or more, non-greedy.

Rob

-Original Message-
From: Rob Benton [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 19, 2003 2:07 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: Problem with regular expressions!!!


How does it translate?

* = 0 or more of preceding char
? = 1 or 0 of preceding char
*? = ???


On Tue, 2003-03-18 at 21:41, Michael Kelly wrote:
> On Tue, Mar 18, 2003 at 05:53:45PM -0600, Rob Benton wrote:
> > It looks odd to me b/c * and ? are both quantifiers...
> 
> * and ? alone are both quantifiers, but *? is a non-greedy *.
> 
> -- 
> Michael
> [EMAIL PROTECTED]
> http://www.jedimike.net/
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


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

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



Re: Problem with regular expressions!!!

2003-03-19 Thread Rob Benton
How does it translate?

* = 0 or more of preceding char
? = 1 or 0 of preceding char
*? = ???


On Tue, 2003-03-18 at 21:41, Michael Kelly wrote:
> On Tue, Mar 18, 2003 at 05:53:45PM -0600, Rob Benton wrote:
> > It looks odd to me b/c * and ? are both quantifiers...
> 
> * and ? alone are both quantifiers, but *? is a non-greedy *.
> 
> -- 
> Michael
> [EMAIL PROTECTED]
> http://www.jedimike.net/
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


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



Re: Problem with regular expressions!!!

2003-03-18 Thread Rob Benton
It looks odd to me b/c * and ? are both quantifiers which usually
triggers an error when you try to run it.  See if this works for you:

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


On Tue, 2003-03-18 at 15:28, Marcelo Taube wrote:
> As u probably have guessed some part of my code is not working properly and 
> i don't understand why!!
> 
> This is the code.
> #
> $file_completename =~ /(.*?)\.(.*)/;
> if ($2 eq $extension]) {
>   #DO SOMETHING!!!
> }
> #
> As u see, i'm trying to separate the complete name of a file in two parts, 
> the filename ($1) and the extension($2)... then i check to see whatever a 
> extension is of some kind and if it is, i do something.
> However this doesn't work. Because in $2, perl adds a "." before the 
> extension.
> 4 example: if file_completename equal to "myfile.jpeg", then $2 equials to 
> ".jpeg", but it should be "jpeg".
> What am i doing wrong?
> Thank u very much,
> Marcelo Taube
> 
> 
> 
> _
> The new MSN 8: advanced junk mail protection and 2 months FREE* 
> http://join.msn.com/?page=features/junkmail
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


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



passing cgi params

2003-03-15 Thread Rob Benton
If I use:

my $query = new CGI;
my %params = $query->Vars;

to grab the incoming parameters is it safe to just send all of them over
to a new cgi script like this:

my $form = CGI::FormBuilder->new( fields => \%params, method => 'POST');
print $form->render();

Or will that pass along built-in parameters that should be?



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



CGI::FormBuilder

2003-03-14 Thread Rob Benton
Is there a way to print a 'button' input type without a label next to it
using the FormBuilder object?  I can't find the right combination.

I always wind up with this

 +---+
Next |Next   |
 +---+

and what I want is

 +---+
 |Next   |
 +---+

$form->field(name => 'next', value => 'Next', label => 0)
is all I could think of to try but that doesn't work.

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



RE: html table limit

2003-03-12 Thread Rob Benton
Scroll up and down to the bottom of the page then see if the borders
screw up.

On Wed, 2003-03-12 at 14:57, Bob Showalter wrote:
> Rob Benton wrote:
> > Mozilla, Konqueror, Opera, and IE all act the same way. Check out this
> > page to see what I mean.  The top, bottom, and right side of the
> > table borders act funky: 
> > 
> > http://www.geocities.com/emperorrob/test.html
> 
> Hmm, this page displays fine for me in IE6.
> 
> > 
> > I tried the validator but it keeps timing out. :)  I guess the file
> > is too big. 
> 
> I was able to run the validator. The only problem is you're missing a
>  section and some complaints about the junk yahoo adds on. No
> problem with the table.
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


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



RE: html table limit

2003-03-12 Thread Rob Benton
1000+ rows is a rare situation on my page but in can happen.  It's a dbi
script.  I couldn't really think of a better design but I am open to
suggestions...

On Wed, 2003-03-12 at 15:07, Brett W. McCoy wrote:
> On 12 Mar 2003, Rob Benton wrote:
> 
> > > > Is there a limit to how many rows you can put in an html table?  I
> > > > can't find anything wrong with my script but when I get over 1000
> > > > rows or so in my tables they start drawing weird borders.
> 
> I think if you are needing tables on an HTML page that have over a 1000
> rows you might want to redesign your UI.  Just IMHO, of course. :-D
> 
> -- Brett
>   http://www.chapelperilous.net/
> 
> I have never understood the female capacity to avoid a direct answer to
> any question.
>   -- Spock, "This Side of Paradise", stardate 3417.3
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


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



RE: html table limit

2003-03-12 Thread Rob Benton
Mozilla, Konqueror, Opera, and IE all act the same way.  Check out this
page to see what I mean.  The top, bottom, and right side of the table
borders act funky:

http://www.geocities.com/emperorrob/test.html

I tried the validator but it keeps timing out. :)  I guess the file is
too big.

On Wed, 2003-03-12 at 12:02, Bob Showalter wrote:
> Rob Benton wrote:
> > Is there a limit to how many rows you can put in an html table?  I
> > can't find anything wrong with my script but when I get over 1000
> > rows or so in my tables they start drawing weird borders.
> 
> That would be a function of the browser, so see if your browser has any
> limits. Try viewing the page with different browsers. Also, make sure your
> all your tags are balanced ( with ,  with , etc.)
> 
> You can run your HTML through a validator such as http://validator.w3.org/
> 
> 
> 


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



html table limit

2003-03-12 Thread Rob Benton
Is there a limit to how many rows you can put in an html table?  I can't
find anything wrong with my script but when I get over 1000 rows or so
in my tables they start drawing weird borders.



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



CGI::FormBuilder parsing

2003-03-10 Thread Rob Benton
I've noticed that when using the formbuilder that field names that have
underscores in them are replaced with spaces.  And also that if a field
has a '.' in it, that . and everything after are truncated when
printing.  Is there any way to modify this?



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



RE: my( $string )

2003-03-06 Thread Hanson, Rob
> do I need them every time I declare a variable?

Nope.  The parens force "list context".  Without them is "scalar" context.

For example...

my @foo = qw(1 2 3 4 5);

my $x = @foo; # =5, the number of elements
my ($y) = @foo; # =1, the first element

Certain functions and operations will do different things based on the
context they are called in.  For example when setting a scalar to an array
(like above), the number of elements is returned... but when setting an
array to a list (like above) you get as many elements as you have variables.

Hope that helps.

Rob


-Original Message-
From: David Gilden [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 06, 2003 2:17 PM
To: fliptop; [EMAIL PROTECTED]
Subject: my( $string ) 


Quick question:
my( $string ) = "you ordered " . $q->param('quantity') . " foobars\n";


What with the '( )'  do I need them every time I declare a variable?

Thanks!


Dave
( kora musician / audiophile / web master @ cora connection /  Ft. Worth,
TX, USA)
==
 Cora Connection: Your West African Music Source
  Resources, Recordings, Instruments & More!
   <http://www.coraconnection.com/> 
==

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

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



RE: data structures

2003-03-04 Thread Hanson, Rob
> any suggestions?

I'll try.

> @bags = param('handbag');  get all of the bags styles

Missing comment...

@bags = param('handbag'); # get all of the bags styles

> push %bags_ordered,$bag_name;

You can't push onto a hash, only an array.  So either %bags_ordered need to
be an array, or you mean something else.

Maybe this is what you mean...

use strict; # a big bonus for debugging
use Data::Dumper; # for testing

my %bags_ordered;
my @bags = param('handbag'); # get all of the bags styles
my @bag_quantity = param('quantity'); # get all of the bags quantity 

for (my $i = 0; $i < @bags; $i++) {
  # split the bag item
  my ($bag_name, $imgName) = split (/,/, $bags[$i]);

  # create an empty hash if this is a new bag
  $bags_ordered{$bag_name} = {} unless exists $bags_ordered{$bag_name};

  # set the image name
  $bags_ordered{$bag_name}->{image_name} = $imgName;

  # set the quantity. should it be additive with +=?
  $bags_ordered{$bag_name}->{quantity} = $bag_quantity[$i];
}

# print the structure for testing using Data::Dumper
print Dumper \%bags_ordered;


Rob


-Original Message-
From: David Gilden [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 04, 2003 4:57 PM
To: [EMAIL PROTECTED]
Subject: data structures 


I am trying to build a data structure, and am tripping up here.  
any suggestions?
Thx!
Dave

!/usr/bin/perl -w
 snip...
@bags = param('handbag');   get all of the bags styles
@bag_quantity = param('quantity');   get all of the bags quantity 

foreach my $bag (@bags){
($bag_name,$imgName)  =  split (/,/,$bag);
push %bags_ordered,$bag_name;
push %bags_ordered{$bag_name}{image_name} = $imgName;
}

foreach my $q (@bag_quantity){
push %bags_ordered{$bag_name}{$bag_quantity} =$q; 
}


Data structure: 



%bags_ordered = (
"bag-style1" =>   { price => 10,
image_name => 'FIO-142b-small',
 quantity=> 5
   },

"bag-style2" =>   { price => 12,
image_name => 'GUC-208-small',
   quantity=> 5,
   },

);

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

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



RE: How much is too much

2003-02-27 Thread Hanson, Rob
I dunno for sure, but if they wanted to measure the processor time they
could.  It is also likely that they give CGI scripts a lower priority than
system functions, so a very greedy Perl script would end up being pretty
slow.

> they make vague statements about removing
> inappropriately-greedy scripts

I have a feeling that they are only pulling those scripts that have runtimes
of minutes, and aren't really being used for the usual purposes.  For
example, you could write a script that spidered a set of sites for you, then
returned some statistics.  ...Something like that would probably be frowned
upon.

You really need to ask them to know for sure.

Rob

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 27, 2003 9:43 AM
To: [EMAIL PROTECTED]
Subject: How much is too much


I write MacPerl at work to munge local files but use CGIs for my personal
website. The various hosting plans I have allow Perl and I have never had a
problem with them. I am starting a new, more CGI-intensive project and I'm
troubled by the question "how much PERL is too much." Bandwidth can be
metered, but I haven't seen hosters who meter processor time. Instead they
make vague statements about removing inappropriately-greedy scripts.

Does anyone know how hosting companies really approach this issue? Are
there CGI-friendly hosters? Do scripts and accounts get pulled all the
time, or is this not something to worry about. Can I start calculating pi
now?

Thanks,
Tim



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

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



RE: parsing text files ...

2003-02-26 Thread Hanson, Rob
> is there a way to tell the program to
> "read until you see this line and
> place everything you have read up to
> that line into @array"

# yes.
my @lines = ();
open IN, "somefile" or die $!;
while () {
  last if /some_match/;
  pusdh @lines, $_;
}
close IN;

> could this start at the bottom of the file
> and read backwards

Nothing built in.  A quick search of CPAN shows a module called
File::ReadBackwards.

http://search.cpan.org/author/URI/File-ReadBackwards-0.99/


Hope that helps.

Rob



-Original Message-
From: Jamie Bridges [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 26, 2003 2:08 PM
To: [EMAIL PROTECTED]
Subject: parsing text files ... 


i have admittedly been lurking for awhile on this list b/c all of your
advice has been helpful as reference in building some of my code.  i
haven't seen anything since i joined the list which could help me with the
following problem so i hoped maybe you guys could address it for me.

what i have is text files we created using a bourne shell script.  we chunk
together output from a solaris box into a standard format ( prtdiag | dmesg
| format ) and then place this file on a server.   we're writing a utility
to unchunk this data and place it directly into individual cells in a mysql
database.

is there a way to tell the program to "read until you see this line and
place everything you have read up to that line into @array" ...also could
this start at the bottom of the file and read backwards up to a certain
line?

my big hang up that follows this problem is that these files are obviously
dynamic and therefore can be of different lengths, and in some cases can
also include drastically different information.   in looking through many
examples however, i have found lines which start and stop each portion that
i can use as "end points" in my searching.

i would post code but at this stage i don't have anything written past the
initial :

open( FILE, $file );
while (  ) {
  push( @masterlist, $_ );
}
close( FILE );

any advice that could be offered would be helpful.
-
Jamie Bridges
Asst. Sun Hardware Lead




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

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



RE: DBI question

2003-02-14 Thread Hanson, Rob
> Basically, i'm trying to write a little abstraction layer

Someone already did the work for you, check out Class::DBI.

Here is a good article on it, it might be all you need.
http://www.perl.com/pub/a/2002/11/27/classdbi.html

Rob

-Original Message-
From: Peter Kappus [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 14, 2003 3:59 PM
To: CGI
Subject: DBI question


Hi List,
Sorry if this is a little offtopic but I'm trying to learn DBI for a
CGI I'm writing.  Been reading http://www.perldoc.com/cpan/DBI.html but
seems a little over complex for what I need...just inserts, updates, and
queries really. Portability isn't too important.  Probably going to use
DBD::ODBC on top of it anyway. Also trying to learn about packages and OOP
with perl at the same time...yikes.

Basically, i'm trying to write a little abstraction layer so that I can say
things like:


$dbh = MyPackages::DB->new();  #handles my connection stuff.

#and then
my @values = $dbh->getvalues("username","users");

#or maybe,
my @rowsHashRefs = @{$dbh->query("select username,email from users")};

#and then
foreach my $hashRef (@rowsHashRefs){
my %row = %{$hashRef};
#some html...
print "user $row{'username'}'s email is $row{'email'}"; 
#or whatever
}



Not sure how much code I'm actually saving by doing this...Does anybody have
experience using DBI or any tricks for keeping things simple and avoiding
excessive prepare, execute, selectall_hashrefs...etc.


Secondly, I thought I had something working (see my "package" below) but
it's complaining that I'm only passing one argument to selectall_hashref
despite the documentation saying you can use just a simple statement.

here's the error: Usage: $h->selectall_hashref($statement, $keyfield [,
\%attr [, @bind_params ] ]) at Score/DB.pm line 56.


Thanks for any pointers...


-peter





here's the package that I'm trying to write:  (be warned:  It's ugly)



use strict;
use DBI;
use DBD::ODBC;
package MyPackages::DB;


sub new {
#my $class=shift;
my $self={};
bless $self;
#go ahead and connect
$self->connect();
return $self;
}

sub connect{
my $self = shift;
$self->{dbh} =
DBI->connect("dbi:ODBC:myDSN","username","sekretpassword",{
AutoCommit=>0,
RaiseError=>1}) or die("Can't connect! $!");
}

sub getValue{
my ($self,$field,$table,$condition) = @_;
return if($#_<2);

my @rowHashRefs;

if($condition){
@rowHashRefs = @{$self->query("Select $field from $table
where $condition")};
}else{
@rowHashRefs = @{$self->query("select $field from $table")};
}

#get at our hash from our arrayref [0] and pull out the value of
field:$field
#if ($#rowHasheRefs == 0){
#   return ${${$arrayRef}[0]}{$field};
#}

my @fieldValues;
foreach my $rowHashRef (@rowHashRefs){
push(@fieldValues,${$rowHashRef}{$field});
}

#give back the array of values ...or do I want a reference to it?
return @fieldValues;

}

sub query{
my ($self,$qry) = @_;
return unless($qry);
return $self->{dbh}->selectall_hashref($qry);  #why does it complain
here

}

1;



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

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




Premature end of script headers -- solved

2003-01-12 Thread Rob Richardson
Greetings!

I found the problem.  In one execution path, my script has the
following steps:

$month = param('month');
$day = param('day');
$year = param('year');
$position = param('position');
$indmonth = param('indmonth');
$selection = param('selection');

When this execution path was followed, there was no parameter named
'selecton'.

RobR


__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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




Re: Sending a location Header

2003-01-12 Thread Rob Richardson
Greetings!

I have successfully added the new functionality to the script I have
been upgrading.  Now the old functionality doesn't work.  When I try to
use it, I get an error page announcing Error 500, Internal Server
Error.  The log file contains the following message:

"Premature end of script headers"

What does this mean?  I don't know enough to know where to begin to
search for the cause of this problem.

Also, when is this error generated?  Can I print to a log file before
this error occurs, or is this error generated before any code in my
script is run?

Thanks very much!

RobR


__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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




Re: using an AND operator

2003-01-11 Thread Rob Dixon
Hi Susan

"Susan Aurand" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
> Is there an AND operator in perl? For example;
>
> if ($SRF=1 and $SRL=1) {print"YES";)
>
>  Any help would be appreciated.
> Thank you - Susan
>

What you've written will work as it is, except that for comparing numeric
quantities for equality you need '==' instead of the assigment operator '='.
(You also have a typo - a closing parenthesis instead of a closing brace).
Try this:

if ($SRF == 1 and $SRL == 1) { print "YES" };

Perl provides both the C-like '&&' operator and 'and', which do the same
thing but bind with their operands with different priorities. The most
important difference is that the assignment operators have a lower priority
than '&&' but a higher priority than 'and', so:

$bool = $SRF == 1 && $SRL == 1
means
$bool = (($SRF == 1) && ($SRL == 1))

but

$bool = $SRF == 1 and $SRL == 1
means
($bool = ($SRF == 1)) and ($SRL == 1)

HTH,

Rob






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




Re: IF statments -- ORs short circuit too

2002-12-24 Thread Rob Richardson
--- Michael Kelly <[EMAIL PROTECTED]> wrote:

> Only and's short-circuit. Or's test every argument by necessity.


Mike,

In just about every Perl script that has to read from or write to a
file, you will see a line similar to the following:

open (MYFILE, "myfile.txt") or die "Can't open myfile.txt: $!\n";

This is an conditional statement using an "or".  If your statement was
correct, both the open clause and the die clause would be executed and
the program would never get beyond this point.  But what actually
happens in most instances is that the open statement succeeds and
returns a value that evaluates to true.  An or statement is true if at
least one of its clauses is true.  So if the open clause is true, Perl
does not bother checking the other clause, the die statement is skipped
over, and the program continues running.

RobR





__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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




start_tr

2002-12-13 Thread Rob Richardson
Greetings!

I am having some trouble with a script designed to create a table. 
Here is the important part:

use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard :html center *big *strong *table *tr *td
delete_all/;
use Time::Local;

build_calendar(param('month'), param('year'));

sub build_calendar
{
my ($month, $year);
my (@calendar);
my ($currentDate);

$month = $_[0];
$year = $_[1];

@calendar = rawCalendar($month, $year);
print start_table({-align=>center, -width=>"95%", -border=>1});
for ($i = 0; $i < 6; $i++)
{
# $line = "";
print start_tr();
for ($j = 0; $j < 7; $j++)
{
$currentDate = shift(@calendar);
# $line = $line . $currentDate . ' ';
# $line = "$line$currentDate ";
print td($currentDate);
}
# print "$line";
print end_tr();
}
print end_table();
}

When I run this, I get the following error:
Undefined subroutine CGI::start_tr
 at c:\INDIGO~1\HTDOCS\CREW\CALENDAR.CGI line 82

I don't have a good book on CGI, but I think the use statement is
correct, and the start_table() routine is working.  Why don't I have
start_tr()?

Also, is there a bood book that actually talks about CGI?  I have a
couple whose titles include "CGI", but they say nothing about CGI.  All
they talk about is Perl.

Thanks!

Rob



__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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




database update

2002-08-15 Thread Rob

The following line works from a script run from the command line on the
server...

$sql = "UPDATE data SET CustNo = $custNo, PIN = $pin, Notes = '$notes'
WHERE CustNo = $custNo and PIN = $pin and CustName = '$custName' and
Serial = '$serial'";

but when run from cgi I get the following error...

ERROR: parser: parse error at or near ","

I'm using the Pg module, any idea why it won't run from the web?

Rob

Good judgement comes from experience, and experience -
well, that comes from poor judgement.




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




RE: Better regrex method

2002-08-14 Thread Hanson, Rob

This works for me...

# sample data
my @tags = qw(K001900 L001234 GP001675);
my @prefixs = qw(SP 8 L K GP TP MP);

# join them with pipes for use in the regex
my $prefix = join('|', @prefixs);

# match prefix against each tag, seprate the parts.
# the "o" switch cause the regex to only compile once.
# the split tags go back into the @tag array.
my @tags = map {/^($prefix)(.*)$/o;{PRE=>$1,NUM=>$2}} (@tags);

# this print out the prefix/number pairs
foreach my $tag (@tags) {
print "PREFIX: ", $tag->{PRE}, "\n";
print "NUMBER: ", $tag->{NUM}, "\n";
print "\n";
}

Something like that?

Rob

-Original Message-
From: Mike(mickako)Blezien [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 14, 2002 2:44 PM
To: Perl List
Subject: Better regrex method


Hello,

I'm working on a project where I need to split various tag numbers, from a
standard set of prefixes, entered into a form and check the number against a
database.

A sample test code that works, but was wondering if there's a better way to
utilize the regrex of this code:

# @tags similuate the tag numbers entered into a form, multiple numbers
my @tags = qw(K001900 L001234 GP001675);

# @prefixs are a pre-determined set of prefixes used.
my @prefixs = qw(SP 8 L K GP TP MP);

my($tagid,$tnum);

print header('text/html');
  while(my $prefix = <@prefixs>) {
  foreach $tagid (@tags) {
   if ($tagid =~ m!^$prefix!) {
 $tagid =~ s!^$prefix!!;
 print qq|Prefix: $prefix - Number: $tagid|;
 # Results: Prefix: K - Number: 001900
 # ...etc
}
  }
}

My questions is, is there a better way to separate the prefix from the
number ??
Any suggest would be much appreciated.

TIA,
-- 
Mike(mickalo)Blezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
Bus Phone:  1(985)902-8484
Cellular:   1(985)320-1191
Fax:1(985)345-2419
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

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

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




RE: Submitting Form Passes Old Values

2002-08-14 Thread Hanson, Rob

Running Perl as a CGI will *not* cache any variables (or anything else).
Each time the script is called the Perl executable will be started, and when
finished it will free all memory that it was using.  If you are using
mod_perl it is a little different.  mod_perl will cache a script (and any
modules used) in memory so that it starts up faster the next time it is
called, and it *can* cache variables if your code isn't written with
mod_perl in mind.

I hope that helps.

Rob

-Original Message-
From: Hal Vaughan [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 13, 2002 11:27 PM
To: [EMAIL PROTECTED]
Subject: Submitting Form Passes Old Values


I've got what amounts to a control panel or preferences settings system that

uses HTML and perl scripts.  I'm running this on Mandrake Linux 8.2 with 
Apache 1.3.  I have two pages that interact with each other.  The 2nd page, 
the one I'm having problems with, has a number of checkboxes, drop down 
menus, and radio buttons.  The first time I press Submit, all the values 
are passed properly to the called perl script.  The problem comes in after 
that.  When I use this page again, (both second and later times) and press 
"Submit", the page passes all the form elements (or rather their values) 
again, but twice.  It keeps building, but I'm not sure if it adds another 
copy of all the values each time I submit the page or not.

In other words, I press submit once, I get one set of values, and am 
returned to a front page.  I go from the front page back to the page with 
the form and press submit again, and I get two sets of the same values.  I 
just keep getting more and more values.

How are these values staying in memory?  How can I purge them?

Thanks.

Hal


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

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




get data over ssh

2002-08-02 Thread Rob

Hi, I don't have any relevant code to post but what I would like to do is;
from a server behind a firewall I would like to ssh to an Internet server
and grep a line out of the password file into my script running behind the
firewall.  Any ideas if this is possible or what category on the CPAN that
I should look at?

Thanks

Rob

Good judgement comes from experience, and experience -
well, that comes from poor judgement.




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




ftp to get a file from my cgi

2002-07-03 Thread Rob Roudebush


 Hi,
When my form processess it needs to ftp into a site to grab information - can I use a 
here document for that? Any quick example please.
Thanks, Rob
  Todd Wade <[EMAIL PROTECTED]> wrote: 

wrote in message
008801c222a5$a7c3cb10$d381f6cc@david">news:008801c222a5$a7c3cb10$d381f6cc@david...
> The reason I explained how to slurp the file into a variable was so that
it could be printed anytime
> anywhere. My solution does not force the file contents to be printed
right away. This is also
> useful for if you wish to replace something in the faq before printing it,
or adding some to the top
> and bottom. In short, it gives the programmer much more control before
simply printing the file.
>
> Regards,
> David
>

You really didnt need to explain yourself in relpy to my post.

Here is a snip from the op's original post:

"Kyle Babich" wrote in message
000501c2207c$f543f3e0$be683b41@oemcomputer">news:000501c2207c$f543f3e0$be683b41@oemcomputer...
> What would I use to include external pages in my script? (like if I
wanted
> to print the contents of faq.txt or log.cgi in my script)

I was providing the op with an alternative way to get identical results.
Sometimes your solution is better, for the reason that you stated, so that
the info could be filtered.

Sometimes the code I provided is better, for example the file is very large
and it is best to avoid loading the data in to memory.

Sometimes there are other solutions that are better for other reasons.

The point I was trying to make was how print() takes a list of data and not
just a simple scalar, a key concept for new perl programmers to understand.
It probably took me months to understand it. It had nothing to do at all
with your solution.

But since your solution involves "turning on slurp mode" I do suggest
explaining what that means, and what side effects it could have to the rest
of the code. For instance, if your example is used, and later on in the
program in the same scope I say:

while () { # oops!

It is probably going to confuse someone. Again, someone is back in the
newsgroup trying to get help tracking down a very difficult-to-track bug.

Probably every example in the docs that show modification of $/ in action
have the corresponding code wrapped in a block, i.e.

{
.
local $/ = undef();
$_ = 
.
}.

Quick quiz: can anyone explain why?

Todd W.

>
> - Original Message -
> From: "Todd Wade" 
> To: 
> Sent: Tuesday, July 02, 2002 6:19 PM
> Subject: Re: Including External Pages
>
>
> [EMAIL PROTECTED] wrote:
>
> > open(FH, " for write, >> for
> > append local $/ = undef; # slurp mode (allow for shoving the whole file
> > into a scalar)
> > my $faq = ; # slurp the whole file into this scalar.
> > close(FH);
> >
>
> open(FH, $file) or die("open $file: $!");
> print(); # print() takes a list. DWIM in action.
> close(FH) or die("close $file: $!");
>
> Todd W.




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



single quotes kill my scripts

2002-06-10 Thread Rob Roudebush


 I have the following code  - when someone enters a whatever ' whatever into one of my 
forms my script dies because of the single quote. Aggg... of course the first time 
I come across it is when my boss is testing out the script.
  $sth = $dbh->do( "insert into maintenance (owner, email, maintype, title, requested, 
engineer, ticket, impact, comm,
dispo, dispodate, action, sponname, sponop, sponcp, sponp, conname, conop, concp, 
conp, partname, partop, partcp, par
tp, manname, manop, mancp, manp, dbaname, dbaop, dbacp, dbap, engname, engop, engcp, 
engp, mainname, mainop, maincp,
mainp, process, rollback, closeout, datetime, purpose, risk, saname, saop, sacp, sap, 
total, pending, counting) value
s ('$owner', '@names', '$maintype', '$title', '$requested', '$engineer', '$ticket', 
'$impact', '$comm', '$dispo', '$d
ispodate', '$action', '$sponname', '$sponop', '$sponcp', '$sponp', '$conname', 
'$conop', '$concp', '$conp', '$partnam
e', '$partop', '$partcp', '$partp', '$manname', '$manop', '$mancp', '$manp', 
'$dbaname', '$dbaop', '$dbacp', '$dbap',
 '$engname', '$engop', '$engcp', '$engp', '$mainname', '$mainop', '$maincp', '$mainp', 
'$process', '$rollback', '$clo
seout', '$datetime', '$purpose', '$risk', '$saname', '$saop', '$sacp', '$sap', 
'$total', '$pending', '$counting')");




-
Do You Yahoo!?
Sign-up for Video Highlights of 2002 FIFA World Cup


Capturing signal to cgi form

2002-06-05 Thread Rob Roudebush


 Does anyone know how to capture the carriage return to prevent a user from 
accidentally submitting the form by pressing 'return' before they actually finish 
completing the form?
-Rob



-
Do You Yahoo!?
Sign-up for Video Highlights of 2002 FIFA World Cup


why do I get the following warning for taint

2002-05-29 Thread Rob Roudebush


 When I run perl -c myscript.cgi to test the syntax or perl -w ..., it produces this: 
Too late for "-T" option at maintenance.cgi line 1 (my line 1 is just the shebang line 
with the -T option). Does this mean that something is wrong?
-Rob
  Carl Franks <[EMAIL PROTECTED]> wrote: Hi,
This is how I do it.

#!/usr/bin/perl -wT
use strict;
my $conf;

unless ($conf = do ('/path/to/config.pl')) {
die ("Could not open file");
}

print $conf->{'var1'}, "\n";

-

Then in a file called "config.pl"


{
var1 => "one",
var2 => "two"
}

-

The "unless" part is just to check that the file was opened successfully.
The "do" actually opens the file and assigns the hash structure to $conf.

Hope this helps!
Carl

> Hi all,
>
> I want to use:
>
> use strict;
>
> And I want to use a configuration file in a Perl script.
> The configuration file uses:
> %page1=(
> 
> );
>
> %page2=(
> 
> );
>
> This way I get errors if I run the script because the variables are not
> defined with "my".
>
> I've tried putting in the configuration file:
>
> my %page1=(
> 
> );
>
> But this method doesn't work.
>
> I use a configuration file and I would like to put the settings only in this
> file without modifying the script.
>
> Is it possible?
>
> Thanks.
>
> Teddy,
> [EMAIL PROTECTED]
>
>


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



-
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup


Re: Using strict with DBI

2002-05-15 Thread Rob Roudebush


> $sth = $dbh->prepare("select ID from maintenance");
>this should read:
>my($sth) = $dbh->prepare("select ID from maintenance");


That didn't seem to work for me for some reason.

Another question - how do I apply strict to the lines below. And how do I just avoid 
the private or my declaration by specifically declaring a variable as a global 
variable (using vars?).
 foreach $var (@email){
$var =~ /(^.*)\\@.*/;
@names = (@names, "$1 ");}
@names = map (uc($_), @names);

  Todd Wade <[EMAIL PROTECTED]> wrote: 
"Rob Roudebush" wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
> I've seemed to have narrowed down the problem to $sth variable, I guess I
can't declare this as a private variable because it "prepares" it and needs
to have it at least local or global to access it?
> Rob Roudebush wrote:
> I think pulling the ID field may be causing the problem with use strict; ?
>
> $dbh = DBI->connect( "DBI:mysql:turnover", "root", "", {RaiseError => 1,
AutoCommit => 0});
> $sth = $dbh->do( "insert into maintenance (owner, email, maintype, title,
requested, engineer, ticket, impact, comm
> .

the do() method dosent return a statement handle. The transaction is
complete after do() executes sucessfully.
remove: ``$sth = '' from above, and then wrap $sth in my() in the line
below, as in:

> $sth = $dbh->prepare("select ID from maintenance");

this should read:

my($sth) = $dbh->prepare("select ID from maintenance");

> $sth->execute();
> while ($ref = $sth->fetchrow_hashref()){
> $ID = $ref->{'ID'};}
> $dbh->disconnect;
>
> Mark Bergeron wrote: Rob,
> use strict; shouldn't really affect the syntax of any DBI handle or
statement. ...

When strict is giving you problems, its because you are doing something
wrong, even though you swear you arent. Ive learned to trust perl before I
trust my own code, its a good policy.

Todd W.
[EMAIL PROTECTED]




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



-
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience


Re: Using strict with DBI

2002-04-30 Thread Rob Roudebush


 I've seemed to have narrowed down the problem to $sth variable, I guess I can't 
declare this as a private variable because it "prepares" it and needs to have it at 
least local or global to access it?
  Rob Roudebush <[EMAIL PROTECTED]> wrote: 
I think pulling the ID field may be causing the problem with use strict; ?

$dbh = DBI->connect( "DBI:mysql:turnover", "root", "", {RaiseError => 1, AutoCommit => 
0});
$sth = $dbh->do( "insert into maintenance (owner, email, maintype, title, requested, 
engineer, ticket, impact, comm
, dispo, dispodate, action, sponname, sponop, sponcp, sponp, conname, conop, concp, 
conp, partname, partop, partcp,
partp, manname, manop, mancp, manp, dbaname, dbaop, dbacp, dbap, engname, engop, 
engcp, engp, mainname, mainop, ma
incp, mainp, process, rollback, closeout, datetime, purpose, risk, saname, saop, sacp, 
sap, total, pending, countin
g) values ('$owner', '@names', '$maintype', '$title', '$requested', '$engineer', 
'$ticket', '$impact', '$comm', '$d
ispo', '$dispodate', '$action', '$sponname', '$sponop', '$sponcp', '$sponp', 
'$conname', '$conop', '$concp', '$conp
', '$partname', '$partop', '$partcp', '$partp', '$manname', '$manop', '$mancp', 
'$manp', '$dbaname', '$dbaop', '$db
acp', '$dbap', '$engname', '$engop', '$engcp', '$engp', '$mainname', '$mainop', 
'$maincp', '$mainp', '$process', '$
rollback', '$closeout', '$datetime', '$purpose', '$risk', '$saname', '$saop', '$sacp', 
'$sap', '$total', '$pending'
, '$counting')");
$sth = $dbh->prepare("select ID from maintenance");
$sth->execute();
while ($ref = $sth->fetchrow_hashref()){
$ID = $ref->{'ID'};}
$dbh->disconnect;

Mark Bergeron wrote: Rob,
use strict; shouldn't really affect the syntax of any DBI handle or statement. I would 
help if you included an example for us to have look at here.

-Original Message-
From: "Rob Roudebush"
To: [EMAIL PROTECTED]
Date: Mon Apr 29 18:15:23 PDT 2002
Subject: Using strict with DBI

>
> For some reason the DBI part of my code doesn't work with strict - is this a 
>limitation or am I doing something wrong - I declare my variables as my or private - 
>my $sth = DBI->...
>
>Another question how can I test my script at the command line with -w if it is 
>interactive? Or how do I push warnings to browser?
>
>-Rob
>
>
>
>
>-
>Do You Yahoo!?
>Yahoo! Health - your guide to health and wellness


___
GO.com Mail 
Get Your Free, Private E-mail at http://mail.go.com



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



-
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness


-
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness


Using strict with DBI

2002-04-29 Thread Rob Roudebush


 For some reason the DBI part of my code doesn't work with strict - is this a 
limitation or am I doing something wrong - I declare my variables as my or private - 
my $sth = DBI->...

Another question how can I test my script at the command line with -w if it is 
interactive? Or how do I push warnings to browser?

-Rob




-
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness


Password code!!

2002-04-11 Thread Rob Roudebush


 Please help - I need to password protect my form by COB today. I initially had just a 
password field at the bottom to authenticate prior to clicking submit. Is there 
anything better - say something that launches when a link is selected to the form??
 
  Nate Brunson <[EMAIL PROTECTED]> wrote: when you run perl with the -w flag does 
perl store all the warnings in a variable, like $! ?
or is $! only errors?

the reason I ask is I am using flash to run a .cgi script then print back the scripts 
results to flash, but for testing I want to be able to see some of the warnings I get, 
but because I am printing Content-type: text/html the warnings don't get displayed, 
how can I display them?
any help would be appreciated

nate



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


Mod_perl

2002-03-22 Thread Rob Roudebush


 I have created basic forms using CGI.pm and now I'm interested in using Apache 
mod_perl to speed things up  and use associated apache modules. Question: Can I 
continue to program using regular CGI, using params etc. or does mod_perl require me 
to program differently? Links to good resources would be appreciated.
Thanks, Rob
  



-
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards®


Re: Secure Logoff from Session CGI

2002-03-15 Thread Rob Roudebush

I'm not sure, but how do you set a cookie and have it
expire in ten minutes?

-Rob

--- Sean Abrahams <[EMAIL PROTECTED]> wrote:
> I have a small series of web pages that talks to a
> database and uses
> forms to input/alter data.
> 
> In order to get to these web pages a user has to
> authenticate. If
> valid, I put a cookie on their machine that expires
> in 10 minutes. So
> basically, they can use the forms for up to 10
> minutes, from which
> time they have to log back into the system.
> 
> My problem is that when the user exists the web
> page, they can still
> hit the back button and see all the data they
> entered. This is a
> security issue since someone could basically sit
> down at the same
> computer and hit back to find out some vital
> information, assuming the
> original user doesn't exit the browser.
> 
> I'm trying to setup something that prevents the
> client from just going
> back into the secured area by hitting back. I notice
> that on systems
> such as Wells Fargo's online banking, once you
> logoff, you cannot hit
> back to get back to your account. This is exactly
> what I'm trying to
> do, yet I have been unable to find out how to
> accomplish this.
> 
> I already have all the no-cache meta options in my
> HTML. What would be
> perfect would be if there were a perl/CGI function
> that could detect
> if the user is going back to the .cgi file via the
> back button and
> then act how you choose. However, I feel there
> should be an even
> easier way about this.
> 
> Any ideas?
> 
> 
> Thank you,
> Sean Abrahams
> SFSU : Fiscal Affairs Business Systems
> [EMAIL PROTECTED]
> 
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


__
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

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




Match and remove an element in an array

2002-03-15 Thread Rob Roudebush


 Okay my script takes names from a fom and puts them into an array - then later I need 
to match a $variable (one of the names) against that array and take that specific 
element out of the array. I figure there is probably an easy function to do this?
@array=(john, lucy, mike);
$name=john  
I need to modify the array and remove john.
  



-
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage


Re: changing the defualt "nobody"@somecomputer.com (mailx)

2002-03-10 Thread Rob Roudebush


 I'm using mailx from within a script, so I can't use it interactively open (MFH, "| 
mailx -s 'Subject' [EMAIL PROTECTED]")
print MFH < wrote: On Fri, Mar 08, 2002 at 06:05:07PM -0800, Rob 
Roudebush wrote:
> 
> My CGI script shoots out an automated e-mail using mailx. Is there any way to change 
>the "nobody"?
> -Rob

Hi Rob,


Yes, you can change the "From:" header.

Are you actually constructing an email and passing it to
mailx? You should, specify the To:, From:, Subject: headers,
then pass it to mail ( is there any reason to use mailx? It's
supposed to be for interactive use.



Thanks,
Rob

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



-
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!


Re: changing the defualt "nobody"@somecomputer.com (mailx)

2002-03-08 Thread Rob Helmer

On Fri, Mar 08, 2002 at 06:05:07PM -0800, Rob Roudebush wrote:
> 
>  My CGI script shoots out an automated e-mail using mailx. Is there any way to 
>change the "nobody"?
> -Rob

Hi Rob,


Yes, you can change the "From:" header.

Are you actually constructing an email and passing it to
mailx? You should, specify the To:, From:, Subject: headers,
then pass it to mail ( is there any reason to use mailx? It's
supposed to be for interactive use.



Thanks,
Rob

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




changing the defualt "nobody"@somecomputer.com (mailx)

2002-03-08 Thread Rob Roudebush


 My CGI script shoots out an automated e-mail using mailx. Is there any way to change 
the "nobody"?
-Rob



-
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!


telling user agent the full path of a file to downlaod

2002-03-08 Thread Rob Helmer

Hello,


I am trying to set a "preferred" absolute path on the user agent's
drive for a downloaded file.

It seems that the "filename" param of the "Content-disposition" header
the user agent SHOULD NOT ( according to the RFC ) honor the absolute
path like this.

I've found that it actually works for Windows pathnames ( e.g. "C:\temp\test" )
but Unix pathnames are set to - instead of / ( tested in latest Mozilla
release on both platforms.

Is there another way to go about this? I can't think of one, but I've
heard that PVCS does this through it's web interface so I figured there
must be a way.



Thanks,
Rob Helmer

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




Re: Running a CGI script as root

2002-03-08 Thread Rob Helmer

Hello,


I don't understand why you need to be root, I would suggest finding
another means, for security reasons. Can you explain a little more
about this? 

That said, here is one way you can do it :

Have you seen the sudo command? You can give root access to specific
users ( or groups of users ) to run specific commands ( or groups
of commands ).

You then just need to preface your command with "sudo", like instead
of :

cp /tmp/file /root/file

You do :

sudo cp /tmp/file /root/file



HTH,
Rob Helmer

On Fri, Mar 08, 2002 at 11:35:01AM +0100, Paolo Cavicchini wrote:
> 
> Hello,
> I need to write a CGI script able to launch, from an Intranet Web page, an
> executable on my Linux RH.
> To do that I need to run the executable as root because it works fine only
> if I've got root's privileges.
> The problem is: I cannot do that.
> 
> Could anyone gives me any help?
> Thank you
> Paolo
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




Expanding param("someinput") in here document

2002-03-07 Thread Rob Roudebush


I'm trying to avoid assigning each param("somekey") to a variable in order to expand 
it in my here document.
I can refer to it as a hash element without any variable assignment using - print 
param("somekey"); - but I don't want to have to use print statements instead of a here 
document to display it to a Web page.
Any help?



-
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!


CGI Design problem

2002-03-06 Thread Rob Roudebush

Okay, I created a HTML Form that calls a CGI script.
After the form is submitted it sends out e-mails with
a link inside to certain managers. They follow the
link which is a separate HTML page that calls a
separate CGI script. 

Question: I need to keep track of the managers who
follow the link and approve/disapprove the project in
the e-mail. Somehow I need to put logic into the CGI
script to keep track of that, and then send out an
e-mail when everyone has approved. Should I just
create a new file and just keep track of names and
test it every time someone approves/disapproves? 


__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

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




Regular expression help w/timestamp

2002-03-03 Thread Rob Roudebush


Has anyone ever turned the mysql timestamp format  20020303223726 into something more 
readable like - 03/03/2002 22:37:26? I am also trying to do this from an array (the 
timestamp is in a array). I just figured somebody has probably done this already.

Thanks, Rob



-
Do You Yahoo!?
Yahoo! Sports - Sign up for Fantasy Baseball


Text input fields with preassigned text??

2002-03-01 Thread Rob Roudebush


 Is there anyway to display text input fields with text already inside, that can be 
modified and submitted? 
  Bhanu Prakash <[EMAIL PROTECTED]> wrote: Perl Listers,
I'm unable to retrieve cookies once I set them! I
can see my html headers on my page once they are set,
along with the page, but when I move out to another
page, I'm not able to retrieve them, in the new cgi
script. My script is complaining "Can't call method
"value" on an undefined value"
Any Help?!
Thanks
Bhanu.

=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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



-
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!


Re: Escaping special characters for regular expressions

2002-02-28 Thread Rob Roudebush


 Wouldn't single quotes do the trick?
  Curtis Poe <[EMAIL PROTECTED]> wrote: --- W P wrote:
> i don't want to just escape those characters. they were merely examples. i
> was hoping maybe there was some built-in way to escape ALL the characters
> that mean anything to regular expressions.

Well, technically, *all* characters mean something to a regex. I assume that you want 
to escape
metacharacters which transform the behavior of the regular expressions.

perldoc -f quotemeta

quotemeta will escape all non-word characters (prepend them with a backslash) which 
should match
your needs. If that's too general, start looking at qr// and related functions.

Cheers,
Curtis "Ovid" Poe

=
"Ovid" on http://www.perlmonks.org/
Someone asked me how to count to 10 in Perl:
push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A

__
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com

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



-
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!


Re: Taking entire Oracle application (forms, reports) to WEB using CGI?

2002-02-28 Thread Rob Roudebush


 I currently use mysql and it works great - I have at least 10 different forms running 
on Apache that I've created in the past month or so.
  fliptop <[EMAIL PROTECTED]> wrote: Bruce Ambraal wrote:

> Hi All
> How possible is this.?


very.

> This a good Idea?


personally, i'd use postgresql (since it's free).

> I am currently defining a 6 month project deploying our current Oracle 

> financial system to the WEB using CGI. Can anyone point out current success 

> stories, that really works.

mod_perl success stories can be found here:

http://perl.apache.org/sites.html

perl success stories are found here:

http://perl.oreilly.com/news/success_stories.html


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



-
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!


Re: How can I Track the client IP, when a web request is made to my server.

2002-02-27 Thread Rob Roudebush


 In the CGI script put $varwhatever=remote_addr;
  vijayak <[EMAIL PROTECTED]> wrote: All,

I am Just a Beginner in this & I want to know about 
How to track the client IP, when a web request is made to my server, and pass is to 
one variable for further use.



thanks a lot if you can give some full function to keep in my script.



vijay




-
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!


Re: Very serious security hole in your script

2002-02-26 Thread Rob

Is there a good tutorial on untainting data received via a cgi script?

On Tue, 26 Feb 2002, Curtis Poe wrote:

> --- erotomek <[EMAIL PROTECTED]> wrote:
> > ALWAYS USE THE TAINT MODE !!!
> > 
> > Use the -T switch:
> > 
> > #!/usr/bin/perl -wT
> > 
> > and untaint the $file variable:
> > 
> > die 'INSECURE $file !!!' if $file =~ /\.\./;
> > if ($file =~ /^([-\w./]+)$/) { $file = $1 }
> > else { die 'INSECURE $file !!!' }
> > 
> > and now you can use it.
> 
> You supplied some great information, however, your example of plugging the security 
>hole has a
> security hole itself.  From the command line on any *nix system, enter the following 
>(assuming you
> are not in root):
> 
> cd \.\.
> 
> You quickly discover that the shell allows those dots to be escaped.  In a url, that 
>translates to
> something like:
> 
> %5c.%5c.%2F%5c.%5c.%2Fetc%2Fpasswd
> 
> (That's "\.\./\.\./etc/passwd")
> 
> Many variations of that can be tried to find out if their is a security hole.  If 
>you must allow
> the user to specify a file name, get rid of any ASCII zeroes in the file name (to 
>prevent NUL byte
> hacks -- I explain that at
> http://www.easystreet.com/~ovid/cgi_course/lesson_three/lesson_three.html under the 
>title "Poison
> Null byte").  Then, you can use File::Path to get the real filename.  Even then, 
>though, I'm leery
> of allowing the user data near the shell, but sometimes it is necessary.
> 
> Cheers,
> Curtis "Ovid" Poe
> 
> =
> "Ovid" on http://www.perlmonks.org/
> Someone asked me how to count to 10 in Perl:
> push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
> shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A
> 
> __
> Do You Yahoo!?
> Yahoo! Sports - Coverage of the 2002 Olympic Games
> http://sports.yahoo.com
> 

-- 
Rob

Good judgement comes from experience, and experience -
well, that comes from poor judgement.



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




Uploading a file?

2002-02-25 Thread Rob Roudebush


Does anyone know how to upload a file to your site? 
-Rob



-
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games


Multiple Print "Location:$link";

2002-02-07 Thread Rob

We have an epage server for our customers to use; one of them is a fire
department and they would like to have a page setup with check boxes and
send the same message to all who have a check beside there name.  I've
been trying something like the following...
if($shawn ne "") {
$link = "http://server.net/cgi-bin/epage.cgi?pin=$shawn\&mess=$mess
print "Location:$link";
}
if($rob ne "") {
$link = "http://server.net/cgi-bin/epage.cgi?pin=$rob\&mess=$mess
print "Location:$link";
}

This works if only one checkbox is checked, but if both are checked the
first message gets the message along with Location:http://server.etc
appended to it.  Is there someway to reset the header for the second
message? Or perhaps a better way to proceed all together?

Thanks in advance.

Rob

Good judgement comes from experience, and experience -
well, that comes from poor judgement.




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




Re: Form parameter as filename?

2002-01-07 Thread Rob Cottingham

Thanks for the suggestion, Fliptop.  Someone finally pointed out my problem:
data tainting was on, and I had to untaint the data before Perl would let me
use it in something as exposed as a filename.

Whew!!

Cheers,
--rob


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




Form parameter as filename?

2002-01-07 Thread Rob Cottingham



Hi, all --

I'm trying to use a parameter passed from a CGI form as the basis of a
filename:

   my $file_location = "/home2/samuel-c/HTML/alex/urltest/";
   my $filename=param('category');
   my $fileid=$file_location.'urls_'.$filename;

   open(ULL, ">>$fileid") || die "Can't open the URL file: $! \n";

Doesn't work worth a damn.  (The "category" parameter is a keyword, like
"intro".)  But if I use this line instead to define $fileid...

   my $fileid="/home2/samuel-c/HTML/alex/urltest/urls_intro;

...then it works like a charm.  I've also tried this with a keyword read in
from a text file; that didn't work either.  Any suggestions?

Thanks,
--rob


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




Re: encrypt Pass

2001-12-06 Thread Rob

This is what I use.

sub CryptPW {

my($passWord) = $_[0];
my($salt) = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand
64];
my($crypted) = crypt($passWord, $salt);

return $crypted;

}

Rob

Good judgement comes from experience, and experience -
well, that comes from poor judgement.



On Thu, 6 Dec 2001, Christo Rademeyer wrote:

> Hi how must I go to encrypt my passwd on my adduser I wrote?
> Thanx
> Christo
>
> PS! is it make salt or something like that ?
>
>


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




Re: System call from a CGI script

2001-10-24 Thread Rob

I setup something similar for an ISP once and I had the cgi-bin script
right out the information to a file.  Then I had another script that ran
every 10 minutes and setup the user based on the info in the file.

Rob

Good judgement comes from experience, and experience -
well, that comes from poor judgement.



On Wed, 24 Oct 2001, James B. Williams II wrote:

> Hi all,
> 
> I just posted a question to the beginners-cgi list yesterday;  I'm
> having almost the exact same problem.  Both my cgi script and the script
> I am trying to call via system are owned by root, but I'm not sure if
> that is related to the user the cgi script is run as under the web
> server. (Forgive me if my vernacular is incorrect).  Anyway, the
> important part is, how do I get the system call to work?
> 
> Thanks,
> 
> James
> 
> On Wed, 24 Oct 2001, Daniel Falkenberg wrote:
> 
> > I am working on a CGI script that needs to execute this command from 
> a
> > sub within the script...
> >
> > system("/usr/sbin/adduser test");
> >
> > I can issue this from a single non-CGI script and it works fine.  I 
> have
> > also double checked the permission on the file but it still won't
> > execute this system call?
> 
> adduser is a system program that should be run as root.  If you are
> running this in a CGI environment, you won't be able to run the script
> because the user the CGI script is running as is the same as that of 
> your
> web server (probably 'nobody'), and is not allowed to run the program.
> 
> -- Brett
> 


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




RE: E-mail with the -T switch

2001-10-11 Thread Rob

Thanks, this one worked.

$ENV{PATH}='/usr/sbin';
my($mailprog) = 'sendmail';
my($recipient) = '[EMAIL PROTECTED]';
open (MAIL, "|$mailprog -t") ;

#Do mail stuff

delete $ENV{PATH};

:wq



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




RE: E-mail with the -T switch

2001-10-11 Thread Rob


open (MAIL, "|-", "$mailprog" , "-t");

gives me the following in the error log...

Can't use an undefined value as filehandle reference at
/home/rob/cgi-bin/completeOrder.cgi line 9.


On Thu, 11 Oct 2001, Kipp, James wrote:

> > 
> > my($name) = "John";
> > my($mailprog) = '/usr/sbin/sendmail';
> > my($recipient) = '[EMAIL PROTECTED]';
> > open (MAIL, "|$mailprog -t");  #The script fails here
> 
> Try this:
> open (MAIL, "|-", "$mailprog" , "-t");  #avoids using the shell
> 
> or you can do at the top of script:
> $ENV{PATH} = 'bin:/usr/bin'; # restrict the path env var
> 
> 
> > 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


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




E-mail with the -T switch

2001-10-11 Thread Rob

I've been following this list with the digest version for some time now
and have started using the -T swith in all of the scripts that I write
now.  Unfortunately, I don't know how to send e-mail with the -T switch
turned on.  I would normally do it like this...

/usr/bin/perl -wT

use strict;

my($name) = "John";
my($mailprog) = '/usr/sbin/sendmail';
my($recipient) = '[EMAIL PROTECTED]';
open (MAIL, "|$mailprog -t");  #The script fails here

print MAIL "To: $recipient\n";
print MAIL "From: $name\n";
print MAIL "Subject: Test\n\n";


format MAIL =

Name:  @<<<<<<<<<
$name

***
.
write (MAIL);
close(MAIL);
 

The log file gives me this error message...

Insecure $ENV{PATH} while running with -T switch at
/home/rob/cgi-bin/completeOrder.cgi line 8.

If I take the -T off, it works fine but I'm hesitant to do that.

Thanks,

Rob
[EMAIL PROTECTED]



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




mod_perl/browser language

2001-10-03 Thread Rob

How can I detect the browser language using mod_perl? 

I tried this:

$ENV{'HTTP_ACCEPT_LANGUAGE'};

but it doesn't seem to work..


Thanks.



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




file type detection

2001-09-30 Thread Rob

Is there a simple way for a script to scan a file and know if it is a valid
file type? What I mean is if I have an mpeg file that has been renamed to
something like movie.html or movie.gif is there a way to know that it is not
a valid html or gif file?

Thanks.



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




making graphics..

2001-08-07 Thread Rob

Hi,

I want to be able to create graphic logos witha perl script - any ideas on
how to do this?

What I mean is I will provide a list of titles and a list of font styles
then the script will create a gif for each title using a random font style..

Can it be done? Is it difficult? I've never tried any kind of graphical
stuff with perl before so its all a mystery..


Thanks.



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




RE: Packages, classes, cgi

2001-07-19 Thread Rob Sexstone

Hi Shawn,

I'm currently working through the same learning curve on OOP in perl and
bought a copy of 'Perl Developer's Guide' by Ed Peschko and Michele deWolfe.

I'm finding the tutorial style suits my beginners/intermediate level, and it
also comes with a CD full of code examples.

(I plan to buy Damian's book too)

cheers,
RS

-Original Message-
From: shawn [mailto:[EMAIL PROTECTED]]
Sent: 18 July 2001 21:19
To: perlcgi
Subject: Packages, classes, cgi


I am in need of some direction when working with .pm(s). I have had a couple
years experience with writing straight perl scripts, but am having a hard
time with using and writing packages. I don't understand the overall process
of calling a method from an object. I've been given a project to write a
cgi/linux/perl/mysql/barcode data-center inventory application and need
guidance quick.

Can someone point me in the right direction (book or website) to learn the
internal workings of packages, classes, objects, etc...

Thanks much!
Shawn


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




RE: Dreaded Internal Server Error

2001-07-18 Thread Rob Yale

Thanks folks,

Bill Luebkert showed me that three of my scripts were actually DOS files,
and needed to be saved properly.  I'm now a much happier camper!

Rob Yale

-Original Message-
From: Lisa Nyman [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 18, 2001 8:33 AM
To: [EMAIL PROTECTED]
Subject: Re: Dreaded Internal Server Error


Hi,

When a CGI script runs from the command line but not from the web server,
a common culprit is permissions.  Be sure that anything the script does,
like create files, write to files, read files, execute commands, etc, are
allowed for the web server user and group.

Lisa Wolfisch Nyman  <[EMAIL PROTECTED]>  IT Warrior Princess
"Life is too short to wear ugly underwear."
Get the facts at http://quickfacts.census.gov/

On Tue, 17 Jul 2001, Rob Yale wrote:

> Hi,
>
> I'm trying to get a cgi program working (I didn't write it) and I'm
> experiencing some mysterious problems.
>
> 3) I can execute a simple 'hello world' program in the same cgi-bin
> directory both from the shell, and through CGI.  The permissions for all
the
> files are 755.  The owner of the file is 'nobody', and the group is
'root'.


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


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




Dreaded Internal Server Error

2001-07-17 Thread Rob Yale

Hi,

I'm trying to get a cgi program working (I didn't write it) and I'm
experiencing some mysterious problems.  First of I'll, I should tell you
that the error I get is the dreaded "Internal Server Error" message.  I've
also looked in the logs, and they're further explicated as follows:

[Tue Jul 17 00:42:16 2001] [error] (2)No such file or directory: exec of
/var/www/html/ebay/cgi-bin/spawn_server.cgi failed
[Tue Jul 17 00:42:16 2001] [error] [client 64.231.11.99] Premature end of
script headers: /var/www/html/ebay/cgi-bin/spawn_server.cgi

Now for some details:

1) I'm using Apache 1.3.20

2) I'm using ScriptAlias to specify the cgi-bin directory

3) I can execute a simple 'hello world' program in the same cgi-bin
directory both from the shell, and through CGI.  The permissions for all the
files are 755.  The owner of the file is 'nobody', and the group is 'root'.

4) I've tried debugging the script by adding a print statement, and I found
that the program would execute from the shell, but not through CGI.  The
program expects a ton of parameters to be passed to it from the browser, and
when I'm executing it from the shell, the only sign that it is working is
the output from my print statement.

It almost seems as if CGI is actually intermittent.  I ran the script as
follows:

perl -cw spawn_server.cgi and the output of that indicated that the code was
ok.

I know that this error is very general, but any help pointing me in a
direction for debugging it would be most appreciated.

Rob Yale


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




  1   2   >