Re: Can I set '$!' ?

2003-12-30 Thread R. Joseph Newton
Dan Muey wrote:

> > I want to be able to return a true or false value from a
> > function in a module and populate the $! variable with the
> > specific errors. Is this possible? Is there documentation on
> > how to do this? I can find docs on how to use $! but not how
> > to set it. Thanks for any help -Ken
>
> Did anyone ever reply to this post?

Yes.  There was actually an extensive thread.

>
> I couldn't find it in the archives and I thinnk it's a pretty good question.
>
> For instance would it be 'safe' and 'proper', and 'ok', etc... to do somethign like:
>
> sub whatever {
> my $foo = shift;
> undef $!;
> if($foo eq 'bar') { return 1; }
> else { $! = "Foo must equal bar";return 0; }
> }
>
> TIA
>
> Dan

I agree that a close localization can be relatively harmless, maybe even useful.  Still
I would not recommend getting into the habit, since it could mask much more valuable
information from the interpreter, and since there are tons of other ways to communicate
custom errors.

Joseph


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




RE: Can I set '$!' ?

2003-12-29 Thread Dan Muey

> > "Dan" == Dan Muey <[EMAIL PROTECTED]> writes:
> 
> >> I want to be able to return a true or false value from a
> >> function in a module and populate the $! variable with the
> >> specific errors. Is this possible? Is there documentation on
> >> how to do this? I can find docs on how to use $! but not how to
> >> set it. Thanks for any help -Ken
> 
> Dan> Did anyone ever reply to this post?  I couldn't find it in
> Dan> the archives and I thinnk it's a pretty good question.
> 
> Dan> For instance would it be 'safe' and 'proper', and 'ok',
> Dan> etc... to do somethign like:
> 
> Dan> sub whatever { my $foo = shift; undef $!; if($foo eq 'bar') {
> Dan> return 1; } else { $! = "Foo must equal bar";return 0; } }
> 
> $! is for system-call-related errors that can be mapped to 
> errno return values.  I don't see "Foo must equal bar" fits 
> that definition. Perhaps you want to look at the "Exception" module.
> 
> Having said that, you can set $! to a numeric value, and 
> it'll return that number in a numeric context, and the 
> appropriate error text in a string context.  Rememeber that 
> $! is just a thin wrapper over errno though, so any 
> system-call-related activity will change it.
> 
> -- 
Thanks for the info, very helpful!

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




Re: Can I set '$!' ?

2003-12-29 Thread Randal L. Schwartz
> "Dan" == Dan Muey <[EMAIL PROTECTED]> writes:

>> I want to be able to return a true or false value from a
>> function in a module and populate the $! variable with the
>> specific errors. Is this possible? Is there documentation on
>> how to do this? I can find docs on how to use $! but not how to
>> set it. Thanks for any help -Ken

Dan> Did anyone ever reply to this post?  I couldn't find it in
Dan> the archives and I thinnk it's a pretty good question.

Dan> For instance would it be 'safe' and 'proper', and 'ok',
Dan> etc... to do somethign like:

Dan> sub whatever { my $foo = shift; undef $!; if($foo eq 'bar') {
Dan> return 1; } else { $! = "Foo must equal bar";return 0; } }

$! is for system-call-related errors that can be mapped to errno
return values.  I don't see "Foo must equal bar" fits that definition.
Perhaps you want to look at the "Exception" module.

Having said that, you can set $! to a numeric value, and it'll return
that number in a numeric context, and the appropriate error text in a
string context.  Rememeber that $! is just a thin wrapper over errno
though, so any system-call-related activity will change it.

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

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




RE: Can I set '$!' ?

2003-12-29 Thread Dan Muey

> --As off Monday, December 29, 2003 12:54 PM -0600, Dan Muey is 
> alleged to have said:
> 
> >> I want to be able to return a true or false value from a 
> function in 
> >> a module and populate the $! variable with the specific errors. Is 
> >> this possible? Is there documentation on how to do this? I 
> can find 
> >> docs on how to use $! but not how to set it. Thanks for 
> any help -Ken
> >
> > Did anyone ever reply to this post?
> > I couldn't find it in the archives and I thinnk it's a pretty good 
> > question.
> 
> There were several responses, I can forward them to you if you really 
> want them.  Basically it boiled down to: "Read 'perldoc perlvar' for 
> how and possible values.", and "Are you sure you want to do that?".
> 
> > For instance would it be 'safe' and 'proper', and 'ok', 
> etc... to do 
> > somethign like:
> >
> > sub whatever {
> > my $foo = shift;
> > undef $!;
> > if($foo eq 'bar') { return 1; }
> > else { $! = "Foo must equal bar";return 0; }
> > }
> 
> "Foo must equal bar" is not a valid value for $!, most likely. :-) 
> For what you are doing here I would really prefer you either 'die' or 
> 'warn', depending on what severity you think the problem is.  (You 
> could of course 'croak' or 'carp' instead, as applicable.)
> 
> Daniel T. Staal

I'll probably just do something else besides setting it. If I 
must have a variable then I can just have my own little $error 
variable to use fo rthat purpose. Thanks for the offer to forward them, 
I'll just look at the perldoc and go from there.

Thanks

Dan

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




RE: Can I set '$!' ?

2003-12-29 Thread Daniel Staal
--As off Monday, December 29, 2003 12:54 PM -0600, Dan Muey is 
alleged to have said:

I want to be able to return a true or false value from a
function in a module and populate the $! variable with the
specific errors. Is this possible? Is there documentation on
how to do this? I can find docs on how to use $! but not how
to set it. Thanks for any help -Ken
Did anyone ever reply to this post?
I couldn't find it in the archives and I thinnk it's a pretty good
question.
There were several responses, I can forward them to you if you really 
want them.  Basically it boiled down to: "Read 'perldoc perlvar' for 
how and possible values.", and "Are you sure you want to do that?".

For instance would it be 'safe' and 'proper', and 'ok', etc... to
do somethign like:
sub whatever {
my $foo = shift;
undef $!;
if($foo eq 'bar') { return 1; }
else { $! = "Foo must equal bar";return 0; }
}
"Foo must equal bar" is not a valid value for $!, most likely. :-) 
For what you are doing here I would really prefer you either 'die' or 
'warn', depending on what severity you think the problem is.  (You 
could of course 'croak' or 'carp' instead, as applicable.)

