Re: perl DBI

2003-03-25 Thread Brett W. McCoy
On 26 Mar 2003, mark  sony wrote:

> What are the good online sites which will give details about perl
> DBI, about using perl interacting with databases,right from basic
> to advanced stage?

Start with http://dbi.perl.org/

-- Brett
  http://www.chapelperilous.net/

No directory.


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



Re: Problem with regular expressions!!!

2003-03-18 Thread Brett W. McCoy
On Tue, 18 Mar 2003, 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!!!
> }
> #

You should use the split function here:

my @file = split /\./, $file_completename;

$file[1] will contain the extension, without the leading .

-- Brett
  http://www.chapelperilous.net/

When you speak to others for their own good it's advice;
when they speak to you for your own good it's interference.



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



Re: Good Perl cgi book?

2003-03-18 Thread Brett W. McCoy
On Tue, 18 Mar 2003, Dennis Stout wrote:

> That is the mother of all perl books.  It's also more of a reference book than
> anything else.  Altho if you're that type of learner, it'll be a great read.
> It should also sit on the bookshelf of any Perl programmer, regardless of
> whether they use it to read from cover to cover, or to lookup those
> miscelanious little tid bits they kind of know and need clarification on.

Any programming manual that has _The Lord of the Rings_ on its list of
recommended reading is certainly worth owning, IMHO. *_^

-- Brett
  http://www.chapelperilous.net/

The first half of our lives is ruined by our parents and the second half
by our children.
-- Clarence Darrow


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



Re: sprintf questions

2003-03-13 Thread Brett W. McCoy
On Wed, 12 Mar 2003, David Gilden wrote:

> Is the following considered ok as in good PERL style?
>
> #!/usr/bin/perl -w
>
> $num =1.12345;
>
> my $tax_formated = sprintf("%.2f", $num);  # <--- THIS LINE
>
> print "$tax_formated  " ,length($tax_formated), "\n";

The important thing is, does it do what youo are expecting it to do?

-- Brett
  http://www.chapelperilous.net/

QOTD:
"The elder gods went to Suggoth and all I got was this lousy T-shirt."


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



RE: html table limit

2003-03-12 Thread Brett W. McCoy
On 12 Mar 2003, Rob Benton wrote:

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

Ideally you could page the returned data in groups of 100.  Take a look at
this:

http://www.carumba.com/talk/perl/multiview.shtml

-- Brett
  http://www.chapelperilous.net/

Despite all appearances, your boss is a thinking, feeling, human being.


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



RE: html table limit

2003-03-12 Thread Brett W. McCoy
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]



Re: Camel Book

2002-03-20 Thread Brett W. McCoy

On Wed, 20 Mar 2002, Octavian Rasnita wrote:

> I heard about that famous Camel Book for Perl but I don't know its real
> name.

The full name is _Programming Perl_, by Larry Wall, et al.  It's an
O'Reilly book and can be found in any bookstore that has a computer
section.

-- Brett
  http://www.chapelperilous.net/

Reality does not exist -- yet.


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




Re: first glimpse of regex

2002-03-19 Thread Brett W. McCoy

On Tue, 19 Mar 2002, Matthew Harrison wrote:

> i need to say something like
> if $username = "" then ...
>
> where "" is literally nothing. i want to match it ONLY if the variable is
> totally empty.
>
> this is my first experience with regex so what should this be?

if(!$username) {

}

An empty string returns boolean false (like 0 does), so you can test for
truth in an expression.  I think a regex is unnecessary here.

-- Brett


The sooner you fall behind, the more time you have to catch up.


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




Re: Can someone explain the difference ?

2002-03-19 Thread Brett W. McCoy

On Tue, 19 Mar 2002, Kamali Muthukrishnan wrote:

> I have the following perl-script , which gives the user ( supposedly a
> first or second grader) a problem in addition or subtraction by
> generating random numbers.  The random numbers generated are between 1
> and 10 for first graders and 10 and 100 for second graders.  I am trying
> to just execute the code at the command prompt.  It runs OK if the line
> -
>
>  use CGI qw(:standard );
>
> is commented out.  The loop goes through till I say 'n' to the query -
> do you want to continue ? If that line is not commented out ( I know it
> is not needed till I put a HTML piece to this ) it does not give an
> error, but runs wrong. Even if I pick 'Addition' as the operation I
> want, it gives me the subtraction problem (that is even if the
> expression in the if statement is true, it executes the 'else' ) and the
> loop does not go on till I say 'n'.  Can somebody tell me why ?( I am a
> beginner)

Don't use CGI.pm unless you are really using it -- it expects certain
things to be coming in from STDIN (CGI parameters) and using it as an
interactive command-line program is going to do nothing but frustrate you.
It runs the subtraction block because the value retrieved from STDIN is
never assigned to the correct variable.

-- Brett
  http://www.chapelperilous.net/

The meek are contesting the will.


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




Re: extracting params to a hash

2002-03-05 Thread Brett W. McCoy

On Tue, 5 Mar 2002, Jeff 'japhy' Pinyan wrote:

