Open new window.

2002-08-26 Thread Mike(mickako)Blezien

Hello all,

this maybe bit off topic, but was hoping someone may have some suggestions.

I have simple form that a person makes a selection from a drop box and we would
like to open a new window, and resize it similar to using javascript(pop-up
window), but can't really use javascript, because we need to do some simple math
calculation, which would be produced in the new window that's opened, and would
rather not open a full browser new window if at all possible,... and I haven't
seen any js scripts that does this.

was hoping someone may have done this with perl..

thanks,

-- 
Mike(mickalo)Blezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
Bus Phone:  1(985)902-8484
MSN Message Contact: [EMAIL PROTECTED]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

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




Re: Open new window.

2002-08-26 Thread Exile

Perl don't handle this, but you can try :

form . target=_new
.
...
/form
!--// However, you can't resize it without js //--

Rgds,
Connie

- Original Message - 
From: Mike(mickako)Blezien [EMAIL PROTECTED]
To: Perl List [EMAIL PROTECTED]
Sent: Tuesday, August 27, 2002 2:48 AM
Subject: Open new window.


 Hello all,
 
 this maybe bit off topic, but was hoping someone may have some suggestions.
 
 I have simple form that a person makes a selection from a drop box and we would
 like to open a new window, and resize it similar to using javascript(pop-up
 window), but can't really use javascript, because we need to do some simple math
 calculation, which would be produced in the new window that's opened, and would
 rather not open a full browser new window if at all possible,... and I haven't
 seen any js scripts that does this.
 
 was hoping someone may have done this with perl..
 
 thanks,
 
 -- 
 Mike(mickalo)Blezien
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Thunder Rain Internet Publishing
 Providing Internet Solutions that work!
 http://www.thunder-rain.com
 Bus Phone:  1(985)902-8484
 MSN Message Contact: [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]




Question about dates

2002-08-26 Thread Soheil Shaghaghi

Hi everyone,
I am trying to do some calculations based on the date the users have
registered with the site.

I want to sell a service.
I have a form where the user comes to purchase the service.
I can get the date from SQL database in any format and display it in form.

At this point, when the user fills out the form and submits it, I want to
look at the date.
If the date is before August of 2002, the price should be set to $25.00, and
if it's after August of 2002, it will be $50.00

Can anyone tell me how I can do this please?

Note: The form does not use SQL itself. It's just CGI.

Thanks



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




Re: Question about dates

2002-08-26 Thread Felix Geerinckx

on Mon, 26 Aug 2002 20:37:22 GMT, Soheil Shaghaghi wrote:

 I want to sell a service.
 I have a form where the user comes to purchase the service.
 I can get the date from SQL database in any format and display it in
 form. 
 
 At this point, when the user fills out the form and submits it, I
 want to look at the date.
 If the date is before August of 2002, the price should be set to
 $25.00, and if it's after August of 2002, it will be $50.00

You may want to consider returning the date in two formats from your SQL 
query. One for comparing and one for displaying. If you take the format 
'mmdd', the comparison is easy:

if ($date lt '20020801') {
$price = 25;
} else {
$price = 50;
}

You may also want to consider working in cents instead of dollars, to 
avoid rounding errors.


-- 
felix

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




Re: Question about dates

2002-08-26 Thread Jim Lundeen

Here's a piece of code from a script I wrote for our jewelry store that looks to
see if the promotional discount code is still valid...   I don't see any reason
why Felix's method wouldn't work either; it's doing pretty much the same thing
as mine...

  $mysql_query=qq{SELECT CURRENT_DATE-DATE_FORMAT(VALID_TO,'%Y%m%d') from
discount_codes where discount_code='$DISCOUNT_CODE'};
$sth = $dbh-prepare ($mysql_query);
$sth-execute();
$EXPIRED=$sth-fetchrow_array();
$sth-finish();

if ($EXPIRED = 0) {$EXPIRED=N;}
if ($EXPIRED  0)  {$EXPIRED=Y;}



Soheil Shaghaghi wrote:

 Hi everyone,
 I am trying to do some calculations based on the date the users have
 registered with the site.

 I want to sell a service.
 I have a form where the user comes to purchase the service.
 I can get the date from SQL database in any format and display it in form.

 At this point, when the user fills out the form and submits it, I want to
 look at the date.
 If the date is before August of 2002, the price should be set to $25.00, and
 if it's after August of 2002, it will be $50.00

 Can anyone tell me how I can do this please?

 Note: The form does not use SQL itself. It's just CGI.

 Thanks

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



RE: Question about dates

2002-08-26 Thread Soheil Shaghaghi

Thanks so much. I think it's a good way :)
Now, I can't get the date printed in that format!

Here is the code I have:
sub DATEJOINEDRAW{
my %arg = @_;

if ($arg{USER}) {
my $UserID = $arg{USER}-get(field = 'UserID');
if ($UserID) {
my %arg = @_;

my $query = select RegistrationDate FROM USERS where UserID=$UserID;;
my $sdb = $arg{DBOBJ}-prepare($query);
$sdb-execute;
my($reg)=$sdb-fetchrow;
return $reg;
}
}
return '0';
}

This prints the date, but in order to get the raw data, I don't know what to
do!
I tried using the DATE_FORMAT, but it's not working:

sub DATEJOINEDRAW{
my %arg = @_;

if ($arg{USER}) {
my $UserID = $arg{USER}-get(field = 'UserID');
if ($UserID) {
my %arg = @_;
my $query = select DATE_FORMAT(RegistrationDate, '%Y %M %D') FROM 
USERS
where UserID=$UserID;;
my $sdb = $arg{DBOBJ}-prepare($query);
$sdb-execute;
my($reg)=$sdb-fetchrow;
return $reg;
}
}
return '0';
}

Any help would be appreciated.
Soheil



