Deleting a hash value

2001-12-10 Thread Daniel Falkenberg

Hi all,

%allusers = (
 'users' => {
'user' => 'Test Account',
'*Crudles' => 'Hello World',
'Crud' => 'Another Test',
'*test' => 'Crud User'
  }
   );

Does any one know how I would go about deleing all hash keys with a star
in them from the following hash?

Would I go something like the following

#!/usr/bin/perl -w

%allusers = (
  'users' => {
'user' => 'Test Account',
'*Crudles' => 'Hello World',
'Crud' => 'Another Test',
'*test' => 'Crud User'
 }
);

#Delete all hashs values with a * at the beginning of their value...

delete $allusers{$users}{$all_values} if ($all_values != /^\*/);

Any ideas?

Regards,

Dan

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




RE: File creation...

2001-12-10 Thread Daniel Falkenberg

Dan,

Just figured it out...

my $backup = #Dir in hash somewhere.  Not important

-T $backup || open(BACKUP, ">/tmp/passwd_backup");

Very, very cool!

Cheers,

Dan


Hi all,

I want my perl code to be able to check to see if a file exist and if
the file doesn't exist I want that file to be created.  What would be my
best way of going about this?

Something like...

$backup_file = $conhash{$title}{'Linux Passwd Backup'}; #Grab location
from a directory located in a hash.

next if (exists($backup_file)) {}
else {
  open(BACKUP, ">backup_file") #Create file backup_file; 


#%conhash looks like this...

%conhash = (
{
 Backup => /tmp/backup_file
},
);

Can any one add or correct this?

Regards,

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]




File creation...

2001-12-10 Thread Daniel Falkenberg

Hi all,

I want my perl code to be able to check to see if a file exist and if
the file doesn't exist I want that file to be created.  What would be my
best way of going about this?

Something like...

$backup_file = $conhash{$title}{'Linux Passwd Backup'}; #Grab location
from a directory located in a hash.

next if (exists($backup_file)) {}
else {
  open(BACKUP, ">backup_file") #Create file backup_file; 


#%conhash looks like this...

%conhash = (
{
 Backup => /tmp/backup_file
},
);

Can any one add or correct this?

Regards,

Dan

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




Re: Open for Reading and Writing.

2001-12-10 Thread John W. Krahn

Joshua Colson wrote:
> 
> I have this code that is acting strange... does anyone know why.
> 
> open( CONFIG, "+ 
> while(  ) {
>   print;
>   print CONFIG;
> }
> 
> close( CONFIG );
> 
> The first time I run the script, it reads the file, which is one line, and
> duplicates that line.
> Now, correct me if I'm wrong, but I would think that each time this is run,
> it would double the size of the file. But it doesn't, it just reads the
> first line, prints it to STDOUT, but not the file again, and exits.  I have
> the sticky bit set on the script, and I don't know if that is what is
> causing it.  Any Ideas?

Each time you read and write to a file the current position in the file
changes (perldoc -f seek perldoc -f tell)  When you have a one line file
the current position points to the end of that line and the second line
is output there.  If you have a two line file the first line is read in,
the pointer moves to the end of that line and the second line is
over-written.


#!/usr/bin/perl -w
use strict;
use Fcntl ':seek';

open CONFIG, '+;

seek CONFIG, 0, SEEK_SET;
print CONFIG $_, $_ for @lines;

close CONFIG;




John
-- 
use Perl;
program
fulfillment

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




Re: mysql....postgres

2001-12-10 Thread iain truskett

* Kiarash Em. ([EMAIL PROTECTED]) [11 Dec 2001 06:29]:

> mySQL vs postgreSQL?!?!

> check this out

> http://www.phpbuilder.com/columns/tim2705.php3?page=1

> ;)

Hmm. Seems rather out of date wrt postgres.

8kb rows? Is that of data? Because postgres quite happily has field
types that allow arbitrary blobs of text or data. I'd probably say that
anyone who hits data limits like that has some issues with the design of
their database itself rather than the DBMS.

The article is also somewhat self-contradictory:

"Postgres is making headway in the performance and stability
departments."

"MySQL loses points in the long-term stability department."

"Postgres will run smoothly for extended periods of time without
trouble."

When it comes to transactions:

"Finally, for the hardest-core developers, Postgres could be pretty
slick. Foreign keys, views, subselects, and transactions can all be
pretty cool -- if you need them and you will make any use of them.
If you don't need them or won't use them, then you're probably
better off with MySQL and its superior performance."

But on the PG page it raves about transactions. For some reason the
author doesn't recommend you investigate transactions.



Then again, I ran MySQL for a year, Oracle for a year and have been
running PostgreSQL for half a year so far.

MySQL was irritating due to its lack of subqueries and transactions (a
somewhat half-baked table type is now available that supports
transactions, rather than it being part of the core of the DBMS, plus,
is it actually release quality yet?). Plus it would frequently decide to
not handle a query for no apparent reason.

Oracle was too large and complex for my purposes. I wasn't willing to
spend the amount of time and effort needed to properly configure and
administer it. Go for Oracle if you have a dedicated DBA and need its
features. It's a good program, just worthy of the Sledgehammer award.

PostgreSQL offers appropriate speed, transactions and fkeys. The
majority of my websites use multiple tables in their database design.
Assorted pages update data as necessary and this data needs to be
reflected in multiple tables. Thus, transactions are superb. I can do
the operations and if any of them fail, I can just rollback, rather than
trying to do them all backwards.

PostgreSQL and its transactions are stable and well worth the effort of
initially learning. All part of the Laziness that Larry talks about. You
can either do it all manually, and thus not necessarily properly, or you
can spend initial effort learning about transactions and have it pay off
in the amount of time you recoup later.


cheers,
-- 
iain.  

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




Re: Permission denied - rename

2001-12-10 Thread John W. Krahn

COLLINEAU wrote:
> 
> I 've written the code below.
> There is a problem with "rename": i have the message: "permission denied".
> 
> Nevertheless, I have all the rights.
> 
> What 's happen ?

Just a guess but it could be that your OS will not let you rename a file
that is open.  You don't have to open the file to stat() it, you can use
the file name.  And instead of using stat() you might want to use the -M
function (perldoc -f -M)



John
-- 
use Perl;
program
fulfillment

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




Re: create multiple unix accounts

2001-12-10 Thread John W. Krahn

Shaunn Johnson wrote:
> 
> It's not so much the logic of the script that I'm concerned
> with, but the security part.  For instance, sometimes if I
> create a user by hand, editing the /etc/passwd (using vipw)
> doesn't really edit the /etc/shadow file.  I'm not sure why,
> either.   It *should*.

To edit /etc/shadow

vipw -s


:-)
John
-- 
use Perl;
program
fulfillment

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




Re: Comparing Lists of Users

2001-12-10 Thread John W. Krahn

Joshua Colson wrote:
> 
> Hello Perl Mongers,
> 
>   I'm trying to compare two lists of users, but I would like input on what
> each of you think would be the best way to do it?
> 
> The first list is comprised of all users in a particular group, in the
> /etc/group format.
> The second list is very similar, but the format is slightly different.
> For example:
> First Group of Users,
> testgroup:x:UID:user0,user1,user2,user3  etc.
> 
> Second Group of Users,
> members=user0,user1,user2
> 
> When a user is added to the first group I need to add them to the second
> group also, and likewise for deleting.