> On Mar 4, Shaun Fryer said:
>
> >I'm trying to convert an old script that used cgi-lib.pl over to using
> >CGI.pm. In order to save time I'd like to simply do something like
> >what follows (though that doesn't actually work it seems).
> >
> >%in = param;
>
> param() only returns field names.  But why not just do:
>
>   use CGI 'Vars';
>   my %in = Vars();
>   # or, for a hash reference instead
>   # my $in = Vars();

It should be pointed out that if you use it as a hashref, it's actually a
*tied* hashref, which means you can alter the contents of the CGI
parameters (as opposed to just making a copy).

-- Brett
  http://www.chapelperilous.net/

If the girl you love moves in with another guy once, it's more than enough.
Twice, it's much too much.  Three times, it's the story of your life.


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




Re: Asynchronous Perl

2002-03-04 Thread Brett W. McCoy

On Mon, 4 Mar 2002, Jason Frisvold wrote:

>   I'm looking for a way to have perl output in an asynchronous
> manner.  What I mean is, if I write a perl script to generate a large
> amount of data and output it to the screen, it seems to pause until some
> unknown buffer is full and then spit out the output..  pause again, show
> output, etc.  It does the same thing with files.  I can watch the
> filesize for the output and it seems to only jump in size every so
> often.
>
>   My main goal here is so that the data is streamed so that a web
> browser can begin displaying the data without a long pause.
>
>   Is there a way to do this, or should I switch to C++?

Set $| to a positive value ($|++ will do).  This turns on the autoflush
mechanism for the currecntly selected filehandle.

There's a FAQ on this:

perldoc -q flush

-- Brett
  http://www.chapelperilous.net/

Space tells matter how to move and matter tells space how to curve.
-- Wheeler


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




Re: SHIFT in a subroutine

2002-02-20 Thread Brett W. McCoy

On Wed, 20 Feb 2002, Curtis Poe wrote:

> Great description with one minor caveat:  shift with no arguments will
> pull from @ARGV if not used in a subroutine.

Yes, thanks for pointing that out.

-- Brett
  http://www.chapelperilous.net/

tax office, n.:
Den of inequity.


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




Re: SHIFT in a subroutine

2002-02-20 Thread Brett W. McCoy

On Wed, 20 Feb 2002, Nestor Florez wrote:

> I was wondering about the "shift" inside a subroutine.
>
> I have never used it.  What is the purpose of it been there?

It pulls off the first element of the array passed to it.  Using shift
with no arguments always pulls from @_ -- it returns $_[0] and also shifts
the other elements down ($_[1] becomes $_[0], $_[2] becomes $_[1], etc).
@_ is the 'default' array (analogous to $_), and in a subroutine, is the
array of subroutine arguments.  If you say

mysub('arg1', 'arg2');

then

sub mysub {
  $arg1 = shift; #gets the first argument 'arg1'
  $arg2 = shift; #gets the second argument 'arg2'
  ...

}

-- Brett
  http://www.chapelperilous.net/

Computer programmers never die, they just get lost in the processing.


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




Re: Spaces in form values --> cgi

2002-02-15 Thread Brett W. McCoy

On Fri, 15 Feb 2002, David Gilden wrote:

> Kayak Touring Rescue 
>Techniques
>
> Or do I need to use underscores,
>
> Kayak Touring Rescue 
>Techniques

I believe the spaces will get replaced with %20.  I question the necessity
of making the value of the option the same as the text you are displaying
(actually, if you don't specify a value, the text IS the value).  It would
be better to make the value something short, like 'KTRT' or some similar
mnemonic (like perhaps an id field you wouuld be looking up in a
database...)  It will make your life a lot easier.

-- Brett
  http://www.chapelperilous.net/

To err is human -- but it feels divine.
-- Mae West


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




Re: buton names

2002-02-14 Thread Brett W. McCoy

On Thu, 14 Feb 2002, GsuLinuX wrote:

> It worked on normal submit buttons but problem on image submit button.
>
> I couldn't manage to work it with
> image submit buttons. Fot example if their 2 image submit buttons as :
>
>  src="c:\windows\desktop\house.gif" width="100" height="50">
>  src="c:\windows\desktop\debugreport.jpg" width="100" height="50">
>
> cgi cannot get the names of these? Must i use other module?

The problem with image buttons is that they return name.x and name.y (with
the corrdinates of where they were clicked) to your CGI script, so you
will need to find out which image was clicked that way.  You could do
something like (using CGI.pm):

use CGI;

my $q = new CGI;

my %params = $q->Vars(); #put all params into hash
my $button;
foreach(keys %params) {
  if(/(.*)\.x) {
$button = $1;
  }
}

-- Brett

  http://www.chapelperilous.net/

QOTD:
If you're looking for trouble, I can offer you a wide selection.


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




Re: use, require, do... which is appropriate?

2002-02-12 Thread Brett W. McCoy

On Tue, 12 Feb 2002, W  P wrote:

> my problem is simple.  i have a number of scripts on my server, and i
> would like all of them to initially run a function defined by me.
> however, it would be burdensome to write that function over for every
> script.  creating a custom module, however, doesn't really seem that
> much easier.  i have read the chapter on modules in Programming Perl,
> and i am still not sure about a few things.  if i were to create my own
> module, what directory does it go in?

While writing a module is more work, it's better and safer, IMHO.  'use'
actually does a require, but has some other things it does, like proerply
imports exported sub names, etc.

As for which directory, use any directory you wish.  You can always put
the directory in the PERL5LIB environment variable, or, do this in your
files:

use lib '/path/to/Module'; #adds /path/to/Module to @INC
use Module;

BTW, . is already included in @INC, so you can put the moduel in the saem
directory as your script.

-- Brett
  http://www.chapelperilous.net/

Where there's a will, there's a relative.


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




Re: image button submit?

2002-02-08 Thread Brett W. McCoy

On Fri, 8 Feb 2002, Josiah Altschuler wrote:

> Is there a way to use an image button in CGI.pm to submit?

Sure:

print image_button(-name=>'name', -src=>'path/to/img');

will produce:



This is documented in the CGI.pm documentation, accessible via perldoc.

-- Brett
  http://www.chapelperilous.net/

BOFH excuse #393:

Interferance from the Van Allen Belt.


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




RE: beginners-cgi Digest 8 Feb 2002 17:29:24 -0000 Issue 165

2002-02-08 Thread Brett W. McCoy

On Fri, 8 Feb 2002, Allen Wang wrote:

> I want to change the string  "d:\orant\oracle" to "d:\\orant\\oracle"
>
> Anyone know how to do this?

$string =~ s|\\||g;

(\ is used to escape metacharacters in a regexp, so you need to escape \
also).

-- Brett
  http://www.chapelperilous.net/

Mathematicians practice absolute freedom.
-- Henry Adams


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




Re: Reading a big text file

2002-02-08 Thread Brett W. McCoy

On Fri, 8 Feb 2002, Octavian Rasnita wrote:

> To store the file in an array, then to insert the changed value in that
> array, and then to write that array to the file, or to use a temporary file
> to store each line from the source file and twhen I want to modify a line, I
> have just to insert it in the temporary file.

I recommend the latter, using a temp file to write your changes out to.
Reading a file into an array will eat up memory if it's a big file.

-- Brett

  http://www.chapelperilous.net/

Q:  Why do WASPs play golf ?
A:  So they can dress like pimps.


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




Re: procmail or perl to drop dups?

2002-02-08 Thread Brett W. McCoy

On Fri, 8 Feb 2002, Dennis G. Wicks wrote:

> Has anyone developed any method to drop messages that
> are cross-posted to both [EMAIL PROTECTED] and
> [EMAIL PROTECTED]?

Here's the procmail recipe I use for duplicates:

:0 Whc: msgid.lock
| formail -D 8192 msgid.cache

:0 a:
DUPLICATES

-- Brett
  http://www.chapelperilous.net/

A king's castle is his home.


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




RE: Passing a hash through a URL

2002-02-07 Thread Brett W. McCoy

On Thu, 7 Feb 2002, Josiah Altschuler wrote:

> Hi.  Thanks for the response.  I'm passing the hash with an href in this
> manner.  So does this mean that I'm not using get or post?
>
> $query = CGI->new({red => [%{$clusArrayHash[$i]}]})->query_string;
> print pre h6 ("   ", a ({ -href =>
> "http://140.247.111.176/cgi-bin/redundancies.pl?red=$query"; }, "Redundant
> sequences"));

It's a 'get' method.  You're limited, I think, to 256 characters.

-Brett
  http://www.chapelperilous.net/

Hollywood is where if you don't have happiness you send out for it.
-- Rex Reed


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




Re: module errors

2002-02-07 Thread Brett W. McCoy

On Thu, 7 Feb 2002, Uwe Voelker wrote:

> > use HTML::Parse;
>
>
> The module is called HTML::Parser.

A further investigation via CPAN showed me that HTML::Parse is part of the
HTML::Tree bundle and is now actually a deprecated module, according to
the readme.

-- Brett
  http://www.chapelperilous.net/

All generalizations are false, including this one.
-- Mark Twain


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




Re: module errors

2002-02-07 Thread Brett W. McCoy

On Thu, 7 Feb 2002, GsuLinuX wrote:

> we wroted a perl code to fetch some information we want from a web site. The code is 
>as below:
>
> #!/usr/bin/perl
> use LWP::Simple;
> use HTML::Parse;



> We have the debug error:
>
> Can't locate HTML/Parse.pm in @INC(@INC contains:
> /usr/lib/perl5/5.6.0/i386-linux
> /usr/lib/...
> ) at
> /usr/local/plesk/apache/vhosts/loop10.com/httpdocs/DDdeneme/parite2.cgi line
> 3
>
> Begin Failed-compilation aborted at
> /usr/local/plesk/apache/vhosts/loop10.com/httpdocs/DDdeneme/parite2.cgi line
> 3
> "

Are you sure you don't mean HTML::Parser (they are two differenty
modules)?

-- Brett
  http://www.chapelperilous.net/

Where do I find the time for not reading so many books?
-- Karl Kraus


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




Re: To write a script that reads numbers from STDIN and print onSTDOUT.

2002-02-07 Thread Brett W. McCoy

On Thu, 7 Feb 2002, Bruce Ambraal wrote:

> Could  any one write some coding for the problem.
>
> In perl against Linx could someone help.
>
> I want to write a script that reads in four numbers from STDIN and add
> the first two together, and than adds the second 2 together.
>
> The input format is a number on a line.(press enter after every number)
> I also want to ompare the resulting two numbers with > or < and print
> the largest on STDOUT.

Is this a homework problem perchance?

I won't take all of your fun away from writing the code yourself, but will
give you a hint:

You can retrieve values from STDIN like this:

my $value = ;
chomp value; #remove trailing newline

-- Brett
  http://www.chapelperilous.net/

"There are things that are so serious that you can only joke about them"
- Heisenberg


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




Re: CGI Form Submit Buttons

2002-02-06 Thread Brett W. McCoy

On Wed, 6 Feb 2002, Andre` Niel Cameron wrote:

> But what about cases of having two image buttons?  Does the one that is
> clicked default as submit or does this require java script?

You give them differnet names and have your script do different things
based on the name that was clicked.

-- Brett
  http://www.chapelperilous.net/

But scientists, who ought to know
Assure us that it must be so.
Oh, let us never, never doubt
What nobody is sure about.
-- Hilaire Belloc


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




Re: printing an email address

2002-02-06 Thread Brett W. McCoy

On Wed, 6 Feb 2002, Brett W. McCoy wrote:

> On Wed, 6 Feb 2002, Octavian Rasnita wrote:
>
> > I tried to print my email address when it is enclosed in < and > signs but
> > it didn't print anything.
> > The code:
> >
> > my $line;
> > $line= "";
> > # I also tried with $line = \";
> > print "$line";
>
> No need for the double quotes (it will try to interpolate the @):
>
> ~$ perl
> $line = '<[EMAIL PROTECTED]>';
> print "$line\n";
>
> <[EMAIL PROTECTED]>
> ~$

Oh, but if you are doing this on a web page, you should use also < and
> instead of < and >, because the HTML interpreter will see those as tag
delimiters.  Better yet, use HTML::Entities::encode.  See the perldoc on
HTML::Entities for more details.

But still, don't double quote unless you need to (i.e., you need to
interpolate variables or control characters like \n inside the string).

-- Brett
  http://www.chapelperilous.net/

love,  n.:
Love ties in a knot in the end of the rope.




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




Re: printing an email address

2002-02-06 Thread Brett W. McCoy

On Wed, 6 Feb 2002, Octavian Rasnita wrote:

> I tried to print my email address when it is enclosed in < and > signs but
> it didn't print anything.
> The code:
>
> my $line;
> $line= "";
> # I also tried with $line = \";
> print "$line";

No need for the double quotes (it will try to interpolate the @):

~$ perl
$line = '<[EMAIL PROTECTED]>';
print "$line\n";

<[EMAIL PROTECTED]>
~$

-- Brett
  http://www.chapelperilous.net/

If you don't go to other men's funerals they won't go to yours.
-- Clarence Day


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




Re: Hexadecimal Dictionary

2002-02-05 Thread Brett W. McCoy

On Tue, 5 Feb 2002, Fred Sahakian wrote:

> Anyone know of a good online Hexadecimal Dictionary?
>
> I know that %OD%OA is a carriage return, but I need to know what the
> code is for a quote mark (") as well as a few others..thanks!

perl -e 'foreach(0..127) {printf("%s: %x (%d)\n", chr($_), $_, $_)}'

Here's a one liner that prints out a list of the character 0 - 127.  Of
course, this doesn't handle non-printable characters like ^M, ^J, etc.

-- Brett
  http://www.chapelperilous.net/

blithwapping:
Using anything BUT a hammer to hammer a nail into the
wall, such as shoes, lamp bases, doorstops, etc.
-- "Sniglets", Rich Hall & Friends


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




Re: validation

2002-02-02 Thread Brett W. McCoy

On Sat, 2 Feb 2002, Brett W. McCoy wrote:

> >  return 1 unless ($Bid_Amount =~ [/d/] );
>
> Your regular expression should be /[0-9]/

Or rather, /\D/ if you are matching against non-numerical values.

-- Brett
  http://www.chapelperilous.net/

BOFH excuse #74:

You're out of memory


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




Re: validation

2002-02-02 Thread Brett W. McCoy

On Fri, 1 Feb 2002, Al Hospers wrote:

> I need a regular expression that will only allow a variable to contain
> digits. it should fail if there is anything else in the variable:
> dollar signs, commas, dots, alphas, spaces, quotes etc. I thought the
> following would work, I am obviously incorrect.
>
>  return 1 unless ($Bid_Amount =~ [/d/] );

Your regular expression should be /[0-9]/

-- Brett

  http://www.chapelperilous.net/

About all some men accomplish in life is to send a son to Harvard.


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




Re: Perl Compiler

2002-01-03 Thread Brett W. McCoy

On Thu, 3 Jan 2002, Barrie Heck wrote:

> We fully respect the conditions of the GPL and in fact have contributed
> greatly ourselves towards the development of applications based on perl, as
> well as many others. This specific requirement is security related, where a
> user with any intelligence, could read the source and make use of a security
> issue created by using sudo.

Well, you have that same problem with every single shell script on the
same box.  If it's a security issue, then the use of sudo needs to be
restricted.  There really isn't a good way to hide code with Perl, unless
you create intentionally obfuscated code when you deploy the software.

-- Brett

  http://www.chapelperilous.net/

Bedfellows make strange politicians.


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




Re: Interesting Chop question.

2001-12-12 Thread Brett W. McCoy

On Wed, 12 Dec 2001, Brett W. McCoy wrote:

> > I have a pain in the butt array that SOMETIMES has a CR at the end and
> > sometimes does not.  Can anyone think of a way to test to see if the \n is
> > there and if it is then chop else no chop?  Cause if I just use chop then it
> > starts chopping off letters sometimes...
>
> Don't use chop, use chomp.  It does exactly what you want -- technically,
> it chops off $?, which by default is \n, but doesn't chop it if it's not
> there.  You can test the return value of chomp to see how many characters
> it removed.

My hand didn't make it off the shift key when I was typing $?.  That
should be $/

-- Brett
  http://www.chapelperilous.net/

A strong conviction that something must be done is the parent of many
bad measures.
-- Daniel Webster


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




Re: Interesting Chop question.

2001-12-12 Thread Brett W. McCoy

On Wed, 12 Dec 2001, Andre` Niel Cameron wrote:

> I have a pain in the butt array that SOMETIMES has a CR at the end and
> sometimes does not.  Can anyone think of a way to test to see if the \n is
> there and if it is then chop else no chop?  Cause if I just use chop then it
> starts chopping off letters sometimes...

Don't use chop, use chomp.  It does exactly what you want -- technically,
it chops off $?, which by default is \n, but doesn't chop it if it's not
there.  You can test the return value of chomp to see how many characters
it removed.

perldoc -f chomp

-- Brett
  http://www.chapelperilous.net/

Some people manage by the book, even though they don't know who wrote the
book or even what book.


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




Re: Creating a CGI menu

2001-12-12 Thread Brett W. McCoy

On Wed, 12 Dec 2001, Gerry Jones wrote:

> I want to create a menu/navigational section for a website I plan on
> building, and I would like to know if there are any easy-to-use modules I
> could use, or if there's another way. My website will have many levels and I
> don't fancy copying, pasting and tweaking the HTML to get the menu to look
> right on every page. I need someway that will make life easier, that will
> preferably, automatically include new pages.

For raw HTML, you should use SSI, or some kind of templating scheme to
insert the menu into the page.  I've built sub-components with
Text::Template and inserted them into a main page (also using
Text::Template), and it worked out very well.  You can even have dynamic
code in your sub-components.

Beyond templating, you can go with a component-based system like Mason,
which lets you build up web applications using pre-built components.

-- Brett
  http://www.chapelperilous.net/

Too many people are thinking of security instead of opportunity.  They seem
more afraid of life than death.
-- James F. Byrnes


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




Re: IP Address Reverse Lookup

2001-12-10 Thread Brett W. McCoy

On Mon, 10 Dec 2001, Brian wrote:

> If at all possible, which perl module would I need to call in order to
> perform a reverse lookup on an IP address?
>
> I need to produce something simalar to the "host" command
> ie:
>
> [brian@mustang brian]$ host 12.90.6.4
> 4.6.90.12.in-addr.arpa domain name pointer 4.philadelphia-16-17rs.pa.dial-
> access.att.net.

Take a look at Sys::Hostname (it comes standard with Perl).  It has a
bunch of IP-related functions for hostname & address lookup functions.

-- Brett
  http://www.chapelperilous.net/

The human animal differs from the lesser primates in his passion for
lists of "Ten Best".
-- H. Allen Smith


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




Re: Next 10 Results Help Needed

2001-12-07 Thread Brett W. McCoy

On 7 Dec 2001, Randal L. Schwartz wrote:

> 
>
> ... too bad I've already written my *last* WT column, to appear
> in Feb 2002, because the magazine is terminating. :(

Bummer.

-- Brett
  http://www.chapelperilous.net/

Life is a concentration camp.  You're stuck here and there's no way
out and you can only rage impotently against your persecutors.
-- Woody Allen


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




Re: graphic manipulation program

2001-12-07 Thread Brett W. McCoy

On Fri, 7 Dec 2001, Carl Franks wrote:

> Could someone advise me on a program to use.
> I want to use a command-line program to resize .jpegs, and specify
> compression.
> I've not found anything suitable so far.
> The GD module looks promising, but I can't find useful documentation for it.

Check out ImageMagick!

I think there is also a module for the Gimp, so you can write Perl-Fu
scripts.

-- Brett


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




Re: Help with Debug Please.

2001-12-06 Thread Brett W. McCoy

On Thu, 6 Dec 2001, Andre` Niel Cameron wrote:

> Hey I got an error on a script and went to run it from the command line to
> figure out what i forgot but to my surprise I got this:
> (offline mode: enter name=value pairs on standard input)
>
> What the he$$ is it and how can I get by it to run my script from the
> command line?

It's waiting for you to type in CGI parameters (you're using CGI.pm,
right?), and it need parameters to run.  You can enter param=value pairs
right there, or run your script like:

script "param=value¶m=value"

-- Brett
  http://www.chapelperilous.net/

Every time I look at you I am more convinced of Darwin's theory.


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




Re: Generating static HTML Pages

2001-12-05 Thread Brett W. McCoy

On Wed, 5 Dec 2001, Richard S. Crawford wrote:

> Long time reader, first time writer here...
>
> For a personal project, I would like to use Perl to generate static HTML
> pages.  Can the output of CGI be redirected to a file which can be read
> later by a browser?  What is the best way to approach this problem?

Sure, instead of printing to the browser, print to a file (assuming you
are using CGI.pm, and if you aren't, why not?)

use CGI;

open HTML, ">index.html" or die "Could not open index.html: $!\n";

print HTML start_html, h1("something"), end_html;

-- Brett
  http://www.chapelperilous.net/

After an instrument has been assembled, extra components will be found
on the bench.


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




Re: "\n" in Perl

2001-12-05 Thread Brett W. McCoy

On Wed, 5 Dec 2001 [EMAIL PROTECTED] wrote:

> I' d like to know why, when I use a cgi script under Win95, the browser
> doesn't print in output the carriage-return "\n".
> An example: this is my simple cgi script:
>
> print qq'
> 
> Perl Page
> ';
> for (1..5) {print qq'Hello\n';}
> print qq'';
>
> In output I see the word "Hello" repeated 5 times in a same line. Instead
> of using the char "\n", is it possible to use some combination of Ascii
> code?

Yes, the combination is ''!  (\n doesn't display in a browser, 
does).

-- Brett
  http://www.chapelperilous.net/

Ever notice that the word "therapist" breaks down into "the rapist"?
Simple coincidence?
Maybe...


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




Re: variables using blank spaces

2001-12-04 Thread Brett W. McCoy

On Tue, 4 Dec 2001, Wagner Garcia Campagner wrote:

> I have a varilable:
>
> $var = 'asdf asdf asdf';   #using blank spaces
>
> Then i send it to another script like this:
>
> 
>
> The problem is when i get it back the value became:
>
> $var = asdf
>
> It stops in the first blank space is there a way for me to recover all
> the variable??

Duh... escaping isn't what you need, since you're probably doing this as a
post.  You should put your variable in quotes (which is what you should be
doing anyway):



-- Brett
  http://www.chapelperilous.net/

In the realm of scientific observation, luck is granted only to those who are
prepared.
- Louis Pasteur


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




Re: variables using blank spaces

2001-12-04 Thread Brett W. McCoy

On Tue, 4 Dec 2001, Wagner Garcia Campagner wrote:

> I have a varilable:
>
> $var = 'asdf asdf asdf';   #using blank spaces
>
> Then i send it to another script like this:
>
> 
>
> The problem is when i get it back the value became:
>
> $var = asdf
>
> It stops in the first blank space is there a way for me to recover all
> the variable??

You need to replace all of the space with %20.  You can do this manually,
or use URI::Escape (<-- recommended).  See the appropriate perldoc on
this.  You may need to get it from CPAN.

-- Brett
  http://www.chapelperilous.net/

A compliment is something like a kiss through a veil.
-- Victor Hugo



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




Re: Fwd: Fw: PLEEEEEEEASE READ!!!

2001-12-01 Thread Brett W. McCoy

On Fri, 30 Nov 2001, lynn bui wrote:

> this does not concern perl, but maybe you should read
> it.
> it may be true and if so it's a really good deal.

This is a hoax.  Please do some research before sending things like this
along.  A good place to look is http://www.snopes.com

-- Brett
  http://www.chapelperilous.net/

A failure will not appear until a unit has passed final inspection.


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




Re: Program dilema

2001-11-30 Thread Brett W. McCoy

On Fri, 30 Nov 2001, Andre` Niel Cameron wrote:

> I am having a bit of a problem.  Does anyone have any idea how I could have
> a variable and see if the value of that variable is also located in an array
> and hash?  IE:
>
> $myvar= 6
>
> @myarray= ("4", "7", 10", 6")
>
> if (6 exists in @myarray) (
> dothis}
> else{
> dothis}

foreach (@myarray) {

  if ($_ == $myvar) {
#do something
  } else {
#do something else
  }
}

-- Brett

  http://www.chapelperilous.net/

Rebellion lay in his way, and he found it.
-- William Shakespeare, "Henry IV"


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




RE: Redirecting STDOUT to a variable...

2001-11-28 Thread Brett W. McCoy

On Wed, 28 Nov 2001 [EMAIL PROTECTED] wrote:

> Thanks, but I need to preserve the value returned by $mycommand also. I
> guess using backticks won't allow me to do that .
> Mostly what I need to do is read from STDOUT into a variable. But I don't
> know how to do that.

Then just redirect STDOUT of the command into a file and then open the
file, like you were doing.  That's the simplest way of doing it.

-- Brett
  http://www.chapelperilous.net/

HOW YOU CAN TELL THAT IT'S GOING TO BE A ROTTEN DAY:
#15 Your pet rock snaps at you.


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




Re: Redirecting STDOUT to a variable...

2001-11-28 Thread Brett W. McCoy

On Wed, 28 Nov 2001 [EMAIL PROTECTED] wrote:

> I am looking to run a command using perl and get its return value as well as
> its STDOUT. Currently I am doing is
>
> $result = system("$myCommand >out.txt");
> open(FILE,"< out.txt");
>
> and then processing the data from the file. This is terribly slow for my
> application. Is there some way where I can redirect the output directly to a
> variable and not have to do the file thing.

Certainly.  Use the backtick operator to slurp all of the output at once,
use a scalar to store it all in one string, or put it into list context
and dump each line into an array.

my $result = `$myCommand`;
my @result = `$myCommand`;

If you think the output is going to be big, or you want to process each
line of output as it occurs, you can do this:

open CMD, "$myCommand |" or die "couldn't fork: $!\n";

while() {

do something if /some pattern to match/;
}

close CMD;

-- Brett
  http://www.chapelperilous.net/

The finest eloquence is that which gets things done.


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




Re: deleting a file

2001-11-23 Thread Brett W. McCoy

On Fri, 23 Nov 2001, Wagner Garcia Campagner wrote:

> Sorry for the stupid question, but i didn't find in the FAQ.
>
> What is the sintax to delete a file???

unlink deletes a file.

perldoc -f unlink

-- Brett
  http://www.chapelperilous.net/

Nice guys finish last.
-- Leo Durocher


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




Re: why is perl better then PHP

2001-11-15 Thread Brett W. McCoy

On Thu, 15 Nov 2001, rabs wrote:

> Ive been using perl for a few months now, most people I speak to seem to
> prefer PHP. Why?

Maybe you should ask the PHP users and not the Perl users... :-)

I would venture to say that a lot of people like PHP because it is
specifically designed for web development and it's easy to pick up and
learn how to use.  I daresay most PHP programmers were drawn to things
like this:




Result = 

In other words, they didn't really have to learn the full syntax of a
language to get things working on their web pages, they could just embed
simple statements into HTML and have dynamic pages.  They look at
something like Java and Perl (meaning servlets and plain old CGI) and see
there's potentially a lot more of an intellectual investment to get things
working. This may be especially true if they are coming into the Unix
world from Windows, and PHP is very similar in spirit to ASP.

-- Brett
  http://www.chapelperilous.net/

Extremism in the defense of liberty is no vice... moderation in the pursuit
of justice is no virtue.
-- Barry Goldwater


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




Re: Text Field Question

2001-11-13 Thread Brett W. McCoy

On Tue, 13 Nov 2001, Justin Howell wrote:

> I'm working on a perl script using CGI.pm and had some general
> questions.  Is there a way to set the focus (ie put the cursor) in a
> text input field on page load?  And when I finish typing in that field
> and hit enter, for it being the same as hitting submit?  I couldn't
> find anything about that in the books I have.

That sounds like a JavaScript thing -- things like focus and keyboard
control have to be handled by the client, not on the server.  Hitting
enter will only work if the submit button is the next in the tab order, I
believe, but that may be browser dependent.  At any rate, you can't solve
the problem with server-side Perl.

-- Brett
  http://www.chapelperilous.net/

I'm having a MID-WEEK CRISIS!


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




Re: End of File

2001-11-08 Thread Brett W. McCoy

On Thu, 8 Nov 2001, Wagner Garcia Campagner wrote:

> I don't know how to tell perl EOF, i am doing a search in a file like this:

You don't need to -- you can loop through a file and it will stop
automatically when EOF is reached.

>
> $username eq 'wagner';
> $file = 'c:\file';
>
> open(INFO, $file);

You should make sure you handle the condition that the file can't be
opened:

open(INFO, $file) or die "Could not open $file:\n";

> do
> {
> $lines = ;
> chop $lines;
> }

This is not the way to do it.  This will work:

while() {

last if /$username/;
}

close(INFO);

-- Brett

  http://www.chapelperilous.net/

Ambidextrous, adj.:
Able to pick with equal skill a right-hand pocket or a left.
-- Ambrose Bierce, "The Devil's Dictionary"


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




Re: Printing Hash Keys

2001-10-25 Thread Brett W. McCoy

On Thu, 25 Oct 2001, RaFaL Pocztarski wrote:

> You can always use http://www.perldoc.com/ but it's hard to believe that
> any version of perl comes without perldoc, however I don't know MacPerl
> at all. Try to find any info about perldoc in MacPerl docs or website.

Yeah, but recall that Macs (pre OS X) don't have command-lines!  Perldoc
would be a little more different than what is used on Unix & Windows,
where a CLI is available.

-- Brett
  http://www.chapelperilous.net/

"Love is an ideal thing, marriage a real thing; a confusion of the real with
the ideal never goes unpunished."
-- Goethe


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




Re: Printing Hash Keys

2001-10-25 Thread Brett W. McCoy

On Thu, 25 Oct 2001, Shannon Murdoch wrote:

> So I take it there is no way to list all the keys contained in a hash in the
> same order they were entered in, like I can with a normal array?

Why do you need to?  There is way by using the Tie::IxHash module.  It is
available from CPAN (if you have the Perl Cookbook, there are also
examples in it)

-- Brett
  http://www.chapelperilous.net/

The modern child will answer you back before you've said anything.
-- Laurence J. Peter


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




Re: System call from a CGI script

2001-10-24 Thread Brett W. McCoy

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

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

The ownership permissions aren't what is necessary here, it's the uid the
script & web server are running as.  You are asking for some serious
security issues if you are trying to *run* CGI scripts as root (i.e., suid
root).

-- Brett
  http://www.chapelperilous.net/

Being a mime means never having to say you're sorry.


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




Re: Printing Hash Keys

2001-10-24 Thread Brett W. McCoy

On Wed, 24 Oct 2001, Shannon Murdoch wrote:

> What everyone has said so far is ways to list all the VALUES contained in a
> hash array, what I need to do is list all the KEYS contained in the hash
> array-with a tab (\t) between each.

Read the perldoc on the keys function.  It takes all of the keys from a
hash and builds a list for you, which you can stick in an array or loop
through, which is what was done in the examples).  It does exactly what
you are asking for.

-- Brett
  http://www.chapelperilous.net/

"If you lived today as if it were your last, you'd buy up a box of rockets and
fire them all off, wouldn't you?"
-- Garrison Keillor


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




Re: Printing Hash Keys

2001-10-24 Thread Brett W. McCoy

On Wed, 24 Oct 2001, Shannon Murdoch wrote:

> >> foreach (sort keys %params) { print "\t$params{$_}" }
> >
> > The same way.  $_ is the key for the hash element in the while loop.
>
>
> I want a list of keys, not their values though.

Right -- the 'keys' function extracts the list of keys from a hash.  See
the perldoc on it.

-- Brett
  http://www.chapelperilous.net/

Trying to establish voice contact ... please yell into keyboard.


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




Re: Auto-initialising a client-side download

2001-10-24 Thread Brett W. McCoy

On Wed, 24 Oct 2001, Shannon Murdoch wrote:

> I think it would be good to have an online searchable database of this
> newsgroup, so you don't have to download every message to see if your
> question has already been answered a few days or weeks ago! =)

