counter update

2001-06-05 Thread Luinrandir Hernson

from within the body of the .htm page use this command






This is the .cgi program

#!/usr/bin/perl -w
use strict;
use diagnostics;
my $count;
$count = "12345";
print "Content-type: text/html\n\n";
print "-($count)-\n";
exit;

##

this works.. now to build up the rest of the program.

thanks again
lou




Re: $= and $~

2001-06-05 Thread Jeff 'japhy' Pinyan

On Jun 5, Alan F. Larimer, Jr. said:

>> >>$old = $=;
>> >>$~ = "HEADER";
>> >>$= = 25;  #cuz that's how many lines on the screen
>> >>(print some stuff with HEADER format)
>> >>$~ = "STDOUT";
>> >>$= = $old;
>> >>
>> >>I used a print statement to ensure that $= is being set properly,
>> and
>> >>it is.  But when I print stuff with HEADER format, it seems to not
>> >>stick with that new $= = 25;  Yes, the output is still going to
>> STDOUT
>> >>(screen), where I want it, but just not with the new
>> >>format_lines_per_page.
>> >
>> >How do you know this, Alan?  Do you have a format_header set?  If
>> not, I'm
>> >afraid you won't be able to tell where one "page" ends and the next
>> >begins.
>> 
>> Rather, format_top_name, set via the $^ variables.
>
>Your first response did kinda confuse me, but now I see what you mean. 
>Then my question becomes: Will the display wait for me to see the first
>screen before jumping to the next?  Or do I need to implement that in
>some other way?  (ie ; # like getch() in C)

No.  The FORMAT_LINES_PER_PAGE variable, $=, just holds how many lines get
printed per each header-content text.  You'll need to make some sort of
pager for your program.  In fact, $= isn't even needed, then.

  #!/usr/bin/perl -w

  use strict;

  sub pager {
my ($fh, $func, $pause, $lines) = @_;
local (*READ, *WRITE, *FH, *SAVE);

pipe READ, WRITE;
*FH = $fh;

open SAVE, ">&FH"; 
open FH, ">&WRITE";

my $old = select FH;

$func->();

close FH;
close WRITE;

open FH, ">&SAVE";   
close SAVE;   

while () {
  print;
  $pause->() if $. % $lines == 0;
}
 
close READ;

select $old;
  }

  pager(\*STDOUT, sub { print `ls -lag` }, sub {  }, 20);

If you need an explanation of this code, I'll gladly give one in the
morning.  Until then, I really need some sleep. ;)

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
Eruséro Marillion -- wielder of Ringril, known as Hesinaur, the Winter-Sun
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **




Re: one last attempt?

2001-06-05 Thread Luinrandir Hernson

well i cant beleive it
know what the first problem was
spaces after and before the double dashes.
i was using

and the correct command is

this caused three days of hairpulling madness...
I'm laughing on the outside... but inside ERRR!
the spaces were suggested to me on this list.

ANYWAY..
when i get the program up and running 
(and this may not yet be the last of this horse hockey)
i will share it with every... since you all help me do it...

thanks again to everyone even that one guy/suggestion (E!)
it made my pour over 5 perl and html books in 48 hours.

but I learned and grew (ERR!)

:-) Lou
  - Original Message - 
  From: iain truskett 
  To: [EMAIL PROTECTED] 
  Sent: Tuesday, June 05, 2001 11:08 PM
  Subject: Re: one last attempt?


  * Alan F. Larimer, Jr. ([EMAIL PROTECTED]) [06 Jun 2001 02:59]:
  > > > this is the command line from my index.htm file
  > > > 
  [...]
  > --- Peter Cornelius <[EMAIL PROTECTED]> wrote:
  > > Umm. Don't you need an http header? print "content type:
  > > text/html\n\n"; before printing anything else out. CGI.pm would
  > > allow you to just say 'print header();' btw.

  > I thought of that, but it is being executed from an html doc, not a
  > perl script.  So now, I wonder, where is this being placed w/in the
  > html doc?  If it's w/in the body, then the header is already there.
  [...]

  If you're doing #exec, then you don't need the HTTP headers. In most
  cases, you don't even want to use #exec.

  If you're doing 
  then you do need HTTP headers (at least a content-type). You also get
  the added advantage that Apache determines whether the caller has
  appropriate permissions to run the script and you also get all the
  Apache URL parsing and handling happening (hence mod_rewrite and
  MultiViews work).

  I believe the problem that is happening occurs within the user's (sorry,
  I've lost the original email so I don't have your name) interpretation
  of the server configuration.


  cheers,
  -- 
  iain.  



Re: Substring retrieval

2001-06-05 Thread Hasanuddin Tamir

On Tue, 5 Jun 2001, Nathaniel Mallet <[EMAIL PROTECTED]> wrote,

> The Index function isn't listed on the perl.com website, which was the only
> place I looked for documentation up until now. I haven't recieved my Perl
> books from Fatbrain yet. ;-)

It's always right there (among other functions as well), in your
local documentation.  If you prefer the web, www.perldoc.org to go.

hth
s.a.n
-- 
Hasanuddin Tamir: [EMAIL PROTECTED] - Trabas: www.trabas.com




RE: one last attempt?

2001-06-05 Thread Hasanuddin Tamir

On Tue, 5 Jun 2001, Peter Cornelius <[EMAIL PROTECTED]> wrote,

> Umm.  Don't you need an http header?
> print "content type: text/html\n\n";
>  before printing anything else out.  CGI.pm would allow you to just say
> 'print header();' btw.

No, you don't need that for "#exec cmd".

You can even do,



provided that you have the right configuration.

s.a.n
-- 
Hasanuddin Tamir: [EMAIL PROTECTED] - Trabas: www.trabas.com




RE: one last attempt?

2001-06-05 Thread Hasanuddin Tamir

On Tue, 5 Jun 2001, Alan F. Larimer, Jr. <[EMAIL PROTECTED]> wrote,

> I also am not too knowledgable on SSI.  Therefore, I wonder when does
> the SSI parse?  Before the doc is sent to the client?  If so, this
> might be an issue.  Like I said, I'm not sure about SSI.

Alan,

you can read a HOWTO about SSI in Apache site,

http://httpd.apache.org/docs/howto/ssi.html

hth
s.a.n
-- 
Hasanuddin Tamir: [EMAIL PROTECTED] - Trabas: www.trabas.com




ppm> install not working

2001-06-05 Thread Murzc


Hi! 
I installed xitami on my computer.
It works well.
I have noticed that since the installation I cannot use the ppm install.

ppm> install ppm ##  (for example) 
install ppm (y/N) ? ### (when I hit "y")
ppm>

I used to get all sorts of code downloading to my computer. Now,
nothing happened. Does xitami stop install? 
I checked ppm list in vain. I assume that xitami is responsible but I don't 
know.
Other commands like

ppm>search 

works. It displays the various modules. 
Before this I was able to downloaded dbi, and it went well.

Even if I run ppm before starting up xitami, to still won't work.
Let me know, if anyone has an idea.

Moshe



Re: one last attempt?

2001-06-05 Thread iain truskett

* Alan F. Larimer, Jr. ([EMAIL PROTECTED]) [06 Jun 2001 02:59]:
> > > this is the command line from my index.htm file
> > > 
[...]
> --- Peter Cornelius <[EMAIL PROTECTED]> wrote:
> > Umm. Don't you need an http header? print "content type:
> > text/html\n\n"; before printing anything else out. CGI.pm would
> > allow you to just say 'print header();' btw.

> I thought of that, but it is being executed from an html doc, not a
> perl script.  So now, I wonder, where is this being placed w/in the
> html doc?  If it's w/in the body, then the header is already there.
[...]

If you're doing #exec, then you don't need the HTTP headers. In most
cases, you don't even want to use #exec.

If you're doing 
then you do need HTTP headers (at least a content-type). You also get
the added advantage that Apache determines whether the caller has
appropriate permissions to run the script and you also get all the
Apache URL parsing and handling happening (hence mod_rewrite and
MultiViews work).

I believe the problem that is happening occurs within the user's (sorry,
I've lost the original email so I don't have your name) interpretation
of the server configuration.


cheers,
-- 
iain.  



Re: $= and $~

2001-06-05 Thread Alan F. Larimer, Jr.

> >>$old = $=;
> >>$~ = "HEADER";
> >>$= = 25;  #cuz that's how many lines on the screen
> >>(print some stuff with HEADER format)
> >>$~ = "STDOUT";
> >>$= = $old;
> >>
> >>I used a print statement to ensure that $= is being set properly,
> and
> >>it is.  But when I print stuff with HEADER format, it seems to not
> >>stick with that new $= = 25;  Yes, the output is still going to
> STDOUT
> >>(screen), where I want it, but just not with the new
> >>format_lines_per_page.
> >
> >How do you know this, Alan?  Do you have a format_header set?  If
> not, I'm
> >afraid you won't be able to tell where one "page" ends and the next
> >begins.
> 
> Rather, format_top_name, set via the $^ variables.