Daniel T. Staal

---
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: Can I set '$!' ?

2003-12-29 Thread Dan Muey

> I want to be able to return a true or false value from a 
> function in a module and populate the $! variable with the 
> specific errors. Is this possible? Is there documentation on 
> how to do this? I can find docs on how to use $! but not how 
> to set it. Thanks for any help -Ken

Did anyone ever reply to this post?
I couldn't find it in the archives and I thinnk it's a pretty good question.

For instance would it be 'safe' and 'proper', and 'ok', etc... to do somethign like:

sub whatever {
my $foo = shift;
undef $!;
if($foo eq 'bar') { return 1; }
else { $! = "Foo must equal bar";return 0; }
}

TIA

Dan

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




Re: Can I set '$!' ?

2003-12-16 Thread John W. Krahn
Ken Lehman wrote:
> 
> I want to be able to return a true or false value from a function in a
> module and populate the $! variable with the specific errors. Is this
> possible? Is there documentation on how to do this? I can find docs on how
> to use $! but not how to set it. Thanks for any help

$! is a special variable that is a number in numeric context and a
string in string context.  You can assign a number to $! and it will
display the corresponding system error message but you cannot assign a
string to it.  $! is set by perl whenever a system call sets errno.  $!
is described in the perlvar.pod document.

perldoc perlvar

So, you CAN set it if you want to return one of the pre-defined error
messages but it can also be changed by perl on any system call so it
might not retain the value that you set.


John
-- 
use Perl;
program
fulfillment

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




Re: Can I set '$!' ?

2003-12-16 Thread david
Ken Lehman wrote:

> I want to be able to return a true or false value from a function in a
> module and populate the $! variable with the specific errors. Is this
> possible? Is there documentation on how to do this? I can find docs on how
> to use $! but not how to set it. Thanks for any help

$! is tied to errno which is basically (usually) an interger set by the 
system calls in case of an error. it's defined by the ISO C standard. you 
can't set errno to an arbitrary number or string and expect the it to work.
check 'man errno' for a full discussion. you can check your system's errno.h 
to see values are defined for errno. for example, in my linux box:

[panda]# more /usr/include/asm/errno.h
...
#define ENOTBLK 15  /* Block device required */
#define EBUSY   16  /* Device or resource busy */
#define EEXIST  17  /* File exists */
...

you can then assign $! like:

[panda]# perl -MErrno=:POSIX -le '$!=ENOTDIR; print $!+0,": ",$!'
20: Not a directory

mess with errno only when you really need to!

david
-- 
sub'_{print"@_ ";* \ = * __ ,\ & \}
sub'__{print"@_ ";* \ = * ___ ,\ & \}
sub'___{print"@_ ";* \ = *  ,\ & \}
sub'{print"@_,\n"}&{_+Just}(another)->(Perl)->(Hacker)

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




Re: Can I set '$!' ?

2003-12-16 Thread Jenda Krynicky
From: Ken Lehman <[EMAIL PROTECTED]>
> I want to be able to return a true or false value from a function in a
> module and populate the $! variable with the specific errors. Is this
> possible? Is there documentation on how to do this? I can find docs on
> how to use $! but not how to set it. Thanks for any help -Ken

You can set $! ... but not to a specific error.

Try
foreach (0..30) {
$! = $_;
print "$!\n";
}
and
$! = "Hello world";
print "$!\n";

As you can see you can assign the error numbers, but not the 
messages, those are fixed.

You need to use another variable to hold the error message.

You may also want to die("with the message") and wrap the code in an 
eval{} block.

See
perldoc -f eval

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


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




Can I set '$!' ?

2003-12-16 Thread Ken Lehman
I want to be able to return a true or false value from a function in a
module and populate the $! variable with the specific errors. Is this
possible? Is there documentation on how to do this? I can find docs on how
to use $! but not how to set it. Thanks for any help
-Ken




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



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




RE: Can I set this as a hash?

2002-03-25 Thread Daniel Falkenberg

Timothy,

I was to wrapped up in the code to spend 5 minutes thanking you.  My
apologizes for that. The code worked perfectly.  Thank you very much for
that :)

Regards,

Dan

-Original Message-
From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 26 March 2002 1:33 PM
To: Daniel Falkenberg; Timothy Johnson
Cc: [EMAIL PROTECTED]
Subject: RE: Can I set this as a hash?



Oh, okay.  I thought you just weren't sure how to access the data.

print "Enter your username: ";
chomp($input = );
if($users{$input}){
print "Welcome, $input.\n";
foreach(sort keys %{$users{$input}}){
print "   $_ owes ${$users{$input}}{$_}\n";
}
}else{
print "Incorrect Username!\n";
}

-Original Message-
From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 7:00 PM
To: Timothy Johnson
Subject: RE: Can I set this as a hash?


Thats all good Tim, but what I am really looking at doing is something
like the following...

print "Enter your username:";
chop ($find=);

print "You are searching for $find...?\n";

# Now go and search through every $users{$username} and seee if $find =
$users{$username}.  If it does match # then display $company from
$users{$find}{$company} and $owing from $users{$find}{$company}{$owing}.
Is # # this even possible?

Kind Regards,

Dan

-Original Message-
From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 26 March 2002 1:14 PM
To: Daniel Falkenberg; Matthew Harrison
Cc: [EMAIL PROTECTED]
Subject: RE: Can I set this as a hash?



Try this:

foreach $key(sort keys %users){
foreach $inkey(sort keys %{$users{$key}}){
print "$key, ${$users{$key}}{$inkey}\n";
}
}

-Original Message-
From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 6:23 PM
To: Matthew Harrison
Cc: [EMAIL PROTECTED]
Subject: RE: Can I set this as a hash?


Hm, yes I was thinking of that but I have gone against it.  After
tweaking around with my code I was able to insert all the date into a
hash...

%users = (
   'Username1' => {
'Comapny1' => 'owing1'
  },
   'Username2' => {
  'Company2' => 'owing2'
},
   'Username3' => {

   'Company3' => 'owing3'
}
);

This now works perfectly.  Just this once it is going to be easier for
me to do it with a hash rather than setting it up in a mySQL or Postfix
db.

I do however have one more question.  If I have a user enter their
username i.e $user_stdin - ;. How can I get my script to search
through each Username in my hash and then display the Company and how
much they have owing?  Any ideas on this?

