Taint mode and redirect with cookie

2002-08-29 Thread Alex Agerholm

Hi,

I have 2 questions:

1) I am developing some Perl code under Windows 2000. If I in the first line
writes !c:\perl\bin\perl -wT I get the error too late for -T option what
does that mean

2) when I make a print redirect(-uri=xxx.cgi, -cookie=$cookie); then my
xxx.cgi script does not get the cookie - what is wrong ?

Thanks in advance
Alex



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


Weekly list FAQ posting

2002-08-29 Thread casey

NAME
beginners-faq - FAQ for the beginners-cgi 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]

  1.4 - Is there an archive on the web?

Yes, there is. It is located at:

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

  1.5 - How can I get this FAQ?

This document will be emailed to the list once a month, and will be
available online in the archives, and at http://beginners.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-cgi 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/CGI beginners.

  1.11 - When was this FAQ last updated?

Sept 07, 2001

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

A list for beginning Perl programmers to ask questions in a friendly
atmosphere. The topic of the list is, of course, CGI with Perl.

  2.2 - What is this list _not_ for?

* SPAM
* Homework
* Solicitation
* Things that aren't Perl related
* Non Perl/CGI questions or issues
* Lemurs
  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/CGI , then it is allowed. If your
question has nothing at all to do with Perl/CGI, it will likely be
ignored.

  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 :)

  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

3 - Other Resources
  3.1 - What other websites may be useful to a beginner ?

* Perl Home Page - http://www.perl.com
* PerlMonks - http://www.perlmonks.org
* Perldoc - http://www.perldoc.com
* Perl Archives - http://www.perlarchives.com
  3.2 - What resources may be harmful to a beginner?

Beware of Perl4-like code-- You might find some script archives and
unauthorized mirrors with old Perl4 versions of Selena Sol and Matt
Wright scripts. Don't use those scripts. They are outdated and may even
in some cases contain bugs or security problems since many may not have
been updated in 

update.cgi

2002-08-29 Thread Vargas Media

Hi,
I have been studying with the O'Reilly book CGI Programming with Perl -
Chapter 5 page 99
Below is an example of a upload.cgi that utilizes CGI.pm
I am not able to get it to work correctly yet and I am trying to find out if
it is the directory I am trying to load the file to or a progammatical
error. The html is at:
http://www.vargasmedia.com/upload.htm
I have been using
http://www.vargasmedia.com/cgi-bin/env_var.cgi
to help me get the information I need to upload files using the correct
path.
Is that a good way to go about it and if so what Environment Variable should
I be looking at to return a path I can use...
DOCUMENT_ROOT
I have an empty folder on my server under www that is called uploads and
wanted to upload files there.
Here is the code from the Book CGI Programming with Perl - it is in Chapter
5 - page 99
-PS:btw- What is the CHMOD setting that I should be using with this CGI and
uploads directory?
Forgive me I'm new :)
Any help extremely appreciated.
Steve

#
#!/usr/bin/perl -wT

use strict;
use CGI;
use Fcntl qw( :DEFAULT :flock );

# use constant UPLOAD_DIR = /usr/local/bin;
use constant UPLOAD_DIR  =  /www/vargasmedia/uploads/;
use constant BUFFER_SIZE =16_384;
use constant MAX_FILE_SIZE = 100 * 1_048_576;
use constant MAX_DIR_SIZE = 100 * 1_048_576;
use constant MAX_OPEN_TRIES =100;

$CGI::DISABLE_UPLOADS= 0;
$CGI::POST_MAX   = MAX_FILE_SIZE;

my $q = new CGI;
$q-cgi_error and error( $q, Error transferring file: . $q-cgi_error );

my $file   = $q-param( file )|| error( $q, No file
recieved. );
my $filename   = $q-param( filename )|| error( $q, No filename
entered. );
my $fh = $q-upload( $file );
my $buffer = ;

if ( dir_size( UPLOAD_DIR ) + $ENV{CONTENT_LENGTH}  MAX_DIR_SIZE ) {
error( $q, Upload directory is full. );
}

# Convert odd ball characters to underscore
$filename =~ s/[^\w.-]/_/g;
if ( $filename =~ /^(\w[\w.-]*)/ ) {
 $filename = $1;
}
else {
 error( $q, Invalid file name; files must start with a letter or
number. );
}

# open output file, making sure the file name is unique
until ( sysopen OUTPUT, UPLOAD_DIR . $filename, O_CREAT | O_EXCL ) {
$filename =~ s/(\d*)(\.\w+)$/($1||0) + 1 . $2/e;
$1 = MAX_OPEN_TRIES and error( $q, Unable to save your file. );
}
# This is neccessary for non-Unix systems does nothing on UNIX
binmode $fh;
binmode OUTPUT;

# write contents to output file
while ( read($fh, $buffer, BUFFER_SIZE ) ) {
   print OUTPUT $buffer;
}

close OUTPUT;

sub dir_size {
   my $dir = shift;
   my $dir_size = 0;


   # loop through files and sume the sizes; doesn't decend down subdirs
   opendir DIR, $dir or die Unable to open $dir: $!;
   while ( readdir DIR ) {
  $dir_size += -s $dir/$_;
   }
 return $dir_size;
}

sub error {
   my( $q, $reason ) = @_;

  print $q-header( text/html ),
$q-start_html( Error ),
$q-h1( Error ),
$q-p( Your upload was not processed because the following error,
occured: ),
$q-p( $q-i( $reason )),
$q-end_html;
 exit;
}

































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




Re: update.cgi

2002-08-29 Thread david

Vargas Media wrote:

 Hi,
 I have been studying with the O'Reilly book CGI Programming with Perl -
 Chapter 5 page 99
 Below is an example of a upload.cgi that utilizes CGI.pm
 I am not able to get it to work correctly yet and I am trying to find out

what exactly is the error message that you get that indicates your script is 
not working? you should be able to get that from your server's error log. 
with the exact error message, people should be able to pinpon the error for 
you

 if it is the directory I am trying to load the file to or a progammatical
 error. The html is at:
 http://www.vargasmedia.com/upload.htm
 I have been using
 http://www.vargasmedia.com/cgi-bin/env_var.cgi
 to help me get the information I need to upload files using the correct
 path.
 Is that a good way to go about it and if so what Environment Variable
 should I be looking at to return a path I can use...
 DOCUMENT_ROOT
 I have an empty folder on my server under www that is called uploads and
 wanted to upload files there.
 Here is the code from the Book CGI Programming with Perl - it is in
 Chapter 5 - page 99
 -PS:btw- What is the CHMOD setting that I should be using with this CGI
 and uploads directory?