-Original Message-
From: Felix Geerinckx [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 26, 2002 1:40 PM
To: [EMAIL PROTECTED]
Subject: Re: Question about dates


on Mon, 26 Aug 2002 20:37:22 GMT, Soheil Shaghaghi wrote:

 I want to sell a service.
 I have a form where the user comes to purchase the service.
 I can get the date from SQL database in any format and display it in
 form.

 At this point, when the user fills out the form and submits it, I
 want to look at the date.
 If the date is before August of 2002, the price should be set to
 $25.00, and if it's after August of 2002, it will be $50.00

You may want to consider returning the date in two formats from your SQL
query. One for comparing and one for displaying. If you take the format
'mmdd', the comparison is easy:

if ($date lt '20020801') {
$price = 25;
} else {
$price = 50;
}

You may also want to consider working in cents instead of dollars, to
avoid rounding errors.


--
felix

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




Safe.pm

2002-08-26 Thread Avi Nehori


Hi,

In general I'm trying to do something like that:

1. create a safe compartment .
2. inherit certain variables/methods and objects to the new compartment.
3. apply few limitations to the compartment.
4. execute code under the new compartment via safe rdo() method which
can execute perl code from a file.

assume the pseudo code :

content in main.pl


   use strict;


   $CPT= new Safe;   //create a compartment
   $CPT-limit();  //apply limitatations to the compartment
   $CPT-get_shares();  //share variables and functions
   $CPT-rdo( file.pl);//execute perl code in file.pl
   print $@;

content in file.pl

use strict;
use Data::Dumper;
...
...

when executing the main.pl
i get the error message:

Can't load module Data::Dumper, dynamic loading not available in this perl.
  (You may need to build a new perl executable which either supports
  dynamic loading or has the Data::Dumper module statically linked into it.)
 at file.pl line 2
Compilation failed in require at file.pl line 2.
BEGIN failed--compilation aborted at file.pl line 2.

any idea?

Tnx for your help.

Avi Nehori


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




use Variable as a hashname?

2002-08-26 Thread Angerstein

Hello, 
can I / how can I use a variable as a hash name? 

$$myVar{key}? 

Thanxs!

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




AW: use Variable as a hashname?

2002-08-26 Thread Angerstein

It a little bit misunderstandable...

let´s say i got 100 hashes named after each of my routers.

a list auf my routeres is in @allmyrouters.

My hashes contains fileds: ip, interfaces, admin.

I want to access each hashes field admin in a loop.

How do i do that?

 -Ursprüngliche Nachricht-
 Von: Connie Chan [mailto:[EMAIL PROTECTED]]
 Gesendet am: Montag, 26. August 2002 13:38
 An: Angerstein; [EMAIL PROTECTED]
 Betreff: Re: use Variable as a hashname?

 $x = 'key';

 %Y = ();

 $Y{$x} = 10;

 print $Y{key}; # You got 10;

 Rgds,
 Connie



 - Original Message -
 From: Angerstein [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Monday, August 26, 2002 7:33 PM
 Subject: use Variable as a hashname?


  Hello,
  can I / how can I use a variable as a hash name?
 
  $$myVar{key}?
 
  Thanxs!
 
  --
  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: use Variable as a hashname?

2002-08-26 Thread Connie Chan

$x = 'key';

%Y = ();

$Y{$x} = 10;

print $Y{key}; # You got 10;

Rgds,
Connie



- Original Message - 
From: Angerstein [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, August 26, 2002 7:33 PM
Subject: use Variable as a hashname? 


 Hello, 
 can I / how can I use a variable as a hash name? 
 
 $$myVar{key}? 
 
 Thanxs!
 
 -- 
 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: AW: use Variable as a hashname?

2002-08-26 Thread Dharmendra Rai


 use foreach keys(%ur_hash)

{

do something;

}




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

http://uk.docs.yahoo.com/mail_storage.html


Re: use Variable as a hashname?

2002-08-26 Thread Dharmendra Rai


Connie,

  the query was abt ref of a hash . 




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

http://uk.docs.yahoo.com/mail_storage.html


Re: use Variable as a hashname?

2002-08-26 Thread doug


Here's one way:

  my %router = ();

  $router{size} = big;

  my $varname = router;

  eval EXEC or die $@;
  print \$$varname\{'size'\} . \n;
  EXEC


Although you most certainly should be using a multi-dimensional datatype,
like a hash of refs to hashes.

Doug





On Mon, 26 Aug 2002, Angerstein wrote:

 Hello,
 can I / how can I use a variable as a hash name?

 $$myVar{key}?

 Thanxs!

 --
 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: AW: use Variable as a hashname?

2002-08-26 Thread Felix Geerinckx

on Mon, 26 Aug 2002 11:47:00 GMT, [EMAIL PROTECTED] (Angerstein) 
wrote:

[blank lines trimmed]

 It a little bit misunderstandable...
 let´s say i got 100 hashes named after each of my routers.
 a list auf my routeres is in @allmyrouters.
 My hashes contains fileds: ip, interfaces, admin.

So, you would have:

my %thisrouter = ( ip = '1.2.3.4',
   interfaces = 'whatever',
   admin  = 'whatevermore'
 );

Or, as a hasref:

my $thisrouter = { ip = '1.2.3.4',
   interfaces = 'whatever',
   admin  = 'whatevermore'
 };



 I want to access each hashes field admin in a loop.
 How do i do that?

The idea is to create a hash of which the keys are you routernames, 
and the values are hashrefs with the above information.

my %allrouters = ( thisrouter = { ip = '1.2.3.4',
   interfaces = 'whatever',
   admin  = 'whatevermore',
 },
   thatrouter = { ip = '5.6.7.8',
   interfaces = 'whateverevenmore',
   admin  = 'whateverigiveup',
 },
 );


Then you can do:

for my $r (keys %allrouters) {
print $r: $allrouters{$r}-{admin}\n;
 }


Believe me, you don't want to mess with symbolic references.

-- 
felix

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




Re: use Variable as a hashname?

2002-08-26 Thread Dharmendra Rai


hi ,

 %my_hash=(f', 1, s, 2, t, 3);

### Take its reference 

$my_ref=\%my_hash;

print $$my_ref{f}, \n;

### Here u r printing the value associated with key f of the hash-table using the 
ref #of that hash-table and refs r always scalar 




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

http://uk.docs.yahoo.com/mail_storage.html


What perl module converts unix time to regular time and date

2002-08-26 Thread FLAHERTY, JIM-CONT

What perl module converts unix time to regular time and date ?
 
Thanks 
Jim



Re: AW: use Variable as a hashname?

2002-08-26 Thread Dharmendra Rai

use foreach keys (%ur_hash_table)



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

http://uk.docs.yahoo.com/mail_storage.html


Re: What perl module converts unix time to regular time and date

2002-08-26 Thread Felix Geerinckx

on Mon, 26 Aug 2002 12:43:17 GMT, [EMAIL PROTECTED] (Jim-Cont 
Flaherty) wrote:

 What perl module converts unix time to regular time and date ?

If you mean with 'unix time' seconds since epoch, and with 'regular 
time' year, month, day, hour, min and sec, you don't need a module.

See 

perldoc -f localtime
perldoc -f gmtime

for these built-in functions.

-- 
felix

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




Re: AW: use Variable as a hashname?

2002-08-26 Thread Felix Geerinckx

on Mon, 26 Aug 2002 12:49:17 GMT, [EMAIL PROTECTED] (Dharmendra 
rai) wrote:

 use foreach keys (%ur_hash_table)

What is your point with this single line message?
Do you realize that

# WRONG
foreach keys (%ur_hash_table) {
# ...
}

is a syntax error? Did you test it?
Perhaps you meant (using $_ as an implicit loop variable):

foreach (keys %ur_hash_table) {
# ...
}

-- 
felix

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




should i switch to 5.8.0?

2002-08-26 Thread David T-G

Hi, all --

I see that 5.8 is out...  Any thoughts on how stable it is and when we
might be likely to see 5.8.1 (not that perl every has any errors, even in
the code that's written to run under perl ;-)  I'm debating whether or
not to upgrade now...


TIA  HAND

:-D
-- 
David T-G  * It's easier to fight for one's principles
(play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie
(work) [EMAIL PROTECTED]
http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg!




msg29479/pgp0.pgp
Description: PGP signature


RE: looping issue

2002-08-26 Thread Winchester, Derek S (Derek)

Thanks Rob for your reply. I included the log to clarify. The way I want to
script to run is that:
1) when $vr =2 the $vci and $vpi and the ip address should increment once.
Then when $vr=3 then they should increment once again. In the log the vr
waits till the ip address finishes incrementing and then waits for each
addition variable to increment before incrementing. 


new script:
$telnet-cmd (up\n);
for ($vr=2; $vr=42; $vr++) {
  for ($vci=101; $vci=141; $vci++) {
  for ($vcp=201; $vcp=241; $vcp++) {
for ($ip=1; $ip=61; $ip++) {
  for ($i=1; $i=41; $i++) {

$telnet-cmd (router provider ipsectest$vr engine 3/2\n);
$telnet-cmd (service-domain 1\n);
$telnet-cmd (ike secret ip-address 0.0.0.0 secret
springtidenet\n);
$telnet-cmd (ike preferences 1 ip-address 0.0.0.0 encryption
des\n);
$telnet-cmd (ike preferences 1 ip-address 0.0.0.0 group 1\n);
$telnet-cmd (ike preferences 1 ip-address 0.0.0.0 hash sha\n);
$telnet-cmd (ike preferences 1 ip-address 0.0.0.0 lifetime 12\n);
$telnet-cmd (ike preferences 1 ip-address 0.0.0.0 lifebytes 0\n);
$telnet-cmd (interface internal-atm-pvc 1/$vci 3/2 1/$vcp\n);
$telnet-cmd (ip address 10.$ip.$ip.2 netmask 255.255.255.0\n);
$telnet-cmd (up\n);
$telnet-cmd (up\n);
$telnet-cmd (virtual-interface tunnel IPSEC$i policy-name
policy7\n);
$telnet-cmd (ip unnumbered\n);
$telnet-cmd (up\n);
$telnet-cmd (up\n);
$telnet-cmd (up\n);
}
}
}
}
}



Log:

08/26/2002 00:35:13 admin/1 Support47(config-vrouter)# up , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If)# up , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If-logIf)# ip address
10.54.54.1 netma
sk 255.255.255.0 , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If)# interface
internal-atm-pvc 1/101
3/2 1/101 , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter)# up , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If)# up , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If-logIf)# ip address
10.53.53.1 netma
sk 255.255.255.0 , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If)# interface
internal-atm-pvc 1/101
3/2 1/101 , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter)# up , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If)# up , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If-logIf)# ip address
10.52.52.1 netma
sk 255.255.255.0 , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If)# interface
internal-atm-pvc 1/101
3/2 1/101 , Status=Passed
08/26/2002 00:35:12 admin/1 Support47(config-vrouter)# up , Status=Passed
08/26/2002 00:35:12 admin/1 Support47(config-vrouter-If)# up , Status=Passed
08/26/2002 00:35:12 admin/1 Support47(config-vrouter-If-logIf)# ip address
10.51.51.1 netma
sk 255.255.255.0 , Status=Passed
08/26/2002 00:35:12 admin/1 Support47(config-vrouter-If)# interface
internal-atm-pvc 1/101