When a user is added or deleted from the first group just copy the whole
list to the second group since they are in the same format.


> What I thought about doing was loading each list into a hash, and checking
> to see if the keys are defined in the other groups hash, but I'm sure that
> there is a better way.  So, if anyone knows what it is, I would appreciate
> the help.



John
-- 
use Perl;
program
fulfillment

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




Re: Help on parsing record file

2001-12-10 Thread John W. Krahn

Shiping Wang wrote:
> 
> Hi , I have following a record file like this:
> 
> [snipped data. see below]
> 
> What I want output is:
> 
> CustProdCata
> 1711
> 842 1523C
> 9306152 B
> 24727   15225   A
> 46917   9828B
> 50  4309C
> 
> For each customer, I only select one product based on an order of B, C, A,
> D.
> 
> I thought I might use some kind of data structure like AOA or HOH, but don't
> know how. Can anyone give me a help to use perl to handle this case?


Here is one way to do it (given the supplied data):


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

my ( %data, $cust, $prod );

while (  ) {
if ( /^Customer ID:\s*(\d+)/ or eof ) {
$cust = $1;
}
elsif ( /^\s+Product ID:\s*(\d+)/ ) {
$prod = $1;
}
elsif ( /^\s+Category:\s*(\S+)/ ) {
$data{$cust}{$prod} = $1;
}
else {
$data{$cust}{''} = '';
}
}

for $cust ( keys %data ) {
for $prod ( keys %{$data{$cust}} ) {
printf "%-8s%-8s%s\n", $cust, $prod, $data{$cust}{$prod};
}
}

__DATA__
Customer ID:1711
* * * No record * * *
Customer ID:842
Product ID: 716
Category:A
Product ID: 1523
Category:C
Product ID: 753
Category:D
Product ID: 76
Customer ID:9306
Product ID: 152
Category:B
Product ID: 34762
Category:D
Product ID: 1956
Category:D
Customer ID:24727
Product ID: 15225
Category:A
Product ID: 9615
Category:D
Customer ID:46917
Product ID: 20401
Category:A
Product ID: 9828
Category:B
Product ID: 665
Category:C
Product ID: 461
Category:D
Product ID: 1335
Customer ID:50
Product ID: 19554
Category:A
Product ID: 4309
Category:C


Output:
46917   665 C
46917   461 D
46917   9828B
46917   20401   A
930634762   D
9306152 B
93061956D
24727   9615D
24727   15225   A
1711
50  19554   A
842 1523C
842 716 A
842 753 D



John
-- 
use Perl;
program
fulfillment

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




getting lines from a file

2001-12-10 Thread Pradeep Sethi

With this code, I get :

#!/usr/bin/perl -w

my $ordfile=shift || die "unable to open : $!s\n";

open (LIST, "<$ordfile") || die "unable to open file $ordfile : $!\n";


while () {
#  chomp;  # a)
  my $line=$_;
  print STDERR "\nline : *** $line ***";
}


line : *** 6M2FD9XV 
 ***
line : *** A9Q2YFU8 
 ***
line : *** BDE6MDBJ 
 ***

If I chang line a) to chomp, I  get

 ***line : *** 6M2FD9XV 
 ***line : *** A9Q2YFU8 
 ***line : *** BDE6MDBJ 

Can somebody explain, what do I need to get lines as complete words with
line breaks etc.

Thanks

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




Data::Dumper and eval question

2001-12-10 Thread Robert Thompson

Hello List,

I am using Data:Dumper in a script and am running into a problem with "use 
strict" and eval. Basically the conundrum is that the data I will be loading from the 
Data::Dumper file is going to be based off input to the final script, so it may not be 
the same for each run of the script. There will be many dumper files that have 
different variables. I cannot predeclare them for "use strict" since I won't know what 
they are until the eval.

The only work around is to turn off use strict, but I would like to continue 
using it. Is there a way, either with Data:Dumper, or something else to get this to 
work?

Here is the snippet of code and some source files, so if one is confused 
hopefully this will explain:

eval shift(@wholetemplatefile); # define $datadumperfile.
eval shift(@wholetemplatefile); # define $outfile.
shift(@wholetemplatefile);  # Get rid of the divider.

# Get the Data::Dumper information.
open (READ_DD, $datadumperfile);
while() {
  eval $_;
}
close(READ_DD);


The error message and source files:

Global symbol "$Test01" requires explicit package name at (eval 3) line 1,  
chunk 1.

>head -3 template.test.html 
$datadumperfile = "test.data";  # The file with the Data::Dumper database.
$outfile = "test.html"; # The final output file.
 DATA BELOW HERE 

>cat test.data
$Test01 = "Foo Baz";
>

Thanks,

=-= Robert Thompson

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




RE: create an NT user with Perl

2001-12-10 Thread norishaam

Hi,
   Try Win32::Netadmin. It has all the modules to handle user accounts in
NT.

   \|||/ 
 (o o) 
ooO-(_)-Ooo
Norishaam Adam
MSA Field Services