Kind regards,

Dan

-Original Message-
From: Matthew Harrison [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 26 March 2002 12:27 PM
To: Crook, Richard W
Cc: [EMAIL PROTECTED]
Subject: RE: Can I set this as a hash?


That is exactly my stand too. I have found it much easier to learn some 
simple and re-useable MySQL functions using the DBI module, than to
learn 
regex and all the other crap associated with manipulating strings etc.

On Mon, 25 Mar 2002, Crook, Richard  W wrote:

> Well from a beginner's point of view, plus the KISS priciple I'd say
you
> should keep your data in a database like MySQL. You would then
organize the
> data by:
> 
> USERNAME   FULLNAME   COMPANY   OWING
> username1  fullname1  company1  owing1
> username2  fullname2  company2  owing2
> 
> Where you access the data for each person via the unique username. 
> If you still want to use PERL then maybe you should keep the data in a
> seperate file and parse though it instead of keeping the data in a
> multidemensional hash.
> 
> -Original Message-
> From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]]
> Sent: Monday, March 25, 2002 5:38 PM
> To: Timothy Johnson
> Cc: [EMAIL PROTECTED]
> Subject: RE: Can I set this as a hash?
> 
> 
> I am still new to Perl as well.
> 
> I want the end result to look like the following...
> 
> USERNAME   FULLNAME   COMPANY   OWING
> username1  fullname1  company1  owing1
> username2  fullname2  company2  owing2
> 
> and so on
> 
> Then I need for a user to type in their username and I need my script
to
> be able to extract the rest of the data such as if the user enters
> username1 as their username I need to display...
> 
> fullname1  company1  owing1.
> 
> Does this make sense?
> 
> Regards,
> 
> Dan
> 
>  
> 
> -Original Message-
> From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday

RE: Can I set this as a hash?

2002-03-25 Thread Timothy Johnson


Oh, okay.  I thought you just weren't sure how to access the data.

print "Enter your username: ";
chomp($input = );
if($users{$input}){
print "Welcome, $input.\n";
foreach(sort keys %{$users{$input}}){
print "   $_ owes ${$users{$input}}{$_}\n";
}
}else{
print "Incorrect Username!\n";
}

-Original Message-
From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 7:00 PM
To: Timothy Johnson
Subject: RE: Can I set this as a hash?


Thats all good Tim, but what I am really looking at doing is something
like the following...

print "Enter your username:";
chop ($find=);

print "You are searching for $find...?\n";

# Now go and search through every $users{$username} and seee if $find =
$users{$username}.  If it does match # then display $company from
$users{$find}{$company} and $owing from $users{$find}{$company}{$owing}.
Is # # this even possible?

Kind Regards,

Dan

-Original Message-
From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 26 March 2002 1:14 PM
To: Daniel Falkenberg; Matthew Harrison
Cc: [EMAIL PROTECTED]
Subject: RE: Can I set this as a hash?



Try this:

foreach $key(sort keys %users){
foreach $inkey(sort keys %{$users{$key}}){
print "$key, ${$users{$key}}{$inkey}\n";
}
}

-Original Message-
From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 6:23 PM
To: Matthew Harrison
Cc: [EMAIL PROTECTED]
Subject: RE: Can I set this as a hash?


Hm, yes I was thinking of that but I have gone against it.  After
tweaking around with my code I was able to insert all the date into a
hash...

%users = (
   'Username1' => {
'Comapny1' => 'owing1'
  },
   'Username2' => {
  'Company2' => 'owing2'
},
   'Username3' => {

   'Company3' => 'owing3'
}
);

This now works perfectly.  Just this once it is going to be easier for
me to do it with a hash rather than setting it up in a mySQL or Postfix
db.

I do however have one more question.  If I have a user enter their
username i.e $user_stdin - ;. How can I get my script to search
through each Username in my hash and then display the Company and how
much they have owing?  Any ideas on this?

Kind regards,

Dan

-Original Message-
From: Matthew Harrison [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 26 March 2002 12:27 PM
To: Crook, Richard W
Cc: [EMAIL PROTECTED]
Subject: RE: Can I set this as a hash?


That is exactly my stand too. I have found it much easier to learn some 
simple and re-useable MySQL functions using the DBI module, than to
learn 
regex and all the other crap associated with manipulating strings etc.

On Mon, 25 Mar 2002, Crook, Richard  W wrote:

> Well from a beginner's point of view, plus the KISS priciple I'd say
you
> should keep your data in a database like MySQL. You would then
organize the
> data by:
> 
> USERNAME   FULLNAME   COMPANY   OWING
> username1  fullname1  company1  owing1
> username2  fullname2  company2  owing2
> 
> Where you access the data for each person via the unique username. 
> If you still want to use PERL then maybe you should keep the data in a
> seperate file and parse though it instead of keeping the data in a
> multidemensional hash.
> 
> -Original Message-
> From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]]
> Sent: Monday, March 25, 2002 5:38 PM
> To: Timothy Johnson
> Cc: [EMAIL PROTECTED]
> Subject: RE: Can I set this as a hash?
> 
> 
> I am still new to Perl as well.
> 
> I want the end result to look like the following...
> 
> USERNAME   FULLNAME   COMPANY   OWING
> username1  fullname1  company1  owing1
> username2  fullname2  company2  owing2
> 
> and so on
> 
> Then I need for a user to type in their username and I need my script
to
> be able to extract the rest of the data such as if the user enters
> username1 as their username I need to display...
> 
> fullname1  company1  owing1.
> 
> Does this make sense?
> 
> Regards,
> 
> Dan
> 
>  
> 
> -Original Message-
> From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, 26 March 2002 11:46 AM
> To: 'Matthew Harrison'; Daniel Falkenberg
> Cc: [EMAIL PROTECTED]
> Subject: RE: Can I set this as a hash?
> 
> 
> 
> Or perhaps a list of lists... Maybe you should describe your HOH
better.
> What do you want the end result to look like?
> 
> -Original Message-
> From: Matthew Harrison [mailto:[EMAIL PROTECTED]]
>

RE: Can I set this as a hash?

2002-03-25 Thread Timothy Johnson


Try this:

foreach $key(sort keys %users){
foreach $inkey(sort keys %{$users{$key}}){
print "$key, ${$users{$key}}{$inkey}\n";
}
}