-Original Message-
From: Hanson, Rob [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 23, 2002 5:05 PM
To: 'Winchester, Derek S (Derek)'; [EMAIL PROTECTED]
Subject: RE: looping issue


I'm not exactly sure what you are doing, so all I can do is give some tips.

First of all, you probably want to use for(), and not foreach().  for()
takes 3 arguments... an initialization, a expression to test, and an
incrementor.  So your loop might look like this...

for ($vr=2; $vr=42; $vr++) {
  for ($vci=101; $vci=141; $vci++) {
for ($ip=1; $ip=61; $ip++) {
  for ($i=1; $i=41; $i++) {
  }
}
  }
}

You can then increment any of the values inside of the loop in needed.  Like
this...

# prints 12346789, skips 5
for ($x=1; $x=9; $x++) {
   $x++ if ($x == 5);
   print $x;
}

Hope that helps.

Rob


-Original Message-
From: Winchester, Derek S (Derek) [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 23, 2002 4:52 PM
To: [EMAIL PROTECTED]
Subject: looping issue


This is just an example of what I am trying to do. Only I don't know any
other format in which to do it and when I look in documentation it is
confusing. I have always used foreach, but in this case I don't want to loop
in my loop. For example, below if if the variable on ipsectest$vr equals 2
then I want the rest of the variables to increment when the first variable
increments to perform just one loop. I cant find a way to do such. And I
think Perl doc is just as confusing. If you understand could someone show me
a way of doing what I have described. 
 
 
$vr = 2; 
 $vci = 101; 
 $ip = 1; 
 $vti = 1; 
 
 foreach $vr (2..42) {
 foreach $vci (101..141)  { 
 foreach $ip (1..61) {
 foreach $1 (1..41) {
  
 $telnet-cmd (router provider ipsectest$vr engine 3/2\n);
 $telnet-cmd (service-domain 1\n);
 $telnet-cmd (ike secret ip-address 

Forking question.

2002-08-26 Thread Chad Kellerman

Good morning, afternoon, night,

I have been trying to work on a script that does forking.  But
the script dies in the fork.  Here is what I have:

I push some information about a server into an array.

snip
use POSIX sys_wait_h;
my $child_limit = 1;
my $child_pids = 0;
$SIG{CHLD} = \CHILD_COUNT($child_limit);


 push @server_list, $href;

  FORK:
 {
while ( $#server_list  -1 ) {
 next if $child_pids  $child_limit;
 my $server_todo = pop @server_list;
 if (my $pid = fork) {
 # sleep 1;  # failing due to bad
subroutine? 
 #do the parent
 $child_pids++;
 next;
 }
 elsif (defined $pid) {
 # ok now the child.
 do_stuff($server_todo); #subroutine
 exit;
 }
 elsif ($! =~ /No more process/) {
 print  No more process ...sleeping\n;
 sleep 5;
 redo FORK;
 }
 else {
 die  Can't fork: $! \n;
 }
}   
 }

sub CHILD_COUNT {
my $child_limit = @_;
my $child;
$child = waitpid(-1, WNOHANG);
while ( $child  0  ( $child_pids  0)) {
$child_pids-- if ( $child_pids  0);
$child = waitpid(-1,WNOHANG);
}
}



/snip


  I get the error:
Not a subroutine reference at serverbackup.pl line 65.

Line 65 is the next if statement.

  I am at a loss here.  It seems that the more I read about this the
more I get confused.

Can anyone give me a hand with this?  Or a push in the right direction? 
It would be much appreciated.

Thanks
--chad

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




RE: can't find eof on ebcdic file

2002-08-26 Thread Sean Rowe

I really appreciate this guys.  Thanks!

Sean

-Original Message-
From: Steve Grazzini [mailto:[EMAIL PROTECTED]]On Behalf Of Steve
Grazzini
Sent: Friday, August 23, 2002 6:55 PM
To: [EMAIL PROTECTED]
Subject: Re: can't find eof on ebcdic file


John W. Krahn [EMAIL PROTECTED] wrote:
 Sean Rowe wrote:
 Is there a way to convert, say a 10 meg file, from EBCDIC to 
 ASCII quickly?
 
 This should be pretty fast.
 
 # table borrowed from snippets file a2e.c
 my %e2a = do { my $i; map { chr, chr( $i++ ) } 
 ( 0 .. 3, 156, 9, 134, 127, 151, 141, 142,
  11 .. 19, 157, 133, 8, 135, 24, 25, 146,
 143, 28 .. 31, 128 .. 132, 10, 23, 27,
 136 .. 140, 5 .. 7, 144, 145, 22, 147 .. 150,
   4, 152 .. 155, 20, 21, 158, 26, 32,
 160 .. 168, 91, 46, 60, 40, 43, 33, 38,
 169 .. 177, 93, 36, 42, 41, 59, 94, 45, 47,
 178 .. 185, 124, 44, 37, 95, 62, 63,
 186 .. 194, 96, 58, 35, 64, 39, 61, 34, 195,
  97 .. 99, 100 .. 105, 196 .. 202, 106 .. 114,
 203 .. 209, 126, 115 .. 122, 210 .. 231, 123,
  65 .. 73, 232 .. 237, 125, 74 .. 82, 238 .. 243,
  92, 159, 83 .. 90, 244 .. 249, 48 .. 57, 250 .. 255,
 ) };
 
 
 open INFILE, $EbcdicFile or die Could not open $EbcdicFile: $!;
 binmode INFILE;
 
 $/ = \16384;  # Input buffer size
   # adjust to taste
 
 while ( INFILE ) {
 s/(.)/$e2a{$1}/sg;
 print OUTFILE;
 }

This should be a bit faster... :)

  %e2a = do { my $i; map { $_, $i++ }

... same table ...

  };
 
  $e = sprintf '\%o'x256, keys %e2a;
  $a = sprintf '\%o'x256, values %e2a;

  eval tr/$e/$a/, print while INFILE;

-- 
Steve

perldoc -qa.j | perl -lpe '($_)=m((.*))'

-- 
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: Forking question.

2002-08-26 Thread Felix Geerinckx

on Mon, 26 Aug 2002 14:15:02 GMT, [EMAIL PROTECTED] (Chad
Kellerman) wrote: 

 I have been trying to work on a script that does forking. 
 But the script dies in the fork.  Here is what I have:

 [...]

 my $child_limit = 1;
 my $child_pids = 0;
 $SIG{CHLD} = \CHILD_COUNT($child_limit);

You can't have arguments here. This line should be:

$SIG{CHLD} = \CHILD_COUNT;

 [...]

 sub CHILD_COUNT {
 my $child_limit = @_;
  ^

Remove this line, so you essentially work with the my-variable
$child_limit declared at file scope at the top of your program. 

-- 
felix

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




Re: AW: use Variable as a hashname?

2002-08-26 Thread Dharmendra Rai

u r right felix. that was a typing error. nothing else. sorry for that



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

http://uk.docs.yahoo.com/mail_storage.html


Re: Read file from second line

2002-08-26 Thread Tanton Gibbs

How do i read on from the second line of a text file? 

Just read in the first line and ignore it

open FILE, file.txt or die Could not open file.txt: $!\n;

my $first_line = FILE;

# now FILE is at the second line.
while( FILE ) {
  # do your processing
}

Tanton


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




Re: Read file from second line

2002-08-26 Thread Felix Geerinckx

on Mon, 26 Aug 2002 15:15:06 GMT, [EMAIL PROTECTED] (Q) wrote:

 Apologies for such a 'lame' question but i read the FAQ on 
 http://theoryx5.uwinnipeg.ca/CPAN/perl/pod/perlfaq5-full.html
 
 How do i read on from the second line of a text file? 

You start reading from the first line but throw it away ;-)

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

open IN, $0 or die Cannot open myself: $!\n;

IN; # Throw away first line

# Process from second line onwards.
while (IN) {
print;
}

close IN;

-- 
felix

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




Re: Read file from second line

2002-08-26 Thread Q

Thank you Tanton, Felix;


- Original Message - 
From: Felix Geerinckx [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, August 26, 2002 5:32 PM
Subject: Re: Read file from second line


 on Mon, 26 Aug 2002 15:15:06 GMT, [EMAIL PROTECTED] (Q) wrote:
 
  Apologies for such a 'lame' question but i read the FAQ on 
  http://theoryx5.uwinnipeg.ca/CPAN/perl/pod/perlfaq5-full.html
  
  How do i read on from the second line of a text file? 
 
 You start reading from the first line but throw it away ;-)
 
 #! /usr/bin/perl -w
 use strict;
 
 open IN, $0 or die Cannot open myself: $!\n;
 
 IN; # Throw away first line
 
 # Process from second line onwards.
 while (IN) {
 print;
 }
 
 close IN;
 
 -- 
 felix
 
 -- 
 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: What perl module converts unix time to regular time and date

2002-08-26 Thread drieux


On Monday, August 26, 2002, at 05:43 , FLAHERTY, JIM-CONT wrote:

 What perl module converts unix time to regular time and date ?

 Thanks
 Jim

perldoc -f localtime

vladimir: 76:] perl -e 'my @stuff=localtime ; print @stuff\n;'
17 52 8 26 7 102 1 237 1
vladimir: 77:]perl -e '$thing=localtime ; print $thing\n;'
Mon Aug 26 08:52:52 2002
vladimir: 79:]

or were you interestin in more of the

perldoc Time::Local

ciao
drieux

---


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




RE: use Variable as a hashname?

2002-08-26 Thread Timothy Johnson


Here's one way to go about it.  It sounds to me like an array of hashes will
work just fine for you.

Let's say you have an array:

  my @routers = ();

You can do a 

  push @routers,stimpy;

to add a scalar to the end, but you can also add an entire hash indirectly
by using hash references:

  #Example 1:
  push @routers,\%infohash;
  #Example 2:
  push @routers,{name = stimpy, brand = ren, model =
powdered_toast}

In example 2, I created an anonymous hash and added it to the end, which has
the same effect as example 1 except that I didn't have to already have a
hash created.

The end result is that once I've created an array of hash references, I can
do this:

  foreach(@routers){
print(sort keys %{$_});#dereference
print $_-{name}\n;  #access indirectly
  }

Check out perldoc perllol (list of lists) for more info.


-Original Message-
From: Angerstein [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 26, 2002 4:47 AM
To: [EMAIL PROTECTED]
Subject: AW: use Variable as a hashname? 


It a little bit misunderstandable...

let´s say i got 100 hashes named after each of my routers.

a list auf my routeres is in @allmyrouters.

My hashes contains fileds: ip, interfaces, admin.

I want to access each hashes field admin in a loop.

How do i do that?

 -Ursprüngliche Nachricht-
 Von: Connie Chan [mailto:[EMAIL PROTECTED]]
 Gesendet am: Montag, 26. August 2002 13:38
 An: Angerstein; [EMAIL PROTECTED]
 Betreff: Re: use Variable as a hashname?

 $x = 'key';

 %Y = ();

 $Y{$x} = 10;

 print $Y{key}; # You got 10;

 Rgds,
 Connie



 - Original Message -
 From: Angerstein [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Monday, August 26, 2002 7:33 PM
 Subject: use Variable as a hashname?


  Hello,
  can I / how can I use a variable as a hash name?
 
  $$myVar{key}?
 
  Thanxs!
 
  --
  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]




perl version skew not a Safe problem? Re: Safe.pm

2002-08-26 Thread drieux


On Monday, August 26, 2002, at 02:51 , Avi Nehori wrote:
[..]
 when executing the main.pl
 i get the error message:

 Can't load module Data::Dumper, dynamic loading not available in this 
 perl.
   (You may need to build a new perl executable which either supports
   dynamic loading or has the Data::Dumper module statically linked into 
 it.)
  at file.pl line 2
 Compilation failed in require at file.pl line 2.
 BEGIN failed--compilation aborted at file.pl line 2.

 any idea?

I rather think that you have some sort of version skew here
that has little to do with the Safe.pm issues - so let's try
to solve that first. check to see if the version of perl
you are calling internal to your script is the same as
the version that you want eg:

which perl

whereis perl

and resolve if they are one and the same. In the case of
solaris - from solaris8 onward they deliver a version that
is either a reference to /usr/perl5/bin/perl or get there
by various means.

So you can check your version of perl(s) with the -V
flag and see if they have the

  Dynamic Linking:
 dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-R   /usr/perl5/
5.00503/sun4-solaris/CORE'
 cccdlflags='-KPIC', lddlflags='-G'

that is appropriate for your OS - many sysAdmins do not build
them for dynamic loading - and that is OK IF all of the perl
modules that you can find in the @INC are also built to the
same thesis namely that they will all be build as 'static-ish'.

so you may want to start down the simpler pipe of testing if you
can write a simple script that uses just Data::Dumper to do the
simplest of tricks like

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

user Data::Dumper

my $me = {
var1 = 'v1',
var2 = 'v2'
};

print Dumper $me ;

this should generate output of the form:

$VAR1 = {
  'var1' = 'v1',
  'var2' = 'v2'
};

if you still get the Data::Dumper error case - then you
will definitely need to run to ground which versions of
perl are really suppose to have access to which @INC sections...

ciao
drieux

---


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




Regexp

2002-08-26 Thread David Samuelsson (PAC)

more regexps..

$_ comes in this form: 

servername:D:\CC_Storage\Views\EUSDNKG_Madeleine_Tae68_view.vws [uuid 
74a6b3b0.d1cd11d4.896e.00:b0:d0:83:b4:9b]

i want $_ to be just the uuid number that is: 74a6b3b0.d1cd11d4.896e.00:b0:d0:83:b4:9b

how do i get that the easiest way? all $_ are the same they are all within brackets 
[text here variables, exept . and :]

//Dave



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




Weekly posting statistics - 34/2002

2002-08-26 Thread Felix Geerinckx

Weekly posting statistics for perl.beginners - week 34 of 2002.

From Monday 2002-08-19 to Sunday 2002-08-25 there were 
466 articles posted (22566 lines) by 122 authors, giving an average 
3.82 articles per author, and an average article length of 48 lpa.
The average number of articles per day was 67.

There were 97 (21%) original articles, and 369 (79%) replies
(articles that started with 'RE:' in their subject line).

48 (39%) authors posted only one article.

The authors top-10 by number of articles is as follows:

 All/Ori Lines  lpa  Author

  46/02195   47  [EMAIL PROTECTED] (David)
  34/41550   45  [EMAIL PROTECTED] (Drieux)
  30/1 818   27  [EMAIL PROTECTED] (Felix Geerinckx)
  28/01456   52  [EMAIL PROTECTED] (John W. Krahn)
  16/31106   69  [EMAIL PROTECTED] (Nikola Janceski)
  16/1 714   44  [EMAIL PROTECTED] (Connie Chan)
  16/0 600   37  [EMAIL PROTECTED] (Bob Showalter)
  13/0 523   40  [EMAIL PROTECTED] (Janek Schleicher)
   7/2 490   70  [EMAIL PROTECTED] (Shawn Milochik)
   7/1 303   43  [EMAIL PROTECTED] (Yan Lin)

-- 
felix

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




RE: Regexp

2002-08-26 Thread David . Wagner

Something along the line of:

my $uuid ;

if ( ! /\[uuid\s+([^\]]+)/ ) {
 # if no hit then do something
   # warn or die depending on what you expect
   }
  $uuid = $1;
 
  If you want $_ then you can do $_ = $uuid;

Wags ;)

-Original Message-
From: David Samuelsson (PAC) [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 26, 2002 05:12
To: '[EMAIL PROTECTED]'
Subject: Regexp 


more regexps..

$_ comes in this form: 

servername:D:\CC_Storage\Views\EUSDNKG_Madeleine_Tae68_view.vws [uuid
74a6b3b0.d1cd11d4.896e.00:b0:d0:83:b4:9b]

i want $_ to be just the uuid number that is:
74a6b3b0.d1cd11d4.896e.00:b0:d0:83:b4:9b

how do i get that the easiest way? all $_ are the same they are all within
brackets [text here variables, exept . and :]

//Dave



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

2002-08-26 Thread Felix Geerinckx

on Mon, 26 Aug 2002 12:12:08 GMT, David Samuelsson wrote:

 $_ comes in this form: 
 
 servername:D:\CC_Storage\Views\EUSDNKG_Madeleine_Tae68_view.vws [uuid
 74a6b3b0.d1cd11d4.896e.00:b0:d0:83:b4:9b] 
 
 i want $_ to be just the uuid number that is:
 74a6b3b0.d1cd11d4.896e.00:b0:d0:83:b4:9b 


s/.*\[uuid (.*)\]/$1/;

-- 
felix

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




Re: Regexp

2002-08-26 Thread Robin Norwood

David Samuelsson (PAC) [EMAIL PROTECTED] writes:

 more regexps..
 
 $_ comes in this form: 
 
 servername:D:\CC_Storage\Views\EUSDNKG_Madeleine_Tae68_view.vws [uuid 
74a6b3b0.d1cd11d4.896e.00:b0:d0:83:b4:9b]
 
 i want $_ to be just the uuid number that is: 
74a6b3b0.d1cd11d4.896e.00:b0:d0:83:b4:9b
 
 how do i get that the easiest way? all $_ are the same they are all within brackets 
[text here variables, exept . and :]
 
 //Dave

'
m/\[uuid\s+(.*)\]/;

my $uuid = $1;
'

Should be sufficient.

-RN

-- 

Robin Norwood
Red Hat, Inc.

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

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




Re: AW: use Variable as a hashname?

2002-08-26 Thread david

since you said you have a list of routeres in @allmyrouters, i am assuming 
that they are stored in an array. if that the case, you can try:

my @allmyrouters = ({'ip'='1.1.1.1',
 'interface'='interface1',
 'admin'='admin1'},

{'ip'='2.2.2.2',
 'interface'='interface2',
 'admin'='admin2'});

foreach(@allmyrouters){
print $_-{'ip'} $_-{'interface'} $_-{'admin'}\n;
}

if you need to add another entry to the @allmyrounters, you can do:

push(@allmyrouters,{'ip'='3.3.3.3','interface'='interface3','admin'='admin3'});

david

Angerstein wrote:

 It a little bit misunderstandable...
 
 let´s say i got 100 hashes named after each of my routers.
 
 a list auf my routeres is in @allmyrouters.
 
 My hashes contains fileds: ip, interfaces, admin.
 
 I want to access each hashes field admin in a loop.
 
 How do i do that?
 

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




Net::AIM

2002-08-26 Thread coe smythe

I relatively recently stumbled upon perl bots for aim,
and figured i might as well try to write my own. 
However, my knowledge of perl is minimal, and I was
looking for anyone with some familiarity to the
module.

In specific, right now I'm trying to get my bot to
look at an incoming message, see who the sender is,
and base a reply based on the senders SN.

Help is, as always, much appreciated.



__
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com

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




Re: Forking question.

2002-08-26 Thread david

you have:

 my $child_limit = 1;
 my $child_pids = 0;
 $SIG{CHLD} = \CHILD_COUNT($child_limit);

the $child_limit thingy is ignored by Perl. this means when Perl calls your
CHIL_COUNT subroutine, the value of the variable $child_limit is not passed 
in to your subroutine.

and then in the CHIL_COUNT subroutine, you have:

 sub CHILD_COUNT {
 my $child_limit = @_;

my $child_limit declares another variable, which happen to have the same 
name as the $child_limit variable declared at the beginning of your program 
but they are completely different thing. besides, i don't see you reference 
$child_limit anywhere else inside your CHIL_COUNT subroutine, what's the 
purpose of this $child_limit variable then?

 my $child;
 $child = waitpid(-1, WNOHANG);
 while ( $child  0  ( $child_pids  0)) {
 $child_pids-- if ( $child_pids  0);
 $child = waitpid(-1,WNOHANG);
 }
 }

another thing:
 while ( $#server_list  -1 ) {

this might never be true.



if you try to archive:

1. given a list of servers
2. for each individual server, fork off a different child process(but stop 
creating more child process once a certain number of them has been created) 
to handle each server.
3. the parent will keep track the number of child process and wait for them 
to finish.

then you might want to structure something like:

my @servers = ('server1','server2','server3');
my $child_max = 10; #-- allow 10 child process at once
my $child_process = 0;

$SIG{CHLD} = sub {
while((my $pid = waitpid(-1,WNOHANG))  0){
$child_process--; #-- one less child process
print $pid finished\n;
}
};

while(@servers){
if($child_process  $child_max){sleep(1);next;} #-- wait a little
my $pid = fork;
next unless(defined $pid); #-- fork success?
my $server = pop @servers;
if($pid){
#-- parent
$child_process++; #-- one more process
print $pid created.\n;
}else{
#-- child
handle_server($server);
print $server done. about to exit\n;
exit;
}
}

i hope that will help you a little.

david

Chad Kellerman wrote:

 Good morning, afternoon, night,
 
 I have been trying to work on a script that does forking.  But
 the script dies in the fork.  Here is what I have:
 
 I push some information about a server into an array.
 
 snip
 use POSIX sys_wait_h;
 my $child_limit = 1;
 my $child_pids = 0;
 $SIG{CHLD} = \CHILD_COUNT($child_limit);
 
 
  push @server_list, $href;
 
   FORK:
  {
 while ( $#server_list  -1 ) {
  next if $child_pids  $child_limit;
  my $server_todo = pop @server_list;
  if (my $pid = fork) {
  # sleep 1;  # failing due to bad
 subroutine?
  #do the parent
  $child_pids++;
  next;
  }
  elsif (defined $pid) {
  # ok now the child.
  do_stuff($server_todo); #subroutine
  exit;
  }
  elsif ($! =~ /No more process/) {
  print  No more process ...sleeping\n;
  sleep 5;
  redo FORK;
  }
  else {
  die  Can't fork: $! \n;
  }
 }
  }
 
 sub CHILD_COUNT {
 my $child_limit = @_;
 my $child;
 $child = waitpid(-1, WNOHANG);
 while ( $child  0  ( $child_pids  0)) {
 $child_pids-- if ( $child_pids  0);
 $child = waitpid(-1,WNOHANG);
 }
 }
 
 
 
 /snip
 
 
   I get the error:
 Not a subroutine reference at serverbackup.pl line 65.
 
 Line 65 is the next if statement.
 
   I am at a loss here.  It seems that the more I read about this the
 more I get confused.
 
 Can anyone give me a hand with this?  Or a push in the right direction?
 It would be much appreciated.
 
 Thanks
 --chad

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




Re: Forking question.

2002-08-26 Thread david

David wrote:
 another thing:
 while ( $#server_list  -1 ) {
 
 this might never be true.

i cut and paste too much! please ignore that!

david


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




Re: should i switch to 5.8.0?

2002-08-26 Thread Paul Johnson

On Mon, Aug 26, 2002 at 09:22:25AM -0400, David T-G wrote:

 Hi, all --
 
 I see that 5.8 is out...  Any thoughts on how stable it is and when we
 might be likely to see 5.8.1 (not that perl every has any errors, even in
 the code that's written to run under perl ;-)  I'm debating whether or
 not to upgrade now...

It depends what you are upgrading from.  If you are running 5.6.1 and
you are happy with it then there's proably no need to upgrade.  If you
are running anything else and you can upgrade then it might be
worthwhile.  5.8.0 has had an extensive development and test cycle, and
as far as I know there have been no major bugs reported since release.

Note that 5.8.0 is not binary compatible with previous versions so you
will need to recompile all your modules that use XS.

If you're interested in unicode or threads you should definitely
upgrade.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

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




Re: Forking question.

2002-08-26 Thread Felix Geerinckx

on Mon, 26 Aug 2002 18:21:16 GMT, David wrote:

 another thing:
 while ( $#server_list  -1 ) {
 
 this might never be true.

It's true for as long as there are elements in @server_list.
It's equivalent to the (imho more readable)

while (@server_list) {
# do stuff (shifting or popping)
}


-- 
felix

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




perlcc

2002-08-26 Thread William.Ampeh

Hello,

Has anyone experimented with perlcc?

If so, any pointers to how it works will be appreciated.

__

William


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




Re: perlcc

2002-08-26 Thread drieux


On Monday, August 26, 2002, at 12:05 , [EMAIL PROTECTED] wrote:
[..]
 Has anyone experimented with perlcc?

 If so, any pointers to how it works will be appreciated.

as of 5.6.1 the advice remains that it can make
byte-code - and if you are lucky - it can generate
code that is mostly like c code - but that you should
not be attempting to make this into 'production code'.

I last worried about that with solaris 2.6.1 and perl 5.6.1
things may be better in solaris9 with 5.8.0 but I have
not gone there yet.

If you concern is 'porting' perl to 'c' - you may want to
rethink core parts of your problem and look at

perldoc Inline::File

as a way to 'harden/speed_up' your perl code by calling
directly to 'c' code if that is what you need.

ciao
drieux

---


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




Re: Regexp

2002-08-26 Thread david

Felix Geerinckx wrote:

 on Mon, 26 Aug 2002 19:01:27 GMT, David wrote:
 
 Felix Geerinckx wrote:
 
 s/.*\[uuid (.*)\]/$1/;
 
 this might be a bit faster:
 
 /(\S+).$/
 
 If you claim something is faster, prove it ;-)
 (But remember, the OP wanted the result in $_).
 

i only suggest that it might be faster. :-)
i won't go into too much detail to try to prove that. i only ran the 
following:

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

my @t = timethese(99,{'search_assign'   =
   '$_ = \'vws [uuid 1234.abcd]\';($_) = /(\S+).$/;',
  'search_replace'  =
   '$_ = \'vws [uuid 1234.abcd]\';s/.*\[uuid (.*)\]/$1/;'});

gives:

Benchmark: timing 99 iterations of search_assign, search_replace...
search_assign: 21 wallclock secs (10.22 usr +  0.00 sys = 10.22 CPU) @ 
97847.26/s (n=99)
search_replace: 34 wallclock secs (16.49 usr +  0.02 sys = 16.51 CPU) @ 
60569.29/s (n=99)

search_assign:  ($_) = /(\S+).$/;
search_replace: s/.*\[uuid (.*)\]/$1/;

david

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




Re: Regexp

2002-08-26 Thread Felix Geerinckx

on Mon, 26 Aug 2002 19:53:44 GMT, David wrote:

 Felix Geerinckx wrote:
 
 If you claim something is faster, prove it ;-)
 (But remember, the OP wanted the result in $_).
 
 
 i only suggest that it might be faster. :-)
 i won't go into too much detail to try to prove that. i only ran the 
 following:
 
 #!/usr/bin/perl -w
 use strict;
 use Benchmark;
 
 my @t = timethese(99,{'search_assign'   =
'$_ = \'vws [uuid 1234.abcd]\';($_) = /(\S+).$/;',
   'search_replace'  =
'$_ = \'vws [uuid 1234.abcd]\';s/.*\[uuid (.*)\]/$1/;'});
 
 gives:
 
 Benchmark: timing 99 iterations of search_assign, search_replace...
 search_assign: 21 wallclock secs (10.22 usr +  0.00 sys = 10.22 CPU) @ 
 97847.26/s (n=99)
 search_replace: 34 wallclock secs (16.49 usr +  0.02 sys = 16.51 CPU) @ 
 60569.29/s (n=99)

Now you're talking.
But just for the fun of it, run the benchmark again with the OP's original 
(much longer) string ... ;-)

-- 
felix

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




Re: Regexp

2002-08-26 Thread david

Felix Geerinckx wrote:

 Now you're talking.
 But just for the fun of it, run the benchmark again with the OP's original
 (much longer) string ... ;-)


i will do that a bit later. :-) busy doing something else...
yes, the reason why the string is much shorter is becasue i am lazy to 
type... believe it or not, my news reader do not allow(for some unknown 
reason) me to copy and paste outside of it's own window!

david 


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




Re: Regexp

2002-08-26 Thread Robin Norwood

david [EMAIL PROTECTED] writes:

 Felix Geerinckx wrote:
 
  Now you're talking.
  But just for the fun of it, run the benchmark again with the OP's original
  (much longer) string ... ;-)
 
 
 i will do that a bit later. :-) busy doing something else...
 yes, the reason why the string is much shorter is becasue i am lazy to 
 type... believe it or not, my news reader do not allow(for some unknown 
 reason) me to copy and paste outside of it's own window!