Shannon --

Actually, there is an archive of the mailing list.  See
http://archive.develooper.com/beginners%40perl.org/.  It is not
searchable, but I am sure you could use Google to search as well.

-- Brett
  http://www.chapelperilous.net/

I have more hit points that you can possible imagine.


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




Re: Printing Hash Keys

2001-10-23 Thread Brett W. McCoy

On Wed, 24 Oct 2001, Shannon Murdoch wrote:

> I know how to print the contents of a hash, but what if I wanted to print
> the keys themselves that the hash is called from (delimited by tabs)?
>
> This is how I print the contents of a hash (Thanks to Brett W. McCoy):
>
> %params = qw(
> i01 4
> i02 5
> i03 2
> );
>
> foreach (sort keys %params) { print "\t$params{$_}" }

The same way.  $_ is the key for the hash element in the while loop.

-- Brett
  http://www.chapelperilous.net/

Conscious is when you are aware of something and conscience is when you
wish you weren't.


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




Re: Test if first character of a variable is a 0 (zero)

2001-10-18 Thread Brett W. McCoy

On Thu, 18 Oct 2001, Rene Verharen wrote:

> I need to delete the first character of a variable if this (and ONLY this)
> character is a 0 (zero).
>
> What I tried :
>
> $text =~ s/01/1/;
> $text =~ s/02/2/;
> $text =~ s/03/3/;
> etc...
>
> Not what I want, because it also deletes the 0 (zero) if it is NOT the
> first character.