-Original Message-
From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 6:23 PM
To: Matthew Harrison
Cc: [EMAIL PROTECTED]
Subject: RE: Can I set this as a hash?


Hm, yes I was thinking of that but I have gone against it.  After
tweaking around with my code I was able to insert all the date into a
hash...

%users = (
   'Username1' => {
'Comapny1' => 'owing1'
  },
   'Username2' => {
  'Company2' => 'owing2'
},
   'Username3' => {

   'Company3' => 'owing3'
}
);

This now works perfectly.  Just this once it is going to be easier for
me to do it with a hash rather than setting it up in a mySQL or Postfix
db.

I do however have one more question.  If I have a user enter their
username i.e $user_stdin - ;. How can I get my script to search
through each Username in my hash and then display the Company and how
much they have owing?  Any ideas on this?

Kind regards,

Dan

-Original Message-
From: Matthew Harrison [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 26 March 2002 12:27 PM
To: Crook, Richard W
Cc: [EMAIL PROTECTED]
Subject: RE: Can I set this as a hash?


That is exactly my stand too. I have found it much easier to learn some 
simple and re-useable MySQL functions using the DBI module, than to
learn 
regex and all the other crap associated with manipulating strings etc.

On Mon, 25 Mar 2002, Crook, Richard  W wrote:

> Well from a beginner's point of view, plus the KISS priciple I'd say
you
> should keep your data in a database like MySQL. You would then
organize the
> data by:
> 
> USERNAME   FULLNAME   COMPANY   OWING
> username1  fullname1  company1  owing1
> username2  fullname2  company2  owing2
> 
> Where you access the data for each person via the unique username. 
> If you still want to use PERL then maybe you should keep the data in a
> seperate file and parse though it instead of keeping the data in a
> multidemensional hash.
> 
> -Original Message-
> From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]]
> Sent: Monday, March 25, 2002 5:38 PM
> To: Timothy Johnson
> Cc: [EMAIL PROTECTED]
> Subject: RE: Can I set this as a hash?
> 
> 
> I am still new to Perl as well.
> 
> I want the end result to look like the following...
> 
> USERNAME   FULLNAME   COMPANY   OWING
> username1  fullname1  company1  owing1
> username2  fullname2  company2  owing2
> 
> and so on
> 
> Then I need for a user to type in their username and I need my script
to
> be able to extract the rest of the data such as if the user enters
> username1 as their username I need to display...
> 
> fullname1  company1  owing1.
> 
> Does this make sense?
> 
> Regards,
> 
> Dan
> 
>  
> 
> -Original Message-
> From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, 26 March 2002 11:46 AM
> To: 'Matthew Harrison'; Daniel Falkenberg
> Cc: [EMAIL PROTECTED]
> Subject: RE: Can I set this as a hash?
> 
> 
> 
> Or perhaps a list of lists... Maybe you should describe your HOH
better.
> What do you want the end result to look like?
> 
> -Original Message-
> From: Matthew Harrison [mailto:[EMAIL PROTECTED]]
> Sent: Monday, March 25, 2002 5:18 PM
> To: Daniel Falkenberg
> Cc: [EMAIL PROTECTED]
> Subject: Re: Can I set this as a hash?
> 
> 
> I know i'm still only learning perl so feel free to ignore me if i've
> said 
> something stupid, but wouldn't tha be better as a list instead of a
> hash?
> 
> On Tue, 26 Mar 2002, Daniel Falkenberg wrote:
> 
> > Hello All,
> > 
> > Just wondering how I would go about setting up the following hash
and
> if
> > it would be wise to do it this way?
> > 
> > I have the following data...
> > 
> > $username $company $fullname $owing
> > 
> > I want to place all of this in a hash of a hash...
> > 
> > %name_of hash = 
> >  "Username1" => "Company1" => "$fullname1" =>
"$owing"
> > 
> > So basically I want to populate the hash with the above data.  Here
is
> > there perl code I have so far...
> > 
> > #!/usr/bin/perl -w
> > 
> > use Data::Dumper;
> > 
> > 
> > $FILE_NAME = "vintekdb_query_250302.txt";
> > $USER_DATA = "/va

RE: Can I set this as a hash?

2002-03-25 Thread Daniel Falkenberg

Hm, yes I was thinking of that but I have gone against it.  After
tweaking around with my code I was able to insert all the date into a
hash...

%users = (
   'Username1' => {
'Comapny1' => 'owing1'
  },
   'Username2' => {
  'Company2' => 'owing2'
},
   'Username3' => {

   'Company3' => 'owing3'
}
);

This now works perfectly.  Just this once it is going to be easier for
me to do it with a hash rather than setting it up in a mySQL or Postfix
db.

I do however have one more question.  If I have a user enter their
username i.e $user_stdin - ;. How can I get my script to search
through each Username in my hash and then display the Company and how
much they have owing?  Any ideas on this?

Kind regards,

Dan