-Original Message-
From: Jorge Goncalvez [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 04, 2001 7:48 PM
To: [EMAIL PROTECTED]
Subject: RE:create an NT user with Perl


HI, I wonder if there is a way to create an NT user with Perl?


-- 
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: Uploading files to a web site status bar.

2001-12-10 Thread Curtis Poe

--- Mike Butler <[EMAIL PROTECTED]> wrote:
> I need to create a status bar for users who are
> uploading pdf files, some of them quite large, to a
> web site. Some of the users are on dial-up and the
> upload time could be quite lengthy, so they need to
> know that their upload is progressing and not to
> cancel the operation.
> 
> Is there a way to do this in Perl?
> 
> Thanks,
> 
> Mike Butler

Follow-up to earlier response:  read http://www.perlmonks.org/index.pl?node_id=57335.  
This has
some information you might find useful.

Cheers,
Curtis "Ovid" Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

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




Re: Uploading files to a web site status bar.

2001-12-10 Thread Curtis Poe

--- Mike Butler <[EMAIL PROTECTED]> wrote:
> I need to create a status bar for users who are
> uploading pdf files, some of them quite large, to a
> web site. Some of the users are on dial-up and the
> upload time could be quite lengthy, so they need to
> know that their upload is progressing and not to
> cancel the operation.
> 
> Is there a way to do this in Perl?
> 
> Thanks,
> 
> Mike Butler

Mike,

To do this in Perl, you'll need to be able to access what's going on with the Web 
server while
it's uploading.  That means mod_perl or something similar and I can't help you there.  
If you have
a straight CGI or ISAPI script, your script won't be able to respond until *after* 
this file is
uploaded.

Maybe there's something with Javascript?  I don't recall seeing anything like that, 
but it's a
thought.

Cheers,
Curtis "Ovid" Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

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




Open for Reading and Writing.

2001-12-10 Thread Joshua Colson

I have this code that is acting strange... does anyone know why.

open( CONFIG, "+ ) {
  print;
  print CONFIG;
}

close( CONFIG );

The first time I run the script, it reads the file, which is one line, and
duplicates that line.
Now, correct me if I'm wrong, but I would think that each time this is run,
it would double the size of the file. But it doesn't, it just reads the
first line, prints it to STDOUT, but not the file again, and exits.  I have
the sticky bit set on the script, and I don't know if that is what is
causing it.  Any Ideas?

Joshua Colson
Systems Administrator
Giant Industries, Inc.
(480) 585-8714
[EMAIL PROTECTED]




Uploading files to a web site status bar.

2001-12-10 Thread Mike Butler

I need to create a status bar for users who are
uploading pdf files, some of them quite large, to a
web site. Some of the users are on dial-up and the
upload time could be quite lengthy, so they need to
know that their upload is progressing and not to
cancel the operation.

Is there a way to do this in Perl?

Thanks,

Mike Butler

=
email: [EMAIL PROTECTED]
web: www.hotlux.com and www.mikyo.com

__ 
Send your holiday cheer with http://greetings.yahoo.ca

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




RE: help with open open function

2001-12-10 Thread Wagner-David

You are right. I looked at but only saw the ..\.. and not that they were 
switched. I tested(this time) and it worked as it should. You don't need to escape the 
.'s.

Wags ;)
-Original Message-
From: Agustin Rivera [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 10, 2001 15:41
To: Lance Prais; [EMAIL PROTECTED]
Subject: Re: help with open open function


Well, besides escaping the periods, you also have it backwards.  It should
be
open(Workflow, "workflow.txt") || die $!;

Unless someone knows something I don't..but I couldn't get it to work your
way.

Regards,
Agustin Rivera
Webmaster, Pollstar.com
http://www.pollstar.com



- Original Message -
From: "Lance Prais" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, December 10, 2001 5:20 PM
Subject: help with open open function


> I am using the following statement to open a document.
>
> open("..\..\workflow.txt", "Workflow")|| die "Cannot open Workflow $!\n";
>
> 1. the perl.exe resides in e:\perl\bin\perl.exe
> 2. the workflow.txt reside is e:
> 3. the error I am getting is "Cannot open workflow No Such file or
> directory"
>
> What am I doing wrong.
>
> I have tried to place them in the same directory structure and just use
> open(workfloe.txt) but receive the same errors.
>
>
> --
> 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: help with open open function

2001-12-10 Thread Agustin Rivera

Well, besides escaping the periods, you also have it backwards.  It should
be
open(Workflow, "workflow.txt") || die $!;

Unless someone knows something I don't..but I couldn't get it to work your
way.

Regards,
Agustin Rivera
Webmaster, Pollstar.com
http://www.pollstar.com



- Original Message -
From: "Lance Prais" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, December 10, 2001 5:20 PM
Subject: help with open open function


> I am using the following statement to open a document.
>
> open("..\..\workflow.txt", "Workflow")|| die "Cannot open Workflow $!\n";
>
> 1. the perl.exe resides in e:\perl\bin\perl.exe
> 2. the workflow.txt reside is e:
> 3. the error I am getting is "Cannot open workflow No Such file or
> directory"
>
> What am I doing wrong.
>
> I have tried to place them in the same directory structure and just use
> open(workfloe.txt) but receive the same errors.
>
>
> --
> 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]




help with open open function

2001-12-10 Thread Lance Prais

I am using the following statement to open a document.

open("..\..\workflow.txt", "Workflow")|| die "Cannot open Workflow $!\n";

1. the perl.exe resides in e:\perl\bin\perl.exe
2. the workflow.txt reside is e:
3. the error I am getting is "Cannot open workflow No Such file or
directory"

What am I doing wrong.

I have tried to place them in the same directory structure and just use
open(workfloe.txt) but receive the same errors.


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




RE: help with open open function

2001-12-10 Thread Wagner-David

you are escaping your .'s though not want you want to do:
  need either ..\\..\\workflow.txt or ../../workflow.txt

Use one or other and should work if file is there.

Wags ;)

-Original Message-
From: Lance Prais [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 10, 2001 17:21
To: [EMAIL PROTECTED]
Subject: help with open open function


I am using the following statement to open a document.

open("..\..\workflow.txt", "Workflow")|| die "Cannot open Workflow $!\n";

1. the perl.exe resides in e:\perl\bin\perl.exe
2. the workflow.txt reside is e:
3. the error I am getting is "Cannot open workflow No Such file or
directory"

What am I doing wrong.

I have tried to place them in the same directory structure and just use
open(workfloe.txt) but receive the same errors.


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




Permission denied - rename

2001-12-10 Thread COLLINEAU Franck FTRD/DMI/TAM

Hi!

I 've written the code below.
There is a problem with "rename": i have the message: "permission denied".

Nevertheless, I have all the rights.

What 's happen ?

Franck
___
#!/usr/bin/perl -w
$now=time;
opendir (INFO,"l:/01_informatique") || die " impossible  d'ouvrir le
répertoire 01_informatique: $!";
while ($fic=readdir INFO)
{
next if ($fic eq "." or $fic eq "..");
if (($fic=~/^c/) && ($fic=~/htm$/))
{
open (FICHIER,"l:/01_informatique/$fic") || "erreur: $!";
$age1=(stat(FICHIER))[9];
$age2=int(($now-$age1)/3600/24);
rename
("l:/01_informatique/$fic","l:/01_informatique/$fic.old") || die "renomage
impossible: $!" if ($age2>365);

close FICHIER;
}

}
close INFO;

_



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




Re: Passing variables

2001-12-10 Thread William.Ampeh


This may sound too simple but this is the way I would have done it.


In the front-end script, initialize the variables

$VAR_1="";
$VAR_2="";

Then in the child scripts, you can change these variable
$VAR_1="foo1";
$VAR_2="foo2";

If you use strict (what happens?).  I have not tried it yet.
__

William Ampeh (x3939)
Federal Reserve Board


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




RE: mysql....postgres

2001-12-10 Thread Curtis Poe

--- Mike Gargiullo <[EMAIL PROTECTED]> wrote:
> Oracle is 
> 
> How many inserts/second are you taking about?

If anyone would like to follow-up on this, it might be better to email me directly 
rather than
continue this very off-topic thread :)

I don't know how many inserts per second.  We're working in the dark, here.  We have a 
product
that has been relatively successful in keeping our client's costs down, so we now have 
a
particular industry association which has said that if we develop the next phase of 
our product,
they're going to market it to their manufacturers and dealers.  We already have some 
very large
industry players who've come to us telling us that they're on board as soon as we 
finish it. 
Unfortunately, this requires a complete revamping of the way we handle inventory for 
them, but it
earns us a mind-boggling revenue stream if we can deliver and if they follow through 
on their
commitment.

Since this allows manufacturers and retailers to have POS, inventory management, 
e-commerce,
real-time site customization and a true client-server architecture (rather than being 
forced to
rely solely on a Web-based system) we have a rather large database that is still 
growing.  I just
can't recommend migrating from MS SQL Server unless I get better information on the 
databases
under consideration.  MySQL just won't cut it.  Postgres looks interesting, but I just 
haven't
found enough evidence that it will really handle what we need.  Hence, Oracle looks 
like a
promising choice.

Side note:  MS SQL Server has been a huge bottleneck for us because our DBA didn't 
know it very
well (he has been fired) and it keeps crashing, often taking down the box with it.  We 
have some
insite as to why it's been failing, but it's such a pain in the rear, that we're sick 
of it. 
Plus, we can't run it on Linux.

Cheers,
Curtis "Ovid" Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

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




Re: create multiple unix accounts

2001-12-10 Thread William.Ampeh