From david's headers:

User-Agent: KNode/0.7.1

Time to change news readers, I think... :-)

-RN

-- 

Robin Norwood
Red Hat, Inc.

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

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




Re: Regexp

2002-08-26 Thread David Zhuo

yeah, i know. :-) as soon as i have time...

david

 From david's headers:
 
 User-Agent: KNode/0.7.1
 
 Time to change news readers, I think... :-)
 
 -RN
 
 -- 
 
 Robin Norwood
 Red Hat, Inc.
 
 The Sage does nothing, yet nothing remains undone.
 -Lao Tzu, Te Tao Ching


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




Re: Regexp

2002-08-26 Thread david

Robin Norwood wrote:
 From david's headers:
 
 User-Agent: KNode/0.7.1
 
 Time to change news readers, I think... :-)
 
 -RN
 

just curious. what news reader you guys are using?

david


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




Re: Regexp

2002-08-26 Thread Felix Geerinckx

on Mon, 26 Aug 2002 20:46:49 GMT, David wrote:

 Robin Norwood wrote:
 From david's headers:
 
 User-Agent: KNode/0.7.1
 
 just curious. what news reader you guys are using?
 
 david

From my headers: 

User-Agent: Xnews/5.02.24

(That's on win32. If you're on Linux, you may want to give Mozilla a 
look.)