-Original Message-
From: Matthew Harrison [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 26 March 2002 12:27 PM
To: Crook, Richard W
Cc: [EMAIL PROTECTED]
Subject: RE: Can I set this as a hash?


That is exactly my stand too. I have found it much easier to learn some 
simple and re-useable MySQL functions using the DBI module, than to
learn 
regex and all the other crap associated with manipulating strings etc.

On Mon, 25 Mar 2002, Crook, Richard  W wrote:

> Well from a beginner's point of view, plus the KISS priciple I'd say
you
> should keep your data in a database like MySQL. You would then
organize the
> data by:
> 
> USERNAME   FULLNAME   COMPANY   OWING
> username1  fullname1  company1  owing1
> username2  fullname2  company2  owing2
> 
> Where you access the data for each person via the unique username. 
> If you still want to use PERL then maybe you should keep the data in a
> seperate file and parse though it instead of keeping the data in a
> multidemensional hash.
> 
> -Original Message-----
> From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]]
> Sent: Monday, March 25, 2002 5:38 PM
> To: Timothy Johnson
> Cc: [EMAIL PROTECTED]
> Subject: RE: Can I set this as a hash?
> 
> 
> I am still new to Perl as well.
> 
> I want the end result to look like the following...
> 
> USERNAME   FULLNAME   COMPANY   OWING
> username1  fullname1  company1  owing1
> username2  fullname2  company2  owing2
> 
> and so on
> 
> Then I need for a user to type in their username and I need my script
to
> be able to extract the rest of the data such as if the user enters
> username1 as their username I need to display...
> 
> fullname1  company1  owing1.
> 
> Does this make sense?
> 
> Regards,
> 
> Dan
> 
>  
> 
> -Original Message-
> From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, 26 March 2002 11:46 AM
> To: 'Matthew Harrison'; Daniel Falkenberg
> Cc: [EMAIL PROTECTED]
> Subject: RE: Can I set this as a hash?
> 
> 
> 
> Or perhaps a list of lists... Maybe you should describe your HOH
better.
> What do you want the end result to look like?
> 
> -Original Message-
> From: Matthew Harrison [mailto:[EMAIL PROTECTED]]
> Sent: Monday, March 25, 2002 5:18 PM
> To: Daniel Falkenberg
> Cc: [EMAIL PROTECTED]
> Subject: Re: Can I set this as a hash?
> 
> 
> I know i'm still only learning perl so feel free to ignore me if i've
> said 
> something stupid, but wouldn't tha be better as a list instead of a
> hash?
> 
> On Tue, 26 Mar 2002, Daniel Falkenberg wrote:
> 
> > Hello All,
> > 
> > Just wondering how I would go about setting up the following hash
and
> if
> > it would be wise to do it this way?
> > 
> > I have the following data...
> > 
> > $username $company $fullname $owing
> > 
> > I want to place all of this in a hash of a hash...
> > 
> > %name_of hash = 
> >  "Username1" => "Company1" => "$fullname1" =>
"$owing"
> > 
> > So basically I want to populate the hash with the above data.  Here
is
> > there perl code I have so far...
> > 
> > #!/usr/bin/perl -w
> > 
> > use Data::Dumper;
> > 
> > 
> > $FILE_NAME = "vintekdb_query_250302.txt";
> > $USER_DATA = "/var/www/cgi-bin/$FILE_NAME";
> > 
> > sub read_data {
> >   open USER_DATA, "$USER_DATA" or warn "cannot open '$USER_DATA' for
> > reading: $!\n";
> >   flock(USER_DATA, 2) || warn "Can't lock $USER_DATA exclusively:
$!";
> >   while( $USER_DATA= ) {
> > @USER_DATA = split 

RE: Can I set this as a hash?

2002-03-25 Thread Matthew Harrison

That is exactly my stand too. I have found it much easier to learn some 
simple and re-useable MySQL functions using the DBI module, than to learn 
regex and all the other crap associated with manipulating strings etc.

On Mon, 25 Mar 2002, Crook, Richard  W wrote:

> Well from a beginner's point of view, plus the KISS priciple I'd say you
> should keep your data in a database like MySQL. You would then organize the
> data by:
> 
> USERNAME   FULLNAME   COMPANY   OWING
> username1  fullname1  company1  owing1
> username2  fullname2  company2  owing2
> 
> Where you access the data for each person via the unique username. 
> If you still want to use PERL then maybe you should keep the data in a
> seperate file and parse though it instead of keeping the data in a
> multidemensional hash.
> 
> -Original Message-
> From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]]
> Sent: Monday, March 25, 2002 5:38 PM
> To: Timothy Johnson
> Cc: [EMAIL PROTECTED]
> Subject: RE: Can I set this as a hash?
> 
> 
> I am still new to Perl as well.
> 
> I want the end result to look like the following...
> 
> USERNAME   FULLNAME   COMPANY   OWING
> username1  fullname1  company1  owing1
> username2  fullname2  company2  owing2
> 
> and so on
> 
> Then I need for a user to type in their username and I need my script to
> be able to extract the rest of the data such as if the user enters
> username1 as their username I need to display...
> 
> fullname1  company1  owing1.
> 
> Does this make sense?
> 
> Regards,
> 
> Dan
> 
>  
> 
> -Original Message-
> From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, 26 March 2002 11:46 AM
> To: 'Matthew Harrison'; Daniel Falkenberg
> Cc: [EMAIL PROTECTED]
> Subject: RE: Can I set this as a hash?
> 
> 
> 
> Or perhaps a list of lists... Maybe you should describe your HOH better.
> What do you want the end result to look like?
> 
> -Original Message-
> From: Matthew Harrison [mailto:[EMAIL PROTECTED]]
> Sent: Monday, March 25, 2002 5:18 PM
> To: Daniel Falkenberg
> Cc: [EMAIL PROTECTED]
> Subject: Re: Can I set this as a hash?
> 
> 
> I know i'm still only learning perl so feel free to ignore me if i've
> said 
> something stupid, but wouldn't tha be better as a list instead of a
> hash?
> 
> On Tue, 26 Mar 2002, Daniel Falkenberg wrote:
> 
> > Hello All,
> > 
> > Just wondering how I would go about setting up the following hash and
> if
> > it would be wise to do it this way?
> > 
> > I have the following data...
> > 
> > $username $company $fullname $owing
> > 
> > I want to place all of this in a hash of a hash...
> > 
> > %name_of hash = 
> >  "Username1" => "Company1" => "$fullname1" => "$owing"
> > 
> > So basically I want to populate the hash with the above data.  Here is
> > there perl code I have so far...
> > 
> > #!/usr/bin/perl -w
> > 
> > use Data::Dumper;
> > 
> > 
> > $FILE_NAME = "vintekdb_query_250302.txt";
> > $USER_DATA = "/var/www/cgi-bin/$FILE_NAME";
> > 
> > sub read_data {
> >   open USER_DATA, "$USER_DATA" or warn "cannot open '$USER_DATA' for
> > reading: $!\n";
> >   flock(USER_DATA, 2) || warn "Can't lock $USER_DATA exclusively: $!";
> >   while( $USER_DATA= ) {
> > @USER_DATA = split (/,/, $USER_DATA);
> > s/^"|"$//g foreach @USER_DATA;
> > $username = $USER_DATA[0];
> > $fullname = $USERDATA[1];
> > $company  = $USERDATA[2];
> > $owing= $USERDATA[3];
> > #CREATE HASH OF HASH HERE
> > }
> >   }
> >   close USER_DATA;
> >   return %users; #NAME OF HASH
> > }
> > 
> > read_data();
> > 
> > Does any one have any ideas on how I would go about this?  Is this
> even
> > the best way to do something like this?
> > 
> > Regards,
> > 
> > Dan
> > 
> > 
> 
> 