In Bourne shell, you could do:
for i in `echo name_a  name_b  name_c  name_d  name_e  name_f  name_g`
do
 echo "creating user account: $i"; passwd $i< secret_$i
done

--

In C-sh
foreach i (`echo name_a  name_b  name_c  name_d  name_e  name_f  name_g`)
 echo "creating user account: $i"
 useradd $i; passwd $i  < secret_$i
end

-

The only problem I see here is with the password.  Maybe someone has a tip
on randomizing
this, and also I do not know how to use scripting to force a user to change
their password
when they first logon.
__

William Ampeh (x3939)
Federal Reserve Board


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




RE: mysql....postgres

2001-12-10 Thread Mike Gargiullo

Oracle is 

How many inserts/second are you taking about?

-Original Message-
From: Curtis Poe [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 10, 2001 3:52 PM
To: Etienne Marcotte
Cc: [EMAIL PROTECTED]
Subject: Re: mysqlpostgres



--- Etienne Marcotte <[EMAIL PROTECTED]> wrote:
> MySQL is about speed, unless you do tons of inserts and absolutely
can't
> afford table locking, go with mysql..

Regrettably, we do have to handle tons of inserts, so this is
problematic.  The software that
we're evaluating databases for offers complete B-B-C support for an
entire industry, so we may be
forced to take a look at Oracle, too.

Cheers,
Curtis "Ovid" Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.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: mysql....postgres

2001-12-10 Thread Curtis Poe


--- Etienne Marcotte <[EMAIL PROTECTED]> wrote:
> MySQL is about speed, unless you do tons of inserts and absolutely can't
> afford table locking, go with mysql..

Regrettably, we do have to handle tons of inserts, so this is problematic.  The 
software that
we're evaluating databases for offers complete B-B-C support for an entire industry, 
so we may be
forced to take a look at Oracle, too.

Cheers,
Curtis "Ovid" Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

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




Re: printing web search result

2001-12-10 Thread Flavio Soibelmann Glock

>   I want to print just the web result with any other
>  information on the page. How can i do that ?

It's in the browser, not a cgi problem.
Look for "page setup" or equivalent in your browser.
Then disable headers and footers.

- Flávio Soibelmann Glock

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




create multiple unix accounts

2001-12-10 Thread Johnson, Shaunn

Howdy:

It seems that this would have been brought up a few
times, but, is there a script in around to create
multiple unix accounts?  Rather, I have a lot of accounts
to create and I don't want to go over them by hand every
time a batch of request comes in.

It's not so much the logic of the script that I'm concerned
with, but the security part.  For instance, sometimes if I
create a user by hand, editing the /etc/passwd (using vipw)
doesn't really edit the /etc/shadow file.  I'm not sure why, 
either.   It *should*.  As for a script, are there any 
scripts that take security for accounts into account?

Now that I think about it, it sounds like i should butcher
the useradd / adduser script and work from there ... just
wanted to see if there was an alternative with Perl.

Just thinking out loud.

-X



Re: mysql....postgres

2001-12-10 Thread Etienne Marcotte

well

mySQL *DO* now support transactions with innoDB

www.innoDB.com

There is a guy from the innoDB team also on the [EMAIL PROTECTED]
that can probably answer all your questions.

MySQL is about speed, unless you do tons of inserts and absolutely can't
afford table locking, go with mysql..

Plus I read that the settings of his mysql weren't good so that's why
the mysql was crashing after many connections.

Etienne

Curtis Poe wrote:
> 
> --- "Kiarash Em." <[EMAIL PROTECTED]> wrote:
> >
> > mySQL vs postgreSQL?!?!
> >
> > check this out
> >
> > http://www.phpbuilder.com/columns/tim2705.php3?page=1
> >
> > ;)
> 
> While we're on the subject of databases, my company is considering switching from MS 
>SQL Server.
> We absolutely need transactions, so MySQL is out of the question.  However, while I 
>was intrigued
> by Postgres, I told the CTO that I would not endorse it unless I can see empirical 
>(not
> anecdotal!) evidence that it can support what we need.  He pointed out that, by my 
>logic, I can't
> endorse MS SQL Server because their license *specifically forbids* publishing 
>benchmarks of their
> database if you accept their licesnse agreement.  Hmmm
> 
> And yes, we build our Web sites with Perl, so this is kind of on-topic, right? :)
> 
> Cheers,
> Curtis "Ovid" Poe
> --
> 
> =
> Senior Programmer
> Onsite! Technology (http://www.onsitetech.com/)
> "Ovid" on http://www.perlmonks.org/
> 
> __
> Do You Yahoo!?
> Send your FREE holiday greetings online!
> http://greetings.yahoo.com
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
Etienne Marcotte
Specifications Management - Quality Control
Imperial Tobacco Ltd. - Montreal (Qc) Canada
514.932.6161 x.4001

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




Re: mysql....postgres

2001-12-10 Thread Curtis Poe

--- "Kiarash Em." <[EMAIL PROTECTED]> wrote:
> 
> mySQL vs postgreSQL?!?!
> 
> check this out
> 
> http://www.phpbuilder.com/columns/tim2705.php3?page=1
> 
> ;)

While we're on the subject of databases, my company is considering switching from MS 
SQL Server. 
We absolutely need transactions, so MySQL is out of the question.  However, while I 
was intrigued
by Postgres, I told the CTO that I would not endorse it unless I can see empirical (not
anecdotal!) evidence that it can support what we need.  He pointed out that, by my 
logic, I can't
endorse MS SQL Server because their license *specifically forbids* publishing 
benchmarks of their
database if you accept their licesnse agreement.  Hmmm

And yes, we build our Web sites with Perl, so this is kind of on-topic, right? :)

Cheers,
Curtis "Ovid" Poe
--

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

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




Re: printing web search result

2001-12-10 Thread Etienne Marcotte

code snipplet please? :-)

It would really help us to help you!

Etienne

Joe Echavarria wrote:
> 
> Hi there,
> 
>   I have made a web based application using perl, and
> when  i try to print a search result page i always get
> at a footer note indicating the path of the file, the
> date and at the top of the page other information like
> "page 1 of 1".
> 
>   I want to print just the web result with any other
> information on the page. How can i do that ?
> 
>   Thanks for your time,
> 
>  Joe.
> 
> __
> Do You Yahoo!?
> Send your FREE holiday greetings online!
> http://greetings.yahoo.com
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
Etienne Marcotte
Specifications Management - Quality Control
Imperial Tobacco Ltd. - Montreal (Qc) Canada
514.932.6161 x.4001

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




printing web search result

2001-12-10 Thread Joe Echavarria

Hi there,

  I have made a web based application using perl, and
when  i try to print a search result page i always get
at a footer note indicating the path of the file, the
date and at the top of the page other information like
"page 1 of 1".

  I want to print just the web result with any other
information on the page. How can i do that ?


  Thanks for your time,

 Joe.

__
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

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




Re: mysql....postgres

2001-12-10 Thread Kiarash Em.


mySQL vs postgreSQL?!?!

check this out

http://www.phpbuilder.com/columns/tim2705.php3?page=1

;)