-- 
felix

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




Re: Regexp

2002-08-26 Thread Robin Norwood

david [EMAIL PROTECTED] writes:

 Robin Norwood wrote:
  From david's headers:
  
  User-Agent: KNode/0.7.1
  
  Time to change news readers, I think... :-)
  
  -RN
  
 
 just curious. what news reader you guys are using?

[rnorwood@robin perl-beginners]$ perl -le 'my %r;while () {$r{$1}++ if 
/^User-Agent:\s+([^\/]*)/} foreach my $k (sort keys %r) {print $k - $r{$k}}' *

Gnus - 40
Internet Messaging Program (IMP) 3.0
 - 1
KMail - 12
KNode - 48
Messenger-Pro - 3
Microsoft-Entourage - 5
Microsoft-Outlook-Express-Macintosh-Edition - 1
Mozilla - 55
Mutt - 122
Pan - 54
Xnews - 97
tin - 21


That's message counts, not user counts...I'm too lazy to count users.
And it's only since I subscribed earlier this month.  :-)

Personally, I'm using Gnus (http://my.gnus.org/), which works quite
well - however, it runs under Emacs, and the learning curve is a bit
steep, so I'd only recommend it if you love Emacs, and have a day to
spend getting the thing to work and learning the keybindings... :-)

-RN