Your first response did kinda confuse me, but now I see what you mean. 
Then my question becomes: Will the display wait for me to see the first
screen before jumping to the next?  Or do I need to implement that in
some other way?  (ie ; # like getch() in C)

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Re: $= and $~

2001-06-05 Thread Jeff 'japhy' Pinyan

On Jun 5, Jeff 'japhy' Pinyan said:

>On Jun 5, Alan F. Larimer, Jr. said:
>
>>$old = $=;
>>$~ = "HEADER";
>>$= = 25;  #cuz that's how many lines on the screen
>>(print some stuff with HEADER format)
>>$~ = "STDOUT";
>>$= = $old;
>>
>>I used a print statement to ensure that $= is being set properly, and
>>it is.  But when I print stuff with HEADER format, it seems to not
>>stick with that new $= = 25;  Yes, the output is still going to STDOUT
>>(screen), where I want it, but just not with the new
>>format_lines_per_page.
>
>How do you know this, Alan?  Do you have a format_header set?  If not, I'm
>afraid you won't be able to tell where one "page" ends and the next
>begins.

Rather, format_top_name, set via the $^ variables.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
Eruséro Marillion -- wielder of Ringril, known as Hesinaur, the Winter-Sun
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **




Re: $= and $~

2001-06-05 Thread Jeff 'japhy' Pinyan

On Jun 5, Alan F. Larimer, Jr. said:

>$old = $=;
>$~ = "HEADER";
>$= = 25;  #cuz that's how many lines on the screen
>(print some stuff with HEADER format)
>$~ = "STDOUT";
>$= = $old;
>
>I used a print statement to ensure that $= is being set properly, and
>it is.  But when I print stuff with HEADER format, it seems to not
>stick with that new $= = 25;  Yes, the output is still going to STDOUT
>(screen), where I want it, but just not with the new
>format_lines_per_page.

How do you know this, Alan?  Do you have a format_header set?  If not, I'm
afraid you won't be able to tell where one "page" ends and the next
begins.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
Eruséro Marillion -- wielder of Ringril, known as Hesinaur, the Winter-Sun
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **




RE: one last attempt?

2001-06-05 Thread Alan F. Larimer, Jr.

> > this is the command line from my index.htm file
> > 
> > 
> > I've made this so darn simple it should work.
> > this is the perl program in my cgi-bin:
> > 
> > #!/usr/bin/perl -w
> > use strict;
> > use diagnostics;
> > my $count;
> > $count = "12345";
> > print "-( > color=\"green\">$count)-";
> > exit;
--- Peter Cornelius <[EMAIL PROTECTED]> wrote:
> Umm.  Don't you need an http header?  
> print "content type: text/html\n\n";
>  before printing anything else out.  CGI.pm would allow you to just
> say
> 'print header();' btw.

I thought of that, but it is being executed from an html doc, not a
perl script.  So now, I wonder, where is this being placed w/in the
html doc?  If it's w/in the body, then the header is already there.

I also am not too knowledgable on SSI.  Therefore, I wonder when does
the SSI parse?  Before the doc is sent to the client?  If so, this
might be an issue.  Like I said, I'm not sure about SSI.

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



RE: one last attempt?

2001-06-05 Thread Peter Cornelius

Umm.  Don't you need an http header?  
print "content type: text/html\n\n";
 before printing anything else out.  CGI.pm would allow you to just say
'print header();' btw.

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 05, 2001 6:41 PM
> To: [EMAIL PROTECTED]
> Subject: one last attempt?
> 
> 
> Well i'm about to chuck perl out the window
> 
> this is the command line from my index.htm file
> 
> 
> I've made this so darn simple it should work.
> this is the perl program in my cgi-bin:
> 
> #!/usr/bin/perl -w
> use strict;
> use diagnostics;
> my $count;
> $count = "12345";
> print "-( color=\"green\">$count)-";
> exit;
> 
> 
> does anyone see why this wouldn't print to my index.htm file 
> cause if i can't get this simple code to work, how can i get 
> the whole bloody counter program to work would someone 
> please just give me the freaking answer on how to make this work?!
> 



RE: Perl: Finding unique strings in an array

2001-06-05 Thread Jeff 'japhy' Pinyan

On Jun 5, Jamie Krasnoo said:

>From: Peter Scott [mailto:[EMAIL PROTECTED]]
>>
>>{ my %temp;
>>   @temp{@array} = ();
>>   @youwant = keys %temp;
>>}
>>
>>However, that said, 99 times out of a hundred you should have been keeping
>>your data in a hash to begin with and you've made a design error by putting
>>it in an array.  Also, the above method doesn't preserve the order.
>
>using Tie::IxHash would though.

Except that Tie::IxHash does far too much work such a simple task as
removing duplicates from a list.  If you understand what Tie::IxHash does,
you would never suggest it for such a situation.

If order needs to be preserved, a simple grep() (a la the FAQ) will do:

  # from perlfaq4, #38
  undef %saw;
  @out = grep(!$saw{$_}++, @in);

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
Eruséro Marillion -- wielder of Ringril, known as Hesinaur, the Winter-Sun
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **




$= and $~

2001-06-05 Thread Alan F. Larimer, Jr.

I am attempting to fo the following (pseudocode and realcode to
follow):

(nomal stuff with STDOUT)
$old = $=;
$~ = "HEADER";
$= = 25;  #cuz that's how many lines on the screen
(print some stuff with HEADER format)
$~ = "STDOUT";
$= = $old;
(more stuff with STDOUT)

I used a print statement to ensure that $= is being set properly, and
it is.  But when I print stuff with HEADER format, it seems to not
stick with that new $= = 25;  Yes, the output is still going to STDOUT
(screen), where I want it, but just not with the new
format_lines_per_page.

Thoughts, suggestions, concerns, complaints?

Thnx  --Alan


=
Alan F. Larimer, Jr.
http://www.geocities.com/lrng_lnx/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Re: one last attempt?

2001-06-05 Thread Hasanuddin Tamir

On Tue, 5 Jun 2001, Luinrandir Hernson <[EMAIL PROTECTED]> wrote,

> Well i'm about to chuck perl out the window
>
> this is the command line from my index.htm file
> 
>
> I've made this so darn simple it should work.
> this is the perl program in my cgi-bin:
>
> #!/usr/bin/perl -w
> use strict;
> use diagnostics;
> my $count;
> $count = "12345";
> print "-($countcolor=\"blue\">)-";
> exit;

It's ok if you don't want to use CGI.pm for this simple HTML code
but you still can save yourself from escaping by using alternative
quoting,

print qq(-($count)-);

> does anyone see why this wouldn't print to my index.htm file cause if i
> can't get this simple code to work, how can i get the whole bloody
> counter program to work would someone please just give me the
> freaking answer on how to make this work?!

The script is just fine.  But for server side include to work there are
other things you need.  For Apache, you need to set "Options Includes"
and set that your file is meant to be parsed as SSI page.  And I'm not
really comfortable to explain that in this list.


s.a.n
-- 
Hasanuddin Tamir: [EMAIL PROTECTED] - Trabas: www.trabas.com




RE: one last attempt?

2001-06-05 Thread Jamie Krasnoo

What server are you using? (Apache, ... etc ) Are you sure that you have it
configured correctly for SSI?

This should be in httpd.conf (if Apache):

Exec /*.shtml /where/your/proggie/is.pl

Make sure you also have -T enabled on your program (regardless if they take
a value or not).

Jamie


-Original Message-
From: Luinrandir Hernson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 05, 2001 6:41 PM
To: [EMAIL PROTECTED]
Subject: one last attempt?


Well i'm about to chuck perl out the window

this is the command line from my index.htm file


I've made this so darn simple it should work.
this is the perl program in my cgi-bin:

#!/usr/bin/perl -w
use strict;
use diagnostics;
my $count;
$count = "12345";
print "-($count)-";
exit;


does anyone see why this wouldn't print to my index.htm file cause if i
can't get this simple code to work, how can i get the whole bloody counter
program to work would someone please just give me the freaking answer on
how to make this work?!




Re: Substring retrieval

2001-06-05 Thread Nathaniel Mallet

The Index function isn't listed on the perl.com website, which was the only
place I looked for documentation up until now. I haven't recieved my Perl
books from Fatbrain yet. ;-)

Thanks for the info. It was very useful.

Nat
- Original Message -
From: "Hasanuddin Tamir" <[EMAIL PROTECTED]>
To: "Nathaniel Mallet" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, June 04, 2001 10:21 PM
Subject: Re: Substring retrieval


> On Mon, 4 Jun 2001, Nathaniel Mallet <[EMAIL PROTECTED]> wrote,
>
> > Date: Mon, 4 Jun 2001 21:06:43 -0400
> > From: Nathaniel Mallet <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED]
> > Subject: Substring retrieval
> >
> > Hi,
> >
> > I'm trying to retrieve a substring from a string, but I'm not sure
> > exactly where and how big that substring is. The substring is
> > delimited by a start and end special character. It was suggested to
> > me to write two regular expression, one that would match everything
> > up to and including the start special character, and one to match
> > everything following and including the end special character, and
> > replacing the matches with nothing.
> >
> > I thought finding the location of the start and end special
> > characters, then calling substr().
> >
> > And so I have to questions:
> > 1 - How would I find the index for a particular character in a string?
>
> Using index() function.  Now, doesn't it suprise you?
>
> perldoc -f index
>
>
> > 2 - What's the best method, everything considered (simplicity,
> > performance, etc).
>
> -   how many times does the substring you want to retrieve occur
> in the string?  Exactly once? Can be more?
> -   Are the start and end special characters just the same?
>
> Regular expression is the common way to solve this, but you could also
> use split() or combination of substr/index.
>
> __END__
> s.a.n
> --
> Hasanuddin Tamir: [EMAIL PROTECTED] - Trabas: www.trabas.com
>
>




Re: one last attempt?

2001-06-05 Thread Ask Bjoern Hansen

On Tue, 5 Jun 2001, Luinrandir Hernson wrote:

[...]
> print "-($countcolor=\"blue\">)-";

> does anyone see why this wouldn't print to my index.htm file
> cause if i can't get this simple code to work, how can i get the
> whole bloody counter program to work would someone please
> just give me the freaking answer on how to make this work?!

As Elaine pointed out, it's most likely a problem with the server
configuration. Your error log should be of help.

After that you might find more experts in all things CGI-like if you
subscribe to beginners-cgi (send mail to
[EMAIL PROTECTED] or go to http://learn.perl.org/)
and ask there. :-)


on a sidenote,

print "-($count)-";

would be more readable as,

print qq[-($count)-];

see, no more nasty escaping. :-) (of course until you need ']' in
the string, in which case you might want to quote with for example
qq!string! or qq{string} ... :-)

 - ask

-- 
ask bjoern hansen, http://ask.netcetera.dk/   !try; do();
more than 100M impressions per day, http://valueclick.com




Re: one last attempt?

2001-06-05 Thread JTSage

Try clearing the buffer...  either set $| = 1; or add a newline caracter to the
end of that print statement.  Not sure, but it may help

~jon
--- Luinrandir Hernson <[EMAIL PROTECTED]> wrote:
> Well i'm about to chuck perl out the window
> 
> this is the command line from my index.htm file
> 
> 
> I've made this so darn simple it should work.
> this is the perl program in my cgi-bin:
> 
> #!/usr/bin/perl -w
> use strict;
> use diagnostics;
> my $count;
> $count = "12345";
> print "-($count color=\"blue\">)-";
> exit;
> 
> 
> does anyone see why this wouldn't print to my index.htm file cause if i can't
> get this simple code to work, how can i get the whole bloody counter program
> to work would someone please just give me the freaking answer on how to
> make this work?!
> 


=
==
  "Did you ever wonder if the person in the puddle is 
   real, and you're just a reflection of him?"
- Calvin (from Calvin & Hobbes)
==
 [-WiSE-] [EMAIL PROTECTED] HTTP://www.wisefreebsd.org

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Re: one last attempt?

2001-06-05 Thread Alan F. Larimer, Jr.

> Luinrandir Hernson [[EMAIL PROTECTED]] quoth:
> *>
> *>does anyone see why this wouldn't print to my index.htm file cause
> if i can't get this simple code to work, how can i get the whole
> bloody counter program to work would someone please just give me
> the freaking answer on how to make this work?!
> 
> Have you tried looking in your error log? Checked to see if the
> server
> does SSI? etc?
> 
> e.

I missed the initial asking of this question, so please don't take my
response the wrong way.

That was one of my first thoughts.  Check the server logs (if
possible).  Is SSI permitted?  Does your script have to be .pl instead
of .cgi?  How does it appear on the browser (error page, the "counter"
is missing, nothing at all)?  Are permissions set properly?

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Re: one last attempt?

2001-06-05 Thread Elaine -HFB- Ashton

Luinrandir Hernson [[EMAIL PROTECTED]] quoth:
*>
*>does anyone see why this wouldn't print to my index.htm file cause if i can't get 
this simple code to work, how can i get the whole bloody counter program to work 
would someone please just give me the freaking answer on how to make this work?!

Have you tried looking in your error log? Checked to see if the server
does SSI? etc?

e.



one last attempt?

2001-06-05 Thread Luinrandir Hernson

Well i'm about to chuck perl out the window

this is the command line from my index.htm file


I've made this so darn simple it should work.
this is the perl program in my cgi-bin:

#!/usr/bin/perl -w
use strict;
use diagnostics;
my $count;
$count = "12345";
print "-($count)-";
exit;


does anyone see why this wouldn't print to my index.htm file cause if i can't get this 
simple code to work, how can i get the whole bloody counter program to work would 
someone please just give me the freaking answer on how to make this work?!



RE: Perl: Finding unique strings in an array

2001-06-05 Thread Jamie Krasnoo

using Tie::IxHash would though.

use strict;
use Tie::IxHash;

my %seen;
tie %seen, 'Tie::IxHash';

my @array = qw(fee fi fo fum fee fee fi foo fum fogie);
@seen{@array} = 1;
my @wanted = keys %seen;

print "@wanted\n";

outputs: fee fi fo fum foo fogie

Jamie

-Original Message-
From: Peter Scott [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 05, 2001 6:11 PM
To: Philip Peeters; [EMAIL PROTECTED]
Subject: Re: Perl: Finding unique strings in an array


At 06:02 PM 6/5/2001 -0700, Philip Peeters wrote:
>Hi,
>
>Is there some magical way to identify unique strings within an array?
>
>
>Example:
>@array = ( "beer","water","wine","beer","wine");
>and I'd like to end up with:  beer, water, wine

{ my %temp;
   @temp{@array} = ();
   @youwant = keys %temp;
}

However, that said, 99 times out of a hundred you should have been keeping
your data in a hash to begin with and you've made a design error by putting
it in an array.  Also, the above method doesn't preserve the order.





Re: Perl: Finding unique strings in an array

2001-06-05 Thread Peter Scott

At 06:02 PM 6/5/2001 -0700, Philip Peeters wrote:
>Hi,
>
>Is there some magical way to identify unique strings within an array?
>
>
>Example:
>@array = ( "beer","water","wine","beer","wine");
>and I'd like to end up with:  beer, water, wine

{ my %temp;
   @temp{@array} = ();
   @youwant = keys %temp;
}

However, that said, 99 times out of a hundred you should have been keeping 
your data in a hash to begin with and you've made a design error by putting 
it in an array.  Also, the above method doesn't preserve the order.




RE: Perl: Finding unique strings in an array

2001-06-05 Thread Eduard Grinvald

Ok, the simplest way i see is inserting the elements into a hash as keys,
thus eliminating duplicates, and then do keys on the hash.

-Original Message-
From: Philip Peeters [mailto:[EMAIL PROTECTED]]
Sent: 05 e?iy 2001 a. 21:03
To: [EMAIL PROTECTED]
Subject: Perl: Finding unique strings in an array


Hi,

Is there some magical way to identify unique strings within an array?


Example:
@array = ( "beer","water","wine","beer","wine");
and I'd like to end up with:  beer, water, wine

If there is some kind of function that does this, then I'd be most glad
to hear of it. If not, I'll figure something out with cmp.

Thanks,
Philip


___
To get your own FREE ZDNet Onebox - FREE voicemail, email, and fax,
all in one place - sign up today at http://www.zdnetonebox.com





Perl: Finding unique strings in an array

2001-06-05 Thread Philip Peeters

Hi,

Is there some magical way to identify unique strings within an array?


Example:
@array = ( "beer","water","wine","beer","wine");
and I'd like to end up with:  beer, water, wine

If there is some kind of function that does this, then I'd be most glad
to hear of it. If not, I'll figure something out with cmp.

Thanks,
Philip


___
To get your own FREE ZDNet Onebox - FREE voicemail, email, and fax,
all in one place - sign up today at http://www.zdnetonebox.com




splitting strings with quoted white space

2001-06-05 Thread Peter Cornelius

I have this script that reads in lines from a configuration file, processes
them, and then stores them in a hash.  Everything is working (mostly) but I
really don't like the snippet below and wanted to see if anyone could
suggest a better solution.  I would call better a syntactically shorter,
less processor intensive, or just plain faster.  Here's the trick to the
below sample though.  I know that I will get a line that looks like...
NAME DELIM VALUE

The white spaces between the values are required but I have no idea what
NAME, DELIM, or VALUE will be. I know they will not contain new lines but
they may be quoted strings containing spaces themselves as in the code
below.  I'm currently requiring that they cannot contain quotes but it would
be good if I could remove that restriction.

So right now I split the line on white space and then put things together
again in a 'for' loop.  Does anyone have any suggestions?

Thanks,
Peter C.

 use strict;
 use warnings;

 local $_ = 'name = "quoted string with space"';

 my @pair = split;

 #repair damage done to a quoted string
 for (my $i = 0; $i < $#pair; $i++) {
 if ($pair[$i] =~ /^['"]/) {
until (!defined($pair[$i])
 || !defined($pair[$i+1])
 || $pair[$i] =~ /['"]$/) {
 $pair[$i] .= " " . $pair[$i+1];
 splice @pair, $i+1, 1;
 }
 $i++;
 }
 }

 print "$_\n" for (@pair)



Re: problem with script

2001-06-05 Thread John Fox

Verily, on Tuesday June  5, 2001, the Sainted Kweku Addae-Mensah spake:
> However I get this warning when I run it
> Name "main::opt_f" used only once: possible typo at
> openfile.pl line 9.
> What could be the problem.

Perl's '-w' checking warns you about variables that are only used
once, as this often comes about from a typographical error.

For example:

-
#!/path/to/perl -w
$string = "This is fun!";
print $strng; # Oops, left out an 'i'
-

generates the same sort of warning...and in this case,
it is a very welcome warning, basically saying "Hey,
you mistyped a variable name.".

So, your situation amounts to exactly what your error
message said -> "possible typo".  You really don't have
a problem; Perl's just trying real hard to help you
out a bit. :)

HTH,

John
-- 
   John Fox <[EMAIL PROTECTED]>
System Administrator, InfoStructure, Ashland OR USA
  -
"What is loved endures.  And Babylon 5 ... Babylon 5 endures."
  --Delenn, "Rising Stars", Babylon 5



problem with script

2001-06-05 Thread Kweku Addae-Mensah

Hello there someone pointed me to you for problems
with perl
I am a beginner learning perl on my own.
I wrote this script to read a file 
#!/ncsu/perl56/bin/perl -w

#purspose  reads from a file

use Getopt::Long;

#set up command line to accept file name
my $ret = GetOptions ("f|filename:s");
my $filename = $opt_f || die "Usage: $0 -f filename
\n";

#open file

open (INPUT, "$filename") || die "could not open file
$filename : $!\n";
#start reading from file

while()
{
   chop;
   print "Line $. = <$_>\n";

}
 #close file

 close (INPUT);

However I get this warning when I run it
Name "main::opt_f" used only once: possible typo at
openfile.pl line 9.
What could be the problem.
I used portions of scripts taken from PERL 5 How-to
second edition.
Hope that you can get back to me on this
Sincerely
KWeku Addae-Mensah

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



RE: [OT] style

2001-06-05 Thread Hanz, Rob



Michael Fowler [mailto:[EMAIL PROTECTED]] wrote:
>The original discussion was regarding the alternatives:
>
>   open(FILE, $file) || die("open: $!");
>
>open FILE, $file  or die "open: $!";
>
>
>This is the matter of style of style being discussed.  Naturally, if you're
>not using parens, the choice of 'or' or '||' becomes a little more
>important.

Granted.  But, this is a beginner's list, and beginners will often do such
things as assuming "Well, leaving out the parens is okay, and exchanging
'or' for '||' is okay, so doing both must be okay as well!  I know that I've
made a number of such blunders.

For a novice, I would probably recommend the alternative:

   open (FILE, $file) or die ("open: $!");

but that's just me

>Your basic premise, that there's a pretty good reason to use 'or' instead
of
>'||', tries to generalize the problem too much.  There are instances where
>it's much preferable to use '||', for the very reason you mention
preferring
>'or', precedence.  Consider:
>
>$foo = undef || "default";
>$foo = undef or "default";

Again, granted.  I was referring to the common perlism of "do something or
die" (substitute gripe,carp,custom routine, whatever for die at the end if
you so wish).  My main point was that || and or are NOT synonymous in that
instance, which makes the usage of one or the other slightly more than a
matter of style, and wanted to point that out to others who may not have
been aware of the difference.

Perhaps I was not specific enough in my suggestion as to using 'or' instead
of '||'.  I apologize for that.

>The alternative to using '||', while still accomplishing what was intended,
>is, of course:
>
>$foo = (undef or "default");
>
>I think you can guess which I prefer.

I'd probably prefer the form 'undef || "default"' as well.  Though I'd
really probably prefer '(undef || "default")' just to make sure that perl
does exactly what I want, and because I do too much C/C++.  Really, for a
beginner, I'd recommend putting most stuff in ()s when applicable, just
because that's a good way to avoid gotchas exactly like we've just
discussed.

When teaching someone a foreign language, you don't start with slang and
contractions.

I would still recommend, for a beginner, using 'or' in the "do something or
die" construct, just because it's less likely, in that particular construct,
to do something you don't expect.

Rob



Re: Fwd: 'use' question

2001-06-05 Thread Steve Mayer


Actually, I think the problem is that your first line should have the hash (#)
and bang(!) reversed the other way so that is reads:

#!/usr/local/bin/perl

Steve

On Tue, Jun 05, 2001 at 09:48:56PM +0200, M.W. Koskamp wrote:
> 
> 
> - Original Message - 
> From: Bob Mangold <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, June 05, 2001 9:28 PM
> Subject: Re: Fwd: 'use' question
> 
> 
> > ok sorry for the lack of a script before,
> > 
> > here is a little test script i wrote to try to figure out how to use the
> > Getopt::Std module.
> > 
> > ---
> > !#/usr/local/bin/perl
> > 
> > use Getopt::Std;
> > 
> > getopt("abc");
> > 
> > print "$opt_a - $opt_b - $opt_c\n";
> > ---
> > 
> You are missing a semi-colon at the end of line 1
> after the #!/usr/local/bin/perl
> 
=
Steve Mayer Oracle Corporation
Senior Member of Technical Staff1211 SW 5th Ave.
Portland Development Center Suite 900
[EMAIL PROTECTED]Portland, OR 97204 
Phone:  503-525-3127
=



Re: Where can I learn how to use taint?

2001-06-05 Thread Kevin Hancock

>> > >>
>> > >>produces this:
>> > >>"Too late for "-T" option at w:\cgi-bin\admin\tainttest.pl line 1."
>> > >


I had this problem and this exact same message on a linux server cause I had
my CGI running SUID and calling my perl code.

The c program calls my perl code

#include 
#include 
#include 
#include 

void main () {
setuid(0);
setgid(0);
system("/usr/bin/perl program.pl");
setuid(666);
setgid(666);
}

#head -1 program.pl

#!/usr/bin/perl   -wT

This produces your error message because it was too late for the T option.
Putting the -T option in the c code solved the problem. Are you doing
something similar?

Cheers

Kevin




Re: [OT] style

2001-06-05 Thread Michael Fowler

On Tue, Jun 05, 2001 at 02:04:59PM -0700, Hanz, Rob wrote:
> Actually, there's a pretty good reason to use 'or' instead of '||' - for
> anything in list context, remember that '||' binds more tightly than ','
> and 'or' binds less tightly than ','.
> 
> This can lead to bugs if you do things like:
> 
> print OUTFILE $variable || die "Error writing to $nameofmyoutfile ";

The original discussion was regarding the alternatives:

open(FILE, $file) || die("open: $!");

open FILE, $file  or die "open: $!";


This is the matter of style of style being discussed.  Naturally, if you're
not using parens, the choice of 'or' or '||' becomes a little more
important.

Your basic premise, that there's a pretty good reason to use 'or' instead of
'||', tries to generalize the problem too much.  There are instances where
it's much preferable to use '||', for the very reason you mention preferring
'or', precedence.  Consider:

$foo = undef || "default";
$foo = undef or "default";

The alternative to using '||', while still accomplishing what was intended,
is, of course:

$foo = (undef or "default");

I think you can guess which I prefer.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--



Re: newcounter(was did i do that correctly)

2001-06-05 Thread Bill Stilwell

On Tue, Jun 05, 2001 at 08:00:52AM -0400, Luinrandir Hernson wrote:
> many thanks for the assistance
> 
> here is the program in full so you may verify i did it correctly (i'm
sure there was a shorter way, but right now i'm just trying to get the
darn thing to work!!!)  But now an error of an uninitialize value in 46
&51 occurs and I don't know what to do..please assist? I marked them with
a comment like this "###  use of uninitialize value". Also an error
"Arguement "" isn't numeric in eq at line 58" also marked as above.

Just as an additional note, I've found that putting 

use diagnostics;

in all my programs during development is very helpful. This basically
gives you verbose descriptions of the error messages you're experiencing
and will often pinpoint what is wrong. It also means you don't have to 
wade your way through perldoc perldiag.

Cheers,
Bill 

-- 
Bill Stilwell   
[EMAIL PROTECTED]
It's all margins.
Oh, just read my weblog: http://www.marginalia.org



On Beginners' Mindsets, Part III

2001-06-05 Thread Peter Scott

[So far I haven't been accused of a surfeit of hubris, so here's some more 
grist for the mill.  Though I may dial the grist back a bit if it generates 
an excess of flammage.  This and my previous posts are archived on my web 
site.]

Clarity is the secret weapon of the beginner.  To learn a new subject 
quickly, learn to talk about it the way the experts do.  Use the same terms 
they do; if they appear to be splitting hairs, look closer, because the 
distinction is likely to be important.  (Insert the old saw about Eskimos 
and words for snow.)  For instance, although they appear similar, lists and 
arrays are very different entities in Perl; be fanatical about using the 
appropriate term for the one you're referring to.  Likewise, people today 
talk about "hashes"; they gave up on the term "associative arrays" many 
years ago.

One reason for this is to help mark out the new paths in your brain faster; 
picture a herd of cows being led across a corn field.  If they're all led 
along the same path, that path will be very clearly marked and the next 
herd to come along will have no trouble telling which way it should go.  If 
the cows are allowed to roam ("What's the difference?  Y'all know what I'm 
talking about, right?") then there will be a maze of ill-defined paths left 
behind and the next herd will be confused.  You'll learn what you need to 
know faster by being rigorous about how you talk about it.

Paradoxically, beginners often expend far more effort than they should in 
trying to communicate about some problem.  Think of the experts reading 
your posts as an army of Mr. Spocks; they're capable of answering anything 
as long as they're fed accurate data.  Data, not assumptions.  It's not 
necessary to guess at what might be going on; it's not necessary to apply 
any amount of imperfect knowledge.  All they need are the facts: what did 
you do, what happened, what were you expecting to happen?  An ounce of 
visibility into what you're doing beats a ton of unverifiable speculation.

Remember, the experts can't read your mind or look over your shoulder to 
see what you see.  If you got an error, at the very least, they need to see 
the line of code that generated it; often, this isn't the line you might 
think it is, and they'd be better off with the whole script.  In which 
case, the shorter it is, the better.  You'd be surprised how often you'll 
figure out the problem yourself on the way to coming up with a brief example.

Watch out for ambiguities and missing information in your requests.  An 
excellent way of training yourself to spot them and deal with them is in 
what NeuroLinguistic Programming (NLP) calls the Meta Model; see 
explanations at, e.g., 
http://ourworld.compuserve.com/homepages/PatrickM/metamod.htm (found 
through a search, no affiliation).  One way to test your communication 
skill is a game to play with another person; pick a complex diagram that 
they haven't seen, and using only words, describe it well enough for them 
to draw a reproduction.  (You can see the application of this principle in 
the HBO miniseries _From The Earth To The Moon_ when the Apollo 17 crew are 
trained to report their geological observations to Earth.)

Cut and paste is the easiest way to ensure accuracy and requires virtually 
no thought.  On the way, there's a good chance you'll catch "obvious" 
mistakes that you'd be embarrassed to air in public, just by virtue of 
doing this vicarious demonstration, as it were.




Re: return values from instance methods

2001-06-05 Thread Alan F. Larimer, Jr.

--- "Brett W. McCoy" <[EMAIL PROTECTED]> wrote:
> On Tue, 5 Jun 2001, Alan F. Larimer, Jr. wrote:
> 
> > 1) After reading the perltoot manpage and most of the perlobj manpage, I am
> > left with a question of "properness."  Should instance methods always only
> > return references?  In the perltoot manpage it shows an instance method
> > returning an array instead of the reference to it.  Then pushing that onto
> an
> > array (in main) to be used later.  Wouldn't that be less effecient
> > (memory/speed) than just passing back the reference?
> 
> Not necessarily.  You might want to have your instance method do something
> different when used in a list context versus being used in a scalar
> context.  If you used a reference, the user of your class would have to do
> some funny things to go into a list context versus a scalar context.  If
> you let your method handle that, the user of your class will be happier.

Whether it's a scalar, array, etc . . . if you return a reference, the class
user has to dereference it.  So for style's sake, wouldn't you want to keep it
consistent.  Still, there are the memory usage and speed issues.  (I imagine
their really isn't much of an issue, but I'd still like to have an idea.)

> > 2) DESTROY   I'm not sure I understand how this is used.  I do understand
> the
> > purpose.  For example (from perltoot manpage), a class variable is storing
> the
> > poulation of a Person class (increased everytime new is called).  There is
> a
> > DESTROY function/subroutine for accounting for a loss of an object,
> decreasing
> > the population.  Does one using the class have to specifically call the
> > DESTROY, or is that called when the reference to an object is gone?  (In
> case
> > you couldn't tell, it really has me lost.)
> 
> DESTROY should never be called explicitly (although you can) -- it
> functions similarly to C++ destructors.  It is called implicitly when the
> last reference to the object goes away.  In most cases, creating a
> destructor is probably not necessary unless you need to close filehandles,
> socket connections, modify class data (as in your example), etc.

So, for example (from perltoot again) . . . 
I have a Person class that saves (amoung other things) name and peers.  I
create the object and push it onto an array in package main.  When I remove
(pop, shift, or indexing) the object from that main array, the DESTROY is
automatically called and decrements the class variable of population. Correct?

=
Alan F. Larimer, Jr.
http://www.geocities.com/lrng_lnx/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Re: return values from instance methods

2001-06-05 Thread Brett W. McCoy

On Tue, 5 Jun 2001, Alan F. Larimer, Jr. wrote:

> 1) After reading the perltoot manpage and most of the perlobj manpage, I am
> left with a question of "properness."  Should instance methods always only
> return references?  In the perltoot manpage it shows an instance method
> returning an array instead of the reference to it.  Then pushing that onto an
> array (in main) to be used later.  Wouldn't that be less effecient
> (memory/speed) than just passing back the reference?

Not necessarily.  You might want to have your instance method do something
different when used in a list context versus being used in a scalar
context.  If you used a reference, the user of your class would have to do
some funny things to go into a list context versus a scalar context.  If
you let your method handle that, the user of your class will be happier.

> 2) DESTROY   I'm not sure I understand how this is used.  I do understand the
> purpose.  For example (from perltoot manpage), a class variable is storing the
> poulation of a Person class (increased everytime new is called).  There is a
> DESTROY function/subroutine for accounting for a loss of an object, decreasing
> the population.  Does one using the class have to specifically call the
> DESTROY, or is that called when the reference to an object is gone?  (In case
> you couldn't tell, it really has me lost.)

DESTROY should never be called explicitly (although you can) -- it
functions similarly to C++ destructors.  It is called implicitly when the
last reference to the object goes away.  In most cases, creating a
destructor is probably not necessary unless you need to close filehandles,
socket connections, modify class data (as in your example), etc.

-- Brett

Brett W. McCoy
Software Engineer
Broadsoft, Inc.
240-364-5225
[EMAIL PROTECTED]




return values from instance methods

2001-06-05 Thread Alan F. Larimer, Jr.

Here goes the multipart question . . . 

1) After reading the perltoot manpage and most of the perlobj manpage, I am
left with a question of "properness."  Should instance methods always only
return references?  In the perltoot manpage it shows an instance method
returning an array instead of the reference to it.  Then pushing that onto an
array (in main) to be used later.  Wouldn't that be less effecient
(memory/speed) than just passing back the reference?

2) DESTROY   I'm not sure I understand how this is used.  I do understand the
purpose.  For example (from perltoot manpage), a class variable is storing the
poulation of a Person class (increased everytime new is called).  There is a
DESTROY function/subroutine for accounting for a loss of an object, decreasing
the population.  Does one using the class have to specifically call the
DESTROY, or is that called when the reference to an object is gone?  (In case
you couldn't tell, it really has me lost.)

TIA

--Alan


=
Alan F. Larimer, Jr.
http://www.geocities.com/lrng_lnx/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



re:[OT] style

2001-06-05 Thread Hanz, Rob

Paul <[EMAIL PROTECTED]  wrote:
>--- Michael Fowler <[EMAIL PROTECTED]> wrote: 
>> On Tue, Jun 05, 2001 at 10:42:33AM -0700, Paul wrote: 
>> > open FILE, $filename 
>> > or die "Unable to open file \"$filename\": \l$!.\n";
> > > Personally, I prefer the "noisy" version, though I consider it 
>> anything but noisy. Perhaps it's because 'or' came sometime after I 
>> learned Perl, but mostly it's because it serves to delineate what's 
>> what. This may be an artifact of my C experience, or my penchant to
>> use parens in order to give visual seperation from one function call 
>> to another. 
>One man's trash is another man's treasure. =o) In this case, I don't really

>think it matters much. It's more important to be comfortable with it that 
>to stress over a few characters that don't change the operation of the 
>program when taken together. ;o] 

(sorry for the nasty formatting, I'm using outlook from work, and I'm signed
up for the list at home... cut & paste from archives BAD).

Actually, there's a pretty good reason to use 'or' instead of '||' - for
anything in list context, remember that '||' binds more tightly than ',' and
'or' binds less tightly than ','.

This can lead to bugs if you do things like:

print OUTFILE $variable || die "Error writing to $nameofmyoutfile ";

Which will die if $variable is ever something that evaluates to boolean
false (notably 0 or "").

While this can be avoided with use of parentheses (and an experienced perl
coder will probably spot the issue in two seconds), in most circumstances I
could argue it's best to avoid the possible confusion.

Rob



Re: Mysql interface with perl on win 2k, Someone please help !

2001-06-05 Thread Jonathan Stowe

On Sun, 2 Nov 1997 [EMAIL PROTECTED] wrote:
>
> >
> >Hi,
> >
> >Im trying to connect a perl program to a mysql database on my home computer
> >running win 2k.  I can connect, but i have no idea of how to extract the
> >information out of tables using perl. I have a book about SQL, but it never
> >mentions programming or perl. If anyone could point me to a good tutorial,
> >or give me a few pointers I would be greatly appreciative.
> >
> >

Your best bet would be to start with the documentation for the DBI module
in the first place.

A typical session might be :


use DBI;

my $database = DBI->connect('dbi:MySQL:'); # whatever works

my $cursor = $database->prepare('select * from sometable');
 # where sometable is a table in your database

$cursor->execute();

while ( $cursor->fetch() )
{

   print "@{$_}\n";
}

HTH

/J\




RE: Where can I learn how to use taint?

2001-06-05 Thread Peter Scott

At 02:02 PM 6/5/2001 -0700, Mark Ross wrote:
>Here's
>what comes out of the server log:
>
>06/05/01 16:55 "/cgi/admin/tainttest2.pl", proc "/usr/local/bin/perl":
>Too late for "-T" option at /cgi/admin/tainttest2.pl line 1.
>
>And, here's the code again (I switched the T and the w, just to see if it
>made a difference):
>
>#!/usr/local/bin/perl -Tw

Boggle.  Your web server appears to have an unusual configuration.  Check 
that you are using the right file extensions for CGI scripts on that 
particular server.  Try using a different file extension.




RE: Where can I learn how to use taint?

2001-06-05 Thread Mark Ross


> > >>This code:
> > >>
> > >>#!/usr/local/bin/perl -wT
> > >>use strict;
> > >>use CGI;
> > >>my $q = new CGI;
> > >>print ("hi");
> > >>exit;
> > >>
> > >>produces this:
> > >>"Too late for "-T" option at w:\cgi-bin\admin\tainttest.pl line 1."
> > >
> > >The problem is that -T needs to be enabled so early in the invocation
> > >process that by the time a "perl foo.pl" command sees the shebang line,
> > >it's too late to set it.  This also applies to the way .pl scripts are
> > >invoked on DOSish systems through file type associations.
> >Thanks to everyone who replied to all this so quickly. The server I use
(not
> >mine, web hosting service) is a Linux machine running Apache. I still get
> >the error on same error on the server ... am I just SOL when it comes to
> >taint checking or is there a way to smack the server around and make it
do
> >what it sounds like it should be doing?
>
> See, if you post paths like w:\cgi-bin\admin\tainttest.pl then people are
> going to assume you're on DOS unless you say otherwise.  I don't see how
> you could have gotten that message from a Linux machine, so can you be
> explicit about exactly what is happening on the Linux box?  Taint checking
> works just fine on Linux and you don't have to do anything special.

Sorry about not being clear about what the server is spitting out. Here's
what comes out of the server log:

06/05/01 16:55 "/cgi/admin/tainttest2.pl", proc "/usr/local/bin/perl":
Too late for "-T" option at /cgi/admin/tainttest2.pl line 1.

And, here's the code again (I switched the T and the w, just to see if it
made a difference):

#!/usr/local/bin/perl -Tw
use strict;
use CGI;
my $q = new CGI;
print ("hi");
exit;

Without the -T, the server doesn't generate an error.

(BTW: I know that this doesn't display anything in the browser ... I'm just
trying to figure out what the -T generates that "too late" error.)

Mark.





Re: How to pass form data between two CGI's ?

2001-06-05 Thread Timothy Kimball


Tom O'Brien wrote:
: Can someone please give me an example of how to pass form data between
: two CGI programs? Here's what I'm attempting to do.
:   I'm a novice perl programmer at best so I'm just trying to modify two
: programs to do what I need. Basically, I'm trying to use a "affiliate"
: program. What should happen is that a form is submitted to
: "affiliate.pl" . Affiliate.pl then updates a counter and a few other
: things based on the form data passed to it. Affiliate.pl then passes the
: 
: form data over to my form handling script ("formhander.pl").  The
: problem is that some form fields get truncated when the data is passed
: back to my formhandler.
:   My basic understanding of things is that there are differences in the
: way "GET" and "POST" data are handled.

In a GET, the form data is attached to the URL, something like this:

http://ahost.com/cgi-bin/coolscript.pl?foo=bar&baz=stuff%20and%20nonsense

The problem with a GET is that if the query string (the thing after
"?") is big, it might be truncated to fit into a buffer somewhere.

POST data is sent in the body of the HTTP request, so it suffers no
such limitation.

Now I'm not sure what you mean by "passing form data between two CGI
programs".  Do you mean that affiliate.pl should act as a web agent and
hits formhandler.pl through a web access (in which case they could live
on different machines)?  or do you want affiliates.pl to execute
formhandler.pl from the command line?

In the former case, affiliate.pl should use the LWP modules to
create a little user agent and submit the CGI data with a POST request
to formhandler.pl. Then affiliate.pl will need to handle the output
returned from formhandler.pl.

In the latter case, which is what I'm betting you're doing, one way
might be to have affiliate.pl write the CGI data to a temporary file,
redirect the browser to formhandler.pl, and then have formhandler.pl
get the information from the temp file. CGI.pm makes this very easy
(you are using CGI.pm, right? ;):

affiliate.pl

my $cgi = new CGI; # Handles GET or POST
...
my $tmpId = createId(); # Come up with a good temporary ID string
my $tmpFileName = createTempFileName($tmpId); # use $tmpId to create a temporary 
filename
open TMPFILE, ">$tmpFileName" or die "Can't open $tmpFileName: $!";
$cgi->save(*TMPFILE);
close TMPFILE;
print STDOUT $cgi->redirect("http://yourhost.com/cgi-bin/formhandler.pl?id=$tempId";);
# Note: Redirects are always GETs
exit;

formhandler.pl
--
my $cgi = new CGI;
my $tmpId = $cgi->param("id");
my $tmpFileName = createTempFileName($tmpId); # Reconstruct the temp filename
open TMPFILE, $tmpfile or die "Can't open $tmpFileName: $!";
my $savedCgi = CGI->new(*TMPFILE);
close TMPFILE;
...

Then formhandler will have the saved CGI information in $savedCgi.

(Taint-check the daylights out of the $id, to prevent someone from
giving an ID like "../../../../etc/passwd". Also, the ID needs to be
unique for a given access. And don't forget to clean up the temp file
when you're done.)

Yes, it seems weird. but I do this in some scripts, where it works quite
well.  (It's especially nice because my scripts want to send you your
choice of a .tar file or a .zip file, and in the redirect, I can edit
the location to be something like
"http://yourhost.com/cgi-bin/formhandler.pl/stuff.$packageType?id=$tempId";,
where $packageType is one of "tar", "tar.gz", or "zip".  Then in
formhandler.pl, the package type will be available as $ENV{PATH_INFO},
and the default name that pops up in the user's save-as box will be
stuff.tar, stuff.tar.gz, or stuff.zip- whichever they selected- instead
of "formhandler.pl". A nice little convenience for the user.)

-- tdk



Re: Fwd: 'use' question

2001-06-05 Thread Randal L. Schwartz

> "Bob" == Bob Mangold <[EMAIL PROTECTED]> writes:

Bob> !#/usr/local/bin/perl

If that's cut-n-pasted, it's wrong.  You want #! not #!

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



RE: Where can I learn how to use taint?

2001-06-05 Thread Peter Scott

At 01:14 PM 6/5/2001 -0700, Mark Ross wrote:
> >>This code:
> >>
> >>#!/usr/local/bin/perl -wT
> >>use strict;
> >>use CGI;
> >>my $q = new CGI;
> >>print ("hi");
> >>exit;
> >>
> >>produces this:
> >>"Too late for "-T" option at w:\cgi-bin\admin\tainttest.pl line 1."
> >
> >The problem is that -T needs to be enabled so early in the invocation
> >process that by the time a "perl foo.pl" command sees the shebang line,
> >it's too late to set it.  This also applies to the way .pl scripts are
> >invoked on DOSish systems through file type associations.
>Thanks to everyone who replied to all this so quickly. The server I use (not
>mine, web hosting service) is a Linux machine running Apache. I still get
>the error on same error on the server ... am I just SOL when it comes to
>taint checking or is there a way to smack the server around and make it do
>what it sounds like it should be doing?

See, if you post paths like w:\cgi-bin\admin\tainttest.pl then people are 
going to assume you're on DOS unless you say otherwise.  I don't see how 
you could have gotten that message from a Linux machine, so can you be 
explicit about exactly what is happening on the Linux box?  Taint checking 
works just fine on Linux and you don't have to do anything special.




Re: Fwd: 'use' question

2001-06-05 Thread John Fox

Verily, on Tuesday June  5, 2001, the Sainted Bob Mangold spake:
> ok sorry for the lack of a script before,
> 
> here is a little test script i wrote to try to figure out how to use the
> Getopt::Std module.
> 
> ---
> !#/usr/local/bin/perl
> 
> use Getopt::Std;
> 
> getopt("abc");
> 
> print "$opt_a - $opt_b - $opt_c\n";
> ---

You've transposed "#" and "!" in line 1.

HTH,

John
-- 
   John Fox <[EMAIL PROTECTED]>
System Administrator, InfoStructure, Ashland OR USA
  -
"What is loved endures.  And Babylon 5 ... Babylon 5 endures."
  --Delenn, "Rising Stars", Babylon 5



RE: Where can I learn how to use taint?

2001-06-05 Thread Mark Ross

>>This code:
>>
>>#!/usr/local/bin/perl -wT
>>use strict;
>>use CGI;
>>my $q = new CGI;
>>print ("hi");
>>exit;
>>
>>produces this:
>>"Too late for "-T" option at w:\cgi-bin\admin\tainttest.pl line 1."
>
>The problem is that -T needs to be enabled so early in the invocation
>process that by the time a "perl foo.pl" command sees the shebang line,
>it's too late to set it.  This also applies to the way .pl scripts are
>invoked on DOSish systems through file type associations.
>
>You can fix gthis by invoking it with "perl -T tainttest.pl"  I don't know
>how you'd reasonably do this with a file type association double click
>unless you defined a new type, say .tpl.
>
>This *shouldn't* apply to when a script is executed by a web server, as CGI
>scripts of course should be.  But maybe it does, on Windows; I'm just
>surprised I never heard of it before.  In which case the .tpl idea may be
>the only way to go (ouch).

Thanks to everyone who replied to all this so quickly. The server I use (not
mine, web hosting service) is a Linux machine running Apache. I still get
the error on same error on the server ... am I just SOL when it comes to
taint checking or is there a way to smack the server around and make it do
what it sounds like it should be doing?

--Mark.





Re: Where can I learn how to use taint?

2001-06-05 Thread Kevin Meltzer

On Tue, Jun 05, 2001 at 12:46:15PM -0700, Mark Ross ([EMAIL PROTECTED]) spew-ed forth:
> Hi all,
> 
> I'm very confused on how to use taint for my cgi scripts.

Hi Mark,

As well as some of the explinations you will get, also take a look at the
following documentation for more info on tainting:

perldoc perlsec
perldoc diagnostics # Which explains the error

Cheers,
Kevin

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
Scientology, how about that?  You hold on to the tin cans and then this guy
asks you a bunch of questions, and if you pay enough money you get to join  the
master race. How's that for a religion? -- Frank Zappa (Concert at the
Rockpile, Toronto, May 1969



Re: Where can I learn how to use taint?

2001-06-05 Thread Peter Scott

At 12:46 PM 6/5/2001 -0700, Mark Ross wrote:
>This code:
>
>#!/usr/local/bin/perl -wT
>use strict;
>use CGI;
>my $q = new CGI;
>print ("hi");
>exit;
>
>produces this:
>"Too late for "-T" option at w:\cgi-bin\admin\tainttest.pl line 1."

The problem is that -T needs to be enabled so early in the invocation 
process that by the time a "perl foo.pl" command sees the shebang line, 
it's too late to set it.  This also applies to the way .pl scripts are 
invoked on DOSish systems through file type associations.

You can fix gthis by invoking it with "perl -T tainttest.pl"  I don't know 
how you'd reasonably do this with a file type association double click 
unless you defined a new type, say .tpl.

This *shouldn't* apply to when a script is executed by a web server, as CGI 
scripts of course should be.  But maybe it does, on Windows; I'm just 
surprised I never heard of it before.  In which case the .tpl idea may be 
the only way to go (ouch).




Re: Fwd: 'use' question

2001-06-05 Thread Chas Owens

On 05 Jun 2001 15:47:40 -0400, Chas Owens wrote:
> On 05 Jun 2001 12:28:01 -0700, Bob Mangold wrote:
>  
> > so then at the command line I type:
> > perl test.pl -a help, -b me, -c please
> > 
> > i even tried:
> > perl test.pl -a help -b me -c please
> 
> 
> type "chmod u+x test.pl"
> then type "./test.pl"
> 
> The #!/usr/local/bin/perl tells the shell to launch perl for you
> 
> -- 
> Today is Sweetmorn, the 10th day of Confusion in the YOLD 3167
> Hail Eris!
> 

chmod u+x makes test.pl and executable file.  ./test.pl then runs it.
If you want to run one-liners type something like:

cat file | perl -e "while (<>) { print unless (/^\s*#/) }"

or the less verbose
cat file | perl -ne "print unless (/^\s*#/)"

see man perlrun or perldoc perlrun for more fun tricks

BTW: this one-liner prints all lines in file except comments 

-- 
Today is Sweetmorn, the 10th day of Confusion in the YOLD 3167
Hail Eris, Hack Linux!





Re: Fwd: 'use' question

2001-06-05 Thread M.W. Koskamp


- Original Message - 
From: Timothy Kimball <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 05, 2001 9:45 PM
Subject: Re: Fwd: 'use' question


> 
> M.W. Koskamp wrote:
> 
> : You are missing a semi-colon at the end of line 1
> : after the #!/usr/local/bin/perl
> 
> You don't need one there, because that line is not a perl command.
> It's a message to the shell that the script is to be interpreted
> by /usr/local/bin/perl.
> 
> The problem is that he write !# when he meant #!.
> 
Oops, seems i am not yet fully awake (and it is already evening here) :-)




Re: Where can I learn how to use taint?

2001-06-05 Thread Jeff 'japhy' Pinyan

On Jun 5, Mark Ross said:

>I'm very confused on how to use taint for my cgi scripts.
>
>"Too late for "-T" option at w:\cgi-bin\admin\tainttest.pl line 1."

The first place to find explanations for error messages is in the perldiag
documentation.  You can even embed an automatic look-up feature by
including:

  use diagnostics;

in your code.  Looking through the docs, we see:

 Too late for "-T" option
 (X) The #! line (or local equivalent) in a Perl script
 contains the -T option, but Perl was not invoked with -T
 in its command line.  This is an error because, by the
 time Perl discovers a -T in a script, it's too late to
 properly taint everything from the environment.  So Perl
 gives up.

 If the Perl script is being executed as a command using
 the #!  mechanism (or its local equivalent), this error
 can usually be fixed by editing the #! line so that the
 -T option is a part of Perl's first argument: e.g.
 change perl -n -T to perl -T -n.

   > If the Perl script is being executed as perl scriptname,
   > then the -T option must appear on the command line: perl
   > -T scriptname.

That last paragraph is of interest to you, I think.

As far as HOW tainting is used, it demands you check and validate any
outside information (environment variables, arguments, CGI query data,
etc.) before using it in a potentially harmful situation.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
Eruséro Marillion -- wielder of Ringril, known as Hesinaur, the Winter-Sun
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **




Re: Where can I learn how to use taint?

2001-06-05 Thread Paul


--- Mark Ross <[EMAIL PROTECTED]> wrote:
> #!/usr/local/bin/perl -wT
> use strict;
> use CGI;
> my $q = new CGI;
> print ("hi");
> exit;
> 
> produces this:
> 
> "Too late for "-T" option at w:\cgi-bin\admin\tainttest.pl line 1."

I wrote this to a file named x.
Running it with 
   perl x
got the same error.
Making it executable and running it did not.
Running it with 
   perl -T x
did not.

You're running perl without taint checking, then loading a script that
wants taint checking, so it dies. =o)

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Where can I learn how to use taint?

2001-06-05 Thread Mark Ross

Hi all,

I'm very confused on how to use taint for my cgi scripts.

This code:

#!/usr/local/bin/perl -wT

use strict;
use CGI;

my $q = new CGI;

print ("hi");

exit;


produces this:

"Too late for "-T" option at w:\cgi-bin\admin\tainttest.pl line 1."

Ummm ... I'm quite confused about this, since this code above chokes on line
one. :( BTW: I get the same error on my local Windows machine and my remote
Linux server.

I've looked in the Camel and other books, and I'm still stumped on how to
get past this.

Anyone know what I'm don't wrong or where I could read up on it? Heck, even
what I should be looking for in perldoc would be welcome.

Thanks,
--Mark.






Re: Fwd: 'use' question

2001-06-05 Thread Chas Owens

On 05 Jun 2001 12:28:01 -0700, Bob Mangold wrote:
 
> so then at the command line I type:
> perl test.pl -a help, -b me, -c please
> 
> i even tried:
> perl test.pl -a help -b me -c please


type "chmod u+x test.pl"
then type "./test.pl"

The #!/usr/local/bin/perl tells the shell to launch perl for you

-- 
Today is Sweetmorn, the 10th day of Confusion in the YOLD 3167
Hail Eris!





Re: Fwd: 'use' question

2001-06-05 Thread Timothy Kimball


M.W. Koskamp wrote:

: You are missing a semi-colon at the end of line 1
: after the #!/usr/local/bin/perl

You don't need one there, because that line is not a perl command.
It's a message to the shell that the script is to be interpreted
by /usr/local/bin/perl.

The problem is that he write !# when he meant #!.

-- tdk



Re: Fwd: 'use' question

2001-06-05 Thread Timothy Kimball


Bob Mangold wrote:
: !#/usr/local/bin/perl

Should be '#!', not '!#'.

-- tdk



Re: Fwd: 'use' question

2001-06-05 Thread daniels tashi robert


No, but seriously.  Put the # before the !
("she-bang" is, if nothing else, a good mnemonic)



On Tue, 5 Jun 2001, M.W. Koskamp wrote:

>
> - Original Message -
> From: Bob Mangold <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, June 05, 2001 9:28 PM
> Subject: Re: Fwd: 'use' question
>
>
> > ok sorry for the lack of a script before,
> >
> > here is a little test script i wrote to try to figure out how to use the
> > Getopt::Std module.
> >
> > ---
> > !#/usr/local/bin/perl
> >
> > use Getopt::Std;
> >
> > getopt("abc");
> >
> > print "$opt_a - $opt_b - $opt_c\n";
> > ---
> >
> You are missing a semi-colon at the end of line 1
> after the #!/usr/local/bin/perl
>




Re: Fwd: 'use' question

2001-06-05 Thread M.W. Koskamp


- Original Message - 
From: Bob Mangold <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 05, 2001 9:28 PM
Subject: Re: Fwd: 'use' question


> ok sorry for the lack of a script before,
> 
> here is a little test script i wrote to try to figure out how to use the
> Getopt::Std module.
> 
> ---
> !#/usr/local/bin/perl
> 
> use Getopt::Std;
> 
> getopt("abc");
> 
> print "$opt_a - $opt_b - $opt_c\n";
> ---
> 
You are missing a semi-colon at the end of line 1
after the #!/usr/local/bin/perl




Re: printf and other stuff

2001-06-05 Thread Rob Hanz

Michael Fowler wrote:
> On Tue, Jun 05, 2001 at 08:05:24AM -0400, Herb Hall wrote:
> > $min = "0" . $min if $min < 10;
> >
> > will pad your minutes with a 0. I have used both methods for various
> > reasons. You probably only need to use one or the other. I would use the
> > printf unless you have some need to have the variables padded with 0's.
>
> printf will happily pad with zeroes for you:
>
> printf("%03d\n", 4);
>
> outputs
>
> 004
>
> I see no real reason to use manual padding unless you're trying to be
> consistent in the code.

And even if you do need your variables to be padded, well, that's why
there's sprintf

$min = sprintf("%03d",$min);
print "$min\n";

outputs:

003




RE: problems following a refresh meta tag using LWP and open SSL (2ed request)

2001-06-05 Thread Hill, Ronald

[snipped]
> URL=https://mn1-gx6-ib.banking.wellsfargo.com/cgi-bin/session.
> cgi?sessargs=e
> 
> I think your answer is here.
> The refresh data is passed as headers.
> Just parse the URL field out of the header and do a new request.
> 
> Hope this is what you meant.
> 
> Maarten.

Hi Maarten,

Thanks for the reply, I have tried that using:

if ( my $refresh = $req->header("Refresh") ) {

( undef, $final_req ) = split ( /=/, $req->header("Refresh") );

$req =
  $ua->request( POST $final_req,
  { userid =>$ARGV[0], password =>$ARGV[1], 'Account Summary' =>
'ACCT_SUMMARY'  } 
  );
 
}

and I receive a web page that states: unable to process the request, what
should have been displayed is the account information. It seems that I am
unable to form a proper request. During the execution of the script I will
see many redirects. I have no idea what to respond with. 
However, If there was a way to have the useragent handle the refresh (
automatically do the refresh) then the request would be correct. 
Any Ideas?

thanks

Ron



Re: Fwd: 'use' question

2001-06-05 Thread Bob Mangold

ok sorry for the lack of a script before,

here is a little test script i wrote to try to figure out how to use the
Getopt::Std module.

---
!#/usr/local/bin/perl

use Getopt::Std;

getopt("abc");

print "$opt_a - $opt_b - $opt_c\n";
---

so then at the command line I type:
perl test.pl -a help, -b me, -c please

i even tried:
perl test.pl -a help -b me -c please

both times i get the error:
"use" not allowed in expression at test.pl line 3, at end of line
syntax error at test.pl line 3, near "use Getopt::Std"
Execution of test.pl aborted due to compilation errors.


i've tried including other modules, such as CGI or DBI, both of which are
included in numerous other scripts that run on my webserver (the same machine).
So what am I doing wrong here

-Bob



--- Chas Owens <[EMAIL PROTECTED]> wrote:
> Can you post an example script?
> 
> On 05 Jun 2001 12:03:03 -0700, Bob Mangold wrote:
> > Hello,
> > 
> > It seems that whenever I attempt to use the 'use' command, I get an error.
> The
> > error says '"use" not allowed in expression at..'. Funny thing is that
> I
> > have CGI scripts that execute just fine from the command-line. I've tried
> > creating just very simple programs and I always get the error. I'm not sure
> > what to do.
> > 
> > I'm using perl 5.6.0 on a Solaris 8 machine.
> > 
> > Thanks,
> > Bob
> > 
> > 
> > 
> > __
> > Do You Yahoo!?
> > Get personalized email addresses from Yahoo! Mail - only $35 
> > a year!  http://personal.mail.yahoo.com/
> 
> -- 
> Today is Sweetmorn, the 10th day of Confusion in the YOLD 3167
> Kallisti!
> 
> 


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



[ADMIN] Thread is closed! (Re: [meta] Re: help!)

2001-06-05 Thread Kevin Meltzer

Ok folks, that's enough. Please take personal attacks, personality conflicts,
and things of such nature into personal email. This is no longer a useful
discussion for beginners, or anyone else. This thread is closed.

Cheers,
Kevin

> On 5 Jun 2001, Randal L. Schwartz wrote:
> 
> > > "Chuck" == Chuck Ivy <[EMAIL PROTECTED]> writes:
> >
> > Chuck> Randal, no offence meant, but I was under the impression that the
> > Chuck> purpose of this list was to answer questions, and not say tell new
> > Chuck> users to RTFM.
> >
> > Please point to where I've RTFM'ed someone here, except when the
> > question was specifically "where do I read about X?".  In fact, for
> > that matter, let's also point out the (lack of) places I do that on
> > PerlMonks and comp.lang.perl.m*.  So, what are you actually saying
> > here?  Or are you confusing me with your image of "evil expert
> > answerers" which I have not earned?
> >
> > Chuck> I admit, I was disappointed to see you active in this forum,
> > Chuck> because your answers to beginner questions on PerlMonks are the
> > Chuck> type that this list was supposed to be avoiding.
> >
> > Again, are you confusing me with someone else?  I know about once
> > every six weeks or so my life appears to me to have gone to hell, and
> > I spend about a day ranting until I get it burned off.  Do those few
> > days every six weeks so overshadow the other days in the cycle that
> > you can't see the forest for the trees?
> >
> > Chuck> I respect that you know an awful lot about Perl. That's fine
> > Chuck> and good. This forum is for people who don't have your
> > Chuck> expertise, and sometimes when they're looking for an answer to
> > Chuck> a question -- they'd really like to hear an answer to their
> > Chuck> question and not "you don't want to do that -- read this web
> > Chuck> page."
> >
> > And in what way have I done that?  Please point to specifics.
> >
> > There's a great node at PerlMonks, where someone who had carried a
> > grudge about the way I answer things actually went back and looked at
> > what he thought were my horrible answers and behaviors.  And much to
> > his surprise, he was working off some old and inappropriate data, and
> > apologized for that.  Now I'm not expecting the same from you, but is
> > it possible you are lumping *me* in with those people you hate to have
> > around as answerers?  If so, can you please step back and rexamine
> > what you're saying?
> >
> > (See the thread beginning at
> >  for details.)
> >
> > I don't mind being properly shunned, but let's really look at the
> > facts here, and if the facts point out to deconstructive behavior,
> > then RUB MY NOSE in it... don't just handwave.  I'm interested in
> > changing, and looking for feedback to do so.  If you think I'm
> > answering something here inappropriately, HIT THE FRIGGIN REPLY BUTTON
> > on the message, and tell me why it strikes you wrong.  I WILL LISTEN.
> >
> > And I bet you hit that REPLY button far less than your theory about me
> > says you should. :)
> >
> > --
> > Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> > <[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
> > Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> > See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
> >
> 

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
"I know the human being and fish can coexist peacefully."
-- G.W. Bush, Saginaw, MI 09/29/2000



Re: [meta] Re: help!

2001-06-05 Thread Paul

--- "Randal L. Schwartz" <[EMAIL PROTECTED]> wrote:

> I don't mind being properly shunned, but let's really look at the
> facts here, and if the facts point out to deconstructive behavior,
> then RUB MY NOSE in it... don't just handwave.  I'm interested in
> changing, and looking for feedback to do so.  If you think I'm
> answering something here inappropriately, HIT THE FRIGGIN REPLY
> BUTTON on the message, and tell me why it strikes you wrong. 
> I WILL LISTEN.



  You came off as a little short with Chris over the homework thing,
though I'd wager there're several who'll more careful about it next
time, and you have posted things a little deep for this list, such as
the awesomely cool number checking sub I so stumblingly tried to
elaborate for the audience.

  But personally, I love to see your name pop up on the list. Even when
you occasionally sound testy, you tend to offer pithy comments, or
droll humor, or (most consistently) beautiful code fragments from which
to learn more about the language.

  I wouldn't try to teach my grandma to suck eggs, and I'll probably
still follow your posts like a puppy looking for scraps, >:o]  but I
would like to see you soften up a bit on the fledgelings, lol

  Still, I'd remind them that if they can't take posted text with
minimal emotional clues and read it with a grain of salt, they'll live
with hurt feelings. I've caught myself inadvertently sticking my foot
in my mouth often enough, but I trust folk will shrug it off as
carelessness or just bad phrasing.



Paul

PS:
   lol -- I still get a tiny bit of celebrity thrill every time I
correspond with you, ~chuckle~. On that note, though, remember that
you're a semi-idol in the Perl community.
   I don't envy you THAT! :o)
   PH

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Re: Fwd: 'use' question

2001-06-05 Thread Brett W. McCoy

On Tue, 5 Jun 2001, Bob Mangold wrote:

> It seems that whenever I attempt to use the 'use' command, I get an error. The
> error says '"use" not allowed in expression at..'. Funny thing is that I
> have CGI scripts that execute just fine from the command-line. I've tried
> creating just very simple programs and I always get the error. I'm not sure
> what to do.

Why don't you show us the code you are having trouble with?

-- Brett

Brett W. McCoy
Software Engineer
Broadsoft, Inc.
240-364-5225
[EMAIL PROTECTED]




Re: Fwd: 'use' question

2001-06-05 Thread Chas Owens

Can you post an example script?

On 05 Jun 2001 12:03:03 -0700, Bob Mangold wrote:
> Hello,
> 
> It seems that whenever I attempt to use the 'use' command, I get an error. The
> error says '"use" not allowed in expression at..'. Funny thing is that I
> have CGI scripts that execute just fine from the command-line. I've tried
> creating just very simple programs and I always get the error. I'm not sure
> what to do.
> 
> I'm using perl 5.6.0 on a Solaris 8 machine.
> 
> Thanks,
> Bob
> 
> 
> 
> __
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail - only $35 
> a year!  http://personal.mail.yahoo.com/

-- 
Today is Sweetmorn, the 10th day of Confusion in the YOLD 3167
Kallisti!





Re: problems following a refresh meta tag using LWP and open SSL (2ed request)

2001-06-05 Thread M.W. Koskamp


- Original Message -
From: Hill, Ronald <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 05, 2001 7:07 PM
Subject: problems following a refresh meta tag using LWP and open SSL (2ed
request)


> Hello All,
>
> I am trying to connect to the Wells Fargo online bank using the LWP and
open
> SSL modules and am having trouble getting past the  Authenticating User
> screen. I was hopeing for a way to have the LWP useragent  follow  the
> refreash meta tag the same way it does for a redirect. Does anyone know of
a
> way to accomplish this? Can anyone help me with this?
>
> Thanks
>
> Ron
(...)
> HTTP/1.1 200 OK
> Date: Fri, 01 Jun 2001 13:52:48 GMT
> Pragma: no-cache
> Server: Netscape-Enterprise/3.6 SP2
(...)

> Refresh: 1;
>
URL=https://mn1-gx6-ib.banking.wellsfargo.com/cgi-bin/session.cgi?sessargs=e

I think your answer is here.
The refresh data is passed as headers.
Just parse the URL field out of the header and do a new request.

Hope this is what you meant.

Maarten.

(...)




Fwd: 'use' question

2001-06-05 Thread Bob Mangold

Hello,

It seems that whenever I attempt to use the 'use' command, I get an error. The
error says '"use" not allowed in expression at..'. Funny thing is that I
have CGI scripts that execute just fine from the command-line. I've tried
creating just very simple programs and I always get the error. I'm not sure
what to do.

I'm using perl 5.6.0 on a Solaris 8 machine.

Thanks,
Bob



__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Re: [meta] Re: help!

2001-06-05 Thread kevin

I got a good Idea, lets fight about somthing that does not matter in the
least bit. stop spamming up the list with your little bitch fight.



On 5 Jun 2001, Randal L. Schwartz wrote:

> > "Chuck" == Chuck Ivy <[EMAIL PROTECTED]> writes:
>
> Chuck> Randal, no offence meant, but I was under the impression that the
> Chuck> purpose of this list was to answer questions, and not say tell new
> Chuck> users to RTFM.
>
> Please point to where I've RTFM'ed someone here, except when the
> question was specifically "where do I read about X?".  In fact, for
> that matter, let's also point out the (lack of) places I do that on
> PerlMonks and comp.lang.perl.m*.  So, what are you actually saying
> here?  Or are you confusing me with your image of "evil expert
> answerers" which I have not earned?
>
> Chuck> I admit, I was disappointed to see you active in this forum,
> Chuck> because your answers to beginner questions on PerlMonks are the
> Chuck> type that this list was supposed to be avoiding.
>
> Again, are you confusing me with someone else?  I know about once
> every six weeks or so my life appears to me to have gone to hell, and
> I spend about a day ranting until I get it burned off.  Do those few
> days every six weeks so overshadow the other days in the cycle that
> you can't see the forest for the trees?
>
> Chuck> I respect that you know an awful lot about Perl. That's fine
> Chuck> and good. This forum is for people who don't have your
> Chuck> expertise, and sometimes when they're looking for an answer to
> Chuck> a question -- they'd really like to hear an answer to their
> Chuck> question and not "you don't want to do that -- read this web
> Chuck> page."
>
> And in what way have I done that?  Please point to specifics.
>
> There's a great node at PerlMonks, where someone who had carried a
> grudge about the way I answer things actually went back and looked at
> what he thought were my horrible answers and behaviors.  And much to
> his surprise, he was working off some old and inappropriate data, and
> apologized for that.  Now I'm not expecting the same from you, but is
> it possible you are lumping *me* in with those people you hate to have
> around as answerers?  If so, can you please step back and rexamine
> what you're saying?
>
> (See the thread beginning at
>  for details.)
>
> I don't mind being properly shunned, but let's really look at the
> facts here, and if the facts point out to deconstructive behavior,
> then RUB MY NOSE in it... don't just handwave.  I'm interested in
> changing, and looking for feedback to do so.  If you think I'm
> answering something here inappropriately, HIT THE FRIGGIN REPLY BUTTON
> on the message, and tell me why it strikes you wrong.  I WILL LISTEN.
>
> And I bet you hit that REPLY button far less than your theory about me
> says you should. :)
>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> <[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
>




[meta] Re: help!

2001-06-05 Thread Randal L. Schwartz

> "Chuck" == Chuck Ivy <[EMAIL PROTECTED]> writes:

Chuck> Randal, no offence meant, but I was under the impression that the
Chuck> purpose of this list was to answer questions, and not say tell new
Chuck> users to RTFM.

Please point to where I've RTFM'ed someone here, except when the
question was specifically "where do I read about X?".  In fact, for
that matter, let's also point out the (lack of) places I do that on
PerlMonks and comp.lang.perl.m*.  So, what are you actually saying
here?  Or are you confusing me with your image of "evil expert
answerers" which I have not earned?

Chuck> I admit, I was disappointed to see you active in this forum,
Chuck> because your answers to beginner questions on PerlMonks are the
Chuck> type that this list was supposed to be avoiding.

Again, are you confusing me with someone else?  I know about once
every six weeks or so my life appears to me to have gone to hell, and
I spend about a day ranting until I get it burned off.  Do those few
days every six weeks so overshadow the other days in the cycle that
you can't see the forest for the trees?

Chuck> I respect that you know an awful lot about Perl. That's fine
Chuck> and good. This forum is for people who don't have your
Chuck> expertise, and sometimes when they're looking for an answer to
Chuck> a question -- they'd really like to hear an answer to their
Chuck> question and not "you don't want to do that -- read this web
Chuck> page."

And in what way have I done that?  Please point to specifics.

There's a great node at PerlMonks, where someone who had carried a
grudge about the way I answer things actually went back and looked at
what he thought were my horrible answers and behaviors.  And much to
his surprise, he was working off some old and inappropriate data, and
apologized for that.  Now I'm not expecting the same from you, but is
it possible you are lumping *me* in with those people you hate to have
around as answerers?  If so, can you please step back and rexamine
what you're saying?

(See the thread beginning at
 for details.)

I don't mind being properly shunned, but let's really look at the
facts here, and if the facts point out to deconstructive behavior,
then RUB MY NOSE in it... don't just handwave.  I'm interested in
changing, and looking for feedback to do so.  If you think I'm
answering something here inappropriately, HIT THE FRIGGIN REPLY BUTTON
on the message, and tell me why it strikes you wrong.  I WILL LISTEN.

And I bet you hit that REPLY button far less than your theory about me
says you should. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: [OT] style (was:while loop seems to loop through file more than once.)

2001-06-05 Thread Paul


--- Michael Fowler <[EMAIL PROTECTED]> wrote:
> On Tue, Jun 05, 2001 at 10:42:33AM -0700, Paul wrote:
> > If you use "or" instead of "||" you can reduce the "line noise" by
> > taking out the parens.
> > 
> >open(FILE, $filename) 
> >|| die("Unable to open file \"$filename\": \l$!.\n");
> > 
> > becomes
> > 
> >open FILE, $filename 
> > or die "Unable to open file \"$filename\": \l$!.\n";
> 
> Personally, I prefer the "noisy" version, though I consider it
> anything but noisy.  Perhaps it's because 'or' came sometime after I
> learned Perl, but mostly it's because it serves to delineate what's
> what.  This may be an artifact of my C experience, or my penchant to
> use parens in order to give visual seperation from one function call
> to another.

One man's trash is another man's treasure. =o)
In this case, I don't really think it matters much.
It's more important to be comfortable with it that to stress over a few
characters that don't change the operation of the program when taken
together. ;o]
 
> TIMTOWTDI

lol -*AB*-so-lute-ly. >:o)
That's like, I personally *prefer* cuddled else's
  } else {
instead of
  }
  else
  }

To me, it looks cleaner, though Larry doesn't like it.
Mostly, I figure it's just better to be consistent, so the next guy to
read your code knows what to expect! :o)

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Re: while loop seems to loop through file more than once.

2001-06-05 Thread Michael Fowler

On Tue, Jun 05, 2001 at 10:42:33AM -0700, Paul wrote:
> If you use "or" instead of "||" you can reduce the "line noise" by
> taking out the parens.
> 
>open(FILE, $filename) 
>|| die("Unable to open file \"$filename\": \l$!.\n");
> 
> becomes
> 
>open FILE, $filename 
> or die "Unable to open file \"$filename\": \l$!.\n";

Personally, I prefer the "noisy" version, though I consider it anything but
noisy.  Perhaps it's because 'or' came sometime after I learned Perl, but
mostly it's because it serves to delineate what's what.  This may be an
artifact of my C experience, or my penchant to use parens in order to give
visual seperation from one function call to another.

TIMTOWTDI


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--



Re: help!

2001-06-05 Thread Chuck Ivy

On Tuesday, June 5, 2001, at 07:37 AM, Randal L. Schwartz wrote:

> That's why I bring it up as a meta-topic.  We've had
> to deal with the same thing on perlmonks.org

Randal, no offence meant, but I was under the impression that the 
purpose of this list was to answer questions, and not say tell new users 
to RTFM.

I admit, I was disappointed to see you active in this forum, because 
your answers to beginner questions on PerlMonks are the type that this 
list was supposed to be avoiding.

I respect that you know an awful lot about Perl. That's fine and good. 
This forum is for people who don't have your expertise, and sometimes 
when they're looking for an answer to a question -- they'd really like 
to hear an answer to their question and not "you don't want to do 
that -- read this web page."




Re: testing null strings for form field values

2001-06-05 Thread Michael Fowler

On Tue, Jun 05, 2001 at 02:09:30PM +0200, Marcelo E. Magallon wrote:
>  Perhaps also noteworthy is the fact that things like '$foo{bar} eq ""'
>  make the key 'bar' spring into existance in %foo.  -w tells you about
>  it.

The 'bar' key doesn't spring into existence, and -w doesn't tell you about
it.  You can test it with:

> perl -wle 'print "yes" if $foo{"bar"} eq ""; print "foo: ", keys(%foo);'
Use of uninitialized value in string eq at -e line 1.
yes
foo:


Autovivication (the springing into existence of keys or indices) only
happens when you're accessing a complex data structure.

For example:

print $foo{'bar'}[0]

Assuming %foo had nothing in it to begin with, the 'bar' key was created,
with an anonymous array as its value.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--



Re: while loop seems to loop through file more than once.

2001-06-05 Thread Paul


--- Michael Fowler <[EMAIL PROTECTED]> wrote:
> On Mon, Jun 04, 2001 at 11:40:46PM -0500, [EMAIL PROTECTED]
> wrote:
> >   open(FILE, "$filename");
> 
> Always check your open calls.  For example:
> open(FILE, $filename) || die("Unable to open file \"$filename\":
> \l$!.\n");

If you use "or" instead of "||" you can reduce the "line noise" by
taking out the parens.

   open(FILE, $filename) 
   || die("Unable to open file \"$filename\": \l$!.\n");

becomes

   open FILE, $filename 
or die "Unable to open file \"$filename\": \l$!.\n";


> You should move your open(NEWFILE, ...) call outside of the while
> loop, and thus reduce the number of open calls made.

*Absolutely.*



__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Re: printf and other stuff

2001-06-05 Thread Michael Fowler

On Tue, Jun 05, 2001 at 08:05:24AM -0400, Herb Hall wrote:
> $min = "0" . $min if $min < 10;
> 
> will pad your minutes with a 0. I have used both methods for various
> reasons. You probably only need to use one or the other. I would use the
> printf unless you have some need to have the variables padded with 0's.

printf will happily pad with zeroes for you:

printf("%03d\n", 4);

outputs
   
004

I see no real reason to use manual padding unless you're trying to be
consistent in the code.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--



Re: while loop seems to loop through file more than once.

2001-06-05 Thread Michael Fowler

On Mon, Jun 04, 2001 at 11:40:46PM -0500, [EMAIL PROTECTED] wrote:
> } elsif ( $remtag == "1" ) {
>   $remove_email = $formdata{rem_name};
>   open(FILE, "$filename");

Always check your open calls.  For example:
open(FILE, $filename) || die("Unable to open file \"$filename\": \l$!.\n");

or perhaps, if you're in a loop:
unless (open(FILE, $filename)) {
warn("...");
next;
}


>   while () {
> @fields = split(/\@/, $_);
> if ( $fields[0] ne $remove_email ) {
>   open(NEWFILE, ">>$tmpfile");

Another open to check.


> print NEWFILE "$_";
>   close(NEWFILE)
> }
>   }
>   close(FILE);
> }


You should move your open(NEWFILE, ...) call outside of the while loop, and
thus reduce the number of open calls made.

open(NEWFILE, ">>$tmpfile") || die("...");

while () {
...

if (...) {
...
print NEWFILE $_;
}
}

close(NEWFILE);
close(FILE);

Odds are that at least one line from $filename will not match, so the open
isn't wasted.



> the file loops through a couple times causing multiples of lines from
> $filename to be written to $tmpfile. can someone point out my error?

As it stands, your code runs fine.  When I run it I get a temp file
consisting of the lines I expect, with no duplicates.  Perhaps the problem
lies in your data, or in some portion of the code outside of the one you
gave us.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--



problems following a refresh meta tag using LWP and open SSL (2ed request)

2001-06-05 Thread Hill, Ronald

Hello All,

I am trying to connect to the Wells Fargo online bank using the LWP and open
SSL modules and am having trouble getting past the  Authenticating User
screen. I was hopeing for a way to have the LWP useragent  follow  the
refreash meta tag the same way it does for a redirect. Does anyone know of a
way to accomplish this? Can anyone help me with this?

Thanks

Ron

here is the script:
 #!/usr/bin/perl -w
use HTTP::Request::Common;
use HTML::Form;
use LWP::UserAgent;
use HTTP::Response;
#use LWP::Debug qw(+);
BEGIN {
local $^W = 0;
*LWP::UserAgent::redirect_ok = sub {1}
}
use HTTP::Cookies;
use strict;

my $ua = LWP::UserAgent->new;

$ua->cookie_jar(
  HTTP::Cookies->new(
autosave => 1 )
);
my $savefile = 'c:/temp/checkingpage.txt';
$ua->agent('Mozilla/4.73');

my $req  = $ua->request( POST 'https://banking.wellsfargo.com' );
my $form = HTML::Form->parse( $req->content, $req->base());
$form->value( 'userid',   "$ARGV[0]" );
$form->value( 'password', "$ARGV[1]" );

$req = $ua->request( $form->click('Account Summary') );

print $req->as_string;

here is the output of the script:

HTTP/1.1 200 OK
Date: Fri, 01 Jun 2001 13:52:48 GMT
Pragma: no-cache
Server: Netscape-Enterprise/3.6 SP2
Content-Type: text/html
Expires: Mon, 01 Jan 1990 00:00:00 GMT
Client-Date: Fri, 01 Jun 2001 13:54:17 GMT
Client-Peer: 159.37.31.144:443
Client-SSL-Cert-Issuer: /O=VeriSign Trust Network/OU=VeriSign,
Inc./OU=VeriSign International Server CA - Class 3/OU=www
.verisign.com/CPS Incorp.by Ref. LIABILITY LTD.(c)97 VeriSign
Client-SSL-Cert-Subject: /C=US/ST=California/L=San Francisco/O=Wells Fargo
and Company/OU=ISG/CN=mn1-gx6-ib.banking.well
sfargo.com
Client-SSL-Cipher: RC4-MD5
Client-SSL-Warning: Peer certificate not verified
Refresh: 1;
URL=https://mn1-gx6-ib.banking.wellsfargo.com/cgi-bin/session.cgi?sessargs=e
352150ca8c828ab136853e921c6cb9cf
84ede2a096bdeaa435e2fc9a99168d2
Title: Authenticating User




 Authenticating User 

[snipped]



Re: A gentle reminder about jeopardy quoting

2001-06-05 Thread Brett W. McCoy

On Tue, 5 Jun 2001, Mark Folse wrote:

> If there was a welcome to the list e-mail other than the bot
> instructions, I don't remember it and didn't save it like I usually do
> listadmin stuff. Perhaps a gentle introduction to the list to new
> subscribers would be sufficient, with off-line/direct mail nudging of
> folks (so we dont' clutter up the list like I'm doing now) with
> meta-matter.

The FAQ is posted every week, I believe, and is also available online at
http://learn.perl.org.

-- Brett

Brett W. McCoy
Software Engineer
Broadsoft, Inc.
240-364-5225
[EMAIL PROTECTED]




Re: testing null strings for form field values

2001-06-05 Thread Hasanuddin Tamir

On Tue, 5 Jun 2001, Marcelo E. Magallon <[EMAIL PROTECTED]> wrote,

>  Perhaps also noteworthy is the fact that things like '$foo{bar} eq ""'
>  make the key 'bar' spring into existance in %foo.  -w tells you about
>  it.

You mean $foo{bar}{baz} eq "".

perl -wle 'my %foo; if ($foo{bar} eq "")
   {print exists $foo{bar} ? 1 : 0}'
Use of uninitialized value at -e line 1.
0

perl -wle 'my %foo; if ($foo{bar}{baz} eq "")
   {print exists $foo{bar} ? 1 : 0}'
Use of uninitialized value at -e line 1.
1


>From the article (by Uri Guttman) in,

http://tlc.perlarchive.com/articles/perl/ug0002.shtml

"...autovivification happens when Perl automatically create
 a reference of the appropriate type when an undefined scalar
 value is dereferenced."

I've been using it a lot of times without realizing it.  I just learned
it myself.


s.a.n
-- 
Hasanuddin Tamir: [EMAIL PROTECTED] - Trabas: www.trabas.com




Re: Thank You - Re: Probably a "no-brainer" - the last twomessages.

2001-06-05 Thread Timothy Kimball


Gary Luther wrote:

: I am off applying salve to my wounds. It was careless of me to over look that .
: 
: Thanks to the list. Sorry, to take eveyones time for so trivial of an item.

You might be surprised be surprised at how many of these kinds of
errors I make on a regular basis (for me, two this morning).  The only
reason I don't spend four days tracking them down is that I've seen
most of them before, so now it only takes me three. ;)

Never ever apologize for trying.

Cheers -- tdk



Re: problem saving binary data

2001-06-05 Thread Carl Rogers

At 11:38 AM 6/5/2001 -0500, Jeff Davis wrote:
>I'm using LWP to fetch an image and attempting to save it locally.
>The file is successfully created, however all it contains is:
>
>HTTP::Response=HASH(0x8380464)
>
>
>Here's the code snippet:
>
>  $file = "/home/images/$name";
>  open(IMAGE, ">$file") || die "unable to open filehandle $file \n";

binmode(IMAGE); #works with text, maybe it will work with images as 
well??

>  $saveres = $ua->request(HTTP::Request->new(GET => $pic));
>  print IMAGE "$saveres";
>

Not ever having used images, I'd be interested in knowing if this works. 
Hopefully it does.
Take care.




RE: problem saving binary data

2001-06-05 Thread Hill, Ronald

[snipped]
> Here's the code snippet: 
> 
>  $file = "/home/images/$name";
>  open(IMAGE, ">$file") || die "unable to open filehandle $file \n";
>  $saveres = $ua->request(HTTP::Request->new(GET => $pic));
>  print IMAGE "$saveres";
> 
Hello,

You need to specify a filename as an arg 
$ua->simple_request($request, [$arg [, $size]])

This method dispatches a single WWW request on behalf of a user, and returns
the response received. The $request should be a reference to a HTTP::Request
object with values defined for at least the method() and uri() attributes. 
If $arg is a scalar it is taken as a filename where the content of the
response is stored.

So;
$saveres = $ua->request(HTTP::Request->new(GET => $pic), $filename);

should do the trick

Ron



Re: A gentle reminder about jeopardy quoting

2001-06-05 Thread Mark Folse

But we should be encouraging the list members to avail themselves of
the Perl FAQ and all the other resources at their disposal. I know I
always want to exhaust as many other avenues as possible before
admitting to thousands of stranges that I can't figure it out. But
that's just me.

Many of us learned our on-line etiquette the hard way, in less gentle
forms at a time when the Internet was first catching fire in the 90s.
(Remember when AOL.COM = flamebait?). 

If there was a welcome to the list e-mail other than the bot
instructions, I don't remember it and didn't save it like I usually do
listadmin stuff. Perhaps a gentle introduction to the list to new
subscribers would be sufficient, with off-line/direct mail nudging of
folks (so we dont' clutter up the list like I'm doing now) with
meta-matter.

--- Elaine -HFB- Ashton <[EMAIL PROTECTED]> wrote:

> *>I think gentle etiquette reminders are fine, if they don't begin to
> bog
> *>down the list. Perhaps a short list etiquette mailing once a week
> or so
> *>for new users, similar to FAQ postings, would be in order.
> 
> Not a bad idea but I don't much like rules since people like to go
> out of
> their way to break them and seemingly FAQs are the last thing people
> read
> :)
> 
> e.


=

-
Notice: This e-mail is protected by the U.S. Constitution and the U.N. Declaration of 
Human Rights. Unauthorized interception by any public or private agency is an ugly 
sort of work to be in. Does your mother know you spend your days reading other 
people's mail? Would she be proud of you?

-
Please visit: http://clubs.yahoo.com/clubs/district41democrats

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Re: problem saving binary data

2001-06-05 Thread Timothy Kimball


Jeff Davis wrote:
: I'm using LWP to fetch an image and attempting to save it locally.
: The file is successfully created, however all it contains is:
: 
: HTTP::Response=HASH(0x8380464)
: 
: Here's the code snippet: 
: 
:  $file = "/home/images/$name";
:  open(IMAGE, ">$file") || die "unable to open filehandle $file \n";
:  $saveres = $ua->request(HTTP::Request->new(GET => $pic));
:  print IMAGE "$saveres";

$ua->request returns an HTTP::Response object. You can get to its
content through the content() method:

$saveres = $ua->request(HTTP::Request->new(GET => $pic))->content();

or more readably,

$response = $ua->request(HTTP::Request->new(GET => $pic));
$saveres = $response->content();

That makes it easy to check whether the request succeeded:

if ( $response->is_success() ) {
$saveres = $response->content();
} else {
# handle the error...
}

Do "perldoc HTTP::Response" for more info.

-- tdk



Thank You - Re: Probably a "no-brainer" - the last twomessages.

2001-06-05 Thread Gary Luther



I am off applying salve to my wounds. It was careless of me to 
over look that .
 
Thanks to the list. Sorry, to take eveyones time for so 
trivial of an item.
 
---"They 
that can give up essential liberty    to obtain a little temporary 
safety    deserve neither liberty  nor 
safety."  

 
-- Benjamin Franklin 
-R    
Gary LutherRR  
RR   
SAFRR  RR UTABEGAS  2500 BroadwayRR 
RR    
Helena, MT 
59602 
[EMAIL PROTECTED]RR RR  ULE 
!!    RR  
RR   
Visit our website atRR   
RR  
http://www.safmt.org

BEGIN:VCARD
VERSION:2.1
X-GWTYPE:USER
FN:Gary Luther
TEL;WORK:0631
ORG:;Computer Center
TEL;PREF;FAX:(406) 444-0684
EMAIL;WORK;PREF;NGW:[EMAIL PROTECTED]
N:Luther;Gary
TITLE:Systems Administrator
END:VCARD




RE: Mysql interface with perl on win 2k, Someone please help !

2001-06-05 Thread Michael Risser

The best resource I have found is the O'Reilly book "Programming the Perl
DBI".

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, November 02, 1997 10:18 AM
> To: [EMAIL PROTECTED]
> Subject: Mysql interface with perl on win 2k, Someone please help !
> 
> 
> 
> >
> >Hi,
> >
> >Im trying to connect a perl program to a mysql database on 
> my home computer
> >running win 2k.  I can connect, but i have no idea of how to 
> extract the
> >information out of tables using perl. I have a book about 
> SQL, but it never
> >mentions programming or perl. If anyone could point me to a 
> good tutorial,
> >or give me a few pointers I would be greatly appreciative.
> >
> >
> >Thanks
> >
> >Jonathan Macpherson
> 



problem saving binary data

2001-06-05 Thread Jeff Davis

I'm using LWP to fetch an image and attempting to save it locally.
The file is successfully created, however all it contains is:

HTTP::Response=HASH(0x8380464)


Here's the code snippet: 

 $file = "/home/images/$name";
 open(IMAGE, ">$file") || die "unable to open filehandle $file \n";
 $saveres = $ua->request(HTTP::Request->new(GET => $pic));
 print IMAGE "$saveres";


 
Can someone point me in the right direction to fixing this?
Thanks!



Re: Probably a "no-brainer" - the last two messages.

2001-06-05 Thread Rachel Coleman

On Tue, 5 Jun 2001, Gary Luther wrote:

> MESSAGES:
>
> Useless use of string in void context at /common/bin/whaduname.AA line 56.
> Useless use of string in void context at /common/bin/whaduname.AA line 60.
>
> The lines and supporting evidence:
>
> 33 $cdate='/common/lib/cdatetest';
>
> 35 $cnum='/common/lib/cnumtest';
>
>
>  56open(CD, ">$cdate") || "Can't open $cdate: $!";
>  60open(CN, ">$cnum") || "Can't open $cnum: $!";

You need to do something with the "Can't open  " strings, e.g.
insert 'print' or 'die' before them.  You aren't putting the strings to
any use, therefore they are 'useless'.  Does that make sense?

Best wishes,

Rachel Coleman





RE: A gentle reminder about jeopardy quoting

2001-06-05 Thread rachel

On Tue, 5 Jun 2001, Eduard Grinvald wrote:

> Umm, let's get back to perl, please... Etiquette is nice, but is hardly the
> point of this list.

However, good etiquette makes it easier to get at 'the point' of this
list, i.e. the helpful content.  Why did you feel it necessary to ignore
the politely-phrased request when composing your own reply?  Perhaps you
should read the web page mentioned (which I will repeat here):
http://www.xs4all.nl/~wijnands/nnq/nquote.html

Best wishes,

Rachel








Re: Substring retrieval

2001-06-05 Thread Carl Rogers

Good day;
At 08:17 AM 6/5/2001 -0700, Paul wrote:

>--- Nathaniel Mallet <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I'm trying to retrieve a substring from a string, but I'm not
> > sure exactly where and how big that substring is. The substring is
> > delimited by a start and end special character.
>
> > I thought finding the location of the start and end special
> > characters, then calling substr().
> >
> > And so I have to questions:
> > 1 - How would I find the index for a particular character in a
> > string?

To find the start character use index () i.e.:
$startindex = index ($string, "start_character");

There are two ways you can find your end character. You can continue 
index() i.e.:
$endindex = index ($string, "end_character", $startindex +1);   # the "+1" 
ensures index won't catch your start character (if they happen
 # 
to be the same character) by accident

or use rindex, which works right to left on your string i.e.
$endindex = rindex ($string, "end_character");

Then to get your substring, use substr() i.e.:

$newline = substr($string, $startindex, ($endindex - $startindex) -1);  # 
in essence, this says take the portion of $string beginning at position 
$startindex 
# and go ($endindex-$startindex) characters. The -1 makes sure everything 
is# 
captured you want in your substring. I sometimes have to play around with the
 # 
+/- 1 in my start and end indexes to get the substring exact, but it should 
work
 # 
with the length calculation here.

Hope this helps.




Re: Problems using hash.

2001-06-05 Thread Ren Maddox

On Tue, 5 Jun 2001, [EMAIL PROTECTED] wrote:

> Your problem seems to be in the use of single quotes see my example
> code:
> 
> $fields[3]="x";
> $postInputs{'x'}= "the_test";
> 
> print "('$postInputs{ '$fields[3]'}')";
> print "(\'$postInputs{ $fields[3]}\')";
> 
> 
> try that.

or just:

print "('$postInputs{ $fields[3]}')";

In other words, what the OP was originally doing with "('name')" is
exactly the same thing that he needs to do with a variable.

> You don't need the inner set of single quotes, and the outer set
> must be escaped.

Single quotes do not need to be escaped inside double quotes.

-- 
Ren Maddox
[EMAIL PROTECTED]



Re: A gentle reminder about jeopardy quoting

2001-06-05 Thread Elaine -HFB- Ashton

Mark Folse [[EMAIL PROTECTED]] quoth:
*>--- Eduard Grinvald <[EMAIL PROTECTED]> wrote:
*>> Umm, let's get back to perl, please... Etiquette is nice, but is
*>> hardly the point of this list.

Perhaps not, but making email easy to read and reply to is certainly a good
goal to have. Lotus and MS and other MUAs don't come configured to wrap or
quote properly for easy reading outside of that client so it is helpful to
point this out to those who may not be aware of it. The easier your email
is to read, the more likely it will get a reply and/or an answer.

In large groups of people etiquette is essential for keeping some
semblance of civility. With several hundred email a day, good email
etiquette is essential to helping people read through them without giving
up and killing the thread or leaving the list. It's a nit I'll continue to
pick on as 98% of the other Perl lists are not at all tolerant of this
sort of email. 

*>I think gentle etiquette reminders are fine, if they don't begin to bog
*>down the list. Perhaps a short list etiquette mailing once a week or so
*>for new users, similar to FAQ postings, would be in order.

Not a bad idea but I don't much like rules since people like to go out of
their way to break them and seemingly FAQs are the last thing people read
:)

e.



RE: printf and other stuff

2001-06-05 Thread Herb Hall

> ### get time
> my($sec, $min, $hour, $mday, $month, $year) = (localtime)[0..5];
> $year += 1900;
> $mday = "0" . $mday if $mday < 10;
> $month++; # perl counts from -1 on occasion
> $month = "0" . $month if $month < 10;
> 
>
> -- later in the same file --
>
> print TOFILE "On $month/$mday/$year At $hour:$min you wrote:\n\n";
>
> how do I use print to provide a leading '0' to $min, such that
> I get 5:01 and not 5:1

There were several correct responses utilizing printf. I just wanted to
mention that you have another option. You already have two lines of code
that look like this:

$month = "0" . $month if $month < 10;
$mday = "0" . $mday if $mday < 10;

adding

$min = "0" . $min if $min < 10;

will pad your minutes with a 0. I have used both methods for various
reasons. You probably only need to use one or the other. I would use the
printf unless you have some need to have the variables padded with 0's.

Herb Hall





Re: probably a simple matter but...

2001-06-05 Thread M.W. Koskamp


- Original Message - 
From: Marcelo E. Magallon <[EMAIL PROTECTED]>
To: M.W. Koskamp <[EMAIL PROTECTED]>
Cc: Brent Buckalew <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Sunday, June 03, 2001 7:58 PM
Subject: Re: probably a simple matter but...


> >> "M.W. Koskamp" <[EMAIL PROTECTED]> writes:
> 
>  > \s* will match any number of spaces ([0-9.\-]*) will match the
>  > largest sequence of any character since there is a dot in the
>  > expression.
> 
>  No.  A '.' inside a character class is literal.
> 
sorry

Maarten




Re: FW: could not move file

2001-06-05 Thread Paul


--- "Brett W. McCoy" <[EMAIL PROTECTED]> wrote:
> On Tue, 5 Jun 2001, IT Dept - Terry Honeyford wrote: 
> > I have a really strange problem.
> > when my script is run it works fine except for the bit that moves a
> > company's config file. (shown below).
> > the server comes back with a server error page and the server error
> log says
> > :-
> > "the CGI program /admin_tfoak did not produce a valid header (name
> without
> > value: got line 'could not move file illegal seek at /admin_tfoak
> line
> > 322.")
> >
> > snip ->
> >
> > 320if ($query->param("dcomp")) {
> > 321&GETQUERYSTRINGVALUES;
> > 322`mv /web/company_profiles/$company_id
> > /web/deleted_company_profiles/$company_id` or die "could not move
> file $!";
> > 323&GETREWRITEUSERS_CTL;
> > 324$content = "\ > URL=admin_tfoak?display=admin_menu\">";
> > 325}
> > snip -<
> 
> You should use the move function (in the File::Copy module) rather
> than
> the backticked system call, because this won't properly indicate a
> failure
> of the move.  You might be trying to move a file that has an open
> filehandle on it.  It is also generating an error message that the
> server
> thinks is a header, and it is screwing up your redirect.

c.f. :
> > 322`mv /web/company_profiles/$company_id
> > /web/deleted_company_profiles/$company_id` or die "could not move
> file $!";

Backticks return the *output* of the command.
A successful mv probably has no output, so the following boolean test
fails, and the die() kills the script before the Content-type: header
or any real data has been sent.

Rewrite it as a Perl rename().

  rename $oldname, $newname or die $!;

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



RE: A gentle reminder about jeopardy quoting

2001-06-05 Thread Mark Folse

At first I sent this is a direct mail to the listed folks, but decided
to send it on to the list:

--- Eduard Grinvald <[EMAIL PROTECTED]> wrote:
> Umm, let's get back to perl, please... Etiquette is nice, but is
> hardly the
> point of this list.

I think gentle etiquette reminders are fine, if they don't begin to bog
down the list. Perhaps a short list etiquette mailing once a week or so
for new users, similar to FAQ postings, would be in order.

It could be as simple as:

1. Please use descriptive subject headers.

2. Please delete all portions of the messages replied to not directly
related to your response (ie, the example you are discussing, or the
suggestion you are disagreeing with).

3. No off subject posting. Please keep to Perl and the uses of Perl.

4. No flames.

5. No attachments.

Or somebody could write a bot (not me; beyond my meager capabilities).
 still keep and treasure the bot mail from Tom Christiansen's for
jeapardy posting. Its an honor to be chastised by the bot of such an
eminence. And so politely, too.



=

-
Notice: This e-mail is protected by the U.S. Constitution and the U.N. Declaration of 
Human Rights. Unauthorized interception by any public or private agency is an ugly 
sort of work to be in. Does your mother know you spend your days reading other 
people's mail? Would she be proud of you?

-
Please visit: http://clubs.yahoo.com/clubs/district41democrats

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



RE:[OT]A gentle reminder about jeopardy quoting

2001-06-05 Thread Paul


--- Eduard Grinvald <[EMAIL PROTECTED]> wrote:
> Umm, let's get back to perl, please... Etiquette is nice, but is
> hardly the point of this list.

Off topic posts can be very useful, especially for beginners.
Just put [OT] in the subject to alert people who would rather not spend
the off-topic time.

I get a couple hundred emails some days, but I personally tend to peek
at the OT's first, since I can help them more often, lol

> A gentle nudge to please:
> 
> 1) trim off all of the message that is not germane to your response.
> In
> your case, everything below your signature.
> 
> 2) While I realise that MS Outlook or whatever Office comes with
> these
> days doesn't encourage appropriate use of email formatting, please do
> your
> best to _not_ put your response at the top of the message leaving a
> trail
> of 15 email underneath it.
> 
> It helps to make the email easier to read, easier to know who is
> saying
> what and trims off the unwanted text to save someone searching the
> archive
> a bit of time and trouble when looking for an answer to something
> that has
> already been asked.
> 
> This is often called 'jeopardy quoting' in the newsgroups and the
> same
> applies to mailing lists.
> 
> http://www.xs4all.nl/~wijnands/nnq/nquote.html is a nice little
> explanation of it.
> 
> e.
> 


=
print "Just another Perl Hacker\n"; # edited for readability =o)
=
Real friends are those whom, when you inconvenience them, are bothered less by it than 
you are. -- me. =o) 
=
"There are trivial truths and there are great Truths.
 The opposite of a trival truth is obviously false.
 The opposite of a great Truth is also true."  -- Neils Bohr

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Re: help!

2001-06-05 Thread Paul


--- Kevin Meltzer <[EMAIL PROTECTED]> wrote:
> On Tue, Jun 05, 2001 at 07:16:19AM -0700, Randal L. Schwartz
> ([EMAIL PROTECTED]) spew-ed forth:
> > > "chris" == chris robinson <[EMAIL PROTECTED]> writes:
> > 
> > chris> I have the following code.  This code prints a / for each
> > chris> occurance of a certain number/word in a file.  How would I
> > chris> change this to print a / for each 5 instances of a given
> > chris> word/number?
> > 
> > meta-question: Do we have a policy here of suspecting homework
> > and handling it appropriately (as in, DON'T GIVE THE ANSWER)?
> 
> Nothing is set in stone on how to handle (possible) homework
> questions. Just because it
> smells like homework, doesn't mean it is (it could just be teen
> spirit!).
> 
> If you suspect homework, why not just give a pointer to the
> appropriate docs
> instead of a detailed explination (which should be pretty reasonable
> to give
> any beginner on non-homework questions as well). 

Sometimes it works to just ask. A fellow recently gave me a plausible
explanation -- he was doing good old-fashioned self-study.

I helped as much as I could, but the things I gave him were usually
nothing a teacher would have accepted anyway -- classes that assign a
program for such a specific task usually try to teach one thing in the
assignment, and a "better" way to do it sometimes isn't good enough.
=o)

I agree, though -- if you're not sure, help them find the answer,
rather than give it to them. Tutor, don't do it for them. ;o]

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



  1   2   >