$text =~ s/^0//;

-- Brett

  http://www.chapelperilous.net/

MMM-MM!!  So THIS is BIO-NEBULATION!


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




Re: new html window

2001-10-17 Thread Brett W. McCoy

On Wed, 17 Oct 2001 [EMAIL PROTECTED] wrote:

> i'm writing a formmail-esque script that checks for required fields coming
> in from the html form. should a field be missing user input, i'd like to
> have a new html window open displaying the missed fields.
> i'm familiar with using the Location function to redirect the current
> browser to a new page, however, i'm curious to know how i would go about
> opening a new window to display my generated html.

You have to use Javascript to do that, not Perl.

-- Brett
  http://www.chapelperilous.net/

"Even if you're on the right track, you'll get run over if you just sit there."
-- Will Rogers


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




Re: Parsing HTTP links

2001-10-16 Thread Brett W. McCoy

On Tue, 16 Oct 2001 [EMAIL PROTECTED] wrote:

> I need to parse out all http links stored in a local file.
> How would I go about doing this?
>
> which modules would I need to use?

Take a look at HTML::Parser, which is available from CPAN.

-- Brett
  http://www.chapelperilous.net/

You can observe a lot just by watching.
-- Yogi Berra


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




Re: (simple) cgi.pm question

2001-10-16 Thread Brett W. McCoy