>From: "Brett W. McCoy" <[EMAIL PROTECTED]>
>To: nafiseh saberi <[EMAIL PROTECTED]>
>CC: <[EMAIL PROTECTED]>
>Subject: Re: mysqlpostgres
>Date: Thu, 6 Dec 2001 06:57:41 -0500 (EST)
>
>On Thu, 6 Dec 2001, nafiseh saberi wrote:
>
> > why do you use always "mysql" and
> > not "postgres" ??
>
>I use PostgreSQL myself, have since like 1997 or so.
>
>-- Brett
>   http://www.chapelperilous.net/
>
>Booze is the answer.  I don't remember the question.
>
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>


_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


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




dynamically size a text field

2001-12-10 Thread Kevin Harwood

Is there a way to change the size of a text field to dynamically fit the
size of the client window?
Currently I'm using this in cgi.pm

print $query->textarea($entry,$old_values,10,75) . "\n ";




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




Re: set focus on a cgi form upon loading

2001-12-10 Thread Etienne Marcotte

it is dhtml/javascript

onload function in the body tag that sets focus on a particular form
element form.fieldname



HTH

Etienne

Kevin Harwood wrote:
> 
> Is there a way to place the cursor in a text field automatically upon
> loading a cgi form?
> 
> Here is the field and some of the code:
> 
> print $query->start_form();
> 
>   print "";
>   print "Tool Name";
>   print $query->textfield('name'), "\n";
>   print "";
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
Etienne Marcotte
Specifications Management - Quality Control
Imperial Tobacco Ltd. - Montreal (Qc) Canada
514.932.6161 x.4001

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




Re: set focus on a cgi form upon loading

2001-12-10 Thread Maurice Reeves

http://www.wiley.com/legacy/compbooks/stein/text/javascript.txt
This link will take you to the 'OFFICIAL GUIDE TO PROGRAMMING WITH CGI.PM' 
website which lists code examples, and specifically this one
shows how to use Javascript with CGI.

hth,
Maurice Reeves


>From: "Kevin Harwood" <[EMAIL PROTECTED]>
>Reply-To: "Kevin Harwood" <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: set focus on a cgi form upon loading
>Date: Mon, 10 Dec 2001 10:33:53 -0800
>
>Is there a way to place the cursor in a text field automatically upon
>loading a cgi form?
>
>Here is the field and some of the code:
>
>print $query->start_form();
>
>   print "";
>   print "Tool Name";
>   print $query->textfield('name'), "\n";
>   print "";
>
>
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>


_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


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




set focus on a cgi form upon loading

2001-12-10 Thread Kevin Harwood

Is there a way to place the cursor in a text field automatically upon
loading a cgi form?

Here is the field and some of the code:

print $query->start_form();

  print "";
  print "Tool Name";
  print $query->textfield('name'), "\n";
  print "";



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




RE: only accept 10 characters

2001-12-10 Thread Wagner-David

If already cleaned up, then could
$phonenbr = substr($phonenbr,0,10);

Wags ;)

-Original Message-
From: rory o'connor [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 10, 2001 10:03
To: [EMAIL PROTECTED]
Subject: only accept 10 characters


Thanks for everyone's help so far!  This is an enjoyable list to read 
everyday.

OK, can someone tell me how to take a variable that *may* be over 10 
characters, and blow away anything after the 10th caracter?  

I am operating on phone numbers and the first thing I am doing is blowing 
away any non-numeric characters, now I need to blow away anything after 10th 
digit (in case they tried to enter extension or some other accidental 
numbers).

thanks,

rory

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




only accept 10 characters

2001-12-10 Thread rory o'connor

Thanks for everyone's help so far!  This is an enjoyable list to read 
everyday.

OK, can someone tell me how to take a variable that *may* be over 10 
characters, and blow away anything after the 10th caracter?  

I am operating on phone numbers and the first thing I am doing is blowing 
away any non-numeric characters, now I need to blow away anything after 10th 
digit (in case they tried to enter extension or some other accidental 
numbers).

thanks,

rory

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




Re: Use perl to change File names

2001-12-10 Thread Peter Scott

At 11:28 AM 12/10/01 -0600, Booher Timothy B 1stLt AFRL/MNAC wrote:
>I want to be able to rename a file name from one number series to
>another number series ie:
>
>Image1.jpg
>Image2.jpg
>Image3.jpg
>
>
>to
>
>Foo234.jpg
>Foo235.jpg
>Foo236.jpg
>
>
>Is there a way to do this using regular expressions? Is there a more elegant
>way to adding a counter to the script above and hard-code the argument?

Quick-n-dirty:

for (glob("Image*.jpg")) {
   /(\d+)\./ and rename $_, "Foo$1.jpg";
}

A bit more flexible:

# my_rename("Image", "Foo");
sub my_rename {
   my ($from, $to) = @_;
   for (glob("$from*.jpg)) {
 /(\d+)\./ and rename $_, "$to$1.jpg";
   }
}

Even more so:

# my_rename('Image(\d+).jpg', 'Foo$1.jpg');
sub my_rename {
   my $from = qr/^$_[0]$/s;
   for (glob "*") {
 next unless /$from/;
 my $to = eval qq("$_[1]");
 rename $_, $to unless -e $to;
   }
}

Watch that the backslashes get passed through properly, and be aware that 
glob() can have trouble with large result sets pre-5.6.

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com


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




Uninstall and re-install of Perl

2001-12-10 Thread Matt Thoene

Hi,

I have a Mandrake Linux machine running Perl 5.6.0 from the installation
RPM's.  I have tried, several times unsuccessfully, to upgrade to Perl
5.6.1 and am running into all kinds of problems...too numerous to
mention here.  Bottom line is this...I'd like to just remove all
instances of Perl from the machine and start anew, installing the latest
version of Perl.  What's the best way to go about this?  

Thanks.

-Matt


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




Re: Mod_perl insight

2001-12-10 Thread Etienne Marcotte

http://perl.apache.org/guide/

That is the place

As for scripts, well if you are already coding strict, not declaring
file scoped variables, it should not be very difficult. The guide gives
the most common "mistakes" and ways to correct them.

The best thing is to test your scripts on a local network where apache
runs only one process, so that you can check by reloading the page if
some variables are transferred where they should not be.

Etienne

Ian Zapczynski wrote:
> 
> Hello all,
> 
> I'm a UNIX administrator with prior experience with Perl CGI on Windows
> NT.  It looks as if I may be taking on some new Perl work which will
> make use of mod_perl with Apache.  All I know so far about mod_perl is
> that the perl scripts run as part of the Apache process instead of
> forking a new Perl process each time a script is called (at least I hope
> I have described this accurately).  I realize I need to do some reading,
> but I am wondering whether I can expect, given experience with
> traditional Perl CGI, a major or minor learning curve with regards to
> writing scripts that make use of mod_perl.  Is it as simple, for
> example, as calling specific modules at the start of each script, or is
> there much I have to consider when writing my new programs?   URL
> suggestions are certainly welcome.
> 
> Thanks,
> 
> -Ian
> 
>   
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
Etienne Marcotte
Specifications Management - Quality Control
Imperial Tobacco Ltd. - Montreal (Qc) Canada
514.932.6161 x.4001

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




Mod_perl insight

2001-12-10 Thread Ian Zapczynski

Hello all,

I'm a UNIX administrator with prior experience with Perl CGI on Windows
NT.  It looks as if I may be taking on some new Perl work which will
make use of mod_perl with Apache.  All I know so far about mod_perl is
that the perl scripts run as part of the Apache process instead of
forking a new Perl process each time a script is called (at least I hope
I have described this accurately).  I realize I need to do some reading,
but I am wondering whether I can expect, given experience with
traditional Perl CGI, a major or minor learning curve with regards to
writing scripts that make use of mod_perl.  Is it as simple, for
example, as calling specific modules at the start of each script, or is
there much I have to consider when writing my new programs?   URL
suggestions are certainly welcome.

Thanks,

-Ian



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


Use perl to change File names

2001-12-10 Thread Booher Timothy B 1stLt AFRL/MNAC

Hello - I have been trying to use perl to change filenames this morning, and
have been having a lot of luck, but have hit a stopping point. I have
lwall's code:

#!/usr/local/bin/perl
#
# Usage: rename perlexpr [files]

($regexp = shift @ARGV) || die "Usage:  rename perlexpr [filenames]\n";

if (!@ARGV) {
   @ARGV = ;
   chomp(@ARGV);}

foreach $_ (@ARGV) {
   $old_name = $_;
   eval $regexp;
   die $@ if $@;
   rename($old_name, $_) unless $old_name eq $_;
}

exit(0);

but I want to be able to rename a file name from one number series to
another number series ie:

Image1.jpg
Image2.jpg
Image3.jpg


to

Foo234.jpg
Foo235.jpg
Foo236.jpg


Is there a way to do this using regular expressions? Is there a more elegant
way to adding a counter to the script above and hard-code the argument?

Thanks for any help,

tim


Timothy B Booher, Lt USAF, AFRL/MNAC
101 West Eglin Blvd, Suite 339 
Eglin AFB FL 32542-6810 
Phone: 850-882-8302 Ext. 3360 (DSN 872-)
FAX: 850-882-2201

 -Original Message-
From:   COLLINEAU Franck FTRD/DMI/TAM
[mailto:[EMAIL PROTECTED]] 
Sent:   Monday, December 10, 2001 4:08 AM
To: '[EMAIL PROTECTED]'
Subject:Stat function

Greetings,

I have the following code:

opendir (INFO,"l:/01_informatique") || die " impossible  d'ouvrire le
répertoire 01_informatique: $!";

while ($fic=readdir INFO)
{
if($fic=~/^c/)
{
@date=stat($fic);
print "$date[7]\n";
}
}
close INFO;


There is nothing in the screen !

Best regards,

Franck

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



Re: eval scope

2001-12-10 Thread Jenda Krynicky

From: Jon Molin <[EMAIL PROTECTED]>
> I'm trying to use eval () with a constants module and it works very
> funny, can anyone explain this behavior to me. It seems to me as this
> is a scope thing. If i remove the 'my' it works fine but i can't see
> why it shouldn't work with my:
> 
> i have a module with constants (constants.pm):
> ##
> package constants;
> my %month_number = (
> ... 
> 
> sub get_constant
> {
> my $name = shift;
> my $ret = ();
>  "$month_number{Dec}\n"; #<-- ODD ROW
> eval '$ret = \\%month_number';
> print "$_ -> $ret->{$_}\n" foreach (keys %{$ret}); # just to trace
> print "$ret=$ret->{Dec}\n";# just to trace
> return $ret;
> }
> 1;

Well this is a tricky one.

If you write something like :

sub fooGen {
my $x = shift();
return sub { map {$_ + $x} @_};
}

$foo = fooGen(3);
print join(', ', &$foo(1,2,3,4,5)),"\n";

Then you've created a so called "closure". The $foo contains a 
reference to a function that somehow remembers what was the 
value of $x in the block where the subroutine was created.

And it doesn't only remember the VALUE, it really uses the 
VARIABLE! Try this :

sub fooGen {
my $x = shift();
return sub { map {$_ + $x} @_}, sub {$x = shift;};
}

( $foo, $setfoo) = fooGen(3);
print join(', ', &$foo(1,2,3,4,5)),"\n";
&$setfoo(10);
print join(', ', &$foo(1,2,3,4,5)),"\n";

You see that those closures SHARE the variable.

The

my $var = ...;
sub Foo {
...
}

is also a closure even if it doesn't look like one (it's IMHO a 
degenerated case of closure, but ...)

Now if you create a subroutine in a block where you defined a lot of 
lexical variables should it remember them all? Plus all those that 
were defined in the parent block, and its parent ...

That'd be pretty inefficient.

So a closure ONLY remembers those variables that are BEING 
USED in it. And not the others.

So if you include that odd row the compiler knows you are using 
the variable in the closure, so it remembers that variable. If you 
don't ...

Jenda

P.S.: Your constants module looks strange. What do you want to 
acomplish? Wouldn't it be better to use Exporter:

package constants;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(%month_number $scalarConst);

our %month_number = ( ... );
our $scalarConst = 15;

1;

and then use it like this :

use constants qw(%month_number);

Also, please don't use all-lower-case names for modules. All-lower-
case is supposed to be used only for "pragmas". For things like 
"strict", "warnings", "constant" etc.

Use something like "Local::constants" or "JonMolin::constants".


P.P.S.: If you did not understand what am I talking about in this 
mail, don't worry. And if you really only want to have a module with 
some constants, use the Exporter method.

=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
--- me

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




Comparing Lists of Users

2001-12-10 Thread Joshua Colson

Hello Perl Mongers,

  I'm trying to compare two lists of users, but I would like input on what
each of you think would be the best way to do it?

The first list is comprised of all users in a particular group, in the
/etc/group format.
The second list is very similar, but the format is slightly different.
For example:
First Group of Users,
testgroup:x:UID:user0,user1,user2,user3  etc.

Second Group of Users,
members=user0,user1,user2

When a user is added to the first group I need to add them to the second
group also, and likewise for deleting.

What I thought about doing was loading each list into a hash, and checking
to see if the keys are defined in the other groups hash, but I'm sure that
there is a better way.  So, if anyone knows what it is, I would appreciate
the help.

Thanks!

Joshua Colson
Systems Administrator
Giant Industries, Inc.
(480) 585-8714
[EMAIL PROTECTED]




Help on parsing record file

2001-12-10 Thread WANG, SHIPING [AG/1000]

Hi , I have following a record file like this:

Customer ID:1711
* * * No record * * *
Customer ID:842
Product ID: 716
Category:A
Product ID: 1523
Category:C
Product ID: 753
Category:D
Product ID: 76
Customer ID:9306
Product ID: 152
Category:B
Product ID: 34762
Category:D
Product ID: 1956
Category:D
Customer ID:24727
Product ID: 15225
Category:A
Product ID: 9615
Category:D
Customer ID:46917
Product ID: 20401
Category:A
Product ID: 9828
Category:B
Product ID: 665
Category:C
Product ID: 461
Category:D
Product ID: 1335
Customer ID:50
Product ID: 19554
Category:A
Product ID: 4309
Category:C
__

What I want output is:

CustProdCata
1711
842 1523C
9306152 B   
24727   15225   A
46917   9828B
50  4309C

For each customer, I only select one product based on an order of B, C, A,
D.

I thought I might use some kind of data structure like AOA or HOH, but don't
know how. Can anyone give me a help to use perl to handle this case?

Thank you in advance! 

Shiping

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




RE: Problem with replacing hash elements - solved

2001-12-10 Thread Epperson, Randall W

Thanks David, that solved my problem.

-Original Message-
From: Wagner-David [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 07, 2001 12:29 PM
To: Epperson, Randall W; Perl Beginners list (E-mail)
Subject: RE: Problem with replacing hash elements


Here is a shot which works with data provided, but others may
see other real problems with it. When it comes to hash and ref to to
array within hash, I have not the best understanding.

 use strict "refs";
 #-
 # define some variables   
 #-
# $notify_file = "/usr/local/bin/unix_notify";  
# open(NOTIFY, $notify_file) or 
#die "$0: cannot open $notify_file: $!\n";  
   
 # load the notify file into a hash ---
while (  ) {

   chomp;   # remove newline char  
   next if /^\s*#/; # skip comments
   next unless s/^(.*?):\s*//;  # look for xxx:   format   
   $notify_email{$1} = [ split /;/ ];  
 } 

foreach $key ( keys(%notify_email) ) {

   print "the notify code is $key\n";
   my $MyOffset = 0;
   foreach my $element ( @{ $notify_email{$key} } ) {

  if (exists $notify_email{$element}) { 
   # use of splice to replace which may not work correctly if
another array, but like said
   # works with data provided.
   #
 splice( @{ $notify_email{$key}}, $MyOffset, 1, (@{
$notify_email{$element} }) ); 
   }
  $MyOffset++; 
} 
 } 
 
print "\n";
foreach $key ( keys(%notify_email) ) {

   print "the notify code is $key\n";
   foreach my $element ( @{ $notify_email{$key} } ) {

  print "  $element\n";  
} 
 }  
__DATA__
e-internalteam: e-randy;e-joel;e-darren
e-randy: [EMAIL PROTECTED]
e-joel: [EMAIL PROTECTED]
e-darren: [EMAIL PROTECTED]
^--- Script ends here

Output:
the notify code is e-internalteam
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
the notify code is e-joel
  [EMAIL PROTECTED]
the notify code is e-darren
  [EMAIL PROTECTED]
the notify code is e-randy
  [EMAIL PROTECTED]

-Original Message-
From: Epperson, Randall W [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 07, 2001 07:48
To: Perl Beginners list (E-mail)
Subject: Problem with replacing hash elements


Greetings

Here is the format of my notify file:
e-internalteam: e-randy;e-joel;e-darren
e-randy: [EMAIL PROTECTED]
e-joel: [EMAIL PROTECTED]
e-darren: [EMAIL PROTECTED]

I'm trying to build a hash of arrays that looks like this:
e-internalteam [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED]
e-randy [EMAIL PROTECTED]
e-joel [EMAIL PROTECTED]
e-darren [EMAIL PROTECTED]

Here is my code:

 #!/usr/bin/perl -w
 use strict "refs";
 #-
 # define some variables   
 #-
 $notify_file = "/usr/local/bin/unix_notify";  
 open(NOTIFY, $notify_file) or 
die "$0: cannot open $notify_file: $!\n";  
   
 # load the notify file into a hash ---
 while (  )
 { 
   chomp;   # remove newline char  
   next if /^\s*#/; # skip comments
   next unless s/^(.*?):\s*//;  # look for xxx:   format   
   $notify_email{$1} = [ split /;/ ];  
 } 
   
 # insure any notify codes are resolved
 foreach $key ( keys(%notify_email) )  
 { 
 print "the notify code is $key\n";
 foreach my $element ( @{ $notify_email{$key} } )
 { 

eval scope

2001-12-10 Thread Jon Molin

Hi list,

I'm trying to use eval () with a constants module and it works very
funny, can anyone explain this behavior to me. It seems to me as this is
a scope thing. If i remove the 'my' it works fine but i can't see why it
shouldn't work with my:

i have a module with constants (constants.pm):
##
package constants;
my %month_number = (
'Jan' => '01',
'Feb' => '02',
'Mar' => '03',
'Apr' => '04',
'May' => '05',
'Jun' => '06',
'Jul' => '07',
'Aug' => '08',
'Sep' => '09',
'Oct' => '10',
'Nov' => '11',
'Dec' => '12'
);

sub get_constant
{
my $name = shift;
my $ret = ();
 "$month_number{Dec}\n"; #<-- ODD ROW
eval '$ret = \\%month_number';
print "$_ -> $ret->{$_}\n" foreach (keys %{$ret}); # just to trace
print "$ret=$ret->{Dec}\n";# just to trace
return $ret;
}
1;
#EOF

and a dummyscript constant.pl:

use constants;
my $bla = &constants::get_constant ('%month_number');
#EOF


when i run the script with row (<--- ODD ROW) it works fine:
bash-2.04$ perl constant.pl 
Oct -> 10
Dec -> 12
Mar -> 03
Feb -> 02
Jan -> 01
Nov -> 11
May -> 05
Aug -> 08
Sep -> 09
Jul -> 07
Apr -> 04
Jun -> 06
HASH(0x80f8270)=12

but if i remove that line i get:
bash-2.04$ perl constant.pl 
HASH(0x80f8270)=


ie it doesn't seems to find the variable...This seems like vodoo to me.
Can anyone explain or point me to a place with an explanation?


/Jon

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




Re: Stat function

2001-12-10 Thread Maurice Reeves

Perhaps the more idiomatic way to do what you want
would be:

use strict;
my $directory = shift;
chdir $directory or die "Unable to change to directory: $!\n";
while (<*>) # this automagically loops through the current dir
{
# I think you're trying to get last accessed date
print -A, "\n" if /^c/;
}

hth,
Maurice Reeves
buzzcutbuddha www.perlmonks.org

>From: COLLINEAU Franck FTRD/DMI/TAM  
><[EMAIL PROTECTED]>
>To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
>Subject: Stat function
>Date: Mon, 10 Dec 2001 11:08:10 +0100
>
>Greetings,
>
>I have the following code:
>
>opendir (INFO,"l:/01_informatique") || die " impossible  d'ouvrire le
>répertoire 01_informatique: $!";
>
>while ($fic=readdir INFO)
>{
>   if($fic=~/^c/)
>   {
>   @date=stat($fic);
>   print "$date[7]\n";
>   }
>}
>close INFO;
>
>
>There is nothing in the screen !
>
>Best regards,
>
>Franck
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>


_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


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




RE: Stat function

2001-12-10 Thread COLLINEAU Franck FTRD/DMI/TAM

I have found

Thanks

-Message d'origine-
De : COLLINEAU Franck FTRD/DMI
[mailto:[EMAIL PROTECTED]]
Envoyé : lundi 10 décembre 2001 11:08
À : '[EMAIL PROTECTED]'
Objet : Stat function


Greetings,

I have the following code:

opendir (INFO,"l:/01_informatique") || die " impossible  d'ouvrire le
répertoire 01_informatique: $!";

while ($fic=readdir INFO)
{
if($fic=~/^c/)
{
@date=stat($fic);
print "$date[7]\n";
}
}
close INFO;


There is nothing in the screen !

Best regards,

Franck

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




Stat function

2001-12-10 Thread COLLINEAU Franck FTRD/DMI/TAM

Greetings,

I have the following code:

opendir (INFO,"l:/01_informatique") || die " impossible  d'ouvrire le
répertoire 01_informatique: $!";

while ($fic=readdir INFO)
{
if($fic=~/^c/)
{
@date=stat($fic);
print "$date[7]\n";
}
}
close INFO;


There is nothing in the screen !

Best regards,

Franck

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




Re: help with reading a txt file

2001-12-10 Thread Frank

On Mon, Dec 10, 2001 at 08:12:42AM -0800, Lance wrote:
> If I want to read through a text file and parse out the information in order
> to sort or compare data how would I begin to tackle this task?
> 
> I understand logically how I it would work just not sure how to do it in
> perl.
---end quoted text---

open I, 'somefile.txt' or die "Cannot open somefile $!\n";
@_=;
# @_ now contains all the lines from somefile.txt 
# to change the record delimiter change $/ to the required value
# the default is $/="\n";

-- 
 Frank Booth - Consultant
Parasol Solutions Limited.
(www.parasolsolutions.com)

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




help with reading a txt file

2001-12-10 Thread Lance Prais

If I want to read through a text file and parse out the information in order
to sort or compare data how would I begin to tackle this task?

I understand logically how I it would work just not sure how to do it in
perl.


Thank you


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




Re: how to automatically put 'membernames' in the msg posted.

2001-12-10 Thread Etienne Marcotte

well

Use cookies or pass the member name to the posting script

I mean there aren't 20 ways to pass variables to a script..

Either the username is sent to the script by a cookie, or in the hidden
field of a form, but then you'd have to always make your link as forms,
which is way longer to code than simple html links.

I don't know of any other way, the client needs to send some info to
tell your script "it's me"... and there aren't 20 ways to do so.

You can send sessionID and store the associated username in a database
or textfile on the server, but then you get to the same issue about
sending the sessionID at each script request.

Etienne

Leon wrote:
> 
> - Original Message -
> From: <[EMAIL PROTECTED]>
> 
> Thanks for your help John !
> 
> What I actually want is something like those message boards such as
> http://www.ikonboard.com/newindex.iB or www.delphiforums.com whereby after
> successfully logging in, we could view messages and if one decides to post
> message, our message posted will automatically display our 'membernames' .
> 
> One of the members, Greg, says "Use cookies or pass the member name to the
> posting script". I shall look into that. Thanks Greg.
> 
> So, apart from Greg's suggestions, I'd love to hear if there are any other
> alternatives.
> 
> Thanks
> 
> _
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
Etienne Marcotte
Specifications Management - Quality Control
Imperial Tobacco Ltd. - Montreal (Qc) Canada
514.932.6161 x.4001

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




Re: Using die but not break out of the script

2001-12-10 Thread Michael . Mittentag

Just want to thank eveyone who responded.  I have used a combination of all
the resolutions.  This was the first time I used this list and was
surprised how fast and accurate I got a repsonse.

Thanks
- Forwarded by Michael Mittentag/USA/DDS on 12/10/2001 08:52 AM -
   

Daniel Gardner 

  cc: [EMAIL PROTECTED] 

Subject: Re: Using die but not break 
out of the script 
12/07/2001 02:52   

PM 

Please respond 

to Daniel  

Gardner

   

   




Friday, December 07, 2001, 7:38:11 PM, [EMAIL PROTECTED]
wrote:

> Is there a way to use die but not break the entire script?

> system ("dir $servervolume > dirinfo") || die "cant get dir info";

> I want it that if does die to assign a value of zero to a variable?  Is
> that posssible?

how about:

  $var = system ("dir ...");

it'll be 0 on success, which isn't quite what you want, but probably
just as useful.

check perldoc -f system


--
Best regards, Daniel

-- If you do what you always do, you'll get what you always get --






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




RE: Number of week

2001-12-10 Thread Flavio Soibelmann Glock

> How can i get the number of the week from localtime function ?

- feed localtime with "january 04" in this year (for ISO 8601)
- find out when that week begins;
- find out the difference between today and that day;
- divide that by seven days (and add one).

Or, use a date module:

use Date::Tie;
tie %date, 'Date::Tie';
print $date{week};

- Flávio Soibelmann Glock

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




Re: session variables

2001-12-10 Thread Jenda Krynicky

From: "nafiseh saberi" <[EMAIL PROTECTED]>
> hi dear.
> you can use...
> require "cgi-lib.pl"; 

PLEASE FORGET cgi-lib.pl USE CGI.pm !

> &ReadParse; 
> $PASS=$in{"pass"}; 
> 
> pass  exists in  web
> and PASS is a variable that you can use it in your
> program.

This will NOT read a session variable (for any definition of 
"session").

This code reads and parses the QUERY_STRING or POSTed data 
and stores them in hash %in. And then copies the value of the 
parameter "pass" to a variable.

For people used to ASPs. This code is equivalent to ASP's

PASS = Request("pass")

not

PASS = Session("pass")

Now back to the original question.

AFAIK you can't access the data in ASP Session from a normal 
Perl (or PerlIS.dll) CGI script. You can write ASPs in PerlScript 
though and then do this :

$PASS = $Session->{pass};

With one of the ASP modules (not sure which one is still 
maintained. ASP or Win32::ASP) you can write the perl code 
almos as if you were a normal CGI. (print "foo" instead of 
$Response->Write("foo") etc.)

There are also modules for sessions for normal CGIs or Apache's 
mod_perl. http://search.cpan.org

Or you can use cookies.

Jenda

=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
--- me

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




Re: system

2001-12-10 Thread Brett W. McCoy

On Mon, 10 Dec 2001, Brett W. McCoy wrote:

> > if I use the system call like this
> > system ("ping localhost > pinginfo");
> > But in linux this will keep on going how can I set up a time on that ?
>
> Use the -n option to give it a set number of times it pings:
>
> system("ping -n 20 localhsot > pinginfo");

Oops, sorry, wrong version of ping.  Use the -c option.  -n gives numeric
output.

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

You now have Asian Flu.


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




Re: system

2001-12-10 Thread Brett W. McCoy

On Mon, 10 Dec 2001, Christo Rademeyer wrote:

> if I use the system call like this
> system ("ping localhost > pinginfo");
> But in linux this will keep on going how can I set up a time on that ?

Use the -n option to give it a set number of times it pings:

system("ping -n 20 localhsot > pinginfo");

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

Hope not, lest ye be disappointed.
-- M. Horner


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




Re: Number of week

2001-12-10 Thread nafiseh saberi

hi dear.
you can use gmtime...it get many thing to you.

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

be success.
but why do youlike to use local time ??
thx.

  Best regards. Nafiseh Saberi
   www.iraninfocenter.net
 www.sorna.net
Beauty is in the eye of the beholder.
 _
- Original Message -
From: "COLLINEAU Franck FTRD/DMI/TAM"
<[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, December 10, 2001 13:11 PM
Subject: Number of week


> Greetings,
>
> How can i get the number of the week from localtime function ?
>
> Best regards,
>
> Franck
>
> --
> 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]




Number of week

2001-12-10 Thread COLLINEAU Franck FTRD/DMI/TAM

Greetings,

How can i get the number of the week from localtime function ?

Best regards,

Franck

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




Re: system

2001-12-10 Thread Sudarsan Raghavan

Check the -c option of ping (man ping).

hth,
Sudarsan

Christo Rademeyer wrote:

> Hi
> if I use the system call like this
> system ("ping localhost > pinginfo");
> But in linux this will keep on going how can I set up a time on that ?
> Thanx
> christo
>
> --
> 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]




system

2001-12-10 Thread Christo Rademeyer

Hi 
if I use the system call like this 
system ("ping localhost > pinginfo");
But in linux this will keep on going how can I set up a time on that ?
Thanx
christo



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