since you are still debugging the script, you might want to open up the 
permission to your upload directory to everyone like:

chmod 777 www
chmod 777 upload

... etc

just make sure you change it to whatever access permission you need after 
you finish debugging your script.

david

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




Re: Looking for a little help with my first CGI

2002-08-29 Thread david

try replace your while loop with the following:

while(LOG){
chop;
@line = split(/\|/);
next unless(substr($line[0], 0, 8) eq $selectedDate);
push(@display,{'displayDate'=$line[0],
   'pageViwed'=$line[1],
   'ip'=$line[2],
   'remoteAddy'=$line[3],
   'userAgeant'=$line[4],
   'referer'=$line[5]});
}

the problem with your appoach is that when you push the \%rowData reference 
to your @display, it always references the same underlaying %rowData hash. 
that's probably not what you want. i can't actually test the above for you 
right now but you might want to try it out and see how does it differ from 
your original.

david

Renfield wrote:

 Hello,
 
 I am teaching myself perl. I have become stuck. My script is designed to
 write, read and display log files. I am having a hard time getting the
 correct data from the log file to a template file. My code will match the
 correct lines in the log file but when I pass it to the template it
 displays the first line matched each iteration of the HTML::Template loop.
 I am not sure if it is an error in the way I construct the data or an
 error in how I passing to the template.
 
 Here is the code
 
 [.. snip..]
 
 if ($view eq detail) {
   open (LOG, $log_file) or die (Couldn't open log file -  $log_file -
 $!\n);
   while (LOG) {
   chomp;
   @line = split(/\|/, $_);
   $shortDate = substr($line[0], 0, 8);
   if($shortDate eq $selectedDate) {
   push (@displayDate, $line[0]);
   push (@pageViewed, $line[1]);
   push (@ip, $line[2]);
   push (@remoteAddy, $line[3]);
   push (@userAgeant, $line[4]);
   push (@referer, $line[5]);
 } else { next }
 $rowData{displayDate} = shift @displayDate;
 $rowData{pageViewed} = shift @pageViewed;
 $rowData{ip} = shift @ip;
 $rowData{remoteAddy} = shift @remoteAddy;
 $rowData{userAgeant} = shift @userAgeant;
 $rowData{referer} = shift @referer;
 push(@display, \%rowData);
 
 }
 close (LOG) or die (Couldn't close log file -  $log_file - $!\n);
 
 $template-param(DETAIL_DATA = \@display);
 
 [..snip..]
 
 Also, as I am very new to perl I would be grateful for any general tips.
 
 Thanks in advance!


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




Re: problem with foreach and while with array

2002-08-29 Thread Priss

Thank you Connie for helping me on this, it was fixed
by below comment you made :)))

   SOA: while (SOA)
   {
 chomp;

You don't need to chomp it, or you don't need $/ at 
last of the next line.

Priss

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

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




PERL Compiler

2002-08-29 Thread Michael Edwards

I'm a sorta newbie to PERL and i was wondering if therte are any good PERL
compilers.  Back in June I started to experiment with PERL but it takes a
long time to write.  I have a Win 2000 PC.

Cheers
Mikes



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




RE: PERL Compiler

2002-08-29 Thread Timothy Johnson


There are no real Perl compilers, but there are two main programs out there
for creating executables out of your code.  The first, which I use, is
PerlApp from ActiveState.  It works very well, but as far as I know must be
purchased as part of the Perl Dev Kit.  The second is Perl2exe, and I can't
remember who makes it.

-Original Message-
From: Michael Edwards [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 28, 2002 1:25 PM
To: [EMAIL PROTECTED]
Subject: PERL Compiler


I'm a sorta newbie to PERL and i was wondering if therte are any good PERL
compilers.  Back in June I started to experiment with PERL but it takes a
long time to write.  I have a Win 2000 PC.

Cheers
Mikes



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




DBI, Win32::ODBC, encrypted file, udl questions

2002-08-29 Thread mrtlc

I want to pull some data down from a Teradata database to a Win2k/NT server.
I use DBI or Win32::ODBC, a system DSN (teradata1) is created.

use DBI;
use DBD::ODBC;
my $dbh = DBI-connect(DBI:ODBC:teradata1, uname, moo);
...

or

use Win32::ODBC;
$data = new Win32::ODBC(DSN = teradata1; UID=uname; PWD=moo;);
...

My questions are:

(1) How do I create an encrypted file to store moo, open that file and
pass moo to the database?

or

(2) How do I pass an user name and a password to the DSN teradata1 from
an UDL file
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/h
tml/vxtskcreatingconfiguringuniversaldatalinkfiles.asp)
to the above lines?

Thanks in advance,

Stan L




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




Weekly list FAQ posting

2002-08-29 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 list, 

Re: PERL Compiler

2002-08-29 Thread Nigel Peck

As you're a newbie, I thought I'd mention that you don't need to compile
your Perl code, it's done for you by the interpreter before being run.

The interpreter for Win2k is at http://www.activestate.com/

You probably already know but just in case...

Nigel

 Michael Edwards [EMAIL PROTECTED] 08/28/02 09:25pm

I'm a sorta newbie to PERL and i was wondering if therte are any good
PERL
compilers.  Back in June I started to experiment with PERL but it takes
a
long time to write.  I have a Win 2000 PC.

Cheers
Mikes



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



ITM Website Relaunched 15th August 2002
http://www.itm-solutions.co.uk/

ITM Business Solutions
Unit 4
Nine Trees Trading Estate
Morthen Road
Rotherham
S66 9JG

Reception
Tel: 01709 703288
Fax: 01709 701549

Help Desk
Tel:01709 530424
Fax: 01709 702159

CONFIDENTIALITY NOTICE: This message is intended only for the use of
the individual or entity to which it is addressed, and may contain
information that is privileged, confidential and exempt from disclosure
under applicable law.



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




RE: PERL Compiler

2002-08-29 Thread Kirby_Sarah

Since we are on the topic...

I wanted to get the additional modules, so I downloaded the stable.zip onto
my NT machine and unzipped it, but I haven't been able to get it to
recognize any perl scripts.  Did I miss a step? 

-Sarah

-Original Message-
From: Nigel Peck [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 29, 2002 8:23 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: PERL Compiler


As you're a newbie, I thought I'd mention that you don't need to compile
your Perl code, it's done for you by the interpreter before being run.

The interpreter for Win2k is at http://www.activestate.com/

You probably already know but just in case...

Nigel

 Michael Edwards [EMAIL PROTECTED] 08/28/02 09:25pm

I'm a sorta newbie to PERL and i was wondering if therte are any good
PERL
compilers.  Back in June I started to experiment with PERL but it takes
a
long time to write.  I have a Win 2000 PC.

Cheers
Mikes



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



ITM Website Relaunched 15th August 2002
http://www.itm-solutions.co.uk/

ITM Business Solutions
Unit 4
Nine Trees Trading Estate
Morthen Road
Rotherham
S66 9JG

Reception
Tel: 01709 703288
Fax: 01709 701549

Help Desk
Tel:01709 530424
Fax: 01709 702159

CONFIDENTIALITY NOTICE: This message is intended only for the use of
the individual or entity to which it is addressed, and may contain
information that is privileged, confidential and exempt from disclosure
under applicable law.



-- 
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 concurrent processes

2002-08-29 Thread Philip Montgomery

David,

 for ($x;$x4;$x++) {
 if ($pid=fork) {
 } else {
system mkdir dir$x;
 for ($i=1;$i250;$i++) {
 open3(OUTPUT, INPUT, ERRORS, cd dir$x;make clean; make all);
 code to process the output of the make commands and store into
 log files

Basically, I want the fork to fork of 4 children.  Each chiled I want to run
the next for loop which includes the open3 command.  The code to process,
takes the stdout  stderr from the open3, and saves them to log.$i and error.$i.
This way I can have the logs of every iteration through the 250 for loop.

Of course, since each child will be running 250 compilies, I save the log.$i
 errors.$i for each of the children in a different directory.

Phil




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




Re: where to put data files

2002-08-29 Thread drieux


On Tuesday, December 4, 1956, at 07:56 , Paul Tremblay wrote:
[..]
 Okay, I'm getting closer to finishing the d**n beast of a script, so I
 need to think about how to distribute it. This script will be a
 command line utility. Right now it has no switches:

 rtf2xml file

 I want to make it easy to use for people who don't know perl. Should I
 still use a module?

[..]

ah! I see! you really are in the

have code, the rest is temporary data files

sorry for not quite catching your drift the first time.

just a dumb-bunny question - but if I type

rtf2xml --help

will your code dump me some 'advice'? and/or

perldoc rtf2xml

show me if

rtf2xml input_file output_file

would work - or that in this release it is only
sending output to STDOUT?

that being the other rack of basics - all you
really need to do to distribute it would be
to hang the code on a webPage and let folks 'save to file'
from their browser

The next level of complexity is to either go with
the Make::Maker approach of building an installer
based upon the usual

perl *.PL
make install

model - or you will want to look at the other
option of

a) hand crafting an installation script
b) adopting someone else's package installer
- rpm/pkgadd

and complying with their standard.

The basic stuff that you will want to put into the
general release are

a) README - what we are about
- clues to any other documentation
b) ChangeLog - when we did what to this for why
c) The Installation Stuff
- how to check for all the dependencies
- how to check for the installer's desires and wishes
as well as explain to them if they try to install into
places they shouldn't
- how to actually install it...
d) The Code Stuff
- the one item - at this point