On Tue, 16 Oct 2001, Shannon Murdoch wrote:

> So the script halves in size and now becomes:

> print OUTFILE
> "$entrynumber\t$params{q1_1}\t$params{q1_2}\t$params{q1_3}\t$params{q1_4}\t$
> params{q1_5}\t$params{q1_6}\t$params{q1_7}\t$params{q1_8}\t$params{q1_9}\t$p
> arams{q1_10}\t$params{q1_11}\t$params{q1_12}\t$params{q1_13}\t$params{q1_14}
> \t$params{q1_15}\t$params{q1_16}\t$params{q1_17}\t$params{q1_18}\t$params{q1
> _19}\t$params{q1_20}\t$params{q1_21}\t$params{q1_22}\t$params{q1_23}\t$param
> s{q1_24}\t$params{q1_25}\t$params{q1_26}\t$params{q1_27}\t$params{q1_28}\t$p
> arams{q1_29}\t$params{q1_30}\t$params{q1_31}\t$params{q1_32}\t$params{q1_33}
> \t$params{q1_34}\t$params{q1_35}\t$params{q1_36}\t$params{q1_37}\t$params{q1
> _38}\t$params{q1_39}\t$params{q1_40}\t$params{q1_41}\t$params{q1_42}\t$param
> s{q1_43}\t$params{q1_44}\t$params{q1_45}\t$params{q1_46}\t$params{q1_47}\t$p
> arams{q1_48}\t$params{q1_49}\t$params{q1_50}\t$params{q1_51}\t$params{q1_52}
> \t$params{q1_53}\t$params{q1_54}\t$params{q1_55}\t$params{q1_56}\t$params{q1
> _57}\t$params{q1_58}\t$params{q1_59}\t$params{q1_60}\t$params{q1_61}\t$param
> s{q1_62}\t$params{q1_63}\t$params{q1_64}\t$params{q1_65}\t$params{q1_66}\t$p
> arams{q1_67}\t$params{q1_68}\t$params{q1_69}\t$params{q1_70}\t$params{q1_71}
> \t$params{q7_1}\t$params{q7_2}\t$params{q7_3}\t$params{q7_4}\t$params{q7_5\t
> $params{q7_6}\t$params{q7_7}\t$params{q7_8}\t$params{q7_9}\n";
> close(OUTFILE);

You could make it even smaller by looping through the hash:

print OUTFILE $entrynumber;
foreach (sort keys %params) {   print OUTFILE, "\t$params{$_}" }
print OUTFILE "\n";

-- Brett
  http://www.chapelperilous.net/

You are sick, twisted and perverted.  I like that in a person.


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




Re: (simple) cgi.pm question

2001-10-15 Thread Brett W. McCoy

On Tue, 16 Oct 2001, Shannon Murdoch wrote:

> So far my script puts every form item in to it's own variable, and calls
> upon that variable when it is writing the tab-delimited file (which will be
> used in Exel or SPSS etc for data analysis.
>
> Is there an easier way to do this than I have?

You betcha!  There's a method in the CGI module called Vars, which returns
all of the form variables into a hash.  Note that it does have a capital
letter V.

my $cgi = new CGI;

my %params = $cgi->Vars;

If you use the functional interface, you will need to import the keyword
:cgi-lib to use Vars as a function:

use CGI qw(:standard :cgi-lib);

my %params = Vars;

Then you can access your paramters as $params{q1_1}, $params{q1_2}, etc.,
and easily loop threm as necessary.

-- Brett
  http://www.chapelperilous.net/

If you stand on your head, you will get footprints in your hair.


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




Re: How to change shell environment by cgi-file?

2001-10-12 Thread Brett W. McCoy

On Fri, 12 Oct 2001, Qi zhang wrote:

> Thanks Brett for your reply but if i run my script under unix shell as
> " perl  my-script-file" it works well .
> If i call my script online through apache server it does not perform my
> C-file well. Why? The apache cgi director is set already.

Possible the user your CGI script is running under does not have
permission to run the csh script?

-- Brett
  http://www.chapelperilous.net/

Like winter snow on summer lawn, time past is time gone.


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




Re: How to change shell environment by cgi-file?

2001-10-12 Thread Brett W. McCoy

On Fri, 12 Oct 2001, Qi zhang wrote:

> I am using bash but my C file is under C-shell. How could I change the
> bash to shell by perl script file?
>   system ('csh');
>   system ('./my-file');
>   system ('exit');
> does above list work?

It shouldn't matter, if your C-shell script has a proper shebang line,
like

#!/usr/bin/csh

This will invoke the proper shell interpreter for your script.

-- Brett
  http://www.chapelperilous.net/

QOTD:
"I used to go to UCLA, but then my Dad got a job."


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




Re: Format interger printing, MORE INFO

2001-10-12 Thread Brett W. McCoy

On Fri, 12 Oct 2001, Chuck wrote:

> It is now printing the number as a negative:
> print "\n";
> printf "%15d bytes free in $phost:/var/tmp\n", $freespace;
>
> Result:
>  -48288 bytes free in smh4:/var/tmp

Your integer is too big to be handled as an integer. :-) Use %15.f for
your format, that should correctly print the integer value without
following zeroes.  Or use the BitInt module.

-- Brett
  http://www.chapelperilous.net/

Facts, apart from their relationships, are like labels on empty bottles.
-- Sven Italla


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




Re: Format interger printing, MORE INFO

2001-10-12 Thread Brett W. McCoy

On Fri, 12 Oct 2001, Chuck wrote:

> Oh my god. *BONK*'
>
> You are correct, this is no doubt the dumbest mistake I have ever made.

Bah, we've all been there.  It's one of the best ways to learn: "That
which does not kill us makes us stronger." :-)

-- Brett
  http://www.chapelperilous.net/

"Consistency requires you to be as ignorant today as you were a year ago."
-- Bernard Berenson


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




Re: Browser Redirection

2001-10-12 Thread Brett W. McCoy

On Fri, 12 Oct 2001, Carl Franks wrote:

> if (condition) {
>  print "Location:page.html\n\n";
>  } else {
>  print "Content-type: text/html\n\n";
>  print "...html...";
>  }
> }