-- 

Robin Norwood
Red Hat, Inc.

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

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




Re: Regexp

2002-08-26 Thread david

Felix Geerinckx wrote:

 Now you're talking.
 But just for the fun of it, run the benchmark again with the OP's original
 (much longer) string ... ;-)


testing result for a longer string(i use the one from the OP).i add a few 
new lines to make it more readable:

Benchmark: timing 99 iterations of search_assign, search_replace, 
substr...

search_assign: 51 wallclock secs (22.73 usr +  0.02 sys = 22.75 CPU) @ 
43956.00/s (n=99)

search_replace: 37 wallclock secs (17.29 usr +  0.01 sys = 17.30 CPU) @ 
57803.41/s (n=99)

substr: 10 wallclock secs ( 4.40 usr +  0.00 sys =  4.40 CPU) @ 
227272.50/s (n=99)

essentially:

search_assign is:   ($_) = /(\S+).$/;
search_replace: is: s/.*\[uuid (.*)\]/$1/;
substr is:  ($_ = substr($_,rindex($_,' ')+1)) =~ s/.$//;

so for a shorter string, the search_assign thingy is faster. for a longer 
string the search_replace appoach is faster.

but in all cases, the substr appoach is faster(sometimes much faster) than 
the other appocach... nice to know.

david


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




Re: Regexp

2002-08-26 Thread David Zhuo

thanks for providing the stat. it's very nice.

unfortunately, i use vi exclusively and don't like to touch Emacs at all
:-)

david

On Mon, 2002-08-26 at 14:18, Robin Norwood wrote:
 david [EMAIL PROTECTED] writes:
 
  Robin Norwood wrote:
   From david's headers:
   
   User-Agent: KNode/0.7.1
   
   Time to change news readers, I think... :-)
   
   -RN
   
  
  just curious. what news reader you guys are using?
 
 [rnorwood@robin perl-beginners]$ perl -le 'my %r;while () {$r{$1}++ if 
/^User-Agent:\s+([^\/]*)/} foreach my $k (sort keys %r) {print $k - $r{$k}}' *
 
 Gnus - 40
 Internet Messaging Program (IMP) 3.0
  - 1
 KMail - 12
 KNode - 48
 Messenger-Pro - 3
 Microsoft-Entourage - 5
 Microsoft-Outlook-Express-Macintosh-Edition - 1
 Mozilla - 55
 Mutt - 122
 Pan - 54
 Xnews - 97
 tin - 21
 
 
 That's message counts, not user counts...I'm too lazy to count users.
 And it's only since I subscribed earlier this month.  :-)
 
 Personally, I'm using Gnus (http://my.gnus.org/), which works quite
 well - however, it runs under Emacs, and the learning curve is a bit
 steep, so I'd only recommend it if you love Emacs, and have a day to
 spend getting the thing to work and learning the keybindings... :-)
 
 -RN
 
 -- 
 
 Robin Norwood
 Red Hat, Inc.
 
 The Sage does nothing, yet nothing remains undone.
 -Lao Tzu, Te Tao Ching



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




Having problems with AppConfig::Getopt module

2002-08-26 Thread Karl Kaufman


Hello,

I'm trying to use the 'AppConfig::Getopt' module to parse my command-line arguments, 
assigning the passed values to a hash.  It's not working.  And I need help.

For example:

  # test.pl -pagerdest [EMAIL PROTECTED]

Should result in:

  %pagerdest = {
 'karl' = '[EMAIL PROTECTED]'
  };

but, instead, I end up with:

  %pagerdest = {
 '[EMAIL PROTECTED]' = undef
  };


It looks like there's a problem with how AppConfig is linking the values back from 
Getopt::Long.  Getopt::Long appears to be stripping out the key= portion of the 
hash's argument -- if the linkage reference is 'CODE' rather than 'HASH'.

The following code snippet provides an example of how AppConfig is receiving changes 
from Getopt::Long; and the example below shows the loss of the hash key from the 
arguments.

Any idea how to fix the problem?  Or where else to search for an answer?

Thanks in advance.

Regards,
Karl K.


#  code example #
use Getopt::Long;

$linkage = sub { print @_\n; };

Getopt::Long::Configure('debug');
GetOptions(pagerdest=s% = $linkage);
# end of code example ## 


Example debug output -- 

# ./test.pl -pagerdest [EMAIL PROTECTED]

GetOpt::Long 2.19 called from package main.
  GetOptionsAl $Revision: 2.20 $
  ARGV: (-pagerdest [EMAIL PROTECTED])
  autoabbrev=1,bundling=0,getopt_compat=1,order=1,
  ignorecase=1,passthrough=0,genprefix=(--|-|\+).
= link pagerdest to CODE(0xcd370)
= $opctl{pagerdest} = =s%
= option -pagerdest
= find -pagerdest, prefix=(--|-|\+)
= split -+pagerdest 
= 1 hits (pagerdest) with pagerdest out of 1
= found =s% for pagerdest 
= ref($L{pagerdest}) - CODE 
= L{pagerdest}(pagerdest, [EMAIL PROTECTED])
pagerdest [EMAIL PROTECTED]




MIME::Lite 'Datestamp' problem -- truncating timezone? (UT instead of UTC)

2002-08-26 Thread Karl Kaufman

Hello,

I'm trying to determine whether there's a problem with the MIME::Lite
module.  I've sent an email to the module's author, but haven't heard back.
Is there a bugs mailing list somewhere that I can post the following info
to, in order to get verification and facilitate a fix.

(It's my opinion that the UT timezone on line 1057 of MIME::Lite is a
typo/error.)

Thanks in advance..!
Karl K.

Details ---

I noticed that timestamps on my emails generated using MIME::Lite were off
by 5 hours, so I looked into how MIME::Lite was timestamping the messages.
I quickly noticed what appeared to be the problem:   UTC is being
truncated to just UT in the prepared message -- so the receiving system,
unable to translate the unknown timezone (i.e. 'UT'), assumes local time
instead of
UTC/GMT -- causing the 5-hour difference (since my systems are in CDT).