-- 
Matthew Harrison
Internet/Network Services Administrator
Peanut-Butter Cheesecake Hosting Services
Genestate
www.peanutbuttercheesecake.co.uk


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




RE: Can I set this as a hash?

2002-03-25 Thread Crook, Richard W

Well from a beginner's point of view, plus the KISS priciple I'd say you
should keep your data in a database like MySQL. You would then organize the
data by:

USERNAME   FULLNAME   COMPANY   OWING
username1  fullname1  company1  owing1
username2  fullname2  company2  owing2

Where you access the data for each person via the unique username. 
If you still want to use PERL then maybe you should keep the data in a
seperate file and parse though it instead of keeping the data in a
multidemensional hash.

-Original Message-
From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 5:38 PM
To: Timothy Johnson
Cc: [EMAIL PROTECTED]
Subject: RE: Can I set this as a hash?


I am still new to Perl as well.

I want the end result to look like the following...

USERNAME   FULLNAME   COMPANY   OWING
username1  fullname1  company1  owing1
username2  fullname2  company2  owing2

and so on

Then I need for a user to type in their username and I need my script to
be able to extract the rest of the data such as if the user enters
username1 as their username I need to display...

fullname1  company1  owing1.

Does this make sense?

Regards,

Dan

 

-Original Message-
From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 26 March 2002 11:46 AM
To: 'Matthew Harrison'; Daniel Falkenberg
Cc: [EMAIL PROTECTED]
Subject: RE: Can I set this as a hash?



Or perhaps a list of lists... Maybe you should describe your HOH better.
What do you want the end result to look like?

-Original Message-
From: Matthew Harrison [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 5:18 PM
To: Daniel Falkenberg
Cc: [EMAIL PROTECTED]
Subject: Re: Can I set this as a hash?


I know i'm still only learning perl so feel free to ignore me if i've
said 
something stupid, but wouldn't tha be better as a list instead of a
hash?

On Tue, 26 Mar 2002, Daniel Falkenberg wrote:

> Hello All,
> 
> Just wondering how I would go about setting up the following hash and
if
> it would be wise to do it this way?
> 
> I have the following data...
> 
> $username $company $fullname $owing
> 
> I want to place all of this in a hash of a hash...
> 
> %name_of hash = 
>  "Username1" => "Company1" => "$fullname1" => "$owing"
> 
> So basically I want to populate the hash with the above data.  Here is
> there perl code I have so far...
> 
> #!/usr/bin/perl -w
> 
> use Data::Dumper;
> 
> 
> $FILE_NAME = "vintekdb_query_250302.txt";
> $USER_DATA = "/var/www/cgi-bin/$FILE_NAME";
> 
> sub read_data {
>   open USER_DATA, "$USER_DATA" or warn "cannot open '$USER_DATA' for
> reading: $!\n";
>   flock(USER_DATA, 2) || warn "Can't lock $USER_DATA exclusively: $!";
>   while( $USER_DATA= ) {
> @USER_DATA = split (/,/, $USER_DATA);
> s/^"|"$//g foreach @USER_DATA;
> $username = $USER_DATA[0];
> $fullname = $USERDATA[1];
> $company  = $USERDATA[2];
> $owing= $USERDATA[3];
> #CREATE HASH OF HASH HERE
> }
>   }
>   close USER_DATA;
>   return %users; #NAME OF HASH
> }
> 
> read_data();
> 
> Does any one have any ideas on how I would go about this?  Is this
even
> the best way to do something like this?
> 
> Regards,
> 
> Dan
> 
> 

-- 
Matthew Harrison
Internet/Network Services Administrator
Peanut-Butter Cheesecake Hosting Services
Genestate
www.peanutbuttercheesecake.co.uk


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




This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.

-- 
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: Can I set this as a hash?

2002-03-25 Thread DeBaets, Kirk

Sounds like you are looking for a hash of arrays.  From _Programming_Perl_ :
 

Use a hash of arrays when you want to look up each array by a particular string rather 
than merely by an index number. In our example of television characters, rather than 
merely looking up the list of names by the zeroth show, the first show, and so on, 
we'll set it up so we can look up the cast list according to the name of the show.

Because our outer data structure is a hash, we've lost all ordering of its contents. 
That means when you print it out, you can't predict the order things will come out. 
You can call the sort function and print its result if you'd like a particular output 
order.


4.7.2.1 Composition of a hash of arrays

# we customarily omit quotes when keys are identifiers
%HoL = (
flintstones=> [ "fred", "barney" ],
jetsons=> [ "george", "jane", "elroy" ],
simpsons   => [ "homer", "marge", "bart" ],
);
 

-Original Message- 
From: Daniel Falkenberg [mailto:[EMAIL PROTECTED]] 
Sent: Mon 3/25/2002 8:37 PM 
To: Timothy Johnson 
Cc: [EMAIL PROTECTED] 
Subject: RE: Can I set this as a hash?



I am still new to Perl as well.

I want the end result to look like the following...

USERNAME   FULLNAME   COMPANY   OWING
username1  fullname1  company1  owing1
username2  fullname2  company2  owing2

and so on

Then I need for a user to type in their username and I need my script to
be able to extract the rest of the data such as if the user enters
username1 as their username I need to display...

fullname1  company1  owing1.

Does this make sense?

Regards,

Dan



-Original Message-
From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 26 March 2002 11:46 AM
    To: 'Matthew Harrison'; Daniel Falkenberg
Cc: [EMAIL PROTECTED]
Subject: RE: Can I set this as a hash?



Or perhaps a list of lists... Maybe you should describe your HOH better.
What do you want the end result to look like?