BTW, for a Location header, you should an absolute URL and not a relative
URL, even if it's on the same server as the request URI.

-- Brett
  http://www.chapelperilous.net/

"Irrationality is the square root of all evil"
-- Douglas Hofstadter


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




Re: Format interger printing, MORE INFO

2001-10-11 Thread Brett W. McCoy

On Thu, 11 Oct 2001, Chuck wrote:

> Here is a snippet:
> printf "%20d bytes free in $phost:/var/tmp\n", $freespace;
> printf "$shipsize bytes being shipped.\n";
>
> Here is the output:
> -1012379648 bytes free in smh4:/var/tmp
> 359731200 bytes being shipped.

It's because 3282567168, apparently, is too big to be printed as an
integer value.  But this works:

$ perl -e 'printf "%20.f\n", 3282567168'
  3282567168

-- Brett
  http://www.chapelperilous.net/

Nasrudin walked into a teahouse and declaimed, "The moon is more useful
than the sun."
"Why?", he was asked.
"Because at night we need the light more."


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




Re: Format interger printing

2001-10-11 Thread Brett W. McCoy

On Thu, 11 Oct 2001, Chuck wrote:

> Nothing is working, I have tried every permutation.

I tried this right on the command line:

$ perl -e 'printf "%10d\n", 25'
25

-- Brett
  http://www.chapelperilous.net/

Yesterday upon the stair
I met a man who wasn't there.
He wasn't there again today --
I think he's from the CIA.


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




Re: Format interger printing

2001-10-11 Thread Brett W. McCoy

On Thu, 11 Oct 2001, Chuck wrote:

> Arg, I am going crazy. Ok, it has been a long time since I was kneee deep in
> perl, but why does this not work:
>
> printf "%-10d bytes", $x;

Remove the -

printf "%10d", $x;

Works for me.

-- Brett
  http://www.chapelperilous.net/

Yesterday upon the stair
I met a man who wasn't there.
He wasn't there again today --
I think he's from the CIA.


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




RE: Easy way to get output from system()

2001-10-11 Thread Brett W. McCoy

On Thu, 11 Oct 2001, Camilo Gonzalez wrote:

> Dude, assign it to a variable.
>
> $tempdir = system("ls -l /tmp")

No, that only gives you the exit status of the called program (which you
then need to divide by 256 to do anything useful with).  using `` or qx()
will give the output of the called program.  Here's the pertinent info
from the perldoc:


 The return value is the exit status of the program
 as returned by the "wait" call.  To get the actual
 exit value divide by 256.  See also the exec entry
 elsewhere in this document.  This is not what you
 want to use to capture the output from a command,
 for that you should use merely backticks or
 "qx//", as described in the section on "`STRING`"
 in the perlop manpage.  Return value of -1
 indicates a failure to start the program (inspect
 $! for the reason).

-- Brett
  http://www.chapelperilous.net/

Use an accordion.  Go to jail.
-- KFOG, San Francisco


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




Re: Easy way to get output from system()

2001-10-11 Thread Brett W. McCoy

On Thu, 11 Oct 2001, Chuck wrote:

> I have several CGI's that use system() to get various OS details.
>
> What is the most reliable way to glean this information after using this
> command:
>
> For example:
>
> #!/bin/perl
>
> system("ls -l /tmp")
>
> How can I get that data?

Use backticks:

my $output = `ls -l /tmp`;

-- Brett
  http://www.chapelperilous.net/

bug, n:
A son of a glitch.


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




Re: Browser Redirection

2001-10-10 Thread Brett W. McCoy

On Wed, 10 Oct 2001, Michael Kelly wrote:

> print "Content-type: text/html\n";
> print "Location: http://www.mysite.com/page.html\n\n";;

This is incorrect also, because the "Location: ...\n\n" is an http header
and should not be used after a Content-type header is sent to the browser.
It should be used as the only header.

-- Brett
  http://www.chapelperilous.net/

There's another way to survive.  Mutual trust -- and help.
-- Kirk, "Day of the Dove", stardate unknown



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




Re: where to get modules? and any gui for win32?

2001-10-10 Thread Brett W. McCoy

> Where do I get some of these cool modules like www, DBI... etc?

www.cpan.org is the definitive repository.  Many assume the availability
of a C compiler and proper development tools like make or nmake.  On
Win32, you can use VC++, or the CygWin environment, which gives you a lot
of GNU tools.  ActiveState also has a repository for pre-built modules
(PPMs) that you can install, but it is not comprehensive like CPAN is.

> and is there a module to write gui programs using perl in win32
> environmrnt? (WINNT or 2k)

The Tk module works very well under Windows, and best of all, you can move
the code to another platform (Mac, Linux, Solaris) and run it with little
or no modification.

-- Brett
  http://www.chapelperilous.net/

Humor in the Court:
Q: Now, you have investigated other murders, have you not, where there was
   a victim?


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




Re: Sending someone to a new location...

2001-10-08 Thread Brett W. McCoy

On Mon, 8 Oct 2001, _brian_d_foy wrote:

> > print "Location: $url\n\n";
> >
> > This must be the only header sent to the browser.  It won't work if http
> > headers have already been sent.
>
> that's a bit misleading.  as with any CGI script, there is only
> one header.  in a redirection, a Location: field is in the header
> but it is not the only field in that header, necessarily.  it does
> not even imply the lack of a message body. :)

What I am saying is, if you have CGI.pm's header() first, then try to do
the redirect(), the redirect won't work.  The redirect() is sending a
header there.

-- Brett
  http://www.chapelperilous.net/

Is it possible that software is not like anything else, that it is meant to
be discarded:  that the whole point is to always see it as a soap bubble?


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




Re: Sending someone to a new location...

2001-10-08 Thread Brett W. McCoy

On Mon, 8 Oct 2001, James Kelty wrote:

> I would like to be able to send someone automatically to another page when
> requirements in a for are filled out correctly. Other that presenting a link
> I can figure out how to do this.
>
> Example:
>
> Someone correctly fills out a user/pass form and is sent to the default
> page,
> otherwise they are sent to the login page again without having to give
> them a link to back to the login screen...or to the default page.