Here's a sample message generated by MIME::Lite..

  Content-Disposition: inline
  Content-Length: 0
  Content-Transfer-Encoding: binary
  Content-Type: text/plain
  MIME-Version: 1.0
  X-Mailer: MIME::Lite 2.117  (F2.6)
  Date: Mon, 19 Aug 2002 22:18:44 UT
  From: Wile E. Coyote [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Subject: Mon Aug 19 17:18:44 2002

Take a look at line 1057 and 3372 of the MIME::Lite code:

  1057:   my $date = $u_wdy, $u_mdy $u_mon $u_y4 $u_time UT;
  3372: Also added automatic inclusion of a UT Date: at top level unless

Here's my test environment specifics:
- MIME::Lite v2.117 running under Perl 5.005_03 on Solaris 2.6
- Lotus Notes R5 server is receiving the message, I believe.

Is UT supposed to be considered a valid timezone?  I can definitely say
that it's not recognized on either version of Solaris in my environment.
Both UTC and UCT are acceptable (and identical) but not UT.

 ls -ilR /usr/share/lib/zoneinfo | egrep -i 'ut|uc'
100358 -rw-r--r--  11 bin  bin   56 Jul 15  1997 UCT
100358 -rw-r--r--  11 bin  bin   56 Jul 15  1997 UTC
 75316 -rw-r--r--   1 bin  bin15504 Jul 15  1997
southamerica
 82445 -rw-r--r--   1 bin  bin  785 Jul 15  1997 South
13 -rw-r--r--   1 bin  bin  823 Jul 15  1997 Aleutian




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




Re: Having problems with AppConfig::Getopt module

2002-08-26 Thread david

i have never used AppConfig::Getopt before...

Karl Kaufman wrote:

 For example:
 
   # test.pl -pagerdest [EMAIL PROTECTED]
 
 Should result in:
 
   %pagerdest = {
  'karl' = '[EMAIL PROTECTED]'
   };

but are you sure you mean that? it means it should assign a hash reference 
to a hash. if you have -w turn on, you should see a warning. without -w, 
your %pagerdest will end up(silently) using the memeory address of the 
annom. ref as it's key and undef for it's value. how are you going to 
access 'karl'?

david

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




Re: Regexp

2002-08-26 Thread John W. Krahn

Robin Norwood wrote:
 
 david [EMAIL PROTECTED] writes:
 
  Felix Geerinckx wrote:
  
   Now you're talking.
   But just for the fun of it, run the benchmark again with the OP's original
   (much longer) string ... ;-)
  
 
  i will do that a bit later. :-) busy doing something else...
  yes, the reason why the string is much shorter is becasue i am lazy to
  type... believe it or not, my news reader do not allow(for some unknown
  reason) me to copy and paste outside of it's own window!
 
 From david's headers:
 
 User-Agent: KNode/0.7.1
 
 Time to change news readers, I think... :-)

Time to learn how to copy and paste in X, I think... :-)

Hint:  Hilite any text in Xterm, Mozilla, Knode, etc. and use the middle
mouse button (or chord the left and right buttons) and the hilited text
will appear at the text cursor in the current window.



John
-- 
use Perl;
program
fulfillment

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




Exported Vars

2002-08-26 Thread Connie Chan

In package A, I did sth like this :

package A;
use strict;
require Exporter;
our @ISA = qw (Exporter); # What this actually for ?!
our @EXPORT = qw (%hash);
our %hash  ;

# code code code code and code .
# Do sth to assign values for %hash anyway

1;

Then , in the main script, I will use A, B, and C, and D.
but what packages B, C, D are required to use A too.

My question is, will perl re- assign the hash whenever
a 'use package A' declared ? or when Perl found the package
had loaded once, it won't load again ?

The other question is , whatever y/n above, will the outcome(reload or not) be 
difference when :

1. I directly assign values (ie $hash{A} = 1, $hash{B} = 2), 
2. using sub to assign value (ie.  our %hash ; sub GenHash { . } GenHash; 1; )

Rgds,
Connie







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




Re: Regexp

2002-08-26 Thread david

John W. Krahn wrote:
 
 Time to learn how to copy and paste in X, I think... :-)
 

Thanks but i *think* i know how to copy and paste in X  :o
but then why am i still struggling copying from KNote to vim...

since this is off topic a bit, let's kill it now. otherwise, the list master 
might not be happy.

david

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




Best way to save nested data structure.

2002-08-26 Thread Rowan Reid



I'm learning as best I can using every book orielly makes.  I am trying
to saved a complex data structure (hash). I'm trying to use Berkly
DBFile and tie. I am unable to store the file ie retrieve info once I
have exited the program.  Once I tie a hash toe the  file access the
contents should be the same as accessing the contents of the hash

 
Rowan Reid
Job Captain, 
Systems Administrator
STUDIO 3 ARCHITECTS
909  982  1717


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




Re: MIME::Lite 'Datestamp' problem -- truncating timezone? (UT instead of UTC)

2002-08-26 Thread Kevin Meltzer

UT (Universal Time) is a valid TZ. It is the same as UTC and GMT.  
So, treat it as if it is GMT when parsing. Smart mail clients don't
always use the abbreviation, and use the offset (the -0500 bit). So,
sending as UT is perfectly valid, although not always the best way to
do it. You can set the TZ manually in MIME::Lite (which you really
should do, IMO) like:

$msg = MIME::Lite-new(
From   = $from,
To = $to,
Cc = $cc,
Subject= $subject,
Type   = 'TEXT',
Encoding   = $transfer_encoding,
... more stuff if you need ...
Date   = $date,
Data   = $body
);

So, if you create a valid Date string, just set it yourself. This can
also help make your software more internationalized, since you can
properly send email from a users TZ, as opposed to UT with an offset
based on your server (for example, people who use my web-based email
system may be in JST, not EST5EDT, so they want their email to reflect
this).

Cheers,
Kevin

On Mon, Aug 26, 2002 at 04:52:45PM -0500, Karl Kaufman ([EMAIL PROTECTED]) said 
something similar to:
 Hello,
 
 I'm trying to determine whether there's a problem with the MIME::Lite
 module.  I've sent an email to the module's author, but haven't heard back.
 Is there a bugs mailing list somewhere that I can post the following info
 to, in order to get verification and facilitate a fix.
 
 (It's my opinion that the UT timezone on line 1057 of MIME::Lite is a
 typo/error.)
 
 Thanks in advance..!
 Karl K.
 
 Details ---
 
 I noticed that timestamps on my emails generated using MIME::Lite were off
 by 5 hours, so I looked into how MIME::Lite was timestamping the messages.
 I quickly noticed what appeared to be the problem:   UTC is being
 truncated to just UT in the prepared message -- so the receiving system,
 unable to translate the unknown timezone (i.e. 'UT'), assumes local time
 instead of
 UTC/GMT -- causing the 5-hour difference (since my systems are in CDT).
 
 Here's a sample message generated by MIME::Lite..
 
   Content-Disposition: inline
   Content-Length: 0
   Content-Transfer-Encoding: binary
   Content-Type: text/plain
   MIME-Version: 1.0
   X-Mailer: MIME::Lite 2.117  (F2.6)
   Date: Mon, 19 Aug 2002 22:18:44 UT
   From: Wile E. Coyote [EMAIL PROTECTED]
   To: [EMAIL PROTECTED]
   Subject: Mon Aug 19 17:18:44 2002
 
 Take a look at line 1057 and 3372 of the MIME::Lite code:
 
   1057:   my $date = $u_wdy, $u_mdy $u_mon $u_y4 $u_time UT;
   3372: Also added automatic inclusion of a UT Date: at top level unless
 
 Here's my test environment specifics:
 - MIME::Lite v2.117 running under Perl 5.005_03 on Solaris 2.6
 - Lotus Notes R5 server is receiving the message, I believe.
 
 Is UT supposed to be considered a valid timezone?  I can definitely say
 that it's not recognized on either version of Solaris in my environment.
 Both UTC and UCT are acceptable (and identical) but not UT.
 
  ls -ilR /usr/share/lib/zoneinfo | egrep -i 'ut|uc'
 100358 -rw-r--r--  11 bin  bin   56 Jul 15  1997 UCT
 100358 -rw-r--r--  11 bin  bin   56 Jul 15  1997 UTC
  75316 -rw-r--r--   1 bin  bin15504 Jul 15  1997
 southamerica
  82445 -rw-r--r--   1 bin  bin  785 Jul 15  1997 South
 13 -rw-r--r--   1 bin  bin  823 Jul 15  1997 Aleutian
 
 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
It would be easier to pay off the national debt overnight than to neutralize
the long-range effects of OUR NATIONAL STUPIDITY.
-- Frank Zappa

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




Re: Exported Vars

2002-08-26 Thread david

Connie Chan wrote:

 In package A, I did sth like this :
 
 package A;
 use strict;
 require Exporter;
 our @ISA = qw (Exporter); # What this actually for ?!

Exporter provides an easy way for you to make your module's variables and 
functions available for another package to use. the:

our @ISA =qw(Exporter);

thingy essentially translates to:

package A is a Exporter

when Perl sees this statement, it knows that your package wants to be a 
child class of Exporter so it makes all Exporter's publicly available 
methods for your package to use. 

it's(with the @ISA array) basically how Perl modules inheritance in OO 
design. One very simply examples might carify things a bit:

#
Base.pm:

package Base;

sub new{ return bless {'name'='base'} = shift; }
sub get_name{ return shift-{'name'}; }

1;


Child.pm:

package Child;
use Base;

#-- here i make Child a sub-class of Base
#-- so it reads Child ISA(is a) Base
@ISA=qw(Base);

#-- nothing else. Child doesn't have any function of it's own!
1;

##
test.pl:

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

#-- calls Base.pm's new() function. Because Child is a sub-class of 
#-- Base and Child do not has it's own new() function so Perl uses
#-- Base's new() function instead
my $c = new Child;

#-- calls Base.pm's get_name() function. same reason as above.
print $c-get_name(),\n; #-- prints base


notice that i didn't use Exporter anywhere in Base.pm because i am not 
Exporting anything explicitly so no need for Exporter.