-Original Message-
From: Matthew Harrison [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 5:18 PM
To: Daniel Falkenberg
Cc: [EMAIL PROTECTED]
Subject: Re: Can I set this as a hash?


I know i'm still only learning perl so feel free to ignore me if i've
said
something stupid, but wouldn't tha be better as a list instead of a
hash?

On Tue, 26 Mar 2002, Daniel Falkenberg wrote:

> Hello All,
>
> Just wondering how I would go about setting up the following hash and
if
> it would be wise to do it this way?
>
> I have the following data...
>
> $username $company $fullname $owing
>
> I want to place all of this in a hash of a hash...
>
> %name_of hash =
>  "Username1" => "Company1" => "$fullname1" => "$owing"
>
> So basically I want to populate the hash with the above data.  Here is
> there perl code I have so far...
>
> #!/usr/bin/perl -w
>
> use Data::Dumper;
>
>
> $FILE_NAME = "vintekdb_query_250302.txt";
> $USER_DATA = "/var/www/cgi-bin/$FILE_NAME";
>
> sub read_data {
>   open USER_DATA, "$USER_DATA" or warn "cannot open '$USER_DATA' for
> reading: $!\n";
>   flock(USER_DATA, 2) || warn "Can't lock $USER_DATA exclusively: $!";
>   while( $USER_DATA= ) {
> @USER_DATA = split (/,/, $USER_DATA);
> s/^"|"$//g foreach @USER_DATA;
> $username = $USER_DATA[0];
> $fullname = $USERDATA[1];
> $company  = $USERDATA[2];
> $owing= $USERDATA[3];
> #CREATE HASH OF HASH HERE
> }
>   }
>   close USER_DATA;
>   return %users; #NAME OF HASH
> }
>
> read_data();
>
> Does any one have any ideas on how I would go about this?  Is this
even
> the best way to do somet

RE: Can I set this as a hash?

2002-03-25 Thread Daniel Falkenberg

I am still new to Perl as well.

I want the end result to look like the following...

USERNAME   FULLNAME   COMPANY   OWING
username1  fullname1  company1  owing1
username2  fullname2  company2  owing2

and so on

Then I need for a user to type in their username and I need my script to
be able to extract the rest of the data such as if the user enters
username1 as their username I need to display...

fullname1  company1  owing1.

Does this make sense?

Regards,

Dan

 

-Original Message-
From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 26 March 2002 11:46 AM
To: 'Matthew Harrison'; Daniel Falkenberg
Cc: [EMAIL PROTECTED]
Subject: RE: Can I set this as a hash?



Or perhaps a list of lists... Maybe you should describe your HOH better.
What do you want the end result to look like?

-Original Message-
From: Matthew Harrison [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 5:18 PM
To: Daniel Falkenberg
Cc: [EMAIL PROTECTED]
Subject: Re: Can I set this as a hash?


I know i'm still only learning perl so feel free to ignore me if i've
said 
something stupid, but wouldn't tha be better as a list instead of a
hash?

On Tue, 26 Mar 2002, Daniel Falkenberg wrote:

> Hello All,
> 
> Just wondering how I would go about setting up the following hash and
if
> it would be wise to do it this way?
> 
> I have the following data...
> 
> $username $company $fullname $owing
> 
> I want to place all of this in a hash of a hash...
> 
> %name_of hash = 
>  "Username1" => "Company1" => "$fullname1" => "$owing"
> 
> So basically I want to populate the hash with the above data.  Here is
> there perl code I have so far...
> 
> #!/usr/bin/perl -w
> 
> use Data::Dumper;
> 
> 
> $FILE_NAME = "vintekdb_query_250302.txt";
> $USER_DATA = "/var/www/cgi-bin/$FILE_NAME";
> 
> sub read_data {
>   open USER_DATA, "$USER_DATA" or warn "cannot open '$USER_DATA' for
> reading: $!\n";
>   flock(USER_DATA, 2) || warn "Can't lock $USER_DATA exclusively: $!";
>   while( $USER_DATA= ) {
> @USER_DATA = split (/,/, $USER_DATA);
> s/^"|"$//g foreach @USER_DATA;
> $username = $USER_DATA[0];
> $fullname = $USERDATA[1];
> $company  = $USERDATA[2];
> $owing= $USERDATA[3];
> #CREATE HASH OF HASH HERE
> }
>   }
>   close USER_DATA;
>   return %users; #NAME OF HASH
> }
> 
> read_data();
> 
> Does any one have any ideas on how I would go about this?  Is this
even
> the best way to do something like this?
> 
> Regards,
> 
> Dan
> 
> 

-- 
Matthew Harrison
Internet/Network Services Administrator
Peanut-Butter Cheesecake Hosting Services
Genestate
www.peanutbuttercheesecake.co.uk


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




This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.

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




RE: Can I set this as a hash?

2002-03-25 Thread Timothy Johnson


Or perhaps a list of lists... Maybe you should describe your HOH better.
What do you want the end result to look like?

-Original Message-
From: Matthew Harrison [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 5:18 PM
To: Daniel Falkenberg
Cc: [EMAIL PROTECTED]
Subject: Re: Can I set this as a hash?


I know i'm still only learning perl so feel free to ignore me if i've said 
something stupid, but wouldn't tha be better as a list instead of a hash?

On Tue, 26 Mar 2002, Daniel Falkenberg wrote:

> Hello All,
> 
> Just wondering how I would go about setting up the following hash and if
> it would be wise to do it this way?
> 
> I have the following data...
> 
> $username $company $fullname $owing
> 
> I want to place all of this in a hash of a hash...
> 
> %name_of hash = 
>  "Username1" => "Company1" => "$fullname1" => "$owing"
> 
> So basically I want to populate the hash with the above data.  Here is
> there perl code I have so far...
> 
> #!/usr/bin/perl -w
> 
> use Data::Dumper;
> 
> 
> $FILE_NAME = "vintekdb_query_250302.txt";
> $USER_DATA = "/var/www/cgi-bin/$FILE_NAME";
> 
> sub read_data {
>   open USER_DATA, "$USER_DATA" or warn "cannot open '$USER_DATA' for
> reading: $!\n";
>   flock(USER_DATA, 2) || warn "Can't lock $USER_DATA exclusively: $!";
>   while( $USER_DATA= ) {
> @USER_DATA = split (/,/, $USER_DATA);
> s/^"|"$//g foreach @USER_DATA;
> $username = $USER_DATA[0];
> $fullname = $USERDATA[1];
> $company  = $USERDATA[2];
> $owing= $USERDATA[3];
> #CREATE HASH OF HASH HERE
> }
>   }
>   close USER_DATA;
>   return %users; #NAME OF HASH
> }
> 
> read_data();
> 
> Does any one have any ideas on how I would go about this?  Is this even
> the best way to do something like this?
> 
> Regards,
> 
> Dan
> 
> 

-- 
Matthew Harrison
Internet/Network Services Administrator
Peanut-Butter Cheesecake Hosting Services
Genestate
www.peanutbuttercheesecake.co.uk


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



This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.

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




Re: Can I set this as a hash?