Using CGI.pm, use the redirect method.  Or, you can do

print "Location: $url\n\n";

This must be the only header sent to the browser.  It won't work if http
headers have already been sent.

-- Brett
  http://www.chapelperilous.net/

"All my life I wanted to be someone; I guess I should have been more specific."
-- Jane Wagner


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




Re: ultimate stupidity

2001-10-05 Thread Brett W. McCoy

On Fri, 5 Oct 2001, Francesco Scaglioni wrote:

> Answer:
> I had inadvertently put a space in front of the # at the beginning of
> the #!.  The space is, of course covered by the cursor when I visit
> the beginning of the file an I had failed to notice the implied space
> ( implied because I could still see the # ).  Is this a record for the
> most stupid mistake ever made?  Boy have I got much to learn.

Don't feel bad -- we've all done similar things.  You know why programmers
have flat foreheads.  Beacuse they are constantly slapping their forehead
and going 'Doh!'

Being able to admit an error (even one you think is stupid) is a good
quality to have.

-- Brett
  http://www.chapelperilous.net/

Sir, it's very possible this asteroid is not stable.
-- C3P0


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




Re: Looking for a script that will "clean up" and print a page

2001-10-05 Thread Brett W. McCoy

On Fri, 5 Oct 2001, Rusty Wilson wrote:

> Changing the width of the page is not an option as
> that would "break" the interface (graphics/layout/etc)
> which were designed at 760px wide (at the customers
> reqest!) The client does not want a "narrower"
> interface.

Argh, that's one of the 7 deadly sins of web design -- hardcoding screen
widths, for surely where you want users to have a screen width of 760,
someone is going to come along with one that is 640 or 1280, and totally
break your design.  Not only that, having wide block of text is very
difficult to read -- a multi-column layout is much easier.

Oh, well, this entirely off-topic here so I'll shut up now.

-- Brett
  http://www.chapelperilous.net/

Support the Girl Scouts!
(Today's Brownie is tomorrow's Cookie!)


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




Re: References

2001-10-03 Thread Brett W. McCoy

On Wed, 3 Oct 2001, Bill Jones wrote:

> References:
>
> I am looking for a basic explaination and example:
>
> $animal = "Dog";
> $sound  = \$animal;
> $bark   =  $$sound;
>
> $bark is now Dog.

\$animal --> create a reference to $animal, which contains 'Dog'
$sound --> assigned the reference to the variable $animal, which contains
   'Dog'.
$$sound --> dereferences the reference to get the actual data stored,
which is 'Dog'

$bark --> assigned to the value referenced by $sound when $sound is
  dereferenced ($$sound), which is 'Dog'.

Dig out your handy perldoc tool and read perlref and perlreftut.

-- Brett
  http://www.chapelperilous.net/

Zeus gave Leda the bird.


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




Re: anti-SSSCA petition

2001-10-03 Thread Brett W. McCoy

On Wed, 3 Oct 2001, Kevin Meltzer wrote:

> I meant to alter the PDF with a signature, silly.

There's gotta be a Perl module out there for doing that...

-- Brett
  http://www.chapelperilous.net/

You'll never see all the places, or read all the books, but fortunately,
they're not all recommended.


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




Re: How can i search a line in a document and print this line inhtml page??

2001-10-03 Thread Brett W. McCoy

On Wed, 3 Oct 2001, shenneke pl wrote:

> I need to know how can i search a line in a document and print this line in
> html page??
>
> if somebody know how can i do please help me!!!

Can you please be a little more specific?  What document are you
searching?  What do you mean by 'document'?  What are you searching for?
What have you tried so far on your own?

-- Brett
  http://www.chapelperilous.net/

Agree with them now, it will save so much time.


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




Re: Any suggested response ? FW: Need PERL module DBI on SUN1

2001-10-03 Thread Brett W. McCoy

On Wed, 3 Oct 2001, Moon, John wrote:

> > Does anyone have any suggestions as to how to reply to this gentleman ?

There's nowhere near enough information to go on to even venture a guess.

-- Brett
  http://www.chapelperilous.net/

You will get what you deserve.


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




Re: frexp panic

2001-10-02 Thread Brett W. McCoy

On Tue, 2 Oct 2001, Robert Becker wrote:

> Has anyone ever gotten this error from perl?  How do I resolve it?
>
> panic: frexp at IWfacschd.cgi.exp line 366.
>
> line 366:   $fte = sprintf("%2.4f", $fte);
> $fte is a returned number from a database.
>
> frexp is apparently a library that allows the printf('%f') to work but has
> failed.

For testing purposes, what happens when you hard code the number into the
expression?

-- Brett
  http://www.chapelperilous.net/

This PORCUPINE knows his ZIPCODE ... And he has "VISA"!!


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




Re: suggestions?

2001-10-02 Thread Brett W. McCoy

On Tue, 2 Oct 2001, Gareth Londt wrote:

> i have a problem in which i have a lists of Domain names ..k, and i need to
> get there matching email address of an external site but i cant arite a shell
> script so i was wondering if anyone has any ideas or code that can help me
> with what im doing?

Get what matching email addresses?  Are you harvesting email addresses off
of websites?

-- Brett
  http://www.chapelperilous.net/

He who is content with his lot probably has a lot.


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




RE: Replacing carriage returns in a variable

2001-10-02 Thread Brett W. McCoy

On Tue, 2 Oct 2001, Guy Tubbs wrote:

> but it does the same thing, i.e. I get:
>
>   Line1
>   Line2
>
> What I need is:
>
>   Line1Line2
>
> Do you know how to get rid of the returns altogether?

Odd.  Here's the code snippet I ran right at the command-line:

$ perl
$text = "line1\nline2\n";
$text =~ s/\n//g;
print $text;
^d
line1line2$

-- Brett
  http://www.chapelperilous.net/

Tomorrow will be cancelled due to lack of interest.


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




Re: Replacing carriage returns in a variable

2001-10-01 Thread Brett W. McCoy

On Mon, 1 Oct 2001, Guy Tubbs wrote:

> Can anyone give me the code that will replace all the carriage returns in a
> variable with another character.
>
> I am getting input from a web page and need to replace the returns with the
>   tag.

I tried this:

my $text = "some text\n";
$text =~ s/\n//g;
print $text;

This gave me:

some text

-- Brett
  http://www.chapelperilous.net/

I don't kill flies, but I like to mess with their minds.  I hold them above
globes.  They freak out and yell "Whooa, I'm *way* too high."
-- Bruce Baum


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




Re: a new line?

2001-10-01 Thread Brett W. McCoy

On Mon, 1 Oct 2001, Gareth Londt wrote:

> i need to know where to put a new line in.i keep getting errors..?
> here is what the code looks like, if anyone can help with the newlinei
> would much appreciate it.
>
> #!/usr/bin/perl -w
>
> $file = 'dnsbills.06-09-2001';
>
> open FILE, $file;
> @lines = ;
> close (FILE);
>
> for ($line=0;$line <=$#lines;$line++){
> if ($lines[$line] =~ /^Reg Date/) {
> print STDERR $lines[$line+2];
> @columns = split " ", $lines[$line+2];
> print $columns[1];
> }
> }

Dumping a file into an array is not always a good idea.  If that file is
huge, you are going to eat up memory.  Where do you need a newline and
what errors are you getting?

Here's how I would code this, guessing that you need a new line after you
print your column.  I also tidied the code up a little bit (don't use
C-style loops if you don't need to, and definitely not for an array!), and
made use of the default variable.

#!/usr/bin/perl -w

use strict;

open FILE, 'dnsbills.06-09-2001' or die "Could not open file: $!\n";

while() {

if(/^Reg Date/ {
print STDERR;
@columns = split /\s/;
print "$columns[1]\n";
}
}

close FILE;

-- Brett
  http://www.chapelperilous.net/

"No job too big; no fee too big!"
-- Dr. Peter Venkman, "Ghost-busters"


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




Re: Stylesheet line not working

2001-09-30 Thread Brett W. McCoy

On Sun, 30 Sep 2001, Gary L. Armstrong wrote:

> I have skimmed through the Llama and Camel and I don't know why this should
> not work:
>
> #startcode
> print <
>  "http://www.w3.org/TR/xhtml1/DTD/transitional.dtd";>
>
> 
> 
> Geek Shop -- A Web Page
> 
> 
> ...blahblahblah...
> BLOCK1
> #endcode
>
> Actually the whole thing works fine (hooray, my first CGI) except that it's
> not finding my style1.css, and before I start messing around with it too
> much, I thought I'd find out if any of you might throw me a bone.

Where is the style1.css file?  Going by the above code, it should be in
the document root of the web server, not in the cgi-bin directory.  In the
HTML that is output, its context is still that of the web server, not the
CGI script.

-- Brett
  http://www.chapelperilous.net/

It's not hard to admit errors that are [only] cosmetically wrong.
-- J.K. Galbraith


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




Re: Browser Resolution

2001-09-29 Thread Brett W. McCoy

On Sat, 29 Sep 2001, Randy5235 wrote:

> Does anyone know where I can find some information on possibly using perl to
> determine a visitors browser resolution? Is this even possible ( sorry still
> a noob!)
> I have a couple pages that look horrible on certain sizes and would like to
> basically determine the visitors res. and then use that to load an
> appropriate background picture. I have searched the net and all I found was
> some javascript to determine this (don't know java yet!) so that is little
> help to me. Thanks Randy5235

Yep, JavaScript is how you would have to do it -- Perl can't do anything
on the client side, only on the server side.

-- Brett
  http://www.chapelperilous.net/

Only the hypocrite is really rotten to the core.
-- Hannah Arendt


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




Re: How to save and retreive form

2001-09-26 Thread Brett W. McCoy

On 26 Sep 2001, Randal L. Schwartz wrote:

> I've found Pg to be more lightweight than MySQL.
>
> Again, not at all what I would have said a year ago.  But with the
> removal of the 8K limit per record, life with Pg is great!

I was in heaven when they added foreign keys.  Actually, I've been using
Pg since 1997, way before I started using MySQL, and only use MySQL when I
am forced to (i.e., when I have to do work for a client on a managed host
for which I have no way of changing their minds).

-- Brett
  http://www.chapelperilous.net/

Yow!  Are you the self-frying president?


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




RE: How to save and retreive form

2001-09-26 Thread Brett W. McCoy

On Wed, 26 Sep 2001, Camilo Gonzalez wrote:

> Doesn't PostgreSQL have a reputation as being somewhat pokey? Is it open
> source?

It's not pokey anymore, and yes, it is open source, and while MySQL may be
faster for basic queries, for more complex things, MySQL just can't cut
it, plus it's missing some very important features a DBMS should have (at
least it did last time I used it).

But let's not get into database wars here.  Use what you like, and like
what you use.

-- Brett
  http://www.chapelperilous.net/

This must be morning.  I never could get the hang of mornings.


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




Re: How to save and retreive form

2001-09-26 Thread Brett W. McCoy

On 26 Sep 2001, Randal L. Schwartz wrote:

> Brett>   MySQL is very simple to set up and easy to use.
>
> /me whispers "in 2001 and beyond, MySQL is spelled p o s t g r e s q l"
>
> MySQL is dead.  Long Live PostgreSQL.

I agree 100%.  Actually, 1000%.  I suggested MySQL beacuse she wanted
something lightweight.

-- Brett
  http://www.chapelperilous.net/

Disease can be cured; fate is incurable.
-- Chinese proverb


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




Re: How to save and retreive form

2001-09-26 Thread Brett W. McCoy

On Wed, 26 Sep 2001, Lynn Glessner wrote:

> For a small business intranet, I want the user to fill out the form, save it
> onto the web server, and be able to retreive it later. A text file will be
> fine, there won't be any need for reporting etc and a database would be
> overkill. I would like to have a directory structure on the web server that
> matches with three of the fields on the form, a directory for each engineer,
> then a subdirectory for each band (created as needed), and then a text file
> for each song name that that contains the state of the form. Each form will
> be the tracking sheet for a particular song.

>From what you have described, why do you think it would be overkill to use
a database?  A database should be used for just this kind of thing, so you
can focus on your application logic and not have to worry about storage
and retrieval.  MySQL is very simple to set up and easy to use.  But even
something like DB_File or the Storable class would be more helpful for
you.

-- Brett
  http://www.chapelperilous.net/

Unix:  Some say the learning curve is steep, but you only have to climb it once.
-- Karl Lehenbauer


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




Re: redirection with perl

2001-09-26 Thread Brett W. McCoy

On Wed, 26 Sep 2001, Wagner wrote:

> I want to do a redirection based on a variable
>
> for example:
>
> if ($name eq 'invader') {
>
> redirection to some URL ;
>
> }
>
> What do i have to put in the middle line to do the redirection...

If you are using CGI.pm, there is a method called redirect:

my $cgi = new CGI;

$cgi->redirect($new_url);

BTW, this has to be done before any headers are sent from the web server,
or it won't work correctly.  In fact, the redirection method sends its own
header, so you shouldn't send any header after you use this method, since
nothing will be displayed from the CGI script once the redirection is
done.

See http://stein.cshl.org/WWW/software/CGI/cgi_docs.html#header for more
details.

-- Brett


I've read SEVEN MILLION books!!


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




Re: How Do I Extract Elements from an Array?

2001-09-25 Thread Brett W. McCoy

On Tue, 25 Sep 2001, aurillo, gabriel wrote:

> I have an array, as follows:
>
> @allLines = (
>   "line1 = value1",
>   "line2 = value2",
>   "line3 = value3",
>   "!line4 = value1",
>   "!line5 = value2",
>   "!line6 = value3",
>   "line7 = value7",
>   "line8 = value8",
>   "line9 = value9",
>   "line10 = value10"
> ) ;
>
> How do I loop through each line with the following criteria:
> If the line starts with a bang (!) AND the value has already
> been "seen", skip that line AS WELL AS the line previously
> seen. In this case, the remaining list should only have lines
> 7 to 10 because line 4 starts with a bang AND the value is
> equal to the value of line 1. And so on...

In the first place, why use an array here?  This looks like a prime
candidate for a hash!  In fact, you could flip this: use the value column
as your hash keys, and the line column as the hash values, you can check
to see if the key already has a value associated with it, and then delete
the element if it does.  So if you are going along and get to the 4th
line, you will see that the element with key 'value1' has been defined as
'line1', so you know this line and value (which is the key) has already
been seen, so you can just delete it.  It's kind of backwards, but it will
save you some text parsing.

-- Brett
  http://www.chapelperilous.net/

The future is a myth created by insurance salesmen and high school counselors.


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




Re: "Unless" statement

2001-09-18 Thread Brett W. McCoy

On Tue, 18 Sep 2001, Mark Bergeron wrote:

> I would go:
>
> unless ( ($x < 50) || ($x > 80) ){
> print "";
> }

No... that will return true for all values less than fifty or all values
more than 80.  To get the numbers in between, you want numbers that are
more than 50 AND less than 80, the opposite of what was asked about!

-- Brett
  http://www.chapelperilous.net/

A penny saved is ridiculous.




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




Re: FW: formating variables

2001-09-18 Thread Brett W. McCoy

On Tue, 18 Sep 2001, Wagner wrote:

> I have a variable $var and its value is 345.678975 (for example).
> How can i format $var to became 345.67 only two digits after the
> point...

printf("%.2f", $var);

Note that this will do actual rounding of your number as well.

> Another question... my script is generating a html document and i want to
> put the following text: US$
> How can i put the $ symbol? The script interpert it as a variable and i just
> want the caracter...

Either enclose the text in single quotes 'US$', or escape the $ "US\$".

-- Brett


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




Re: "Unless" statement

2001-09-17 Thread Brett W. McCoy

On Mon, 17 Sep 2001, David Draley wrote:

> how would I write an unless statement that is looking for the values
> inbetween two numbers?
>
> unless (50 < $x > 80)

print '' unless( ($x > 50) and ($x < 80) );

-- Brett
  http://www.chapelperilous.net/

I need another lawyer like I need another hole in my head.
-- Fratianno



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




Re: Renaming a File

2001-09-10 Thread Brett W. McCoy

> > Yes, and surprisingly enough, it's called "rename". :)
>
> I've had bad luck using rename, I've had to copy the file to the new name
> and deep six the old, check out File::Copy, I think it ironically, has a
> function called copy(), or even cp(), my memory eludes me.

There's also one called in that same module called move/mv, which is
functionally the same as renaming a file, depending on the system you are
on.

-- Brett
  http://www.chapelperilous.net/

This PORCUPINE knows his ZIPCODE ... And he has "VISA"!!


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




Re: Win32 Apache and Perl

2001-09-02 Thread Brett W. McCoy

On Sun, 2 Sep 2001, Gunther Birznieks wrote:

> >I stand corrected then!  Does Apache interpret the shebang line before
> >running the script?  I've had problems with Apache *requiring* the correct
> >drive and pathname for other things in its configuration under Win32.
>
> I believe it does. But I am not sure what you mean by "other things in its
> configuration". Are you talking about other things in httpd.conf or other
> things in your Perl script?

httpd.conf -- but we shouldn't get into it too deeply here because we're
going off-topic.  I do so very little with Apache under Win32 anyway (or
much anything with Win32).

-- Brett
  http://www.chapelperilous.net/

What does education often do?  It makes a straight cut ditch of a
free meandering brook.
-- Henry David Thoreau


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




  1   2   >