Re: cgi script invoking an exe

2003-01-23 Thread Janek Schleicher
On Wed, 22 Jan 2003 21:22:22 -0800, Mj wrote:

> I am new to CGI. I just want to know if we can execute
> an application/exe file on the winnt server using the
> CGI script depending on the user form input over the
> net.

And your Perl question is ... ?

However, if you want to execute an exe file from Perl,
you just can use e.g. backticks:

With e.g.
`format.exe c:`
you can remove that bug called Windows :-)


Greetings,
Janek

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




Re: looking for a string in multiple files

2003-01-23 Thread Rob Dixon
Hello John.

John W. Krahn wrote:
>> How about this:   :-)
>
> Oops!  slight change.  :-)
>
>
> use strict;
> use warnings;
>
> my %zone;
>
> # get zone names from named.conf type files
> @ARGV = qw( one.txt two.txt three.txt );
> /^zone\b[^"]*"([^"]+)/ and push @{$zone{$1}}, "$ARGV, " while <>;

I like:

/^zone\b/ and /"(.+?)"/ and push @{$zone{$1}}, "$ARGV," while <>;

Also you don't need a space after the comma if you're stringifying the
array in the final print().

>
> # adjust output format
> for ( keys %zone ) {
> $zone{$_}[-1] =~ s/, $//;
> $zone{$_}[-2] =~ s/, $/ and / if @{$zone{$_}} > 1;
> }
>

Hmm. It works but, being a purist, I don't like using 'decorated'
filenames as hash keys. I came up with this:

my $files;
$files = join ' and ', (join ', ', @a), $_ for pop @files;

An interesting point here. I don't think there's a way to persuade
loops to return a value.

$a = do { 'abc' foreach (1) };

gives 'useless use of a constant' for 'abc', but it seems a reasonable
thing to do. Any ideas?

Another option to all this is to use the field separator:

local $" = ', ';

leaving only the ultimate ' and ' separator as a special case

> # report which zone names were found
> @ARGV = 'zonelist.input';
> while ( <> ) {
> chomp;
> if ( @{$zone{$_}} ) {

One hole, two programmers! If the zone wasn't found then $zone{$_}
is undefined and Perl dies trying to dereference it. That's why I
postponed the dereference in my V2. How about:

if (my $zone = $zone{$_} and @$zone) {
print "Zone $_ was found in files ", @$zone, "\n";
}

> print "Zone $_ was found in files ", @{$zone{$_}}, "\n";
> }
> else {
> print "Zone $_ was not found\n";
> }
> }
>
> __END__

Did somebody say this was a beginners' group :-?

Cheers,

Rob




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




Re: free web hosting with full CGI service?

2003-01-23 Thread David T-G
Mike --

...and then MJ said...
% 
% Hi,

Hi!


% I am looking for some free webhosting services where 
% there is full support for CGI. Though, I checked out

Have you asked google yet?  The same question keeps popping up on the php
list; I finally ran a search for 'free php web hosting' or similar and
came up with a mere 1.5 million results.


% few that offer free hosting service, there is a
% limitation in cgi script support only till some
% extent. I may not need much of free space but require
% full cgi support. Can one suggest me few proven
% sites...

With that I cannot help, I'm afraid, but google might be able to find
some chatter on the matter.


% 
% Mike


HTH & HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!




msg37160/pgp0.pgp
Description: PGP signature


Re: Size of number in scalar

2003-01-23 Thread Rob Dixon
Christopher D . Lewis wrote:
> Someone posted a question as to the size of number which a scalar
> would tolerate.  When I wanted to know what size boundaries I faced in
> certain variable types in C, I wrote a little program that added 1 to
> a variable until n+1 was less than n, at which point I concluded the
> variable had been rolled over to its start again.  Perl seems to
> tolerate quite a bit of this, as the app has been churning away,
> printing every so many number just to let me know where it's at, and
> it recently went past two hundred billion (I cheated and am
> incrementing by 1000 instead of 1, because I got impatient
> incrementing by one). $scalars in perl handle big numbers ... and
> maybe Perl notices when a boundary is being crossed and reconstitutes
> the number?

As others have noted, Perl will change to double-precision
representation
when it can no longer express the number in integer format.

The sort of program you have written will work if you 'use integer' at
the top of the code. My machine runs WinXPPro and my values wrap
at 2_147_483_647, or 31 bits.

To get an idea how many significant decimal floating-point digits can be
stored you can write something like this:

printf "%50.40f", 1/3;

Again, on my machine this shows 16.5 digits.

HTH,

Rob






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




Re: use and require

2003-01-23 Thread Rob Dixon
Beau E. Cox wrote:
> Hi -
>
> I thought I had a grip on this, but...
>
> Most of my reading (Camel, perldocs, etc) suggest that
> 'require Foo::Bar' should be used instead of 'use Foo::Bar' within
> modules. I am in the process of building a series of
> modules for a project and am having problems with
> 'require'; does whoever uses a module that requires Foo::Bar
> have to use Foo::Bar (I think so)? So that means changing
> the test scripts, etc.
>
> Is it 'bad' to just say 'use Foo::Bar' in the modules that
> need it? Will I get multiple copies if I do that? From a
> lazy programmer's viewpoint, saying 'use' is the way to go...
>
> Can someone help enligthen me?

Hi Beau.

'use Module' everywhere necessary is exactly what you should do.

'require Module' essentially does 'do "Module.pm"', but only if the
file has not already been included.

'use Module' operates at compile time. It does 'require Module'
and then calls Module::import to fetch the identifiers that
Module exports.

HTH,

Rob






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




Re: perl and progress database.

2003-01-23 Thread Christopher D . Lewis
NOT Abandoned!! Very active!
On Wednesday, January 22, 2003, at 12:54  PM, Bob Showalter wrote:


Ben Siders wrote:

Yes.  DBI has support for PostgreSQL.  You can perform almost any
transaction through it that you would at the command line.

Gerardo wrote:


i want to know if i can to run perl with the dbi module and to view
a Progress database.


n.b. "Progress" <> "PostgreSQL"

A quick search of Google Groups shows that a DBD::Progress effort was
started and then apparantly abandoned.


See http://search.cpan.org/dist/DBD-Pg/ -- several current projects 
depend on it and it is very much alive!

Take care,
	Chris


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



Re: Getting Perl

2003-01-23 Thread Bob X
"Beau E. Cox" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi -
>
> > -Original Message-
> > From: Scott Barnett [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, January 22, 2003 4:33 AM
> >
> > Hi All,
> >
> > Is there a free version of Perl that I can get that will run on
> > Win98 machine. I want to start learning Perl. checked ActiveState
> > but it looks like that is only a 15 or 30 day evaluation, I may be
wrong?
> >
> > Thanks,
> >
> > Scott Barnett
> > Home Care Medical - Technical Support Specialist
>
> Yes you ar wrong! :)
>
> The ActivePerl download page at:
>
> http://activestate.com/Products/Download/Register.plex?id=ActivePerl
>
> Asks for registration information (they do not disclose/sell
> your email address) and then lets you download the package
> of your choice (I would suggest ActivePerl 5.8.0 (804) MSI).
> This is _not_ an evaluation package. It's good forever.
>
> Aloha => Beau;
>

You can actually bypass the registration by just clicking the download
button.



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




Re: How to use ATL COM components in perl

2003-01-23 Thread Nilesh

"Pankaj Kapare" <[EMAIL PROTECTED]> wrote in message
005901c2bf02$59dada70$a300a8c0@anurag">news:005901c2bf02$59dada70$a300a8c0@anurag...
Hi,
   Can anybody tell me how to use perl components in perl.
Pankaj.



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




Re: project

2003-01-23 Thread Nilesh
I thinks thats a good advice from Joseph!
Bravo man
Nilesh

"R. Joseph Newton" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> kasi ramanathen wrote:
>
> > dear friends
> >
> > you can give me idea for any poject networking, using database, testing
programm, writting script for unix, simple or complex. say about a project
that has value using it i may get some good job.
> >
> > kasi
>
> Hi Kasi,
>
> I'd suggest that you look around you.  Get involved with any non-profit
organization that is doing something worthwhile.  Most are short on funds,
and could use volunteer assistance.  Most also have many years worth of
poorly kept records.  Get involved, find out what the needs are, and design
your project to fill them.  That's my strategy anyway.  I pretty much expect
a couple of years of continued poverty, but I also know that the upfront
investment in my own skills, and the contribution to my karma-bank will
bring their rewards if I persevere.  Even if I never strike it rich
materially, I will be very rich inmy experience of life.
>
> Where are you at with your programming skills?  Most importantly, where is
your motivation.  Kasi, there is a world full of people who want jobs
because of the pay.  Seeking the big bucks, you find yourself a very small
fish in a very big pond.  Programming, of all fields, is the one where there
is no substitute for natural, passionate and sustained curiosity.  For
success in programming, you must cultivate this virtue.
>
> Joseph
>



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




Newb Help? Anyone?

2003-01-23 Thread litiglio
Where could I find a good reference wrt starting Perl?



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




Re: looking for a string in multiple files

2003-01-23 Thread John W. Krahn
Rob Dixon wrote:
> 
> Hello John.

Well hello Rob,

> John W. Krahn wrote:
> >> How about this:   :-)
> >
> > Oops!  slight change.  :-)
> >
> > use strict;
> > use warnings;
> >
> > my %zone;
> >
> > # get zone names from named.conf type files
> > @ARGV = qw( one.txt two.txt three.txt );
> > /^zone\b[^"]*"([^"]+)/ and push @{$zone{$1}}, "$ARGV, " while <>;
> 
> I like:
> 
> /^zone\b/ and /"(.+?)"/ and push @{$zone{$1}}, "$ARGV," while <>;

I still like /"([^"]+)/ better than /"(.+?)"/.  :-)


> Also you don't need a space after the comma if you're stringifying the
> array in the final print().
> 
> > # adjust output format
> > for ( keys %zone ) {
> > $zone{$_}[-1] =~ s/, $//;
> > $zone{$_}[-2] =~ s/, $/ and / if @{$zone{$_}} > 1;
> > }
> 
> Hmm. It works but, being a purist, I don't like using 'decorated'
> filenames as hash keys. I came up with this:
> 
> my $files;
> $files = join ' and ', (join ', ', @a), $_ for pop @files;

I think you mean:

 $files = join ' and ', (join ', ', @files), $_ for pop @files;

But that will prepend ' and ' if there is only one file name in @files. 
It also doesn't seem right to use a loop just to force 'pop @files' to
evaluate first.


> An interesting point here. I don't think there's a way to persuade
> loops to return a value.

I think you mean "I don't think there's a way to persuade loops to
return a scalar." and no, you have to use join/concatenation to
transform a list/array to a scalar.


> $a = do { 'abc' foreach (1) };
> 
> gives 'useless use of a constant' for 'abc', but it seems a reasonable
> thing to do.

It does?

> Any ideas?

Sorry, no.

> Another option to all this is to use the field separator:
> 
> local $" = ', ';
> 
> leaving only the ultimate ' and ' separator as a special case
> 
> > # report which zone names were found
> > @ARGV = 'zonelist.input';
> > while ( <> ) {
> > chomp;
> > if ( @{$zone{$_}} ) {
> 
> One hole, two programmers! If the zone wasn't found then $zone{$_}
> is undefined and Perl dies trying to dereference it.

It will if strictures are enabled.  :-)

> That's why I postponed the dereference in my V2. How about:

  if ( ref $zone{$_} and @{$zone{$_}} ) {


> if (my $zone = $zone{$_} and @$zone) {
> print "Zone $_ was found in files ", @$zone, "\n";
> }
> 
> > print "Zone $_ was found in files ", @{$zone{$_}}, "\n";
> > }
> > else {
> > print "Zone $_ was not found\n";
> > }
> > }
> >
> > __END__
> 
> Did somebody say this was a beginners' group :-?

Don't forget -- TMTOWTDI


John
-- 
use Perl;
program
fulfillment

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




Weekly list FAQ posting

2003-01-23 Thread casey
NAME
beginners-faq - FAQ for the beginners mailing list

1 -  Administriva
  1.1 - I'm not subscribed - how do I subscribe?

Send mail to <[EMAIL PROTECTED]>

You can also specify your subscription email address by sending email to
(assuming [EMAIL PROTECTED] is your email address):

<[EMAIL PROTECTED]>.

  1.2 -  How do I unsubscribe?

Now, why would you want to do that? Send mail to
<[EMAIL PROTECTED]>, and wait for a response. Once you
reply to the response, you'll be unsubscribed. If that doesn't work,
find the email address which you are subscribed from and send an email
like the following (let's assume your email is [EMAIL PROTECTED]):

<[EMAIL PROTECTED]>

  1.3 - There is too much traffic on this list. Is there a digest?

Yes. To subscribe to the digest version of this list send an email to:

<[EMAIL PROTECTED]>

To unsubscribe from the digest, send an email to:

<[EMAIL PROTECTED]>

This is a high traffic list (100+ messages per day), so please subscribe
in the way which is best for you.

  1.4 - Is there an archive on the web?

Yes, there is. It is located at:

http://archive.develooper.com/beginners%40perl.org/

  1.5 - How can I get this FAQ?

This document will be emailed to the list once a week, and will be
available online in the archives, and at http://learn.perl.org/

  1.6 - I don't see something in the FAQ, how can I make a suggestion?

Send an email to <[EMAIL PROTECTED]> with your suggestion.

  1.7 - Is there a supporting website for this list?

Yes, there is. It is located at:

http://beginners.perl.org/

  1.8 - Who owns this list?  Who do I complain to?

Casey West owns the beginners list. You can contact him at
[EMAIL PROTECTED]

  1.9 - Who currently maintains the FAQ?

Kevin Meltzer, who can be reached at the email address (for FAQ
suggestions only) in question 1.6

  1.10 - Who will maintain peace and flow on the list?

Casey West, Kevin Meltzer and Ask Bjoern Hansen currently carry large,
yet padded, clue-sticks to maintain peace and order on the list. If you
are privately emailed by one of these folks for flaming, being
off-topic, etc... please listen to what they say. If you see a message
sent to the list by one of these people saying that a thread is closed,
do not continue to post to the list on that thread! If you do, you will
not only meet face to face with a XQJ-37 nuclear powered pansexual
roto-plooker, but you may also be taken off of the list. These people
simply want to make sure the list stays topical, and above-all, useful
to Perl beginners.

  1.11 - When was this FAQ last updated?

Sept 07, 2001

2 -  Questions about the 'beginners' list.
  2.1 - What is the list for?

A list for beginning Perl programmers to ask questions in a friendly
atmosphere.

  2.2 - What is this list _not_ for?

* SPAM
* Homework
* Solicitation
* Things that aren't Perl related
* Monkeys
* Monkeys solicitating homework on non-Perl related SPAM.
  2.3 - Are there any rules?

Yes. As with most communities, there are rules. Not many, and ones that
shouldn't need to be mentioned, but they are.

* Be nice
* No flaming
* Have fun
  2.4 - What topics are allowed on this list?

Basically, if it has to do with Perl, then it is allowed. You can ask
CGI, networking, syntax, style, etc... types of questions. If your
question has nothing at all to do with Perl, it will likely be ignored.
If it has anything to do with Perl, it will likely be answered.

  2.5 - I want to help, what should I do?

Subscribe to the list! If you see a question which you can give an
idiomatic and Good answer to, answer away! If you do not know the
answer, wait for someone to answer, and learn a little.

  2.6 - Is there anything I should keep in mind while answering?

We don't want to see 'RTFM'. That isn't very helpful. Instead, guide the
beginner to the place in the FM they should R :)

Please do not quote the documentation unless you have something to add
to it. It is better to direct someone to the documentation so they
hopefully will read documentation above and beyond that which answers
their question. It also helps teach them how to use the documentation.

  2.7 - I don't want to post a question if it is in an FAQ. Where should I
look first?

Look in the FAQ! Get acquainted with the 'perldoc' utility, and use it.
It can save everyone time if you look in the Perl FAQs first, instead of
having a list of people refer you to the Perl FAQs :) You can learn
about 'perldoc' by typing:

"perldoc perldoc"

At your command prompt. You can also view documentation online at:

http://www.perldoc.com and http://www.perl.com

  2.8 Is this a high traffic list?

YES! You have been warned! If you don't want to get ~100 emails per day
from this

Re: Find same key in 2 hashes?

2003-01-23 Thread Bill Akins
Thank you John!!!  Worked perfectly.

>>> "John W. Krahn" <[EMAIL PROTECTED]> 01/22/03 11:18PM >>>
Bill Akins wrote:
> 
> Hi all,

Hello,

> I have 2 hashes, the keys are a unique field.  Hashes are built like this:
> 
> open (INPUTFH, ) or die "Can't find allusers.chr file!\n";
> while ( $line =  ) {
> #set values here here...
> }
> push ( @{ $NS{$BV_NF} }, $NS_Name, $NS_Cont, $W_Name, $V_FID, $G_P, $GWD, 
>$NS_Creation, $NS_Expiration, $NS_Modified, $NS_Disabled, $GWI );
> 
> I need to grab each key ($BV_NF) from the hash and compare to each key in
> second hash (%BV) and print certain values from each ($NS{value}[2], $BV{$value}[8])
> if there is a match.  Any advice?

Perhaps this is what you want?

for my $key ( grep exists $BV{$_}, keys %NS ) {
print "$NS{$key}[2], $BV{$key}[8]\n";
}



John
-- 
use Perl;
program
fulfillment


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




Re: A better way, a perl way?

2003-01-23 Thread Jeff 'japhy' Pinyan
On Jan 22, david said:

>>   @data_ = map { (my $copy = $_) =~ s/^ //; $copy } @data;
>
>s/^ // for(@data_ = @data);

Sigh.  I usually do that.  I was a little slow on the idiom-uptake.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




How bad is it to use global variables?

2003-01-23 Thread Nils-Anders Persson
Hello,

I've seen many discussions regarding the use of "use strict".

What i wonder is why is it so bad using global variables?

And another question how do you define constants in perl?

regards,
Nils-Anders



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




Re: looking for a string in multiple files

2003-01-23 Thread Rob Dixon
John W. Krahn wrote:
>
> I think you mean:
>
>  $files = join ' and ', (join ', ', @files), $_ for pop @files;
>
> But that will prepend ' and ' if there is only one file name in
> @files.

Thanks.

> It also doesn't seem right to use a loop just to force 'pop
> @files' to evaluate first.

It's only a 'loop' in the same way that 'map' is. I was using it rather
to
avoid an explicit temporary variable.

perldoc perlsyn:

A common idiom for a "switch" statement is to use "foreach"'s
aliasing
to make a temporary assignment to "$_" for convenient matching:

SWITCH: for ($where) {
/In Card Names/ && do { push @flags, '-e';
last; };
/Anywhere/  && do { push @flags, '-h';
last; };
/In Rulings/&& do {
   last; };
die "unknown value for form variable where:
`$where'";
}

>> An interesting point here. I don't think there's a way to persuade
>> loops to return a value.
>
> I think you mean "I don't think there's a way to persuade loops to
> return a scalar." and no, you have to use join/concatenation to
> transform a list/array to a scalar.

I don't know of a way for them to return lists either. As far as I can
tell a 'for/foreach' can't be used as an expression at all. I withhold
judgement on 'while', but I guess it's the same.

> Don't forget -- TMTOWTDI

Amen to that.

/R




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




RE: How bad is it to use global variables?

2003-01-23 Thread Kipp, James
> 
> I've seen many discussions regarding the use of "use strict".
> 
> What i wonder is why is it so bad using global variables?
> 
> And another question how do you define constants in perl?
> 

use strict does not disallow global variables, it simply enforced you to
declare variables with one of my,local, our. there is a article called
"coping with scoping" you might want to read. I don't have the URl handy,
but a google search will find it.

for constants there are a few ways, one is using the constant pragma:
use constant BUFFER_SIZE=> 4096;


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




RE: How bad is it to use global variables?

2003-01-23 Thread wiggins


On Thu, 23 Jan 2003 14:00:19 +0100, "Nils-Anders Persson" 
<[EMAIL PROTECTED]> wrote:

> Hello,
> 
> I've seen many discussions regarding the use of "use strict".

Probably shouldn't be any discussion. Just 'use' it. :-)

> 
> What i wonder is why is it so bad using global variables?
> 

Memory usage, modularity, debugging, are three good reasons.

> And another question how do you define constants in perl?
> 

use constant CONSTANT_NAME => 5;

perldoc constant (for the details).

http://danconia.org

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




RE: How bad is it to use global variables?

2003-01-23 Thread wiggins


On Thu, 23 Jan 2003 08:52:01 -0500, "Kipp, James" <[EMAIL PROTECTED]> wrote:

 there is a article called
> "coping with scoping" you might want to read. I don't have the URl handy,
> but a google search will find it.
> 

I keep it handy:  http://perl.plover.com/FAQs/Namespaces.html

http://danconia.org

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




Re: How bad is it to use global variables?

2003-01-23 Thread Rob Dixon
Nils-Anders Persson wrote:
> Hello,
>
> I've seen many discussions regarding the use of "use strict".
>
> What i wonder is why is it so bad using global variables?
>

It's not. It's bad to use global variables /all the time/, even if
you don't need them. Most variables are only in use for short
sections of code, and using the same global variable everywhere
you have, say,

for ($i = 0; $i < $len; ++$i) {
:
}

will get very confusing and lead to awkward-to-find bugs.

>
> And another question how do you define constants in perl?

use constant MEANING_OF_LIFE => 42;

HTH,

Rob






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




RE: use and require

2003-01-23 Thread Beau E. Cox
Hi Rob -

> -Original Message-
> From: Rob Dixon [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 23, 2003 1:20 AM
> To: [EMAIL PROTECTED]
> Subject: Re: use and require
> 
> 
> Beau E. Cox wrote:
> > Hi -
> >
> > I thought I had a grip on this, but...
> > ...
> > need it? Will I get multiple copies if I do that? From a
> > lazy programmer's viewpoint, saying 'use' is the way to go...
> >
> > Can someone help enligthen me?
> 
> Hi Beau.
> 
> 'use Module' everywhere necessary is exactly what you should do.
> 
> 'require Module' essentially does 'do "Module.pm"', but only if the
> file has not already been included.
> 
> 'use Module' operates at compile time. It does 'require Module'
> and then calls Module::import to fetch the identifiers that
> Module exports.
> 
> HTH,
> 
> Rob

GOOD! That makes my life easier - thanks.

Aloha => Beau.


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




Re: cgi script invoking an exe

2003-01-23 Thread Todd W

"Janek Schleicher" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Wed, 22 Jan 2003 21:22:22 -0800, Mj wrote:
>
> > I am new to CGI. I just want to know if we can execute
> > an application/exe file on the winnt server using the
> > CGI script depending on the user form input over the
> > net.
>
> And your Perl question is ... ?
>
> However, if you want to execute an exe file from Perl,
> you just can use e.g. backticks:
>
> With e.g.
> `format.exe c:`
> you can remove that bug called Windows :-)
>
snd to the op, dont forget that if you are executing user input, you need to
sanitize the data or the abouve will happen sooner or later.

Todd W.



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




RE: Newb Help? Anyone?

2003-01-23 Thread Dan Muey


 
> 
> Where could I find a good reference wrt starting Perl?

For a beginner I'd highly recommend the  Peachpit Press Visual Quick Start Guide to 
Perl
By Elizabeth Castro ( I think ).

It starts by not assuming you are already a 30 year unix veterin and 
explains everything in plain english and gives you examples of using 
the different things. Examples you can do right then and there and 
learn by doing, very helpful.
That's something most of the oreilley books don't do really. They just basically 
Copy stuff straight from perldoc and assume you're going to understand
What to do with that. 

So basically once/while you learn perl, instead of buying Oreilley books just go to 
your unix prompt
And type 'perldoc' , look at the options then you can use that to look up anything 
that you'll find in the oreilley books, 
Although you won't have the cool looking animals but oh well. It's free and it's the 
same thing.

Again, not to offend any Oreilley fans, but if anyone remembers the post before about 
perl books
I mentioned the pack example of how oreilley gives facts but doesn't tell what to do 
with those facts. 
I E good references if you've done it before and just need to see the exact syntax but 
bad teacher 
if you've never used it.

Well perldoc -f pack is the exact, word for word, 
text that Oreilley has in the book I mentioned  in that post.
The formatting wasn't even much different. 

Not to say that the perldoc info isn't good, it's great.

I'm just saying I wish I had a job where all I had to do was
Type perldoc and copy and paste it in a book and make tons of cash as a writer for not 
writing anything.

To me Oreilley has made their line seem very fashionable by the nice colors and cool 
pen and ink animals.
However it's just a marketing ploy to get tyou to think they're special, much like 
Microsoft has everybody thinking that their computer can't run any programs without 
windows when in fact windows can barely run itself!

I will say though that the oreilley Topic Specific books are more helpful but I'd get 
it form the library instead of shelling out $30 +/- to make sure it's what you want. 
Still mostly just copies of perldoc but some usefull real world examples to help you 
grasp what is going on and why/when/how you may want to use it.

Sorry, 

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

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




RE: free web hosting with full CGI service?

2003-01-23 Thread Dan Muey

May I ask what kind of 'support for CGI' you're looking for?
What kind of stuff do want for free? 
What kind of space/bandwidth do you expect to use?
Do you mind ads?

I may know of a few places...

Dan
> Mike --
> 
> ...and then MJ said...
> % 
> % Hi,
> 
> Hi!
> 
> 
> % I am looking for some free webhosting services where 
> % there is full support for CGI. Though, I checked out
> 
> Have you asked google yet?  The same question keeps popping 
> up on the php list; I finally ran a search for 'free php web 
> hosting' or similar and came up with a mere 1.5 million results.
> 
> 
> % few that offer free hosting service, there is a
> % limitation in cgi script support only till some
> % extent. I may not need much of free space but require
> % full cgi support. Can one suggest me few proven
> % sites...
> 
> With that I cannot help, I'm afraid, but google might be able 
> to find some chatter on the matter.
> 
> 
> % 
> % Mike
> 
> 
> HTH & HAND
> 
> :-D
> -- 
> David T-G  * There is too much animal courage in 
> (play) [EMAIL PROTECTED] * society and not sufficient 
> moral courage.
> (work) [EMAIL PROTECTED]  -- Mary Baker Eddy, 
> "Science and Health"
> http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf 
> Qrprapl Npg!
> 
> 

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




cgi and symbolic links

2003-01-23 Thread Harry Putnam
I ran into something today I've never noticed any comment here about.
Maybe I should know this but never ran into it before.

I wanted to use a single cgi script to generate several different
formated pages.  That is, the output page would have different
ordering  depending on the content of ENV{SCRIPT_FILENAME}.

I hoped to have one real cgi script and several symbolic links to it
that would change that ENV item.

I tried the simplist test at www.jtan.com/~reader/scr_filename.cgi which
outputs the SCRIPT_FILENAME ENV item  of the contacting client, by
creating `ln -s link.cgi scr_filename.cgi'

I assumed it would fire scr_filename.cgi but with a different
ENV{SCRIPT_FILENAME}.  But apparently that isn't going to work.

Trying www.jtan.com/~reader/link.cgi

Gives an error in the browser window: Internal Server Error
And this in apache error log:
  Premature end of script headers: /home/reader/public_html/link.cgi

An ls -l shows:
   -rwxr-xr-x  1 [...]   202 Apr  1  2002 scr_filename.cgi
[...]
   lrwxr-xr-x  1 [...] 8 Jan 23 09:19 link.cgi -> diag.cgi

scr_filename.cgi contains:

#!/usr/bin/perl
 print "Content-type: text/html\n\n";

 print "SCRIPT_FILENAME = $ENV{SCRIPT_FILENAME}";


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




RE: cgi and symbolic links

2003-01-23 Thread Dan Muey


> I ran into something today I've never noticed any comment 
> here about. Maybe I should know this but never ran into it before.
> 
> I wanted to use a single cgi script to generate several 
> different formated pages.  That is, the output page would 
> have different ordering  depending on the content of 
> ENV{SCRIPT_FILENAME}.
> 
> I hoped to have one real cgi script and several symbolic 
> links to it that would change that ENV item.
> 
> I tried the simplist test at 
> www.jtan.com/~reader/scr_filename.cgi which > outputs the 
> SCRIPT_FILENAME ENV item  of the contacting client, by 
> creating `ln -s link.cgi scr_filename.cgi'
> 
> I assumed it would fire scr_filename.cgi but with a different 
> ENV{SCRIPT_FILENAME}.  But apparently that isn't going to work.
> 
> Trying www.jtan.com/~reader/link.cgi
> 
> Gives an error in the browser window: Internal Server Error
> And this in apache error log:
>   Premature end of script headers: /home/reader/public_html/link.cgi
> 
> An ls -l shows:
>-rwxr-xr-x  1 [...]   202 Apr  1  2002 scr_filename.cgi
> [...]
>lrwxr-xr-x  1 [...] 8 Jan 23 09:19 link.cgi -> diag.cgi


Looks like link.cgi is a link to and therefore actually executing diag.cgi not 
scr_filename.cgi
I went to your links and to the diag,cgi versionand it works.
Might want to ask the server admin if apache is set to not allow symbolic links to be 
used for web browsing.

> 
> scr_filename.cgi contains:
> 
> #!/usr/bin/perl
>  print "Content-type: text/html\n\n";
> 
>  print "SCRIPT_FILENAME = $ENV{SCRIPT_FILENAME}";

For kicks try 
print "SCRIPT_FILENAME = $ENV{'SCRIPT_FILENAME'}";
With the single quotes and see if that does anything good.

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

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




Re: cgi and symbolic links

2003-01-23 Thread Pete Emerson
I put a working test.pl in /var/www/cgi-bin.
Then I symlinked test2.pl to it.
When I loaded up test2.pl, the web page said:
Forbidden
You don't have permission to access /cgi-bin/test2.pl on this server.

Then I put this in my   section of
httpd.conf: Options FollowSymLinks

Now test2 works, and the $ENV{SCRIPT_FILNEAME} reflects the fact that
it's test2.pl, even though it's a symlink to test.pl

You may need that Options line in your 
section or similar.

Pete

On Thu, 2003-01-23 at 11:24, Harry Putnam, edited by me for brevity,
wrote:

> I hoped to have one real cgi script and several symbolic links to it
> that would change that ENV item.



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




Multiple use of same module question

2003-01-23 Thread Dan Muey
Here's something I've been wondering

What kind of performance issues are there if you do a 'use' on the same module in the 
same script twice or more?

Before you go ' Well that's stupid, why would you do that? ' let me explain :

Script one has 

use CGI; 

require stumpy.lib; 
stumpy_funtion1("joe","mama");
stumpy_funtion2("hiya");

And the stumpy.lib looks something like {

sub stumpy_function1 {

use CGI;
blah blah blah
}

sub stumpy_function1 {

use CGI;
blah blah blah
}

1;

So does that do anything to slow the script down or does it just ignore it if it's 
already been 'use'd?

If it does cause perfance issues is there a way to check and see if the module's 
already been 'use'd and then if it hasn't then do use ?

EG if(??) { use CGI; }

What if you already did

Use CGI params; and in the sub routine you only need say use CGI self_url; ?
Or if you did use CGI param earlier and the sin does use CGI;

See what I I mean there's all kinds of possibilities? What ways can this be avioded or 
at least checked to increase performance?

Or do the modules just do it themselves?

Thanks

Dan



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




RE: cgi and symbolic links

2003-01-23 Thread Dan Muey

> I put a working test.pl in /var/www/cgi-bin.
> Then I symlinked test2.pl to it.
> When I loaded up test2.pl, the web page said:
> Forbidden
> You don't have permission to access /cgi-bin/test2.pl on this server.
> 
> Then I put this in my   section of
> httpd.conf: Options FollowSymLinks

That's what I was trying to remember : Options FollowSymLinks in http.conf!
I'll bet you're right on the money, that his apache doesn't allow symlinks.
That's what I said to but gave no solution besides 'ask the server admin'
Thanks for pointing out the stuff I should have known but my tiny little 
Brain let slip out. One of these days I swear I'll get the genius award! ;) 

> 
> Now test2 works, and the $ENV{SCRIPT_FILNEAME} reflects the 
> fact that it's test2.pl, even though it's a symlink to test.pl
> 
> You may need that Options line in your  /home/*/public_html> section or similar.
> 
> Pete
> 
> On Thu, 2003-01-23 at 11:24, Harry Putnam, edited by me for brevity,
> wrote:
> 
> > I hoped to have one real cgi script and several symbolic 
> links to it 
> > that would change that ENV item.
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




"1;"?

2003-01-23 Thread Rob Richardson
Greetings!

Dan Muey's stumpy.lib file, quoted below, ends with a statement
consisting of a single contstant value: "1;".  This is the second time
I've seen this today.  What is its purpose?

Thanks!

RobR

--- Dan Muey <[EMAIL PROTECTED]> wrote:
> sub stumpy_function1 {
> 
>   use CGI;
>   blah blah blah
> }
> 
> sub stumpy_function1 {
> 
>   use CGI;
>   blah blah blah
> }
> 
> 1;



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

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




Re: Resolving IP's/Hostmasks

2003-01-23 Thread dan

"John W. Krahn" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Dan wrote:
> >
> > Hey
>
> Hello,
>
> > I need a method that resolves Hostmasks into IP's, and IP's into hosts.
I
> > can do the former, with:
> >
> > sub resolve {
> >  return inet_ntoa(scalar gethostbyname("@_"));
>  
> You should be using $_[0] here instead of "@_".  What you are doing is
> the same as join( $", @_ ).
>
>
> > }
> > $data = resolve("host.mask.com");
> >
> > However, if I give it an IP address, it will just return nothing, even
if
> > the IP address is resolvable. Is there as module to do this, or a set of
> > scripts?
>
> It works for me.  :-)
>
> $ perl -le'
> use Socket;
> sub resolve { inet_ntoa( scalar gethostbyname( $_[0] ) ) }
> print resolve( "www.google.com" );
> '
> 216.239.51.101
> $ perl -le'
> use Socket;
> sub resolve { inet_ntoa( scalar gethostbyname( $_[0] ) ) }
> print resolve( "216.239.51.101" );
> '
> 216.239.51.101

^^
my point exactly, it resolves hosts to ips, but not vice versa, and i need
to know how to reverse resolve. i've had a look at the Net::hostent package
that was suggested to me, seems ok, yet to grasp with how it works, but if
there's a simpler solution, i'd like to know.

>
>
>
> John
> --
> use Perl;
> program
> fulfillment

Dan



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




RE: "1;"?

2003-01-23 Thread Dan Muey

At the end of a lib file ( in the script you have require lib.lib; and lib.lib doesn't 
have #!/usr/bin/perl because it's a library not a script ) you put a 1; so that the 
require statement returns true. I believe it's a boolean thing.
 
So if it does a require and can't do it ( ie gets 0 returned instead of the 1 that we 
return put at the end with 1; ) then it gives you an error and quits so that the 
script doesn't do anything stupid since it doesn't have everything it's supposed to 
have to run.

It's at the end also so that it gets returned only after everything else in the lib 
works out ok.

I believe it it the same as return 1;

I don't see require used much anymore because most everybody uses modules but you 
could also use it in routines that are in the same script if you wantsed to do a 
boolean check on something.

I could be bit off, if I am please let me know. 

Thanks

Dan


> 
> Greetings!
> 
> Dan Muey's stumpy.lib file, quoted below, ends with a 
> statement consisting of a single contstant value: "1;".  This 
> is the second time I've seen this today.  What is its purpose?
> 
> Thanks!
> 
> RobR
> 
> --- Dan Muey <[EMAIL PROTECTED]> wrote:
> > sub stumpy_function1 {
> > 
> > use CGI;
> > blah blah blah
> > }
> > 
> > sub stumpy_function1 {
> > 
> > use CGI;
> > blah blah blah
> > }
> > 
> > 1;
> 
> 
> 
> __
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now. 
http://mailplus.yahoo.com

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


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




Re: Multiple use of same module question

2003-01-23 Thread Rob Dixon
Hi Dan

Dan Muey wrote:
> Here's something I've been wondering
>
> What kind of performance issues are there if you do a 'use' on the
> same module in the same script twice or more?

I posted the following earlier today in response to a question of
Beau's:

Rob Dixon wrote:
> Beau E. Cox wrote:
>> Hi -
>>
>> I thought I had a grip on this, but...
>>
>> Most of my reading (Camel, perldocs, etc) suggest that
>> 'require Foo::Bar' should be used instead of 'use Foo::Bar' within
>> modules. I am in the process of building a series of
>> modules for a project and am having problems with
>> 'require'; does whoever uses a module that requires Foo::Bar
>> have to use Foo::Bar (I think so)? So that means changing
>> the test scripts, etc.
>>
>> Is it 'bad' to just say 'use Foo::Bar' in the modules that
>> need it? Will I get multiple copies if I do that? From a
>> lazy programmer's viewpoint, saying 'use' is the way to go...
>>
>> Can someone help enligthen me?
>
> Hi Beau.
>
> 'use Module' everywhere necessary is exactly what you should do.
>
> 'require Module' essentially does 'do "Module.pm"', but only if the
> file has not already been included.
>
> 'use Module' operates at compile time. It does 'require Module'
> and then calls Module::import to fetch the identifiers that
> Module exports.
>
> HTH,
>
> Rob





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




RE: Multiple use of same module question

2003-01-23 Thread Dan Muey

So I don't have to worry about doing use Module; or 
varitions of it like use Module stuffdealy; more than once causing performance issues?

Great, thanks that's load off!

Dan

> 
> Hi Dan
> 
> Dan Muey wrote:
> > Here's something I've been wondering
> >
> > What kind of performance issues are there if you do a 'use' on the 
> > same module in the same script twice or more?
> 
> I posted the following earlier today in response to a question of
> Beau's:
> 
> Rob Dixon wrote:
> > Beau E. Cox wrote:
> >> Hi -
> >>
> >> I thought I had a grip on this, but...
> >>
> >> Most of my reading (Camel, perldocs, etc) suggest that 'require 
> >> Foo::Bar' should be used instead of 'use Foo::Bar' within 
> modules. I 
> >> am in the process of building a series of modules for a 
> project and 
> >> am having problems with 'require'; does whoever uses a module that 
> >> requires Foo::Bar have to use Foo::Bar (I think so)? So that means 
> >> changing the test scripts, etc.
> >>
> >> Is it 'bad' to just say 'use Foo::Bar' in the modules that 
> need it? 
> >> Will I get multiple copies if I do that? From a lazy programmer's 
> >> viewpoint, saying 'use' is the way to go...
> >>
> >> Can someone help enligthen me?
> >
> > Hi Beau.
> >
> > 'use Module' everywhere necessary is exactly what you should do.
> >
> > 'require Module' essentially does 'do "Module.pm"', but only if the 
> > file has not already been included.
> >
> > 'use Module' operates at compile time. It does 'require Module' and 
> > then calls Module::import to fetch the identifiers that Module 
> > exports.
> >
> > HTH,
> >
> > Rob
> 
> 
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




RE: Multiple use of same module question

2003-01-23 Thread Timothy Johnson

And that finally explains why in some of my scripts using the Win32::Lanman
module I have to do a 'require Win32;' instead of a 'use Win32' if I don't
want to get warning messages about conflicting constants.  It's always been
one of those "I got it working, I'll figure out why when I get some extra
time" issues.  I love it when the light bulb finally comes on.

-Original Message-
From: Dan Muey [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 23, 2003 9:37 AM
To: Rob Dixon; [EMAIL PROTECTED]
Subject: RE: Multiple use of same module question



So I don't have to worry about doing use Module; or 
varitions of it like use Module stuffdealy; more than once causing
performance issues?

Great, thanks that's load off!

Dan

> 
> Hi Dan
> 
> Dan Muey wrote:
> > Here's something I've been wondering
> >
> > What kind of performance issues are there if you do a 'use' on the 
> > same module in the same script twice or more?
> 
> I posted the following earlier today in response to a question of
> Beau's:
> 
> Rob Dixon wrote:
> > Beau E. Cox wrote:
> >> Hi -
> >>
> >> I thought I had a grip on this, but...
> >>
> >> Most of my reading (Camel, perldocs, etc) suggest that 'require 
> >> Foo::Bar' should be used instead of 'use Foo::Bar' within 
> modules. I 
> >> am in the process of building a series of modules for a 
> project and 
> >> am having problems with 'require'; does whoever uses a module that 
> >> requires Foo::Bar have to use Foo::Bar (I think so)? So that means 
> >> changing the test scripts, etc.
> >>
> >> Is it 'bad' to just say 'use Foo::Bar' in the modules that 
> need it? 
> >> Will I get multiple copies if I do that? From a lazy programmer's 
> >> viewpoint, saying 'use' is the way to go...
> >>
> >> Can someone help enligthen me?
> >
> > Hi Beau.
> >
> > 'use Module' everywhere necessary is exactly what you should do.
> >
> > 'require Module' essentially does 'do "Module.pm"', but only if the 
> > file has not already been included.
> >
> > 'use Module' operates at compile time. It does 'require Module' and 
> > then calls Module::import to fetch the identifiers that Module 
> > exports.
> >
> > HTH,
> >
> > Rob
> 
> 
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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

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




How do I test a variable to see if it is a scalar or a hash?

2003-01-23 Thread Ken Lehman
How do I test a variable to see what type of variable it is(scalar, array,
hash, etc...)?
What I am trying to accomplish is I have a hash and some values are scalar
data and some values are nested hashes and
I need a way to tell the difference.
Book or web site references are welcome, thanks in advance.
-Ken



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




Probably a simple hash question

2003-01-23 Thread Lara J. Fabans
Hi, perl-friends,

Here's the setup:
I have set up a hash %categories where the key is one number and the value 
is another
i.e. $categories('1094') = 100049-0220-14

So, further on down, I'm trying to do a lookup in %categories to see if a 
value is there.  (I can
swap the key and the value in the setup if it will make this next step 
easier)
and I had a while loop to search through each of the keys & values, but the 
problem is
that it doesn't break out of the while loop, and the wrong value gets set 
as $myID;

$ccid = 1094;

## Attempt #2
### 1.22.03 change to try to get it to stop once it finds
###   the correct value.
#until ($value == $ccid)
# {
# ($key, $value) = each %categories;
# }

## Attempt #1
#while(my ($key, $value) = each %categories )
#{
#print "CC ID: $ccid: Key : $key : Value: $value\n";
#if ($value == $ccid)
# {
#$myID = $key;
 #}## Need to break out of the while loop here once find it.
#}

print "My  ID is $categories{$ccid}\n";  ## Returns a null

Unfortunately, in all the documentation, it shows using an HTG value in the
hash ($categories('1094')), and I only have a variable to access.
I looked into mapping, but got my head wrapped around the axel.

So, here's the question:
Where can I find information on how to use variables as the keys in a hash?

Thanks,
Lara
-
Lara J. Fabans
Lodestone Software, Inc
[EMAIL PROTECTED]


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



RE: Probably a simple hash question

2003-01-23 Thread Dan Muey
> Hi, perl-friends,
> 
> Here's the setup:
> I have set up a hash %categories where the key is one number 
> and the value 
> is another
> i.e. $categories('1094') = 100049-0220-14

 do you mean $catagories{'1094'} ?
> 
> So, further on down, I'm trying to do a lookup in %categories 
> to see if a 
> value is there.  (I can

if(exists $catagories{$ccid}) {  }
You can do that anywhere after the hash is created and it will work peachy!
As far as the while not stopping why not try a foreach

foreach $k(keys %catagories) {  }

> swap the key and the value in the setup if it will make this 
> next step 
> easier)
> and I had a while loop to search through each of the keys & 
> values, but the 
> problem is
> that it doesn't break out of the while loop, and the wrong 
> value gets set 
> as $myID;
> 
> $ccid = 1094;
> 
> ## Attempt #2
> ### 1.22.03 change to try to get it to stop once it finds
> ###   the correct value.
> #until ($value == $ccid)
> # {
> # ($key, $value) = each %categories;
> # }
> 
> ## Attempt #1
> #while(my ($key, $value) = each %categories )
> #{
> #print "CC ID: $ccid: Key : $key : Value: $value\n";
> #if ($value == $ccid)
> # {
> #$myID = $key;
>   #}## Need to break out of the while loop here once find it.
> #}
> 
> print "My  ID is $categories{$ccid}\n";  ## Returns a null
> 
> Unfortunately, in all the documentation, it shows using an 
> HTG value in the hash ($categories('1094')), and I only have 
> a variable to access. I looked into mapping, but got my head 
> wrapped around the axel.
> 
> So, here's the question:
> Where can I find information on how to use variables as the 
> keys in a hash?
> 
> Thanks,
> Lara
> -
> Lara J. Fabans
> Lodestone Software, Inc
> [EMAIL PROTECTED]
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




Re: How do I test a variable to see if it is a scalar or a hash?

2003-01-23 Thread Rob Dixon
Ken Lehman wrote:
> How do I test a variable to see what type of variable it is(scalar,
> array, hash, etc...)?
> What I am trying to accomplish is I have a hash and some values are
> scalar data and some values are nested hashes and
> I need a way to tell the difference.
> Book or web site references are welcome, thanks in advance.

perldoc -f ref

Well it's /like/ a book :)

Rob




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




Re: Probably a simple hash question

2003-01-23 Thread Rob Dixon
Lara J. Fabans wrote:
> Hi, perl-friends,
>
> Here's the setup:
> I have set up a hash %categories where the key is one number and the
> value is another
> i.e. $categories('1094') = 100049-0220-14

You need quotation marks here, like this:

$categories('1094') = '100049-0220-14';

otherwise you're setting the hash value to -99!

>
> So, further on down, I'm trying to do a lookup in %categories to see
> if a value is there.  (I can
> swap the key and the value in the setup if it will make this next step
> easier)
> and I had a while loop to search through each of the keys & values,
> but the problem is
> that it doesn't break out of the while loop, and the wrong value gets
> set as $myID;
>
> $ccid = 1094;
>
> ## Attempt #2
> ### 1.22.03 change to try to get it to stop once it finds
> ###   the correct value.
> #until ($value == $ccid)
> # {
> # ($key, $value) = each %categories;
> # }
>
> ## Attempt #1
> #while(my ($key, $value) = each %categories )
> #{
> #print "CC ID: $ccid: Key : $key : Value: $value\n";
> #if ($value == $ccid)
> # {
> #$myID = $key;
>   #}## Need to break out of the while loop here once find it.
> #}
>
> print "My  ID is $categories{$ccid}\n";  ## Returns a null

Hi Lara.

I think you're misunderstanding hashes. They work this way round:

my (%hash, $key, $value);
$key = 1094;
$value = '100049-0220-14'

$hash{$key} = $value;

so it looks like you're searching the hash for an entry
where $value == 1094, which doesn't exist. Also, this is
exactly what hashes were meant for so you don't need the
loop to find an entry with the given key. Just write:

$value = $hash{$ccid};

and it's done.

I hope I've understood what you're trying to do.

Cheers,

Rob




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




Re: cgi and symbolic links

2003-01-23 Thread Harry Putnam
Pete Emerson <[EMAIL PROTECTED]> writes:

> I put a working test.pl in /var/www/cgi-bin.
> Then I symlinked test2.pl to it.
> When I loaded up test2.pl, the web page said:
> Forbidden
> You don't have permission to access /cgi-bin/test2.pl on this server.

I won't be able to check this immediately since I don't have root.
But will be able eventually.

See below about screw up...

"Dan Muey" <[EMAIL PROTECTED]> writes:
>> 
>> An ls -l shows:
>>-rwxr-xr-x  1 [...]   202 Apr  1  2002 scr_filename.cgi
>> [...]
>>lrwxr-xr-x  1 [...] 8 Jan 23 09:19 link.cgi -> diag.cgi
>
>
> Looks like link.cgi is a link to and therefore actually executing diag.cgi not 
>scr_filename.cgi
> I went to your links and to the diag,cgi versionand it works.
> Might want to ask the server admin if apache is set to not allow symbolic links to 
>be used for web browsing.
>
My screwup Dan, I was messing with those files and renamed them
before finishing my post.  Then edited my post to reflect the new
names.  I missed editing what comes after the -> but it is in fact
scr_filename.cgi

 ls -l [ls][ic]*
lrwxrwxrwx  [...] link.cgi -> /home/reader/public_html/scr_filename.cgi
-rwxr-xr-x  [...] scr_filename.cgi

Sorry for the miss-information.  Looks like Pete and your speculations
about apache settings may be the right answer.

>> 
>> scr_filename.cgi contains:
>> 
>> #!/usr/bin/perl
>>  print "Content-type: text/html\n\n";
>> 
>>  print "SCRIPT_FILENAME = $ENV{SCRIPT_FILENAME}";
>
> For kicks try 
> print "SCRIPT_FILENAME = $ENV{'SCRIPT_FILENAME'}";
> With the single quotes and see if that does anything good.

That puzzled me to at one time.  When I noticed they didn't need to
be there a few days ago.

Try hitting www.jtan.com/~reader/scr_filename.cgi they are missing
there:

Cat src_filename.cgi:
#!/usr/bin/perl
 print "Content-type: text/html\n\n";

 print "SCRIPT_FILENAME = $ENV{SCRIPT_FILENAME}";

I did try inserting them just for good measure.  scr_filename.cgi
still works but still no go at link.cgi



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




RE: How do I test a variable to see if it is a scalar or a hash?

2003-01-23 Thread Dan Muey

> 
> Ken Lehman wrote:
> > How do I test a variable to see what type of variable it is(scalar, 
> > array, hash, etc...)? What I am trying to accomplish is I 
> have a hash 
> > and some values are scalar data and some values are nested 
> hashes and
> > I need a way to tell the difference.
> > Book or web site references are welcome, thanks in advance.
> 
> perldoc -f ref
> 
> Well it's /like/ a book :)

I won't even say anything, though I'm very tempted! :)

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

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




Re: cgi and symbolic links

2003-01-23 Thread Harry Putnam
Harry Putnam <[EMAIL PROTECTED]> writes:

regarding apache setting:
Harry wrote:
> I won't be able to check this immediately since I don't have root.
> But will be able eventually.

I turns out the conf file is only write protected so I was able to
view it as user.

  
  Options FollowSymLinks
  AllowOverride None
  

Appears to be the huckleberry.  ... thanks


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




Quick regex prob

2003-01-23 Thread Dan Muey
Hiya, I'm having a brain melt right now :

I do this to match one word only.
m/^(\w+)$/)

What regex do I need to match multiple , unkown ammounts of words?
Will this do it? Or is there a better way? 
m/^\w[\w*|\s*]\w$/

I know there is but like Isaid my brain stopped for luunch a while ago.

Thanks

Dan

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




Re: "1;"?

2003-01-23 Thread Ben Siders
This is correct.  When you include something the last line has to return 
a true value, so people often stick a 1; at the end.  Consider it a bit 
of plumbing that a module or library just has to have.

Dan Muey wrote:

At the end of a lib file ( in the script you have require lib.lib; and lib.lib doesn't have #!/usr/bin/perl because it's a library not a script ) you put a 1; so that the require statement returns true. I believe it's a boolean thing.

So if it does a require and can't do it ( ie gets 0 returned instead of the 1 that we return put at the end with 1; ) then it gives you an error and quits so that the script doesn't do anything stupid since it doesn't have everything it's supposed to have to run.

It's at the end also so that it gets returned only after everything else in the lib works out ok.

I believe it it the same as return 1;

I don't see require used much anymore because most everybody uses modules but you could also use it in routines that are in the same script if you wantsed to do a boolean check on something.

I could be bit off, if I am please let me know. 

Thanks

Dan


 

Greetings!

Dan Muey's stumpy.lib file, quoted below, ends with a 
statement consisting of a single contstant value: "1;".  This 
is the second time I've seen this today.  What is its purpose?

Thanks!

RobR

--- Dan Muey <[EMAIL PROTECTED]> wrote:
   

sub stumpy_function1 {

	use CGI;
	blah blah blah
}

sub stumpy_function1 {

	use CGI;
	blah blah blah
}

1;
 


__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now. 
   

http://mailplus.yahoo.com

 


--
Benjamin J. Siders
Software Engineer




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




RE: Probably a simple hash question

2003-01-23 Thread Dan Muey


> Morning, Dan

Morning!

> 
> At 11:50 AM 1/23/2003 -0600, you wrote:
> > > i.e. $categories('1094') = 100049-0220-14
> >
> >  do you mean $catagories{'1094'} ?
> 
> Yup, I did.  Never type anything in from memory :-)

I can't anyway because my memory doesn't work.

> 
> 
> > > value is there.  (I can
> >
> >if(exists $catagories{$ccid}) {  }

Also if it would help you could do :

if(!exists $catagories{$ccid}) {  }
Which is saying if the key $ccid does *not* exist in the hash catagories then { ...}
Were as the first one was saying
If the key does exist in the hash ctatgories the {  }

> 
> Coolness.  So then, if I can talk out loud a second,
> to get the value out, I should be able to just say something 
> like $myID = $categories{$ccid}, right? It was returning 

Right, or instead of :
$myID = $categories{$ccid};
print $myID;
You could just do :
print $categories{$ccid};
Or otherwse just use $categories{$ccid} where you would want to use $myID
And save a step or two.

Isn't perl fun?!

> NULL, but I may have swapped out the key with the value when 
> I was initially setting it up.
> 
> 
> Have a most excellent day
> lara
> -
> Lara J. Fabans
> Lodestone Software, Inc
> [EMAIL PROTECTED]
> 
> 

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




Re: Quick regex prob

2003-01-23 Thread Rob Dixon
Dan Muey wrote:
> Hiya, I'm having a brain melt right now :
>
> I do this to match one word only.
> m/^(\w+)$/)

That matches an entire line which is just a string of 'word'
characters ( A-Z, a-z, 0-9, and underscore ).

> What regex do I need to match multiple , unkown ammounts of words?
> Will this do it? Or is there a better way?
> m/^\w[\w*|\s*]\w$/

Well, it doesn't seem a very interesting thing to want to do, but I
think you mean:

/^\w[\w\s]*\w$/

which matches an entire line consisting of word characters or
whitespace,
with no leading or trailing whitespace. Is that what you wanted?

One restriction - the least thing it'll match is two word characters. If
you
want a single-character line to match do this:

/^\w(?:[\w\s]*\w)?$/

which still won't match an empty line. Do you need that too?

Cheers,

Rob




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




RE: Quick regex prob

2003-01-23 Thread Dan Muey


> Dan Muey wrote:
> > Hiya, I'm having a brain melt right now :
> >
> > I do this to match one word only.
> > m/^(\w+)$/)
> 
> That matches an entire line which is just a string of 'word' 
> characters ( A-Z, a-z, 0-9, and underscore ).
> 
> > What regex do I need to match multiple , unkown ammounts of words? 
> > Will this do it? Or is there a better way? m/^\w[\w*|\s*]\w$/
> 
> Well, it doesn't seem a very interesting thing to want to do, 
> but I think you mean:
> 
> /^\w[\w\s]*\w$/

yup
> 
> which matches an entire line consisting of word characters or 
> whitespace, with no leading or trailing whitespace. Is that 
> what you wanted?
> 
> One restriction - the least thing it'll match is two word 
> characters. If you want a single-character line to match do this:
> 
> /^\w(?:[\w\s]*\w)?$/

cool
> 
> which still won't match an empty line. Do you need that too?

I don't think so but if I did all I would need to is :
/(^$)|(^\w(?:[\w\s]*\w)?$)/

Right?

Thanks again Rob , I'm getting farther and farther from that genius award!


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

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




Re: Removing HTML Tags

2003-01-23 Thread david
Colin Johnstone wrote:

> I guess Im looking for a regex to remove anything between the font tags
> e.g and . Of course their could be anynumber of attributes in
> the openning font tag.

i know the temptation is to just use a reg. exp. but you should really 
consider using module that has proven to be working. not only you will be 
confident that the module will work, the module will probably provide more 
functionality that makes your script more extensiveable in the future. a 
large part of becoming proficient programmer is to learn to use the 
libraries that the language provides. for example, the HTML::Parser module 
in CPAN is designed just for parsing HTML page. to remove the  tag, 
for example:

#!/usr/bin/perl -w
use strict;

use HTML::Parser;

my $text = new(
api_version => 3,
text_h  => [sub{ print shift;}, 'dtext'],
start_h => [sub{ print shift;}, 'text'],
end_h   => [sub{ print shift;}, 'text']);

$html->ignore_tags(qw(font));

$html->parse($text);
$html->eof;

__END__

prints:

Some text.
italics
bold

Hi There
ABC Hi


you might be thinking that a one liner reg. exp. is a lot less to type but 
notice how clean your script reads without tons of reg. exp. Of course, 
there is nothing wrong with trying out the reg. exp. for educational 
purpose.

david

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




RE: Quick regex prob

2003-01-23 Thread Liebert, Sander
/^\w(?:[\w\s]*\w)?$/  works well for multiple words, but how do I check a
date that is in the format 01/22/03

I think that it is hanging up on the / 


Thanks for everyone's help.

Sander

-Original Message-
From: Dan Muey [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 23, 2003 1:09 PM
To: Rob Dixon; [EMAIL PROTECTED]
Subject: RE: Quick regex prob




> Dan Muey wrote:
> > Hiya, I'm having a brain melt right now :
> >
> > I do this to match one word only.
> > m/^(\w+)$/)
> 
> That matches an entire line which is just a string of 'word' 
> characters ( A-Z, a-z, 0-9, and underscore ).
> 
> > What regex do I need to match multiple , unkown ammounts of words? 
> > Will this do it? Or is there a better way? m/^\w[\w*|\s*]\w$/
> 
> Well, it doesn't seem a very interesting thing to want to do, 
> but I think you mean:
> 
> /^\w[\w\s]*\w$/

yup
> 
> which matches an entire line consisting of word characters or 
> whitespace, with no leading or trailing whitespace. Is that 
> what you wanted?
> 
> One restriction - the least thing it'll match is two word 
> characters. If you want a single-character line to match do this:
> 
> /^\w(?:[\w\s]*\w)?$/

cool
> 
> which still won't match an empty line. Do you need that too?

I don't think so but if I did all I would need to is :
/(^$)|(^\w(?:[\w\s]*\w)?$)/

Right?

Thanks again Rob , I'm getting farther and farther from that genius award!


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

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

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




RE: Quick regex prob

2003-01-23 Thread Dan Muey


> /^\w(?:[\w\s]*\w)?$/  works well for multiple words, but how 
> do I check a date that is in the format 01/22/03
> 
> I think that it is hanging up on the / 

You have to escape the / by backslaching it \/. 
Didn't you get my last email about it?
Glad you joined the list!

Dan

> 
> 
> Thanks for everyone's help.
> 
> Sander
> 
> -Original Message-
> From: Dan Muey [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 23, 2003 1:09 PM
> To: Rob Dixon; [EMAIL PROTECTED]
> Subject: RE: Quick regex prob
> 
> 
> 
> 
> > Dan Muey wrote:
> > > Hiya, I'm having a brain melt right now :
> > >
> > > I do this to match one word only.
> > > m/^(\w+)$/)
> > 
> > That matches an entire line which is just a string of 'word'
> > characters ( A-Z, a-z, 0-9, and underscore ).
> > 
> > > What regex do I need to match multiple , unkown ammounts of words?
> > > Will this do it? Or is there a better way? m/^\w[\w*|\s*]\w$/
> > 
> > Well, it doesn't seem a very interesting thing to want to do,
> > but I think you mean:
> > 
> > /^\w[\w\s]*\w$/
> 
> yup
> > 
> > which matches an entire line consisting of word characters or
> > whitespace, with no leading or trailing whitespace. Is that 
> > what you wanted?
> > 
> > One restriction - the least thing it'll match is two word
> > characters. If you want a single-character line to match do this:
> > 
> > /^\w(?:[\w\s]*\w)?$/
> 
> cool
> > 
> > which still won't match an empty line. Do you need that too?
> 
> I don't think so but if I did all I would need to is : 
> /(^$)|(^\w(?:[\w\s]*\w)?$)/
> 
> Right?
> 
> Thanks again Rob , I'm getting farther and farther from that 
> genius award!
> 
> 
> > 
> > Cheers,
> > 
> > Rob
> > 
> > 
> > 
> > 
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




Re: Rather complex regular expression for the preg_match_all function

2003-01-23 Thread david
Andreas Sheriff wrote:

> 
> I don't want to find  tags with a complete structure.
> ex: This is a 

tag with a complete structure > > Instead, I want to find the tag with no closing tag, up to the next > tag or a closing tag of any type that doesn't have an opening tag > after the initial found (not including this orphaned closing tag) > a reg. exp. is probably not worth the time. have you try HTML::Parser yet? for example: #!/usr/bin/perl -w use strict; use HTML::Parser; my $text = new(api_version => 3, text_h => [\&text,'dtext'], start_h => [\&open_tag, 'tagname'], end_h => [\&close_tag,'tagname']); $html->parse($text); $html->eof; print @buff if(@buff); sub text{ my $text = shift; #-- reg. just for fun :-) push(@buff,"$text") if($p_tag && $text =~ /\w/); } sub open_tag{ return unless(shift eq 'p'); if($p_tag){ print @buff; @buff = (); } $p_tag = 1; } sub close_tag{ @buff = () and $p_tag = 0 if(shift eq 'p' && $p_tag); } __END__ prints: I want to find this p tag and up to the next opening p tagtestI want to find this one too second time i have recommand HTML::Parser in a day :-) david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]


Re: Resolving IP's/Hostmasks

2003-01-23 Thread david
Dan wrote:

> 
> i've had a look at the Net::hostent
> package that was suggested to me, seems ok, yet to grasp with how it
> works
> 

Net::hostent is easy to use:

#!/usr/bin/perl -w
use strict;

use Net::hostent qw(gethost);

my $h = gethost('216.239.51.101');
if($h){
print $h->name,"\n";
}

__END__

prints:

www.google.com

david

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




How to name STDIN from the command line

2003-01-23 Thread Michael Corgan
How do I name the STDIN from the command line.  I'm trying to write a simple 
script to randomly pick a file from a file name I enter on the command line. 
 This is what I have:

my @cards = (<>); #set stdin to @cards
while (<>) {
   my $random = rand(@cards);
   my $question = $cards[$random];
   chomp $question;
   print $question;
}

_
Add photos to your e-mail with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail


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



RE: How to name STDIN from the command line

2003-01-23 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Michael Corgan wrote:
> How do I name the STDIN from the command line.  I'm trying to write a
> simple script to randomly pick a file from a file name I enter on the
>   command line. This is what I have:
> 
> my @cards = (<>); #set stdin to @cards
> while (<>) {
> my $random = rand(@cards);
> my $question = $cards[$random];
> chomp $question;
> print $question;
> }
> 
@ARGV holds the params passed to the script, so you can use @ARGV or
transfer the info to your array.

Wags ;)


**
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.



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




my struggle to work with structures... pls hlp!

2003-01-23 Thread Peter_Farrar

Hi All,

I'm playing with record formats.  I need to be able to have more than one
kind of delimited
format available at one time.  I've written a sort routine to get the
values in the order
I want, but it assumes one variable name (in this example that is
%delimited format).  I want
something a little more dynamic.  I've tried passing the structure to the
sort routine, but
it wont play along.  Perhaps I'm approaching this all wrong.  Perhaps I'm
missing something
simple.  Any ideas how to better handle this?  Code example follows:

%delimited_format = (
  delimiter => "|",
  fields => { field_three => {index => 3,value => "THREE"},
field_two => {index => 2,value => "TWO"},
field_one => {index => 1,value => "ONE"},
field_four => {index => 4,value => "FOUR"},
field_five => {index => 5,value => "FIVE"},
  },
);

## this part wont work...
#foreach my $fieldname ( sort delim_sort(\%delimited_format) keys %
{$delimited_format{fields}}){
# print "$fieldname\t";
# print ${${$delimited_format{fields}}{$fieldname}}{index}."\t";
# print $delimited_format{delimiter}."\n";
#}
#sub delim_sort{
# my $hRef = shift;
# ${${${$hRef}{fields}}{$a}}{index}
# <=>
# ${${${$hRef}{fields}}{$b}}{index}
#}

## this part will work...
foreach my $fieldname ( sort old_delim_sort keys %
{$delimited_format{fields}}){
  print "$fieldname\t";
  print ${${$delimited_format{fields}}{$fieldname}}{index}."\t";
  print $delimited_format{delimiter}."\n";
}
sub old_delim_sort{
  ${${$delimited_format{fields}}{$a}}{index}
  <=>
  ${${$delimited_format{fields}}{$b}}{index}
}
__END__

TIA,
Peter





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




RE: How to name STDIN from the command line

2003-01-23 Thread Michael Corgan
I used the ARGV earlier, but received errors.  So this is how the script 
looks now:
#! /usr/local/bin/perl -w
use strict;
#
#
#

$/ = "\n%\n";

while (<>) {
   my $random = rand(@ARGV);
   my $question = $ARGV[$random];
   chomp $question;
   print $question;

This is the error I am getting back:

Use of uninitialized value at /home/mcorgan/bin/flash line 12, <> chunk 1.
Use of uninitialized value at /home/mcorgan/bin/flash line 13, <> chunk 1.
Use of uninitialized value at /home/mcorgan/bin/flash line 12, <> chunk 2.
Use of uninitialized value at /home/mcorgan/bin/flash line 13, <> chunk 2.

Aren't I initializing the values with the "my" before the scalar variables?




From: "Wagner, David --- Senior Programmer Analyst --- WGO"	 
<[EMAIL PROTECTED]>
To: 'Michael Corgan' <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
Subject: RE: How to name STDIN from the command line
Date: Thu, 23 Jan 2003 14:18:24 -0600

Michael Corgan wrote:
> How do I name the STDIN from the command line.  I'm trying to write a
> simple script to randomly pick a file from a file name I enter on the
>   command line. This is what I have:
>
> my @cards = (<>); #set stdin to @cards
> while (<>) {
> my $random = rand(@cards);
> my $question = $cards[$random];
> chomp $question;
> print $question;
> }
>
	@ARGV holds the params passed to the script, so you can use @ARGV or
transfer the info to your array.

Wags ;)


**
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.



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


_
Protect your PC - get McAfee.com VirusScan Online  
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


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



RE: How to name STDIN from the command line

2003-01-23 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Michael Corgan wrote:
> I used the ARGV earlier, but received errors.  So this is how the
> script looks now:
> #! /usr/local/bin/perl -w
> use strict;
> #
> #
> #
> 
> $/ = "\n%\n";
> 
> while (<>) {
> my $random = rand(@ARGV);
> my $question = $ARGV[$random];
> chomp $question;
> print $question;
> 
> This is the error I am getting back:
> 
> Use of uninitialized value at /home/mcorgan/bin/flash line 12, <>
> chunk 1. Use of uninitialized value at /home/mcorgan/bin/flash line
> 13, <> chunk 1. Use of uninitialized value at /home/mcorgan/bin/flash
> line 12, <> chunk 2. Use of uninitialized value at
> /home/mcorgan/bin/flash line 13, <> chunk 2. 
> 
> Aren't I initializing the values with the "my" before the scalar
> variables? 
> 
> 
Micheal,
   Unsure what you are trying to do? You say you are picking from a
file which you are inputting via the command line. Then what?  I see you
picking the the file then print the file. Is that what you want to do? The
while (<>) would read data in from one file after another until all files
are gone.

Need some other insight on what you are trying.

Wags ;)


**
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.



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




Using HTML::Parser question

2003-01-23 Thread Dan Muey
Using the excellent example in the an earlier post from david:
RE: Removing HTML Tags

I came up with this slightly modified version based on the post and some cpan 
documentation and it works. 
It just brought up a few more questions.
Basically I'm just trying to grab the body contents without comments or script stuff.

So far this module is really cool and handy!!

#!/usr/bin/perl

use HTML::Parser;

my $text = <
 HI Title 
heaD STUFF


hI HERE'S CONTENT i WANT



i DON'T WANT THIS SCRIPT EITHER






HTML

my $html = HTML::Parser->new(
api_version => 3,
text_h  => [sub{ print shift;}, 'dtext'],
start_h => [sub{ print shift;}, 'text'],
end_h   => [sub{ print shift;}, 'text']);

#Q) Before I kill the head section or body tags below how do I grab these parts of it?
#   1 - my $title =  IE the text between title tags
#   2 - get body tag attributes my $body_attributes =  IE in this example it'd 
be 'bodytag=attributes'

$html->ignore_elements(qw(head script));
$html->ignore_tags(qw(html body));

$html->parse($text);
$html->eof;



It automatically prints the modified version of $text without any print statement.
Q) Why is that? 
Q) How can I save the new version of $text to a new variable instead of automatically 
printing it to the screen? 
( so I can remove empty lines and have my way with it )
Q) I wanted any comments removed too but I didn't do anything special to it and they 
are gone anyway, are comments removed automatically then?

OUTPUT ::
(dmuey@q42(~):21)$ ./html.pl 



hI HERE'S CONTENT i WANT






(dmuey@q42(~):22)$ 


Thanks

Dan

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




Only numbers

2003-01-23 Thread dan
Hey again,

I want to be able to check if a string contains only a number, no letters,
etc. I have this procedure:

if ($numexs =~ /[0-9]/{
# do something
}

which doesn't do what I want it to do, I want it to do more or less this:
if ($numexs contains anything other than numbers) {
# do something
}

All help much appreciated.

Dan



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




Install a Module ???

2003-01-23 Thread Larry Sandwick
I am trying to install a Perl module on a Redhat 7.2 machine. Where do I
put the module before I perform the following:



Perl Makefile.PL

Make

Make test

Make install

 

I have uncompressed the file in a directory as "root" . Is there a
certain directory is should be in  ?  

 

Larry Sandwick

Sarreid, Ltd.

Network Administrator

(252) 291-1414 x223

 




RE: Only numbers

2003-01-23 Thread Dan Muey


 
> Hey again,
> 
> I want to be able to check if a string contains only a 
> number, no letters, etc. I have this procedure:
> 
> if ($numexs =~ /[0-9]/{
> # do something
> }
> 
> which doesn't do what I want it to do, I want it to do more 
> or less this: if ($numexs contains anything other than numbers) {
> # do something
> }

if($numexs !~ m/^(\d+)$/) {
print "Bab Monkey you must use all digits, try again or no bannans for you!";
}

> 
> All help much appreciated.
> 
> Dan
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




Re: Only numbers

2003-01-23 Thread Pete Emerson
if ($numexs=~/^\d+$/) {
# do this if $numexs contains 1 or more numbers, nothing else
} else {

}

Your regex just checks to make sure there's one number in your entire
string. Anchor it at the beginning and the end, and then use a + to say
"one or more occurances of" ...
if ($numexs=~/^[0-9]+$/) { .

\d is the same as [0-9]

On Thu, 2003-01-23 at 16:26, dan wrote:

> if ($numexs =~ /[0-9]/{
> # do something
> }
> 
> which doesn't do what I want it to do, I want it to do more or less this:
> if ($numexs contains anything other than numbers) {
> # do something
> }


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




RE: Only numbers

2003-01-23 Thread Wagner, David --- Senior Programmer Analyst --- WGO
dan wrote:
> Hey again,
> 
> I want to be able to check if a string contains only a number, no
> letters, etc. I have this procedure:
> 
> if ($numexs =~ /[0-9]/{
> # do something
> }
> 
> which doesn't do what I want it to do, I want it to do more or less
> this: if ($numexs contains anything other than numbers) {
> # do something
> }
> 
> All help much appreciated.
> 
> Dan

if ( $numexs =~ /^[-+]{0,1}\d+\.{0,1}\d{0,}/ ) {
   # a number of format: nnn, -nnn, +nnn, -nn.nnn, etc)
 }else {
   # not a number
 }

Wags ;)


**
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.



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




Tk with Perl

2003-01-23 Thread Tony Esposito
Help
I have installed Perl 5.6.1 ( which works ) and Tcl/Tk 8.3 ( which
works ) on Windows 2000 but when I try to perl -e "use Tk" I get the
following error:

Can't locate Tk.pm in @INC ( @INC contains: D:/Perl 5.6.1/lib
D:/Perl 5.6.1/site/lib . ) at -e line 1.

And I can not find any file name Tk.pm on my system.  How is this
file created?  Where should it be?
Thanks!

Anthony (Tony) Esposito
Database Administrator
Inovis(tm), formerly Harbinger and Extricity
2425 North Central Expressway
Suite 900
Richardson, Texas 75080, USA
Direct (972)643-3115
Fax (972)479-9779



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




RE: Using HTML::Parser question

2003-01-23 Thread Dan Muey


> Using the excellent example in the an earlier post from david:
> RE: Removing HTML Tags
> 
> I came up with this slightly modified version based on the 
> post and some cpan documentation and it works. 
> It just brought up a few more questions.
> Basically I'm just trying to grab the body contents without 
> comments or script stuff.
> 
> So far this module is really cool and handy!!
> 
> #!/usr/bin/perl
> 
> use HTML::Parser;
> 
> my $text = < 
> 
>  HI Title 
> heaD STUFF
> 
> 
> hI HERE'S CONTENT i WANT
> 
> 
> 
> i DON'T WANT THIS SCRIPT EITHER
> 
> 
> 
> 
> 
> 
> HTML
> 
> my $html = HTML::Parser->new(
> api_version => 3,
> text_h  => [sub{ print shift;}, 'dtext'],
> start_h => [sub{ print shift;}, 'text'],
> end_h   => [sub{ print shift;}, 'text']);


Ok I see why it's printing. I tell it to right here!
Instead of print shift; I do $temp .= shift; and now $temp holds that data.
One down two to go!


> 
> #Q) Before I kill the head section or body tags below how do 
> I grab these parts of it?
> # 1 - my $title =  IE the text between title tags
> # 2 - get body tag attributes my $body_attributes =  
> IE in this example it'd be 'bodytag=attributes'
> 
> $html->ignore_elements(qw(head script)); 
> $html->ignore_tags(qw(html body));
> 
> $html->parse($text);
> $html->eof;
> 
> 
> 
> It automatically prints the modified version of $text without 
> any print statement.
> Q) Why is that? 
> Q) How can I save the new version of $text to a new variable 
> instead of automatically printing it to the screen? 
>   ( so I can remove empty lines and have my way with it )
> Q) I wanted any comments removed too but I didn't do anything 
> special to it and they are gone anyway, are comments removed 
> automatically then?
> 
> OUTPUT ::
> (dmuey@q42(~):21)$ ./html.pl 
> 
> 
> 
> hI HERE'S CONTENT i WANT
> 
> 
> 
> 
> 
> 
> (dmuey@q42(~):22)$ 
> 
> 
> Thanks
> 
> Dan
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




Re: Tk with Perl

2003-01-23 Thread Peter_Farrar

>I have installed Perl 5.6.1 ( which works ) and Tcl/Tk 8.3 (
which
>works ) on Windows 2000 but when I try to perl -e "use Tk" I get the
>following error:
>
>Can't locate Tk.pm in @INC ( @INC contains: D:/Perl 5.6.1/lib
>D:/Perl 5.6.1/site/lib . ) at -e line 1.

Have you downloaded and installed the Tk.pm from ActiveState.com?  It is
not installed with Perl or Tcl by default.

The actual module is "D:\Perl\site\lib\Tk.pm" on my box.  YMMV (?).




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




RE: Tk with Perl

2003-01-23 Thread Tony Esposito
I did get my Perl and Tcl/Tk from ActiveState.com.  So what you are saying
is I just have to download this Tk.pm file from ActiveState.com and install
it in D:\Perl\site\lib\Tk.pm and I'll be ok, correct?
Thanks!

Anthony (Tony) Esposito
Database Administrator
Inovis(tm), formerly Harbinger and Extricity
2425 North Central Expressway
Suite 900
Richardson, Texas 75080, USA
Direct (972)643-3115
Fax (972)479-9779



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 23, 2003 3:41 PM
To: Tony Esposito
Cc: [EMAIL PROTECTED]
Subject: Re: Tk with Perl



>I have installed Perl 5.6.1 ( which works ) and Tcl/Tk 8.3 (
which
>works ) on Windows 2000 but when I try to perl -e "use Tk" I get the
>following error:
>
>Can't locate Tk.pm in @INC ( @INC contains: D:/Perl 5.6.1/lib
>D:/Perl 5.6.1/site/lib . ) at -e line 1.

Have you downloaded and installed the Tk.pm from ActiveState.com?  It is
not installed with Perl or Tcl by default.

The actual module is "D:\Perl\site\lib\Tk.pm" on my box.  YMMV (?).



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




RE: Install a Module ???

2003-01-23 Thread wiggins


On Thu, 23 Jan 2003 16:30:45 -0500, "Larry Sandwick" <[EMAIL PROTECTED]> wrote:

> I am trying to install a Perl module on a Redhat 7.2 machine. Where do I
> put the module before I perform the following:
> 
> 
> 
> Perl Makefile.PL
> 
> Make
> 
> Make test
> 
> Make install
> 
>  
> 
> I have uncompressed the file in a directory as "root" . Is there a
> certain directory is should be in  ?  
> 

Shouldn't matter. If we are being strict, you should probably configure, build, and 
test the module as a regular unprivileged user, and then only install with privileges, 
but few people worry about it that much probably.  Have you considered using CPAN? 
Certainly there are reasons not to use it, but always try and mention it if someone 
hasn't tried it before

http://danconia.org

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




RE: Only numbers

2003-01-23 Thread Bob Showalter
dan wrote:
> I want to be able to check if a string contains only a number, no
> letters, etc. I have this procedure:
> 
> if ($numexs =~ /[0-9]/{
> # do something
> }
> 
> which doesn't do what I want it to do, I want it to do more or less
> this: if ($numexs contains anything other than numbers) { # do
> something }

  if ($numesx =~ /\D/) {
 # $numesx contains a non-digit
  
  } else {
 # $numesx contains only digits 0 through 9

  }


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




Re: Using HTML::Parser question

2003-01-23 Thread david
Dan Muey wrote:

> 
> #Q) Before I kill the head section or body tags below how do I grab these
> #parts of it? 1 - my $title =  IE the text between title tags
> #2 - get body tag attributes my $body_attributes =  IE in this example
> #it'd be 'bodytag=attributes'
> 

grabs the title and body text and attributes:

#!/usr/bin/perl -w
use strict;

use HTML::Parser;

my $text = <
 HI Title 
heaD STUFF


hI HERE'S CONTENT i WANT



i DON'T WANT THIS SCRIPT EITHER





HTML

my $body = 0;
my $title = 0;
my @body;
my @title;

my $html = HTML::Parser->new(api_version => 3,
text_h => [\&text,'dtext'],
start_h => [\&open_tag, 'tagname,attr'],
end_h   => [\&close_tag, 'tagname']);
$html->ignore_elements(qw(script));
$html->parse($text);
$html->eof;

print "TITLE @title\n";
print "BODY @body\n";

sub text{

my $text = shift;

return unless($text =~ /\w/);

if($title){
push(@title,$text);
}elsif($body){
push(@body,$text);
}
}

sub open_tag{

my $tagname = shift;
my $attr= shift;

$title = 1 if($tagname eq 'title');

$body = 1,push(@body,join('=',%{$attr})) 
  if($tagname eq 'body');
}

sub close_tag{

my $tagname = shift;

$title = 0 if($tagname eq 'title');
$body  = 0 if($tagname eq 'body');
}

__END__

prints:

TITLE  HI Title
BODY bodytag=attributes
hI HERE'S CONTENT i WANT

there are many ways of doing the same thing.

> 
> It automatically prints the modified version of $text without any print
> statement. Q) Why is that?

no. it doesn't print it automatically. i have print statment for this to 
print out.

> Q) How can I save the new version of $text to a new variable instead of
> automatically printing it to the screen? ( so I can remove empty lines and
> have my way with it ) Q) I wanted any comments removed too but I didn't do
> anything special to it and they are gone anyway, are comments removed
> automatically then?

just remove the print statment and store it as you want.
comments are not removed by default, i don't think.

david

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




RE: How to name STDIN from the command line

2003-01-23 Thread Michael Corgan
What I'm trying to write is a script to randomly write to standard output 
questions in a file everytime I execute the script.  I seem to be getting 
these errors, though and I'm just not sure what I'm doing wrong.  I'm not 
sure what the errors are telling me.



From: "Wagner, David --- Senior Programmer Analyst --- WGO" 
<[EMAIL PROTECTED]>
To: 'Michael Corgan' <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
Subject: RE: How to name STDIN from the command line
Date: Thu, 23 Jan 2003 15:14:17 -0600

Michael Corgan wrote:
> I used the ARGV earlier, but received errors.  So this is how the
> script looks now:
> #! /usr/local/bin/perl -w
> use strict;
> #
> #
> #
>
> $/ = "\n%\n";
>
> while (<>) {
> my $random = rand(@ARGV);
> my $question = $ARGV[$random];
> chomp $question;
> print $question;
>
> This is the error I am getting back:
>
> Use of uninitialized value at /home/mcorgan/bin/flash line 12, <>
> chunk 1. Use of uninitialized value at /home/mcorgan/bin/flash line
> 13, <> chunk 1. Use of uninitialized value at /home/mcorgan/bin/flash
> line 12, <> chunk 2. Use of uninitialized value at
> /home/mcorgan/bin/flash line 13, <> chunk 2.
>
> Aren't I initializing the values with the "my" before the scalar
> variables?
>
>
	Micheal,
	   Unsure what you are trying to do? You say you are picking from a
file which you are inputting via the command line. Then what?  I see you
picking the the file then print the file. Is that what you want to do? The
while (<>) would read data in from one file after another until all files
are gone.

	Need some other insight on what you are trying.

Wags ;)


**
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.



_
The new MSN 8: advanced junk mail protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail


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



RE: Tk with Perl

2003-01-23 Thread Bob Showalter
Tony Esposito wrote:
> I did get my Perl and Tcl/Tk from ActiveState.com.  So what you are
> saying is I just have to download this Tk.pm file from
> ActiveState.com and install
> it in D:\Perl\site\lib\Tk.pm and I'll be ok, correct? Thanks!

No, you don't just copy the .pm file. You need to use ppm to install the
module, which installs a ton of files.

  C:\> ppm install Tk

But are you using an ancient verison of ActiveState Perl? Because Tk comes
standard with recent versions, AFAIK.

Note that Perl's Tk module is separate from Tcl/Tk and doesn't use or
require Tcl/Tk to be installed.

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




Re: my struggle to work with structures... pls hlp!

2003-01-23 Thread david
Peter Farrar wrote:

> 
> ## this part wont work...
> #foreach my $fieldname ( sort delim_sort(\%delimited_format) keys %
> {$delimited_format{fields}}){
> # print "$fieldname\t";
> # print ${${$delimited_format{fields}}{$fieldname}}{index}."\t";
> # print $delimited_format{delimiter}."\n";
> #}
> #sub delim_sort{
> # my $hRef = shift;
> # ${${${$hRef}{fields}}{$a}}{index}
> # <=>
> # ${${${$hRef}{fields}}{$b}}{index}
> #}
> 

it won't even compile. sort wants a sub ref., not a sub call. even if it 
compiles, you won't get the result you expect because sort calls your 
function without any parameter.

david

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




RE: Tk with Perl

2003-01-23 Thread Tony Esposito
I am using ActiveState Perl 5.6.1.  That does not seem too old to me.  Is
there an ftp site where I can download Tk.pm?
Then I will install Tk using the Perl Package Mgr.
Thanks!

Anthony (Tony) Esposito
Database Administrator
Inovis(tm), formerly Harbinger and Extricity
2425 North Central Expressway
Suite 900
Richardson, Texas 75080, USA
Direct (972)643-3115
Fax (972)479-9779



-Original Message-
From: Bob Showalter [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 23, 2003 4:06 PM
To: Tony Esposito
Cc: [EMAIL PROTECTED]
Subject: RE: Tk with Perl


Tony Esposito wrote:
> I did get my Perl and Tcl/Tk from ActiveState.com.  So what you are
> saying is I just have to download this Tk.pm file from
> ActiveState.com and install
> it in D:\Perl\site\lib\Tk.pm and I'll be ok, correct? Thanks!

No, you don't just copy the .pm file. You need to use ppm to install the
module, which installs a ton of files.

  C:\> ppm install Tk

But are you using an ancient verison of ActiveState Perl? Because Tk comes
standard with recent versions, AFAIK.

Note that Perl's Tk module is separate from Tcl/Tk and doesn't use or
require Tcl/Tk to be installed.

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




RE: How to name STDIN from the command line

2003-01-23 Thread david
Michael Corgan wrote:

> What I'm trying to write is a script to randomly write to standard output
> questions in a file everytime I execute the script.  I seem to be getting
> these errors, though and I'm just not sure what I'm doing wrong.  I'm not
> sure what the errors are telling me.
> 

have you try:

#!/usr/bin/perl -w
use strict;

#--
#-- random.pl
#--
push(my @buffer,<>);

print $buffer[int(rand(@buffer))];

__END__

[panda@dzhuo]$ random.pl foo.txt
cat,084328
[panda@dzhuo]$

prints a random line from foo.txt. this is NOT the best approach (ie, if 
file is big, it will eat up a lot of memory). there are better methods and 
if you are interested, a lot of people here can give you guide line.

david


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




RE: Using HTML::Parser question

2003-01-23 Thread Dan Muey


Sweet! Thanks. I'll give her a try and study it to understand it better. Thanks!

Dan

> Dan Muey wrote:
> 
> > 
> > #Q) Before I kill the head section or body tags below how do I grab 
> > these #parts of it? 1 - my $title =  IE the text between title 
> > tags #2 - get body tag attributes my $body_attributes =  IE in 
> > this example #it'd be 'bodytag=attributes'
> > 
> 
> grabs the title and body text and attributes:
> 
> #!/usr/bin/perl -w
> use strict;
> 
> use HTML::Parser;
> 
> my $text = < 
>  HI Title 
> heaD STUFF
> 
> 
> hI HERE'S CONTENT i WANT
> 
> 
> 
> i DON'T WANT THIS SCRIPT EITHER
> 
> 
> 
> 
> 
> HTML
> 
> my $body = 0;
> my $title = 0;
> my @body;
> my @title;
> 
> my $html = HTML::Parser->new(api_version => 3,
> text_h => [\&text,'dtext'],
> start_h => [\&open_tag, 
> 'tagname,attr'],
> end_h   => [\&close_tag, 'tagname']);
> $html->ignore_elements(qw(script));
> $html->parse($text);
> $html->eof;
> 
> print "TITLE @title\n";
> print "BODY @body\n";
> 
> sub text{
> 
> my $text = shift;
> 
> return unless($text =~ /\w/);
> 
> if($title){
> push(@title,$text);
> }elsif($body){
> push(@body,$text);
> }
> }
> 
> sub open_tag{
> 
> my $tagname = shift;
> my $attr= shift;
> 
> $title = 1 if($tagname eq 'title');
> 
> $body = 1,push(@body,join('=',%{$attr})) 
>   if($tagname eq 'body');
> }
> 
> sub close_tag{
> 
> my $tagname = shift;
> 
> $title = 0 if($tagname eq 'title');
> $body  = 0 if($tagname eq 'body');
> }
> 
> __END__
> 
> prints:
> 
> TITLE  HI Title
> BODY bodytag=attributes
> hI HERE'S CONTENT i WANT
> 
> there are many ways of doing the same thing.
> 
> > 
> > It automatically prints the modified version of $text without any 
> > print statement. Q) Why is that?
> 
> no. it doesn't print it automatically. i have print statment 
> for this to 
> print out.
> 
> > Q) How can I save the new version of $text to a new 
> variable instead 
> > of automatically printing it to the screen? ( so I can remove empty 
> > lines and have my way with it ) Q) I wanted any comments 
> removed too 
> > but I didn't do anything special to it and they are gone 
> anyway, are 
> > comments removed automatically then?
> 
> just remove the print statment and store it as you want. 
> comments are not removed by default, i don't think.
> 
> david
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




RE: How to name STDIN from the command line

2003-01-23 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Michael Corgan wrote:
> What I'm trying to write is a script to randomly write to standard
> output questions in a file everytime I execute the script.  I seem to
> be getting these errors, though and I'm just not sure what I'm doing
> wrong.  I'm not sure what the errors are telling me.
> 
> 
1)  You might want the files already loaded into an array.
2)  Then you do your random select of the file
3)  open the file to and slurp in all the data into an array.
4)  Do a random on that second array to get the question you
want.
5)  display that to the screen
6)  Might want to setup some type of iteration count, so when
you go over that it will stop
processing.  As it is now, depending on the number of files
entered and the number of records read, will be the number of times you will
do the processing.  I don't believe this is what you are really after.

psuedo code:
counter
max
  while ( counter < max ) {
pull a random file
open random file and slurp all data into an array
pick a random question out of the slurped file
display question
increment counter ( though you could do that in the while as
counter++
 }  

Wags ;)


**
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.



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




Re: Install a Module ???

2003-01-23 Thread Jenda Krynicky
From: "Larry Sandwick" <[EMAIL PROTECTED]>
> I am trying to install a Perl module on a Redhat 7.2 machine. Where do
> I put the module before I perform the following:
> 
> Perl Makefile.PL
> Make
> Make test
> Make install
> 
> I have uncompressed the file in a directory as "root" . Is there a
> certain directory is should be in  ?  

It should be in some temporary directory. The exact location doesn't 
matter, but you have to be in the same directory when you run the 
commands.

Actually ... when extracting you have to make sure you extract the 
files with the directory structure. This should create a directory 
named something like Module-Name-x.x.x. chdir to that directory and 
run the commands above.

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


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




RE: Newb Help? Anyone?

2003-01-23 Thread Jenda Krynicky
From: "Dan Muey" <[EMAIL PROTECTED]>
> > Where could I find a good reference wrt starting Perl?
> 
> For a beginner I'd highly recommend the  Peachpit Press Visual Quick
> Start Guide to Perl By Elizabeth Castro ( I think ).
> 
> It starts by not assuming you are already a 30 year unix veterin and
> explains everything in plain english and gives you examples of using
> the different things. 

Different people need different introductory books ;-)

> Examples you can do right then and there and
> learn by doing, very helpful. That's something most of the oreilley
> books don't do really. They just basically Copy stuff straight from
> perldoc and assume you're going to understand What to do with that. 

Well ... the copying most often went in the exact oposite direction. 
The authors of the best known (not only) O'Reilly books are usualy 
the same people that wrote the man/perldoc pages. 

I agree though they too often assume you have a Unix backround.
I really love it when all the docs give you is a pointer to Unix 
manpages. All I get from 
man foo
is
'man' is not recognized as an internal or external command,
operable program or batch file.

> So basically once/while you learn perl, instead of buying Oreilley
> books just go to your unix prompt And type 'perldoc' , look at the
> options then you can use that to look up anything that you'll find in
> the oreilley books, Although you won't have the cool looking animals
> but oh well. It's free and it's the same thing.

And it's basicaly what I did back when I started learning Perl :-P

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


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




Re: Resolving IP's/Hostmasks

2003-01-23 Thread John W. Krahn
Dan wrote:
> 
> "John W. Krahn" <[EMAIL PROTECTED]> wrote in message
> >
> > $ perl -le'
> > use Socket;
> > sub resolve { inet_ntoa( scalar gethostbyname( $_[0] ) ) }
> > print resolve( "www.google.com" );
> > '
> > 216.239.51.101
> > $ perl -le'
> > use Socket;
> > sub resolve { inet_ntoa( scalar gethostbyname( $_[0] ) ) }
> > print resolve( "216.239.51.101" );
> > '
> > 216.239.51.101
> 
> my point exactly, it resolves hosts to ips, but not vice versa, and i need
> to know how to reverse resolve. i've had a look at the Net::hostent package
> that was suggested to me, seems ok, yet to grasp with how it works, but if
> there's a simpler solution, i'd like to know.

$ perl -le'
use Socket;
sub resolve {  inet_ntoa(scalar gethostbyname($_[0])) } 
print resolve( "www.google.com" );
'
216.239.39.101
$ perl -le'
use Socket;
$name = gethostbyaddr( inet_aton( "216.239.37.101" ), AF_INET );
print $name;  
'
www.google.com




John
-- 
use Perl;
program
fulfillment

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




RE: Tk with Perl

2003-01-23 Thread Perry, Alan
Tony Esposito wrote:
> I am using ActiveState Perl 5.6.1.  That does not seem too old to me.
> Is there an ftp site where I can download Tk.pm?
> Then I will install Tk using the Perl Package Mgr.

There is actually no need for that, as long as you have Internet access.  If
you type (note the "ppm3" instead of "ppm")...

ppm3 install Tk

...PPM will download it for you.

When I tried it though, it said that it was already installed.  I am running
5.6.1 (build 633), and have never installed Tk separately, but it was there
already.

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




RE: Newb Help? Anyone?

2003-01-23 Thread Dan Muey

Yeah different strokes for different folks. As long as it' perl and not Microsoft I'm 
happy ;)
> 
> From: "Dan Muey" <[EMAIL PROTECTED]>
> > > Where could I find a good reference wrt starting Perl?
> > 
> > For a beginner I'd highly recommend the  Peachpit Press 
> Visual Quick 
> > Start Guide to Perl By Elizabeth Castro ( I think ).
> > 
> > It starts by not assuming you are already a 30 year unix 
> veterin and 
> > explains everything in plain english and gives you examples 
> of using 
> > the different things.
> 
> Different people need different introductory books ;-)
> 
> > Examples you can do right then and there and
> > learn by doing, very helpful. That's something most of the oreilley 
> > books don't do really. They just basically Copy stuff straight from 
> > perldoc and assume you're going to understand What to do with that.
> 
> Well ... the copying most often went in the exact oposite direction. 
> The authors of the best known (not only) O'Reilly books are usualy 
> the same people that wrote the man/perldoc pages. 
> 
> I agree though they too often assume you have a Unix 
> backround. I really love it when all the docs give you is a 
> pointer to Unix 
> manpages. All I get from 
>   man foo
> is
>   'man' is not recognized as an internal or external command,
>   operable program or batch file.
> 
> > So basically once/while you learn perl, instead of buying Oreilley 
> > books just go to your unix prompt And type 'perldoc' , look at the 
> > options then you can use that to look up anything that 
> you'll find in 
> > the oreilley books, Although you won't have the cool 
> looking animals 
> > but oh well. It's free and it's the same thing.
> 
> And it's basicaly what I did back when I started learning Perl :-P
> 
> Jenda
> = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
> When it comes to wine, women and song, wizards are allowed 
> to get drunk and croon as much as they like.
>   -- Terry Pratchett in Sourcery
> 
> 

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




RE: Using HTML::Parser question

2003-01-23 Thread Dan Muey

Very nice, although I'd like to keep html tags that are between the body tags as well 
except script & comment.

Also @body contains the attributes of the body tag as well as all of the text in the 
body :

my $new_title = join '', @title;
my $new_body_atts = join(//,@body);

print "TITLE -$new_title- \n BODY ATTRIBUTES -$new_body_atts- \n";

Any ideas?


> 
> Dan Muey wrote:
> 
> > 
> > #Q) Before I kill the head section or body tags below how do I grab 
> > these #parts of it? 1 - my $title =  IE the text between title 
> > tags #2 - get body tag attributes my $body_attributes =  IE in 
> > this example #it'd be 'bodytag=attributes'
> > 
> 
> grabs the title and body text and attributes:
> 
> #!/usr/bin/perl -w
> use strict;
> 
> use HTML::Parser;
> 
> my $text = < 
>  HI Title 
> heaD STUFF
> 
> 
> hI HERE'S CONTENT i WANT
> 
> 
> 
> i DON'T WANT THIS SCRIPT EITHER
> 
> 
> 
> 
> 
> HTML
> 
> my $body = 0;
> my $title = 0;
> my @body;
> my @title;
> 
> my $html = HTML::Parser->new(api_version => 3,
> text_h => [\&text,'dtext'],
> start_h => [\&open_tag, 
> 'tagname,attr'],
> end_h   => [\&close_tag, 'tagname']);
> $html->ignore_elements(qw(script));
> $html->parse($text);
> $html->eof;
> 
> print "TITLE @title\n";
> print "BODY @body\n";
> 
> sub text{
> 
> my $text = shift;
> 
> return unless($text =~ /\w/);
> 
> if($title){
> push(@title,$text);
> }elsif($body){
> push(@body,$text);
> }
> }
> 
> sub open_tag{
> 
> my $tagname = shift;
> my $attr= shift;
> 
> $title = 1 if($tagname eq 'title');
> 
> $body = 1,push(@body,join('=',%{$attr})) 
>   if($tagname eq 'body');
> }
> 
> sub close_tag{
> 
> my $tagname = shift;
> 
> $title = 0 if($tagname eq 'title');
> $body  = 0 if($tagname eq 'body');
> }
> 
> __END__
> 
> prints:
> 
> TITLE  HI Title
> BODY bodytag=attributes
> hI HERE'S CONTENT i WANT
> 
> there are many ways of doing the same thing.
> 
> > 
> > It automatically prints the modified version of $text without any 
> > print statement. Q) Why is that?
> 
> no. it doesn't print it automatically. i have print statment 
> for this to 
> print out.
> 
> > Q) How can I save the new version of $text to a new 
> variable instead 
> > of automatically printing it to the screen? ( so I can remove empty 
> > lines and have my way with it ) Q) I wanted any comments 
> removed too 
> > but I didn't do anything special to it and they are gone 
> anyway, are 
> > comments removed automatically then?
> 
> just remove the print statment and store it as you want. 
> comments are not removed by default, i don't think.
> 
> david
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




RE: Tk with Perl

2003-01-23 Thread Tony Esposito
Trying it now from the Command Prompt.seems to be just 'sitting'
there.

Anthony (Tony) Esposito
Database Administrator
Inovis(tm), formerly Harbinger and Extricity
2425 North Central Expressway
Suite 900
Richardson, Texas 75080, USA
Direct (972)643-3115
Fax (972)479-9779



-Original Message-
From: Perry, Alan [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 23, 2003 4:32 PM
To: [EMAIL PROTECTED]
Cc: Tony Esposito
Subject: RE: Tk with Perl


Tony Esposito wrote:
> I am using ActiveState Perl 5.6.1.  That does not seem too old to me.
> Is there an ftp site where I can download Tk.pm?
> Then I will install Tk using the Perl Package Mgr.

There is actually no need for that, as long as you have Internet access.  If
you type (note the "ppm3" instead of "ppm")...

ppm3 install Tk

...PPM will download it for you.

When I tried it though, it said that it was already installed.  I am running
5.6.1 (build 633), and have never installed Tk separately, but it was there
already.

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




RE: How to use ATL COM components in perl

2003-01-23 Thread Toby Stuart


> -Original Message-
> From: Nilesh [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 23, 2003 11:55 AM
> To: [EMAIL PROTECTED]
> Subject: Re: How to use ATL COM components in perl
> 
> 
> 
> "Pankaj Kapare" <[EMAIL PROTECTED]> wrote in message
> 005901c2bf02$59dada70$a300a8c0@anurag">news:005901c2bf02$59dada70$a300a8c0@anurag...
> Hi,
>Can anybody tell me how to use perl components in perl.
> Pankaj.
> 

I think i answered this the other day.  Anyhoo ...

To access an OLE/COM servers properties/methods 
use the Win32::OLE module.

Note that Win32::OLE only supports the IDispatch interface 
ie. custom interfaces are not supported.  
Learn more in the Win32::OLE docs.

A trivial example follows


use strict;
use Win32::OLE;

my $obj = new Win32::OLE("MyObject.Class");

# Set a property
$obj->{MyProperty} = 1;

# Call a method
$obj->MyMethod();

# Destroy the object
undef $obj;



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




Re: Multiple use of same module question

2003-01-23 Thread Jenda Krynicky
From: "Dan Muey" <[EMAIL PROTECTED]>
> Here's something I've been wondering
> 
> What kind of performance issues are there if you do a 'use' on the
> same module in the same script twice or more?

Depends.
This can be verry different for different modules.

use Module;
does two things:
1. it loads, parses and compiles a module
2. it calls it's import() function

While the first action is only been done the very first time the 
module is use()d anywhere in your script, the import() will be called 
each time you use the module.

Try this:

#file Foo.pm
package Foo;
sub import {
print "Import called\n";
}
1;

#file foo.pl
use Foo;
use Foo;
use Foo;
print "ENDE\n";


The import() function usualy just import some functions or variables 
into the calling package in which you use()d the module, but there 
are some modules that do a lot more. They usualy do take care they do 
not do that twice though.

> Before you go ' Well that's stupid, why would you do that? ' let me
> explain :
> 
> Script one has 
> 
> use CGI; 
> ...
> If it does cause perfance issues is there a way to check and see if
> the module's already been 'use'd and then if it hasn't then do use ?
> 
> EG if(??) { use CGI; }

if (!exists $INC{'CGI.pm'}) {
eval "use CGI";
}
 
> What if you already did
> 
> Use CGI params; and in the sub routine you only need say use CGI
> self_url; ? Or if you did use CGI param earlier and the sin does use
> CGI;

I'm afraid you'll have to try this and see.

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


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




RE: Multiple use of same module question

2003-01-23 Thread Dan Muey

Thanks I'll do that.
> 
> From: "Dan Muey" <[EMAIL PROTECTED]>
> > Here's something I've been wondering
> > 
> > What kind of performance issues are there if you do a 'use' on the 
> > same module in the same script twice or more?
> 
> Depends.
> This can be verry different for different modules.
> 
>   use Module;
> does two things:
>   1. it loads, parses and compiles a module
>   2. it calls it's import() function
> 
> While the first action is only been done the very first time the 
> module is use()d anywhere in your script, the import() will be called 
> each time you use the module.
> 
> Try this:
> 
>   #file Foo.pm
>   package Foo;
>   sub import {
>   print "Import called\n";
>   }
>   1;
> 
>   #file foo.pl
>   use Foo;
>   use Foo;
>   use Foo;
>   print "ENDE\n";
> 
> 
> The import() function usualy just import some functions or variables 
> into the calling package in which you use()d the module, but there 
> are some modules that do a lot more. They usualy do take care they do 
> not do that twice though.
> 
> > Before you go ' Well that's stupid, why would you do that? ' let me 
> > explain :
> > 
> > Script one has
> > 
> > use CGI;
> > ...
> > If it does cause perfance issues is there a way to check and see if
> > the module's already been 'use'd and then if it hasn't then do use ?
> > 
> > EG if(??) { use CGI; }
> 
>   if (!exists $INC{'CGI.pm'}) {
>   eval "use CGI";
>   }
>  
> > What if you already did
> > 
> > Use CGI params; and in the sub routine you only need say use CGI 
> > self_url; ? Or if you did use CGI param earlier and the sin 
> does use 
> > CGI;
> 
> I'm afraid you'll have to try this and see.
> 
> Jenda
> = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
> When it comes to wine, women and song, wizards are allowed 
> to get drunk and croon as much as they like.
>   -- Terry Pratchett in Sourcery
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




Re: How to name STDIN from the command line

2003-01-23 Thread Rob Dixon
Michael Corgan wrote:
> I used the ARGV earlier, but received errors.  So this is how the
> script looks now:
> #! /usr/local/bin/perl -w
> use strict;
> #
> #
> #
>
> $/ = "\n%\n";

It looks like your file contains records separated by a % on its
own on a line? There are much better ways of doing this if so.

> while (<>) {
> my $random = rand(@ARGV);
> my $question = $ARGV[$random];
> chomp $question;
> print $question;


@ARGV is the list of files you specified on your command line, and
$ARGV[$random] is one of those files (or 'undef' if the index is
out of range). Is this what you wanted?

> This is the error I am getting back:
>
> Use of uninitialized value at /home/mcorgan/bin/flash line 12, <>
> chunk 1. Use of uninitialized value at /home/mcorgan/bin/flash line
> 13, <> chunk 1. Use of uninitialized value at /home/mcorgan/bin/flash
> line 12, <> chunk 2. Use of uninitialized value at
> /home/mcorgan/bin/flash line 13, <> chunk 2.
>
> Aren't I initializing the values with the "my" before the scalar
> variables?

It's not complaining about an undeclared variable but an 'uninitialized
value'. The two lines must be 'chomp' and 'print', which you're calling
after you've set $question to an uninitialized value from the array.
Your $random must be out of bounds for the size of the array - most
likely @ARGV is empty.

Note that your loop 'while (<>)' is reading lines from the contents
of these files. As it gets to the end of each file and goes on to
the next one the name of that file will go from the @ARGV array
until it is eventually empty. You certainly didn't mean to do this, and
you need to explain what you do intend. What does your command
line look like, what are the contents of your files like? What are the
things you're trying to select randomly from, and when do you want
to terminate that loop?

Let us know.

Cheers,

Rob




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




Re: How to name STDIN from the command line

2003-01-23 Thread Rob Dixon
David wrote:
>
> push(my @buffer,<>);

That's kinda fancy!

Any reason it's not:

my @buffer = <>;

:-?

Cheers,

Rob




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




RE: Using HTML::Parser question

2003-01-23 Thread david
Dan Muey wrote:

> 
> Very nice, although I'd like to keep html tags that are between the body
> tags as well except script & comment.
> 
> Also @body contains the attributes of the body tag as well as all of the
> text in the body :
> 
> my $new_title = join '', @title;
> my $new_body_atts = join(//,@body);
> 
> print "TITLE -$new_title- \n BODY ATTRIBUTES -$new_body_atts- \n";
> 
> Any ideas?
> 

so you want to:
1. get title
2. get body but without comment and script
3. all other tags except comment and script should be included
4. attribute from body should not be part of body

#!/usr/bin/perl -w
use strict;

use HTML::Parser;

my $text = <
 HI Title 
heaD STUFF


hI HERE'S CONTENT i WANT



i DON'T WANT THIS SCRIPT EITHER

Hello world



HTML

my $body = 0;
my $title = 0;
my @body;
my @title;
my @tags;
my %body_attr;

my $html = HTML::Parser->new(api_version => 3,
text_h  => [\&text,'dtext'],
start_h => [\&open_tag,'tagname,attr'],
end_h   => [\&close_tag,'tagname']);

$html->ignore_elements(qw(script comment));
$html->parse($text);
$html->eof;

print "title is: @title\n";
print "body text: @body\n";
print "body attr.:\n";
while(my($k,$v) = each %body_attr){
print "$k=$v\n";
}
print "Other tag inside body: @tags\n";

#-- DONE --#

sub text{
my $text = shift;

return unless($text =~ /\w/);

if($title){
push(@title,$text);
}elsif($body){
push(@body,$text);
}
}

sub open_tag{

my $tagname = shift;
my $attr= shift;

$title = 1 if($tagname eq 'title');

if($tagname eq 'body'){
$body = 1;
while(my($key,$value) = each %{$attr}){
$body_attr{$key} = "'$value'";
}
}elsif($body){
push(@tags,"<$tagname>");
}
}

sub close_tag{

my $tagname = shift;

$title = 0 if($tagname eq 'title');
$body  = 0 if($tagname eq 'body');

push(@tags,"") if($body);
}

__END__

prints:

title is:  HI Title
body text:
hI HERE'S CONTENT i WANT
 Hello world
body attr.:
bodytag='attributes'
Other tag inside body:  

imagine you have to do the same in reg. expr.

david

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




Re: How to name STDIN from the command line

2003-01-23 Thread david
Rob Dixon wrote:

> That's kinda fancy!
> 
> Any reason it's not:
> 
> my @buffer = <>;
> 
> :-?
> 

no. i like yours. just somehow miss it. :-)

david

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




RE: Using HTML::Parser question

2003-01-23 Thread Dan Muey

Almost perfect
Instead of having an array of tags used in the body. I'd like to keep the tags in the 
body.

IE

print "title is: @title\n"; # perfect
print "body text: @body\n"; # this needs to keep the tags were they are**
print "body attr.:\n"; # perfect
while(my($k,$v) = each %body_attr){
print "$k=$v\n";
}
print "Other tag inside body: @tags\n"; # don't really need this

** if 
my $text = <
 HI Title 
heaD STUFF
 
 
 keep the I tag 
 hI HERE'S CONTENT i WANT
 IMaGE
 
 
 
 i DON'T WANT THIS SCRIPT EITHER
 
 Hello world
 
 
 
HTML

Then out put for body should be ::
 keep the I tag 
 hI HERE'S CONTENT i WANT
 IMaGE

But it is currently :

keep the I tag
hI HERE'S CONTENT i WANT
IMaGE

Other than that it is perfect! I really appreciate your help on this one.

Dan

I'll check back in tomorrow.


> Dan Muey wrote:
> 
> > 
> > Very nice, although I'd like to keep html tags that are between the 
> > body tags as well except script & comment.
> > 
> > Also @body contains the attributes of the body tag as well 
> as all of 
> > the text in the body :
> > 
> > my $new_title = join '', @title;
> > my $new_body_atts = join(//,@body);
> > 
> > print "TITLE -$new_title- \n BODY ATTRIBUTES -$new_body_atts- \n";
> > 
> > Any ideas?
> > 
> 
> so you want to:
> 1. get title
> 2. get body but without comment and script
> 3. all other tags except comment and script should be 
> included 4. attribute from body should not be part of body
> 
> #!/usr/bin/perl -w
> use strict;
> 
> use HTML::Parser;
> 
> my $text = < 
>  HI Title 
> heaD STUFF
> 
> 
> hI HERE'S CONTENT i WANT
> 
> 
> 
> i DON'T WANT THIS SCRIPT EITHER
> 
> Hello world
> 
> 
> 
> HTML
> 
> my $body = 0;
> my $title = 0;
> my @body;
> my @title;
> my @tags;
> my %body_attr;
> 
> my $html = HTML::Parser->new(api_version => 3,
> text_h  => [\&text,'dtext'],
> start_h => 
> [\&open_tag,'tagname,attr'],
> end_h   => [\&close_tag,'tagname']);
> 
> $html->ignore_elements(qw(script comment)); 
> $html->parse($text); $html->eof;
> 
> print "title is: @title\n";
> print "body text: @body\n";
> print "body attr.:\n";
> while(my($k,$v) = each %body_attr){
> print "$k=$v\n";
> }
> print "Other tag inside body: @tags\n";
> 
> #-- DONE --#
> 
> sub text{
> my $text = shift;
> 
> return unless($text =~ /\w/);
> 
> if($title){
> push(@title,$text);
> }elsif($body){
> push(@body,$text);
> }
> }
> 
> sub open_tag{
> 
> my $tagname = shift;
> my $attr= shift;
> 
> $title = 1 if($tagname eq 'title');
> 
> if($tagname eq 'body'){
> $body = 1;
> while(my($key,$value) = each %{$attr}){
> $body_attr{$key} = "'$value'";
> }
> }elsif($body){
> push(@tags,"<$tagname>");
> }
> }
> 
> sub close_tag{
> 
> my $tagname = shift;
> 
> $title = 0 if($tagname eq 'title');
> $body  = 0 if($tagname eq 'body');
> 
> push(@tags,"") if($body);
> }
> 
> __END__
> 
> prints:
> 
> title is:  HI Title
> body text:
> hI HERE'S CONTENT i WANT
>  Hello world
> body attr.:
> bodytag='attributes'
> Other tag inside body:  
> 
> imagine you have to do the same in reg. expr.
> 
> david
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




RE: Using HTML::Parser question

2003-01-23 Thread Dan Muey
For clarity sake with all of the code and changes and stuff here is the code that 
works mostly the way I want with the 3 questions/problems/needs after the #'s, $text 
contains actual html code:
#-

# get $title - EG the 'Your Title Here' in ::  Your Title Here 
# get $bdy_tg_at - EG the 'bgcolor="red" link="#EOEOEO"' in :: 
# This code removes  automatically, which is what I want. But I'm not 
sure how/why exactly it does.

# Should I start a new object that just grabs the title and bdy_tg_at ??
# I tried another example with fetched the title ok but 
#   it made the attributes :: bgcolor="red"=link="#EOEOEO"
# the attributes were in the same data as the body contents, so there was no way 
to separate it fomr the content
#   removed all html from the body content

use HTML::Parser;

my $temp;
my $html = HTML::Parser->new(
api_version => 3,
text_h  => [sub{ $temp .= shift; }, 'dtext'],
start_h => [sub{ $temp .= shift; }, 'text'],
end_h   => [sub{ $temp .= shift; }, 'text']);

$html->ignore_elements(qw(head script));
$html->ignore_tags(qw(html body));

$html->parse($text);
$html->eof;

my $ntemp;
my @t = split(/\n/, $temp);
foreach $t (@t) {
if($t =~ m/\w/) {
$ntemp .= "$t \n";
}
} 

print "TITLE -$title- \n";
print "BDATT -$bdy_tg_at- \n";
print $ntemp;
#

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




RE: Using HTML::Parser question

2003-01-23 Thread Dan Muey


Oops I just got your revised one. Sorry bout that!
> 
> For clarity sake with all of the code and changes and stuff 
> here is the code that works mostly the way I want with the 3 
> questions/problems/needs after the #'s, $text contains actual 
> html code:
> #-
> 
> # get $title - EG the 'Your Title Here' in ::  Your 
> Title Here 
> # get $bdy_tg_at - EG the 'bgcolor="red" link="#EOEOEO"' in 
> :: 
> # This code removes  automatically, which is 
> what I want. But I'm not sure how/why exactly it does.
> 
> # Should I start a new object that just grabs the title and 
> bdy_tg_at ?? # I tried another example with fetched the title ok but 
> # it made the attributes :: bgcolor="red"=link="#EOEOEO"
> # the attributes were in the same data as the body 
> contents, so there was no way to separate it fomr the content
> # removed all html from the body content
> 
> use HTML::Parser;
> 
> my $temp;
> my $html = HTML::Parser->new(
> api_version => 3,
> text_h  => [sub{ $temp .= shift; }, 'dtext'],
> start_h => [sub{ $temp .= shift; }, 'text'],
> end_h   => [sub{ $temp .= shift; }, 'text']);
> 
> $html->ignore_elements(qw(head script)); 
> $html->ignore_tags(qw(html body));
> 
> $html->parse($text);
> $html->eof;
> 
> my $ntemp;
> my @t = split(/\n/, $temp);
> foreach $t (@t) {
> if($t =~ m/\w/) {
> $ntemp .= "$t \n";
> }
> } 
> 
> print "TITLE -$title- \n";
> print "BDATT -$bdy_tg_at- \n";
> print $ntemp;
> #
> 

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




RE: Using HTML::Parser question

2003-01-23 Thread Dan Muey


Those four points are exactly it btw.
That script does 1,2, and 4, #3 is what it's not doing.

Sorry about beinf so confusing with all of these posts!
Hopefully this will clarify all of my babble.

Thanks

Dan
> 
> Dan Muey wrote:
> 
> > 
> > Very nice, although I'd like to keep html tags that are between the 
> > body tags as well except script & comment.
> > 
> > Also @body contains the attributes of the body tag as well 
> as all of 
> > the text in the body :
> > 
> > my $new_title = join '', @title;
> > my $new_body_atts = join(//,@body);
> > 
> > print "TITLE -$new_title- \n BODY ATTRIBUTES -$new_body_atts- \n";
> > 
> > Any ideas?
> > 
> 
> so you want to:
> 1. get title
> 2. get body but without comment and script
> 3. all other tags except comment and script should be 
> included 
> 4. attribute from body should not be part of body
> 
> #!/usr/bin/perl -w
> use strict;
> 
> use HTML::Parser;
> 
> my $text = < 
>  HI Title 
> heaD STUFF
> 
> 
> hI HERE'S CONTENT i WANT
> 
> 
> 
> i DON'T WANT THIS SCRIPT EITHER
> 
> Hello world
> 
> 
> 
> HTML
> 
> my $body = 0;
> my $title = 0;
> my @body;
> my @title;
> my @tags;
> my %body_attr;
> 
> my $html = HTML::Parser->new(api_version => 3,
> text_h  => [\&text,'dtext'],
> start_h => 
> [\&open_tag,'tagname,attr'],
> end_h   => [\&close_tag,'tagname']);
> 
> $html->ignore_elements(qw(script comment)); 
> $html->parse($text); $html->eof;
> 
> print "title is: @title\n";
> print "body text: @body\n";
> print "body attr.:\n";
> while(my($k,$v) = each %body_attr){
> print "$k=$v\n";
> }
> print "Other tag inside body: @tags\n";
> 
> #-- DONE --#
> 
> sub text{
> my $text = shift;
> 
> return unless($text =~ /\w/);
> 
> if($title){
> push(@title,$text);
> }elsif($body){
> push(@body,$text);
> }
> }
> 
> sub open_tag{
> 
> my $tagname = shift;
> my $attr= shift;
> 
> $title = 1 if($tagname eq 'title');
> 
> if($tagname eq 'body'){
> $body = 1;
> while(my($key,$value) = each %{$attr}){
> $body_attr{$key} = "'$value'";
> }
> }elsif($body){
> push(@tags,"<$tagname>");
> }
> }
> 
> sub close_tag{
> 
> my $tagname = shift;
> 
> $title = 0 if($tagname eq 'title');
> $body  = 0 if($tagname eq 'body');
> 
> push(@tags,"") if($body);
> }
> 
> __END__
> 
> prints:
> 
> title is:  HI Title
> body text:
> hI HERE'S CONTENT i WANT
>  Hello world
> body attr.:
> bodytag='attributes'
> Other tag inside body:  
> 
> imagine you have to do the same in reg. expr.
> 
> david
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




RE: Using HTML::Parser question

2003-01-23 Thread david
Dan Muey wrote:

> 
> print "body text: @body\n"; # this needs to keep the tags were they are**
>

that' fairly easy to do:

#!/usr/bin/perl -w
use strict;

use HTMP::Parser;

my $text = <
 HI Title 
heaD STUFF
 
 
 keep the I tag 
 hI HERE'S CONTENT i WANT
 IMaGE
 
 

 i DON'T WANT THIS SCRIPT EITHER
 
 Hello world

 
 
HTML

my $body = 0;
my $title = 0;
my @body;
my @title;
my %body_attr;

my $html = HTML::Parser->new(api_version => 3,
text_h => [\&text,'dtext'],
start_h => [\&open_tag, 'tagname,attr'],
end_h   => [\&close_tag, 'tagname']);
$html->ignore_elements(qw(script comment));
$html->parse($text);
$html->eof;

print "title is:\n@title\n\n";
print "body text:\n@body\n\n";
print "body attr:\n";
while(my($k,$v) = each %body_attr){
print "$k=$v\n";
}

sub text{

my $text = shift;

return unless($text =~ /\w/);

if($title){
push(@title,$text);
}elsif($body){
push(@body,$text);
}
}

sub open_tag{

my $tagname = shift;
my $attr= shift;

$title = 1 if($tagname eq 'title');

if($tagname eq 'body'){
$body = 1;
while(my($key,$value) = each %{$attr}){
$body_attr{$key} = "'$value'";
}
}elsif($body){
my $t = '';
while(my($key,$value) = each %{$attr}){
$t .= "$key='$value' ";
}
$t =~ s/\s$//;
push(@body,"<$tagname" . ($t ? " $t>" : '>'));
}
}

sub close_tag{

my $tagname = shift;

$title = 0 if($tagname eq 'title');
$body  = 0 if($tagname eq 'body');

push(@body,"") if($body);
}

__END__

prints:

title is:
 HI Title

body text:
  keep the I tag  
 hI HERE'S CONTENT i WANT
   IMaGE
   Hello world 

body attr.:
bodytag='attributes'

david

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




Re: cgi and symbolic links

2003-01-23 Thread R. Joseph Newton
Harry Putnam wrote:

> I wanted to use a single cgi script to generate several different
> formated pages.

Hi Harry,

Given that this is CGI, which interacts with forms on a web page, I would suggest a 
different approach:

# In the original calling page:

# In the script to return a page:
print WEBPAGE "";

Joseph


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




Re: cgi and symbolic links

2003-01-23 Thread Harry Putnam
"R. Joseph Newton" <[EMAIL PROTECTED]> writes:

> Harry Putnam wrote:
>
>> I wanted to use a single cgi script to generate several different
>> formated pages.
>
> Hi Harry,
>

> Given that this is CGI, which interacts with forms on a web page, I
> would suggest a different approach:
>
> # In the original calling page:
> 
> # In the script to return a page:
> print WEBPAGE "";

Boy, that sailed right over my head... I guess I'd need a little more
filling on both sides of that input to understand it.


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




How to use com components in perl

2003-01-23 Thread Pankaj Kapare
Hi
Can anybody tell me how to use com components developed in c++  in perl script.If 
provided with sample code it will be great help.
thanks.
Pankaj



  1   2   >