e) Manifest - what should be in the tarball

This way the person who just wants 'the application' Can
just install it - without having to understand what all
the rest of that stuff is about - while others will be able
to keep track of how this evolves as it evolves...





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




Re: multiple concurrent processes

2002-08-29 Thread zentara

On Wed, 28 Aug 2002 11:46:05 -0700, [EMAIL PROTECTED] (David) wrote:
Philip Montgomery wrote:
 I am trying to figure out how to run process concurrently from Perl.  I
 want the parent to spawn off the children and wait until they are complete
 to continue.  I can get the child processes to run in serial, but I need
 them to run in parallel.
 The code I am using thus far is
 for ($x;$x4;$x++) {
 if ($pid=fork) {
 } else {
system mkdir dir$x;
 for ($i=1;$i250;$i++) {
 open3(OUTPUT, INPUT, ERRORS, cd dir$x;make clean; make all);
 code to process the output of the make commands and store into
 log files


you are forking a child, do a system() call, and execute some more code. 
depends on what the code to process ... portion is, your child process 
might(if it doesn't exit) goes back to the for loop and start to fork it's 
own child. is that what you want?

Here try to run this one:
I think your open3 statement is not good, and having the cd dir$x in
there, looks like you are trying to recurse cd down 250 levels.
By the way cd should be chdir.

Anyways, run the code below, add some error checking, and
look at what it does. Then try to work in your open3 and make calls.
What are you trying to do anyways?


#!/usr/bin/perl
use warnings;

if ($#ARGV  0){@ARGV = qw( 1 2 3 4 )}
afork (\@ARGV,4,\mysub);
print Main says: All done now\n;

sub mysub{
 my $x = $_[0];
 system mkdir dir$x;
 chdir dir$xor die $!; 
 for ($i=1;$i250;$i++) {
 system touch $i-$x;

#alot of problems in here 
# open3(OUTPUT, INPUT, ERRORS, cd dir$x;make clean; make all);  
#code to process the output of the make commands and store into log 

}
}

##
sub afork (\@$) {
my ($data, $max, $code) = @_;
my $c = 0;
foreach my $data (@$data) {
wait unless ++ $c = $max;
die Fork failed: $!\n unless defined (my $pid = fork);
exit $code - ($data) unless $pid;
}
1 until -1 == wait;
}
#






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




DBI script won't run as cron job

2002-08-29 Thread Mark Martin

I'm concious that this might be a Linux problem but maybe someone on the
list has had the same issue and solved it.

I copied out below one of the simplest functions from a perl script that I
need to schedule every day. When I run it interactively the table truncates
fine and I get all the print statements. However when I try to run it as a
cron job nothing happens to the table and I only get the first print
statement in a log file - but the script compiles without error and Oracle
doesn't feed back any errors either.

Here is the cron command :

00 00 * * * perl /pathtofile/script.pl  21  /pathtologfile/logfile.txt
(Running on Linux 7.2 and I've tried is as a standard user and as root)

Here is the script :

#!/usr/bin/perl print \n\n ***   CRONTEST   \n\n;
use DBI; use DBD::Oracle; $dbh1 = DBI-connect( dbi:Oracle:dbase, user,
pword ) or die Can't connect to Oracel database: $DBI::errstr\n;
print \n\n ***   LOGGED IN OK   \n\n; my $sqlA =
qq{TRUNCATE TABLE TABLE_NAME};
my $sth1 = $dbh1-prepare($sqlA) or die Can't prepare SQL statement:
$DBI::errstr\n;
$sth1-execute or die Can't execute SQL statement: $DBI::errstr\n;
$dbh1 -disconnect();
print \n\n ***   LOGGED OUT OK   \n\n;
exit;

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




RE: DBI script won't run as cron job

2002-08-29 Thread Bob Showalter

 -Original Message-
 From: Mark Martin [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, August 29, 2002 10:55 AM
 To: [EMAIL PROTECTED]
 Subject: DBI script won't run as cron job
 
 
 I'm concious that this might be a Linux problem but maybe 
 someone on the
 list has had the same issue and solved it.
 
 I copied out below one of the simplest functions from a perl 
 script that I
 need to schedule every day. When I run it interactively the 
 table truncates
 fine and I get all the print statements. However when I try 
 to run it as a
 cron job nothing happens to the table and I only get the first print
 statement in a log file - but the script compiles without 
 error and Oracle
 doesn't feed back any errors either.

Oracle requires various environment variables to be set, and these
are not set in your cron environment unless you explicitly set them.

See perldoc DBD::Oracle for details on what needs to be set.

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




Re: DBI script won't run as cron job

2002-08-29 Thread Frank Wiles

 .--[ Mark Martin wrote (2002/08/29 at 14:54:30) ]--
 | 
 |  I'm concious that this might be a Linux problem but maybe someone on the
 |  list has had the same issue and solved it.
 |  
 |  I copied out below one of the simplest functions from a perl script that I
 |  need to schedule every day. When I run it interactively the table truncates
 |  fine and I get all the print statements. However when I try to run it as a
 |  cron job nothing happens to the table and I only get the first print
 |  statement in a log file - but the script compiles without error and Oracle
 |  doesn't feed back any errors either.
 |  
 |  Here is the cron command :
 |  
 |  00 00 * * * perl /pathtofile/script.pl  21  /pathtologfile/logfile.txt
 |  (Running on Linux 7.2 and I've tried is as a standard user and as root)
 |  
 |  Here is the script :
 |  
 |  #!/usr/bin/perl print \n\n ***   CRONTEST   \n\n;
 |  use DBI; use DBD::Oracle; $dbh1 = DBI-connect( dbi:Oracle:dbase, user,
 |  pword ) or die Can't connect to Oracel database: $DBI::errstr\n;
 |  print \n\n ***   LOGGED IN OK   \n\n; my $sqlA =
 |  qq{TRUNCATE TABLE TABLE_NAME};
 |  my $sth1 = $dbh1-prepare($sqlA) or die Can't prepare SQL statement:
 |  $DBI::errstr\n;
 |  $sth1-execute or die Can't execute SQL statement: $DBI::errstr\n;
 |  $dbh1 -disconnect();
 |  print \n\n ***   LOGGED OUT OK   \n\n;
 |  exit;
 |
 `-

You'll need to make sure that CRON has all the same environment 
variables and is running as the same user as when you are running
it by hand. I would wager that this is the problem. 

 -
   Frank Wiles [EMAIL PROTECTED]
   http://frank.wiles.org
 -


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




Re: new to modules

2002-08-29 Thread drieux


On Wednesday, August 28, 2002, at 07:52 , Erik Price wrote:

 Folks,

 I've used Perl here and there (on my OS X box) for basic stuff, but I 
 haven't really played with modules.  I feel like I'm really missing out 
 on something cool here.  Where do modules get stored by default in Darwin?
   What is a good way to see which ones I have installed? (I actually 
 haven't installed any but I meant pre-installed on Darwin.)

as an exercise with

File::Find

I put up

http://www.wetware.com/drieux/pbl/misc/findModules.txt

I hope it helps.

ciao
drieux

---


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




Re: Error when I try to use perldoc

2002-08-29 Thread Robin Norwood

Brad Fike [EMAIL PROTECTED] writes:

 I get the following error when I try to get documentation about a module or
 function.
 
 Can't spawn cmd.exe: No such file or directory at C:\Perl\bin/perldoc.bat
 line 395.

It looks like the cmd.exe program isn't in your path - IIRC cmd.exe is
the windows 2000 equivelent of 'command.com' - the dos shell.  That
being said, I don't think I remember where it's located - good luck.
:-)

-RN

-- 

Robin Norwood
Red Hat, Inc.

The Sage does nothing, yet nothing remains undone.
-Lao Tzu, Te Tao Ching

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




Re: upload.cgi

2002-08-29 Thread Vargas Media

Hi,
 Note:  questions of this nature you might want to send to
 [EMAIL PROTECTED] as that is a list specifically about cgi, though
 in most cases the beginners list will be able to help you too.
Thanks I will check it out (more below)
 Vargas Media wrote:
  Hi,
  I have been studying with the O'Reilly book CGI Programming with
Perl -
  Chapter 5 page 99
  Below is an example of a upload.cgi that utilizes CGI.pm
  I am not able to get it to work correctly yet and I am trying to find
out if
  it is the directory I am trying to load the file to or a progammatical
  error. The html is at:
  http://www.vargasmedia.com/upload.htm
  I have been using
  http://www.vargasmedia.com/cgi-bin/env_var.cgi
  to help me get the information I need to upload files using the correct
  path.
  Is that a good way to go about it and if so what Environment Variable
should
  I be looking at to return a path I can use...
  DOCUMENT_ROOT


 I don't quite understand what you are asking here?  Can you be more
 specific??
I have a CGI script that is at
http://www.vargasmedia.com/cgi-bin/env_var.cgi
It returns information about my server and I am using the information in the
Environtment Variable Document Root
to grab the path name   /www/vargasmedia/uploads/;


  I have an empty folder on my server under www that is called uploads
and
  wanted to upload files there.
  Here is the code from the Book CGI Programming with Perl - it is in
Chapter
  5 - page 99

 Is this the code you are using, in env_var.cgi??
No I am using the upload.cgi script below the env_var.cgi script I was just
using to give details about my server and
where I should set the path for: use constant UPLOAD_DIR


  -PS:btw- What is the CHMOD setting that I should be using with this CGI
and
  uploads directory?

 two things need to be addressed here, both the ownership and the
 permissions, and they are related.  The web server runs as a particular
 user, example the apache user on some systems with apache, and that
 user has its own group, example httpd on some systems (many others are
 nobody/nobody, etc.).  The user who is writing the file to the disk
 (aka the web server user) must have write permission to the folder this
 is usually either accomplished by setting the ownership of the directory
 to the user and then providing the user write ability, or setting the
 group of the directory to one of the groups that the web server runs as
 and then setting group writeable permissions on that directory.  If you
 are on unix consult - man chown and - man chmod for more about these
 two topics, on windows I can't help you sorry.

What is the easiest way to access man chown.
As I mentioned some of this is new territory - I apologize if the questions
sound to obvious.

 A cursory (read: 30 second) look over your code didn't show any glaring
 problems.  Is there an error given? What shows up in the error log for
 the web server and/or what is printed to the browser? More specific info
 might better help us diagnose the problems you are having. I attempted
 to upload a file and got a 500 error which could be a lot of things but
 should produce an error output in the error log.

I am getting from the Browser and Internal Server Error
The Server encountered and internal error or misconfiguration ans was
unable to complete your request
etc
I believe my problem lies in 2 areas my CHMOD setting and possible the
directory where I am trying to upload the file.
I am reposting the code below.
Thanks! Steve
#
#!/usr/bin/perl -wT

use strict;
use CGI;
use Fcntl qw( :DEFAULT :flock );

# use constant UPLOAD_DIR = /usr/local/bin;
use constant UPLOAD_DIR  =  /www/vargasmedia/uploads/;
use constant BUFFER_SIZE =16_384;
use constant MAX_FILE_SIZE = 100 * 1_048_576;
use constant MAX_DIR_SIZE = 100 * 1_048_576;
use constant MAX_OPEN_TRIES =100;

$CGI::DISABLE_UPLOADS= 0;
$CGI::POST_MAX   = MAX_FILE_SIZE;

my $q = new CGI;
$q-cgi_error and error( $q, Error transferring file: . $q-cgi_error );

my $file   = $q-param( file )|| error( $q, No file
recieved. );
my $filename   = $q-param( filename )|| error( $q, No filename
entered. );
my $fh = $q-upload( $file );
my $buffer = ;

if ( dir_size( UPLOAD_DIR ) + $ENV{CONTENT_LENGTH}  MAX_DIR_SIZE ) {
error( $q, Upload directory is full. );
}

# Convert odd ball characters to underscore
$filename =~ s/[^\w.-]/_/g;
if ( $filename =~ /^(\w[\w.-]*)/ ) {
 $filename = $1;
}
else {
 error( $q, Invalid file name; files must start with a letter or
number. );
}

# open output file, making sure the file name is unique
until ( sysopen OUTPUT, UPLOAD_DIR . $filename, O_CREAT | O_EXCL ) {
$filename =~ s/(\d*)(\.\w+)$/($1||0) + 1 . $2/e;
$1 = MAX_OPEN_TRIES and error( $q, Unable to save your file. );
}
# This is neccessary for non-Unix systems does nothing on UNIX
binmode $fh;
binmode OUTPUT;

# write contents to output file
while ( 

RE: Error when I try to use perldoc

2002-08-29 Thread Timothy Johnson


It should be located in %systemroot%\system32.  If cmd.exe is not in your
path, then it sounds like your path may be too long.  You might want to look
at it and see if there is anything you can get rid of, i.e. old programs
that you no longer use, and make sure that %systemroot% and
%systemroot%\system32 are in it.

-Original Message-
From: Robin Norwood [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 29, 2002 7:49 AM
To: Brad Fike
Cc: [EMAIL PROTECTED]
Subject: Re: Error when I try to use perldoc


Brad Fike [EMAIL PROTECTED] writes:

 I get the following error when I try to get documentation about a module
or
 function.
 
 Can't spawn cmd.exe: No such file or directory at
C:\Perl\bin/perldoc.bat
 line 395.

It looks like the cmd.exe program isn't in your path - IIRC cmd.exe is
the windows 2000 equivelent of 'command.com' - the dos shell.  That
being said, I don't think I remember where it's located - good luck.
:-)

-RN

-- 

Robin Norwood
Red Hat, Inc.

The Sage does nothing, yet nothing remains undone.
-Lao Tzu, Te Tao Ching

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




Extracting bits from a string of bits

2002-08-29 Thread Bridget Benson

I am trying to grab selections of an ip packet stored in a string scalar.

I know if you have a string of characters, you can change the string 
into an array of characters and then reference each character in the 
array.  Can you do something similar with a string of bits?
-- 

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




Re: where to put data files

2002-08-29 Thread Paul Tremblay

On Thu, Aug 29, 2002 at 06:47:26AM -0700, drieux wrote:
 
 ah! I see! you really are in the
 
   have code, the rest is temporary data files

I'm not sure I catch your drift here. Did a line get dropped from the
email?
 
 sorry for not quite catching your drift the first time.
 
 just a dumb-bunny question - but if I type
 
   rtf2xml --help
 
 will your code dump me some 'advice'? and/or
 
   perldoc rtf2xml
 
 show me if
 
   rtf2xml input_file output_file
 

No to both questions! Which means I need to include both. I have just
added some switches for this script. I guess I can just add a switch
for --help. 

#i'v already defined my switch --help and attatched it to $help
if ($help){
print in order to use this script...
}

As far as perldoc goes, if I include any pod in the script, then
typing perldoc rtf2xml should output the documentation? (I'll try this
out right now. I'll probably have the answer before you respond!)

 would work - or that in this release it is only
 sending output to STDOUT?
 
 that being the other rack of basics - all you
 really need to do to distribute it would be
 to hang the code on a webPage and let folks 'save to file'
 from their browser
 
 The next level of complexity is to either go with
 the Make::Maker approach of building an installer
 based upon the usual
 
   perl *.PL
   make install
 
 model - or you will want to look at the other
 option of
 
   a) hand crafting an installation script
   b) adopting someone else's package installer
   - rpm/pkgadd
 
 and complying with their standard.
 
 The basic stuff that you will want to put into the
 general release are
 
   a) README - what we are about
   - clues to any other documentation
   b) ChangeLog - when we did what to this for why
   c) The Installation Stuff
   - how to check for all the dependencies
   - how to check for the installer's desires and wishes
   as well as explain to them if they try to install into
   places they shouldn't
   - how to actually install it...
   d) The Code Stuff
   - the one item - at this point
 
   e) Manifest - what should be in the tarball
 
 This way the person who just wants 'the application' Can
 just install it - without having to understand what all
 the rest of that stuff is about - while others will be able
 to keep track of how this evolves as it evolves...
 


Thanks. This is all useful info. Right now in order to run the script,
a user needs:

1. the code
2. the character_set file
3. a folder called rtf2xml_dir located in /usr/share
4. a temp folder located in the above folder.

It is pretty easy to write a script to make a folder and copy the
character_set file to this folder. Will all users have permission to
make such a folder? 

And where should I put the executable script? In /bin, or /usr/bin, or
what? 

I think I'll go with simply writing my own simple script for making
the installation. I'll also give explicit instructions in README on
how to install the few components by hand, (if the user wants to) as
well as how to change the place the script writes its temporary files,
and where it reads its data. (I put a variable called $directory at
the beginning of the script so a user can change it easily if he
wants.)

I guess I need to work on the pod documentation. I believe I should be
able to simply follow the Perl Cookbook.

Thanks

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

-- 

*Paul Tremblay *
*[EMAIL PROTECTED]*


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




RE: Extracting bits from a string of bits

2002-08-29 Thread Kipp, James

perldoc -f unpack
perldoc -f pack

 -Original Message-
 From: Bridget Benson [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, August 29, 2002 12:46 PM
 To: [EMAIL PROTECTED]
 Subject: Extracting bits from a string of bits
 
 
 I am trying to grab selections of an ip packet stored in a 
 string scalar.
 
 I know if you have a string of characters, you can change the string 
 into an array of characters and then reference each character in the 
 array.  Can you do something similar with a string of bits?
 -- 
 
 -- 
 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 to be safe and secure

2002-08-29 Thread brian gilbert

I asked earlier about a way to hide my password in the script, when calling 
an SQL connection with a line like:

my($db) = new Win32::ODBC(fileDSN=myodbc.dsn; uid=myID; pwd=mysecret);

No answers, so let me ask another way:  what steps should we take to keep 
our scripts and embedded passwords safe from prying eyes?  

I've found very little on how to secure my cgi scripts on the server.  Once 
I moved them to a new server and was horrified to find that when they were 
called by http, they gave a listing instead of running!

So, what SHOULD we be doing?  Any pointers or links?


-Brian


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




Re: how to be safe and secure

2002-08-29 Thread david

i am not a Windos guy and i am limited on what i know about ODBC. but why 
not put your id and password in a config file so that your connect 
statement will look like:

$dsn = get from config
$usr = get from config
$psw = get from config

my $db = new Win32::ODBC(fileDSN=$dsn; uid=$usr; psw=$psw);

that should avoid the horrifying listing effect...

you will put the config file somewhere restricted from outside access. of 
course, it probably doesn't stop anyone(other developers, users of your 
machine) whois using your system from opening the config file manually.

david

Brian Gilbert wrote:

 I asked earlier about a way to hide my password in the script, when
 calling an SQL connection with a line like:
 
 my($db) = new Win32::ODBC(fileDSN=myodbc.dsn; uid=myID; pwd=mysecret);
 
 No answers, so let me ask another way:  what steps should we take to keep
 our scripts and embedded passwords safe from prying eyes?
 
 I've found very little on how to secure my cgi scripts on the server. 
 Once I moved them to a new server and was horrified to find that when they
 were called by http, they gave a listing instead of running!
 
 So, what SHOULD we be doing?  Any pointers or links?
 
 
 -Brian


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




Re: Constant Question

2002-08-29 Thread Timothy

First off thanks a bunch to Jeff for giving me that nice solution
to my Constant Question in yesterdays thread. I even sorta
understand why it worked:) Todays problem is to do with Tk.
How does one change the Tk color scheme globally for the
app? By this I mean is there a way of not having to specify
the -background=$BG_COLOR for every widget?

  $objDialog=$objWindow-Dialog(
-background='grey',
-title=NOTICE,
-text=This space intentionally left blank.,
-default_button='Ok',
-buttons=['Ok']
  );

The above dialog box pops up in some light yellow color
and then slowly repaints intself grey. How do I avoid the
initial light yellow color? I'd prefer a solution from within
Perl rather then editting an X file. TIA:)
-- 
-Timothy

eMail: [EMAIL PROTECTED]
WebPage: http://mail.asl.bc.ca/~timothy
(c) 883 GUE FrobozzCo

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




Re: DBI, Win32::ODBC, encrypted file, udl questions

2002-08-29 Thread Roger Perttu

mrtlc wrote:

I want to pull some data down from a Teradata database to a Win2k/NT server.
I use DBI or Win32::ODBC, a system DSN (teradata1) is created.

use DBI;
use DBD::ODBC;
my $dbh = DBI-connect(DBI:ODBC:teradata1, uname, moo);
...

or

use Win32::ODBC;
$data = new Win32::ODBC(DSN = teradata1; UID=uname; PWD=moo;);
...

My questions are:

(1) How do I create an encrypted file to store moo, open that file and
pass moo to the database?

or

(2) How do I pass an user name and a password to the DSN teradata1 from
an UDL file
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/h
tml/vxtskcreatingconfiguringuniversaldatalinkfiles.asp)
to the above lines?

Why do you want to use an UDL file? They are not encrypted. You can open 
the UDL file like any other text file using Perl and copy the DSN.

There is also a DSN syntax for UDL files: File name=path\\my.udl; 
(from memory)


Thanks in advance,

Stan L




  






smime.p7s
Description: S/MIME Cryptographic Signature


Need help

2002-08-29 Thread Michal Weinfurtner

Hi all ,

I have some data in hash of arrays and i need a print all of entries of
that hash sorted by 2-nd index of arrays. 

Example: 

$a {1} = [ some string,other string,some number ] ;
$a {2} = [ some string,other string,some number ] ;
$a {3} = [ some string,other string,some number ] ;
..
..
..
$a {n} = [ some string,other string,some number ] ;


I need print all hash entries sorted by some number (2-nd index of
arrays ). 

Any suggestions ? 

Thanks a lot 
Michal Weinfurtner 




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




RE: Need help

2002-08-29 Thread David . Wagner

I changed your hash to h, so no conflict with sort values:

my %h = ();

$h {1} = [ some string,other string,3 ] ;
$h {2} = [ some string,other string,2 ] ;
$h {3} = [ some string,other string,1 ] ;

foreach my $MyKey (sort { $a-[1]=$b-[1] } map{[$_,$h{$_}[2]]} keys %h) {
   printf %-s - %-s\n, $MyKey-[0], $MyKey-[1];
}

Output:
3 - 1
2 - 2
1 - 3


Wags ;)
-Original Message-
From: Michal Weinfurtner [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 25, 2002 01:21
To: [EMAIL PROTECTED]
Subject: Need help


Hi all ,

I have some data in hash of arrays and i need a print all of entries of
that hash sorted by 2-nd index of arrays. 

Example: 

$a {1} = [ some string,other string,some number ] ;
$a {2} = [ some string,other string,some number ] ;
$a {3} = [ some string,other string,some number ] ;
...
...
...
$a {n} = [ some string,other string,some number ] ;


I need print all hash entries sorted by some number (2-nd index of
arrays ). 

Any suggestions ? 

Thanks a lot 
Michal Weinfurtner 




-- 
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: Need help

2002-08-29 Thread Felix Geerinckx

on Thu, 29 Aug 2002 20:40:19 GMT, David Wagner wrote:

 my %h = ();
 
 $h {1} = [ some string,other string,3 ] ;
 $h {2} = [ some string,other string,2 ] ;
 $h {3} = [ some string,other string,1 ] ;
 
 foreach my $MyKey (sort { $a-[1]=$b-[1] } map{[$_,$h{$_}[2]]}
 keys %h) { 
printf %-s - %-s\n, $MyKey-[0], $MyKey-[1];
 }
 
 Output:
 3 - 1
 2 - 2
 1 - 3

You don't need map in this case, a simple 

foreach my $MyKey ( sort { $h{$a}-[2] = $h{$b}-[2] } keys %h ) {
printf %-s - %-s\n, $MyKey, $h{$MyKey}-[2];
}

will work equally well without the need to create extra anonymous arrays.

-- 
felix

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




Re: how to be safe and secure

2002-08-29 Thread drieux


On Thursday, August 29, 2002, at 11:44 , david wrote:
[..]

 $dsn = get from config
 $usr = get from config
 $psw = get from config

 my $db = new Win32::ODBC(fileDSN=$dsn; uid=$usr; psw=$psw);

 that should avoid the horrifying listing effect...

my compliments - there is the part about the uid and psw
that you could get with

 ($name,$passwd,$uid,$gid,
$quota,$comment,$gcos,$dir,$shell,$expire) = getpw*

cf perldoc -f getpwname

which would only leave one exposed on the $dsn - unless
you wanted to play the gag of having that in the comment
field of the nis map/active directory/ldap...

unless of course $psw has to be in 'plain text' to begin with...

things folks might want to keep in mind when doing the
ConfigDSN side of the game...

a part of the problem here is whether the perl code
should be 'allowed' to do a 'setgid/setuid' to the
appropriate gid/uid to run under that entry - and
hence allow 'anyone who can run it' to run it...

or should it have an 'access list' of uid's allowed
to run the code...



ciao
drieux

---


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




Re: how to be safe and secure

2002-08-29 Thread david

from Brian's code, it seems to me that he's running a windows machine so the 
getpw* stuff you refers to might not be available for him. again, i seldom 
develop anything in windows, so i can't be sure. if you are worry about 
that someone will manually open the config(text base) file, you might want 
to store those in a dbm file like:

#!/usr/bin/perl -w
use strict;
use NDBM_File;
use DB_File;
use Fcntl;

my %hash;

tie %hash,NDBM_File,auth,O_RDWR|O_CREAT|O_EXCL,0777 || die $!;
$hash{'dsn'} = 'dsn';
$hash{'user'} = 'usr';
$hash{'psw'} = 'psw';

__END__

then in your actual script that needs those parameters, just open the dbm 
file again and fetch them:

#!/usr/bin/perl -w
use strict;
use NDBM_File;
use DB_File;
use Fcntl;

my %hash;

tie %hash,NDBM_File,auth,O_RDWR|O_CREAT|O_EXCL,0777 || die $!;
my $dsn = $hash{'dsn'};
my $user = $hash{'user'};
my $psw = $hash{'psw'};

my $db = new Win32::ODBC(fileDSN=$dsn; uid=$usr; psw=$psw);

#-- ...etc

this way, auth.db became a binary file and thus can't be easily viewed with 
a regular text editor.

david

Drieux wrote:

 
 On Thursday, August 29, 2002, at 11:44 , david wrote:
 [..]

 $dsn = get from config
 $usr = get from config
 $psw = get from config

 my $db = new Win32::ODBC(fileDSN=$dsn; uid=$usr; psw=$psw);

 that should avoid the horrifying listing effect...
 
 my compliments - there is the part about the uid and psw
 that you could get with
 
 ($name,$passwd,$uid,$gid,
 $quota,$comment,$gcos,$dir,$shell,$expire) = getpw*
 
 cf perldoc -f getpwname
 
 which would only leave one exposed on the $dsn - unless
 you wanted to play the gag of having that in the comment
 field of the nis map/active directory/ldap...
 
 unless of course $psw has to be in 'plain text' to begin with...
 
 things folks might want to keep in mind when doing the
 ConfigDSN side of the game...
 
 a part of the problem here is whether the perl code
 should be 'allowed' to do a 'setgid/setuid' to the
 appropriate gid/uid to run under that entry - and
 hence allow 'anyone who can run it' to run it...
 
 or should it have an 'access list' of uid's allowed
 to run the code...
 
 
 
 ciao
 drieux
 
 ---


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




ifelsif/hash errors - question

2002-08-29 Thread Gregg O'Donnell
Hey - I'm receciving syntax and global package errors in lines 540-550 of this script, which is running on WinNT. One error I receive is for not defining my hash "%counties" which is, in fact, defined. So, I'm baffled and stuck. Any insight is greatly appreciated!!
GreggDo You Yahoo!?
Yahoo! Finance - Get real-time stock quotes

logger-notify-script3.cgi
Description: logger-notify-script3.cgi

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


Re: ifelsif/hash errors - question

2002-08-29 Thread Robin Norwood

Gregg O'Donnell [EMAIL PROTECTED] writes:

 Hey - I'm receciving syntax and global package errors in lines 540-550 of this 
script, which is running on WinNT. One error I receive is for not defining my hash 
%counties which is, in fact, defined. So, I'm baffled and stuck. Any insight is 
greatly appreciated!!

Looks like line 60 is missing a semicolon:

'
my $logger_info = {
logger_info = {
optional =
[ qw( name_landowner phone_landowner) ],
required =
[ qw( name_logger address1_logger city_logger state zipcode 
phone_logger email_logger county location logging_start acres) ],
constraints  =
{
email_logger= email,
phone_logger= american_phone,
zipcode = '/^\s*\d{5}(?:[-]\d{4})?\s*$/',
state   = state,

},
},#should be ';'


# County names; region email, county email, abbreviations
my %counties = (
'

-RN

-- 

Robin Norwood
Red Hat, Inc.

The Sage does nothing, yet nothing remains undone.
-Lao Tzu, Te Tao Ching

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




Re: ifelsif/hash errors - question

2002-08-29 Thread david

in line 64, you have:
 my %counties = ( #-- line 64

in line 543, you have:
 if ( ! {$counties}) { #-- line 543

in line 64, you declare a %counties hash variable.
in line 543,  you are trying to access the $counties scalar variable which 
do not exist.

remember in Perl that %counties and $counties are completely different 
thing. one is hash and the other is a scalar. the funny character makes 
them totally different stuff.

in your case, you probably don't need to:

if( ! {$counties}) { #-- what is that do anyway???

just remove that line then your script should work(assume that this is the 
only error you have in your script).

david

Gregg O'Donnell wrote:

 
 Hey - I'm receciving syntax and global package errors in lines 540-550 of
 this script, which is running on WinNT. One error I receive is for not
 defining my hash %counties which is, in fact, defined. So, I'm baffled
 and stuck. Any insight is greatly appreciated!!
 
 Gregg
 
 
 
 -
 Do You Yahoo!?
 Yahoo! Finance - Get real-time stock quotes


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




Re: how to be safe and secure

2002-08-29 Thread drieux


On Thursday, August 29, 2002, at 02:32 , david wrote:
[..]
 from Brian's code, it seems to me that he's running a windows machine so 
 the
 getpw* stuff you refers to might not be available for him. again, i seldom
 develop anything in windows, so i can't be sure.
[..]

given that I do not have a 'passwd' entry local on
the OSX box I am working on - i have a level of
confidence that Brian could test it, and see if
he can get at least his own from the domain controller
and/or NIS server ...

I like your NDBM idea - stylish, chic - but a minor
nit to pick with you

a) use DB_FILE; is not required
or were you being polite about it and vectoring
back to the traditional and meant to imply reseting
the cache size, etc, etc, etc

b) there is the ikky with the 'tie' that could
be having issues with the lack of parens

tie (%hash,NDBM_File,auth,O_RDWR|O_CREAT, 0640)  ||
die problem with tie: $! \n;

actually works on both sides - and there is really no hard
core reason to make it executable...

Granted anyone who can 'read' the perl executable will
be able to 'read' the file just as easily...

but that's a part of 'how safe' and how secure

ciao
drieux

---


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




Re: ifelsif/hash errors - question

2002-08-29 Thread david

Robin Norwood wrote:

 Gregg O'Donnell [EMAIL PROTECTED] writes:
 
 Hey - I'm receciving syntax and global package errors in lines 540-550 of
 this script, which is running on WinNT. One error I receive is for not
 defining my hash %counties which is, in fact, defined. So, I'm baffled
 and stuck. Any insight is greatly appreciated!!
 
 Looks like line 60 is missing a semicolon:
 
 '
 my $logger_info = {
 logger_info = {
 optional =
 [ qw( name_landowner phone_landowner) ],
 required =
 [ qw( name_logger address1_logger city_logger state zipcode phone_logger
 email_logger county location logging_start acres) ],
 constraints  =
 {
 email_logger  = email,
 phone_logger  = american_phone,
 zipcode   = '/^\s*\d{5}(?:[-]\d{4})?\s*$/',
 state = state,
 
 },
 },#should be ';'
 
 

1. he is also lacking a } so }, should actually be:

}};

2. line 558:
 my $county_abbrev = $counties{$query-param('County')}-{Abbrev} || '';
} #-- end of block

and then in line 563:

my $conf_number = I-$county_abbrev-$random-$log_date;

in line 558, you are creating a local variable($county_abbrev) tagged with 
'my' so when the block exit, your $county_abbrev will be destoried. so line 
563 is bad since it tries to reference something that doesn't exist.

3. line 619:
print $message ;

tries to reference the $message variable that doesn't exist. another error.

there might be more of those... didn't check the whole script...

david


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




Re: how to be safe and secure

2002-08-29 Thread david

Drieux wrote:

 
 a) use DB_FILE; is not required
 or were you being polite about it and vectoring
 back to the traditional and meant to imply reseting
 the cache size, etc, etc, etc

no, it's the result of a bad copy/paste. 'use DB_FILE' is not required in 
this case.

 
 b) there is the ikky with the 'tie' that could
 be having issues with the lack of parens
 
 tie (%hash,NDBM_File,auth,O_RDWR|O_CREAT, 0640)  ||
 die problem with tie: $! \n;
 

i like the parens too. :-)

david

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




Re: Need help

2002-08-29 Thread Jeff 'japhy' Pinyan

On Apr 25, Michal Weinfurtner said:

I have some data in hash of arrays and i need a print all of entries of
that hash sorted by 2-nd index of arrays.

  sort { $hash{$a}[2] = $hash{$b}[2] } keys %hash

returns the keys in the proper order.  Change '=' to 'cmp' if you're
dealing with strings and not numbers.

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for Regular Expressions in Perl published by Manning, in 2002 **
stu what does y/// stand for?  tenderpuss 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]




RE: Need help

2002-08-29 Thread Jeff 'japhy' Pinyan

On Aug 29, [EMAIL PROTECTED] said:

foreach my $MyKey (sort { $a-[1]=$b-[1] } map{[$_,$h{$_}[2]]} keys %h) {
   printf %-s - %-s\n, $MyKey-[0], $MyKey-[1];
}

You made that extra-difficult.  The sorting field is already given to us
in the hash, so it needn't be manufactured.

  sort { $hash{$a}[2] = $hash{$b}[2] } keys %hash

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for Regular Expressions in Perl published by Manning, in 2002 **
stu what does y/// stand for?  tenderpuss 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]




uniq elements of an array

2002-08-29 Thread Ramprasad A Padmanabhan

Hi All,
   I have been using perl on linux for quiet some time now and I have 
found that Perl does not work the same in windows

   eg. To get all the unique elements of an array in linux I use a 
simple  one liner

   @unique = grep{!/$seen{$_}++/} @all_elements;

But this does not even  pass syntax check on windows
Can Anyone tell me the best way how to get all the unique elements in an 
array preserving the same order


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




Re: Need help

2002-08-29 Thread Dharmendra Rai

use $a{ur_key}-[Index] 



-
Get a bigger mailbox -- choose a size that fits your needs.



Re: uniq elements of an array

2002-08-29 Thread Omanakuttan

eg. To get all the unique elements of an array in linux I use a
 simple  one liner

@unique = grep{!/$seen{$_}++/} @all_elements;


The above expression did not work for me,
I could not even found out how this should work. So I created a small file
with...

@all_elements = qw(hello all elements hello all this that this) ;
@unique = grep{!/$seen{$_}++/} @all_elements;
print @unique ;

in cygwin, error was Quantifier follows nothing before HERE mark in regex
m/+  HERE +/ at try2.pl line 2.


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




Re: uniq elements of an array

2002-08-29 Thread Sudarshan Raghavan

On Fri, 30 Aug 2002, Ramprasad A Padmanabhan wrote:

 Hi All,
I have been using perl on linux for quiet some time now and I have 
 found that Perl does not work the same in windows
 
eg. To get all the unique elements of an array in linux I use a 
 simple  one liner
 
@unique = grep{!/$seen{$_}++/} @all_elements;

This will not work even on linux.

Why do you need to do a pattern match anyways? Just a
@unique = grep{!$seen{$_}} @all_elements;
should do







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