notice also that i didn't use Exporter in Chil.pm also becuase i don't need 
any functionality from Expoter.pm, i only want the functions in Base so i 
set my @ISA to include Base

 our @EXPORT = qw (%hash);
 our %hash  ;
 
 # code code code code and code .
 # Do sth to assign values for %hash anyway
 
 1;
 
 Then , in the main script, I will use A, B, and C, and D.
 but what packages B, C, D are required to use A too.
 
 My question is, will perl re- assign the hash whenever
 a 'use package A' declared ? or when Perl found the package
 had loaded once, it won't load again ?
 
 The other question is , whatever y/n above, will the outcome(reload or
 not) be difference when :
 
 1. I directly assign values (ie $hash{A} = 1, $hash{B} = 2),
 2. using sub to assign value (ie.  our %hash ; sub GenHash { . }
 GenHash; 1; )
 
 Rgds,
 Connie

the hash won't be loaded again even you have many other packages use it.
again, consider the following:


A.pm:

package A;
use Exporter;
@ISA=qw(Exporter);
@EXPORT=qw(%hash);

$hash{'a'} = 1;

1;

###
test.pl:

#!/usr/bin/perl -w

use strict;
use A;
print $hash{'a'},\n; #-- prints 1;

#-- now change it:
$hash{'a'} = 9;

#-- switch to another package
package Another;
use A;

#-- now, if the 'use A' statement again cause %hash in A.pm to be loaded 
#-- again, it initializes itself '$hash{'a'} = 1' again right?
print $hash{'a'},\n; #-- prints 9 instead

__END__

if you think about it. if Perl allows you to export something, change it and 
loads it again and again when different package refers to them. your data 
will be inconsistence. becuase one module will loads it, modify it, use it. 
another will again loads it, modify it and use it. in that case, you will 
have different things in different module.

david

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




Re: Having problems with AppConfig::Getopt module

2002-08-26 Thread Karl Kaufman

David,

You caught my typo in my email -- the braces should have been parens.
Unfortunately, that was just a typed-in example, and the original problem
remains:  AppConfig::Getopt cannot handle hashes passed on the command-line.

Regs,
Karl K.

- Original Message -
From: david
To: [EMAIL PROTECTED]
Sent: Monday, August 26, 2002 5:12 PM
Subject: Re: Having problems with AppConfig::Getopt module


i have never used AppConfig::Getopt before...

Karl Kaufman wrote:

 For example:

   # test.pl -pagerdest [EMAIL PROTECTED]

 Should result in:

   %pagerdest = (
  'karl' = '[EMAIL PROTECTED]'
   );

Fixed after the fact

but are you sure you mean that? it means it should assign a hash reference
to a hash. if you have -w turn on, you should see a warning. without -w,
your %pagerdest will end up(silently) using the memeory address of the
annom. ref as it's key and undef for it's value. how are you going to
access 'karl'?


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




Re: Having problems with AppConfig::Getopt module

2002-08-26 Thread david

Karl Kaufman wrote:

 For example:

   # test.pl -pagerdest [EMAIL PROTECTED]

is the above another typo? should it be:

test.pl --pagerdest [EMAIL PROTECTED]

you seem to have only one '-' in front of pagerdest?
Getopt::Long uses '--' not '-'

david


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




Re: Exported Vars

2002-08-26 Thread drieux


On Monday, August 26, 2002, at 03:40 , Connie Chan wrote:

 package A;
 use strict;
 require Exporter;
 our @ISA = qw (Exporter); # What this actually for ?!

One way to think of this as a way of stopping the questions
about 'isa' - cf
perldoc UNIVERSAL

In this case it is an Exporter . but if you
play with say:

require HTML::HeadParser;

print is a: $_ \n for @HTML::HeadParser::ISA;

you will note that it return

is a: HTML::Parser

because just as in your package you said you
were a 'sub_class' of Exporter, in their package
they said that they were a sub_class of HTML::Parser.

you might try say:

use HTML::HeadParser;

my $p = new HTML::HeadParser;

#my $upper = ref($p-SUPER::new());


do_the_chain($p);

#
#
sub do_the_chain {
my ($ref) = @_;

my $p_is = ref($ref);

no strict refs;
my @upper = @{${p_is}::ISA};
print \$ref is a $p_is \n  ;

for my $parent (@upper) {
print \tis a child of class $parent \n;
if ( UNIVERSAL::can($parent, 'new' )) {
my $p_type = new $parent;
do_the_chain($p_type);
}
}

} # end of do_the_chain

and you will get output like:

$ref is a HTML::HeadParser
is a child of class HTML::Parser
$ref is a HTML::Parser
is a child of class DynaLoader
[..]

 My question is, will perl re- assign the hash whenever
 a 'use package A' declared ? or when Perl found the package
 had loaded once, it won't load again ?

remember that 'use' goes through and does two things

a) require the package
b) import the package

in the first phase, as you will noted in the explaination
in perldoc -f require - it will return 1, IF it has already
been through the process of 'doing' the package

the import phase sorts out the 'name space issues. So it
really is not a good idea of export the same variable
name from

package A
package B

since you are trying to stuff them into the same space:

%main::hash;

[..]
 2. using sub to assign value (ie.  our %hash ; sub GenHash { . } 
 GenHash; 1; )

This sounds more promising as an idea - especially if you return
a reference to the hash and do not export the same function name
from each package -

hence you might have

use pack_a;
use pack_b;

my $a_hash_ref = pack_a::generate_hash();
my $b_hash_ref = pack_b::generate_hash();

or if you go REALLY freaky you could look at the sub_class
approach where in package A

package A
our @ISA = qw(Exporter);

.
sub generate_hash {

}


next file

package B
@ISA = qw(A);
sub generate_hash {

# foist we get our parents hash
my $upper = $self-SUPER::generate_hash();

#
# now we add our stuff here
#
$upper-{b1} = this block one;
$upper-{b2} = this block two;
.

return($upper);

}


ciao
drieux

---


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




Re: Getopt::Long option prefix

2002-08-26 Thread Karl Kaufman

Hi David,

From what I've seen, Getopt::Long default behavior is to accept either
'--opt|-opt'.   (Tested on Solaris 2.6 w/ Perl 5.005_03)

 test.pl  
#!/usr/local/bin/perl
use strict;
use diagnostics;
use Getopt::Long;
my %pagerdest = ();
Getopt::Long::Configure('default');
GetOptions(  pagerdest=s% = \%pagerdest );
foreach my $keyname (sort keys %pagerdest)
{
print pagerdest $keyname = $pagerdest{$keyname}\n;
}
#

  ./test.pl -pagerdest a=lkfd
pagerdest a = lkfd



- Original Message -
From: david
To: [EMAIL PROTECTED]
Sent: Monday, August 26, 2002 7:03 PM
Subject: Re: Having problems with AppConfig::Getopt module


Karl Kaufman wrote:

 For example:

   # test.pl -pagerdest [EMAIL PROTECTED]

is the above another typo? should it be:

test.pl --pagerdest [EMAIL PROTECTED]

you seem to have only one '-' in front of pagerdest?
Getopt::Long uses '--' not '-'

david


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


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




perl interpreter

2002-08-26 Thread Mark Goland

Hi guys,

I was just wondering is there a perl interpreter that will fit on one floppy
disk ??

mark


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




Re: Best way to save nested data structure.

2002-08-26 Thread Sudarshan Raghavan

On Mon, 26 Aug 2002, Rowan Reid wrote:

 
 
 I'm learning as best I can using every book orielly makes.  I am trying
 to saved a complex data structure (hash). I'm trying to use Berkly
 DBFile and tie. I am unable to store the file ie retrieve info once I
 have exited the program.  Once I tie a hash toe the  file access the
 contents should be the same as accessing the contents of the hash

What have you done so far? If you had posted your code or a snippet of it 
we can help you better. Here is a small example. You might also want to 
take a look at flock (perldoc -f flock). 

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

my ($tiedb, %tied_hash);
$tiedb = tie (%tied_hash, 'DB_File', 'tie_example.db', O_CREAT|O_RDWR, 0666) or
die dbcreat tie_example.db failed : $!\n;
# Once you exit from the program you will have to tie again to access the 
# values. My guess is you are not doing this.

foreach (keys (%tied_hash)) {
print $_ --- $tied_hash{$_}\n;
}

while (STDIN) {
chomp;
$tied_hash{$_} = $_;
}
$tiedb-sync;
undef ($tiedb);
untie ($tiedb);


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




Re: perl interpreter

2002-08-26 Thread Paul Johnson

On Tue, Aug 27, 2002 at 12:14:17AM -0700, Mark Goland wrote:

 Hi guys,
 
 I was just wondering is there a perl interpreter that will fit on one floppy
 disk ??

The perl binary itself will, but you'll probably need various modules to
make it useful.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

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




Re: Exported Vars

2002-08-26 Thread Janek Schleicher

Connie Chan wrote at Tue, 27 Aug 2002 00:40:26 +0200:

 package A;
 use strict;
 require Exporter;
 our @ISA = qw (Exporter); # What this actually for ?!
 our @EXPORT = qw (%hash);
 our %hash  ;
 
 ...
 My question is, will perl re- assign the hash whenever
 a 'use package A' declared ? or when Perl found the package
 had loaded once, it won't load again ?

No. All Perl does is to export %hash in your namespace.
That means, without the Exporter and the @EXPORT array,
you would have access to the variable with
%A::hash.
Now the *same* variable also exists in your namespace,
so you can access it with %hash.


Greetings,
Janek


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