2002-03-25 Thread Matthew Harrison

I know i'm still only learning perl so feel free to ignore me if i've said 
something stupid, but wouldn't tha be better as a list instead of a hash?

On Tue, 26 Mar 2002, Daniel Falkenberg wrote:

> Hello All,
> 
> Just wondering how I would go about setting up the following hash and if
> it would be wise to do it this way?
> 
> I have the following data...
> 
> $username $company $fullname $owing
> 
> I want to place all of this in a hash of a hash...
> 
> %name_of hash = 
>  "Username1" => "Company1" => "$fullname1" => "$owing"
> 
> So basically I want to populate the hash with the above data.  Here is
> there perl code I have so far...
> 
> #!/usr/bin/perl -w
> 
> use Data::Dumper;
> 
> 
> $FILE_NAME = "vintekdb_query_250302.txt";
> $USER_DATA = "/var/www/cgi-bin/$FILE_NAME";
> 
> sub read_data {
>   open USER_DATA, "$USER_DATA" or warn "cannot open '$USER_DATA' for
> reading: $!\n";
>   flock(USER_DATA, 2) || warn "Can't lock $USER_DATA exclusively: $!";
>   while( $USER_DATA= ) {
> @USER_DATA = split (/,/, $USER_DATA);
> s/^"|"$//g foreach @USER_DATA;
> $username = $USER_DATA[0];
> $fullname = $USERDATA[1];
> $company  = $USERDATA[2];
> $owing= $USERDATA[3];
> #CREATE HASH OF HASH HERE
> }
>   }
>   close USER_DATA;
>   return %users; #NAME OF HASH
> }
> 
> read_data();
> 
> Does any one have any ideas on how I would go about this?  Is this even
> the best way to do something like this?
> 
> Regards,
> 
> Dan
> 
> 

-- 
Matthew Harrison
Internet/Network Services Administrator
Peanut-Butter Cheesecake Hosting Services
Genestate
www.peanutbuttercheesecake.co.uk


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




Can I set this as a hash?

2002-03-25 Thread Daniel Falkenberg

Hello All,

Just wondering how I would go about setting up the following hash and if
it would be wise to do it this way?

I have the following data...

$username $company $fullname $owing

I want to place all of this in a hash of a hash...

%name_of hash = 
 "Username1" => "Company1" => "$fullname1" => "$owing"

So basically I want to populate the hash with the above data.  Here is
there perl code I have so far...

#!/usr/bin/perl -w

use Data::Dumper;


$FILE_NAME = "vintekdb_query_250302.txt";
$USER_DATA = "/var/www/cgi-bin/$FILE_NAME";

sub read_data {
  open USER_DATA, "$USER_DATA" or warn "cannot open '$USER_DATA' for
reading: $!\n";
  flock(USER_DATA, 2) || warn "Can't lock $USER_DATA exclusively: $!";
  while( $USER_DATA= ) {
@USER_DATA = split (/,/, $USER_DATA);
s/^"|"$//g foreach @USER_DATA;
$username = $USER_DATA[0];
$fullname = $USERDATA[1];
$company  = $USERDATA[2];
$owing= $USERDATA[3];
#CREATE HASH OF HASH HERE
}
  }
  close USER_DATA;
  return %users; #NAME OF HASH
}

read_data();

Does any one have any ideas on how I would go about this?  Is this even
the best way to do something like this?

Regards,

Dan

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




Re: how can i set up a simple portal?

2001-11-19 Thread Curtis Poe


--- Kevin Meltzer <[EMAIL PROTECTED]> wrote:
> I also think cnn.com ha(s|d) a 'backdoor' with simple text for headlines. I don't
> recall the URL, maybe someone else has it.

It may be gone.  This *used* to be that backdoor:

http://www8.cnn.com/HLN/virtual/swf.headline.txt

Cheers,
Curtis "Ovid" Poe

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

__
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com

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




Re: how can i set up a simple portal?

2001-11-19 Thread Kevin Meltzer

Hi Noah,

Why not use RSS? My book has a chapter on using it, or to save money you can
look at that chapter online: http://perlcgi-book.com/sample/chapter16.pdf

A good past article from perl.com:
http://www.perl.com/pub/a/2000/01/rss.html

Also, the current article on perl.com:
http://www.perl.com/pub/a/2001/11/15/creatingrss.html 

You can find some RSS content here: http://www.xmltree.com/index.html

I also think cnn.com ha(s|d) a 'backdoor' with simple text for headlines. I don't
recall the URL, maybe someone else has it.

HTH,
Kevin

On Mon, Nov 19, 2001 at 06:36:04PM -0500, Noah ([EMAIL PROTECTED]) said 
something similar to:
> I want to make a CGI that grabs the top few headlines from major (or not)
> news sites such as the new york times and cnn, and places them as hyperlinks
> on my web page.  I know there is a lot of stuff out there to do this, but
> I'm doing this as a learning excercise, so I'd like to know if anyone has
> any ideas on doing this from scratch or knows of existing code which is very
> simple.
> 
> Thanks,
> 
> Noah
> 

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
Who are the brain police?
-- Frank Zappa

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




how can i set up a simple portal?

2001-11-19 Thread Noah

I want to make a CGI that grabs the top few headlines from major (or not)
news sites such as the new york times and cnn, and places them as hyperlinks
on my web page.  I know there is a lot of stuff out there to do this, but
I'm doing this as a learning excercise, so I'd like to know if anyone has
any ideas on doing this from scratch or knows of existing code which is very
simple.

Thanks,

Noah



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




Re: How can I set return codes for a perl-script?

2001-06-27 Thread Me

> I want a perl-script to be startet by another application. Is there a
> possibility to send a return code from the perl-script to the
application
> saying whether the perl-script was running properly? Is this working
for
> Unix and NT?

use exit, eg

exit 2;




How can I set return codes for a perl-script?

2001-06-27 Thread Roland Schoenbaechler

I want a perl-script to be startet by another application. Is there a
possibility to send a return code from the perl-script to the application
saying whether the perl-script was running properly? Is this working for
Unix and NT?

Thanks a lot

Roland






*** PLEASE NOTE ***
This message, along with any attachments, may be confidential or legally
privileged.  It is intended only for the named person(s), who is/are the
only authorized recipients. If this message has reached you in error,
kindly destroy it without review and notify the sender immediately. Thank
you for your help.
**