Re: building module/package

2003-09-29 Thread perl
Daniel:

-I've sent this to the mod_perl list but there seems to be no response.

I got the module working in the current directory executing on the command
line. But I have a problem calling a module in my mod_perl dir using
apache on redhat 9. I have a mystuff.pm in the same directory as the
calling perl program. I got it working running on the command line but in
apache mod_perl, it can't find the module.

Questions:
 - Where should the mystuff.pm be located in?
 - The only place i know about mod_perl configuration file is:
/etc/httpd/conf.d/perl.conf. This contains the Alias and Directory
directive.

Error message:
Can't locate mystuff.pm in @INC (@INC contains:
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .)

Any help would be great.
By the way, I just getting started with perl.
-rkl

>
>
> --On Monday, September 29, 2003 19:04 -0700 "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>
>> test.pl
>> ---
>> use mystuff;
>>
>> print mystuff::trim($username);
>>
>> mystuff.pm
>> --
>># do i need any declaration line here
>># is sub here or what?
>># and where do i put this pm file?
>>
>> sub trim
>> { my $z = $_[0];
>>   $z =~ s/^\s+//;
>>   $z =~ s/\s+$//;
>>   return $z;
>> }
>
> You're almost good.  Add '1;' to the end of mystuff.pm, just to
> return a true value when it compiles, and 'package mystuff;' to the
> beginning of the same so Perl knows it is a package.  Also 'use
> warnings' and 'use strict' would be good in both...
>
> As for where you put it: wherever you want.  Just make sure that it
> gets included in the @INC path.  The easiest is in the same folder as
> test.pl (assuming you always run test.pl from there), since the
> current folder is in the path.
>
> 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]
>
>


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



Re: validate chars for a string

2003-09-29 Thread perl
Lots of good stuff here. This oneliner is what makes perl cool but it's
like speaking in tongue -:)

>   sub isValidChars { shift =~ /^[A-Za-z_]+$/ }


Thanks,
-rkl

> On Sep 29, [EMAIL PROTECTED] said:
>
>>Since, everyone is so lively today, I'm going to push my luck today with
>>this list. I need a little help here with validating a string to have
>> only
>>characters that I want, A-z and _ (underscore).
>
> You'll want to use a regular expression, or perhaps just the tr///
> operator.
>
>>sub isValidChars
>>{ my $retVal;
>>
>>  @chars=split(//,$_[0]);
>>
>>  for(@chars)
>>  {
>>if($_ =~ /A-z/) { print "good [" . $_ . "]\n"; $retVal=1; }
>
> First, you probably mean /[A-z]/.  Second, you probably mean /[A-Za-z_]/.
> Third, it's silly to do this character-by-character.
>
>>else { print "bad [" . $_ . "]\n"; $retVal=0; break; }
>
> "break" is spelled "last" in Perl.
>
>>  }
>>  return $retval;
>>}
>
> Here are a few variations:
>
>   sub isValidChars {
> my $str = shift;
> if ($str =~ /^[A-Za-z_]+$/) { return 1 }
> else { return  }
>   }
>
> which can be written as simply
>
>   sub isValidChars {
> return shift =~ /^[A-Za-z_]+$/;
>   }
>
> and, in fact, the 'return' isn't necessary:
>
>   sub isValidChars { shift =~ /^[A-Za-z_]+$/ }
>
> Or you could do the opposite:  make sure the string DOESN'T have any
> ILLEGAL characters in it.  The only problem with this is that an empty
> string is considered valid.  That's why this approach includes a length()
> test.
>
>   sub isValidChars {
> my $str = shift;
> return length($str) and $str !~ /[^A-Za-z_]/;
>   }
>
> That returns true if and only if $str is non-zero in length and DOES NOT
> contain a NON-[A-Za-z_] character.
>
> Another way to do it is with tr///.
>
>   sub isValidChars {
> my $str = shift;
> return length($str) and ($str =~ tr/A-Za-z_//c) == 0;
>   }
>
> This time, we use length() again, but we use the tr/// operator, instead
> of the m// operator.  The tr/// takes a character class, basically, and
> the /c modifier at the end means "take the opposite of this class".  So
> $str =~ tr/A-Za-z_//c is scanning $str for any NON-[A-Za-z_] characters.
> tr/// returns the number of matching characters found.  If the number of
> non-[A-Za-z_] characters is zero, and the length isn't zero, then it's a
> valid string.
>
> Which method should you use?  I'd probably use the simplest form of the
> first isValidChars() I showed.
>
> --
> Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
> RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
>  what does y/// stand for?   why, yansliterate of course.
> [  I'm looking for programming work.  If you like my work, let me know.  ]
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


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



Re: validate chars for a string

2003-09-29 Thread Jeff 'japhy' Pinyan
On Sep 29, [EMAIL PROTECTED] said:

>Since, everyone is so lively today, I'm going to push my luck today with
>this list. I need a little help here with validating a string to have only
>characters that I want, A-z and _ (underscore).

You'll want to use a regular expression, or perhaps just the tr///
operator.

>sub isValidChars
>{ my $retVal;
>
>  @chars=split(//,$_[0]);
>
>  for(@chars)
>  {
>if($_ =~ /A-z/) { print "good [" . $_ . "]\n"; $retVal=1; }

First, you probably mean /[A-z]/.  Second, you probably mean /[A-Za-z_]/.
Third, it's silly to do this character-by-character.

>else { print "bad [" . $_ . "]\n"; $retVal=0; break; }

"break" is spelled "last" in Perl.

>  }
>  return $retval;
>}

Here are a few variations:

  sub isValidChars {
my $str = shift;
if ($str =~ /^[A-Za-z_]+$/) { return 1 }
else { return 0 }
  }

which can be written as simply

  sub isValidChars {
return shift =~ /^[A-Za-z_]+$/;
  }

and, in fact, the 'return' isn't necessary:

  sub isValidChars { shift =~ /^[A-Za-z_]+$/ }

Or you could do the opposite:  make sure the string DOESN'T have any
ILLEGAL characters in it.  The only problem with this is that an empty
string is considered valid.  That's why this approach includes a length()
test.

  sub isValidChars {
my $str = shift;
return length($str) and $str !~ /[^A-Za-z_]/;
  }

That returns true if and only if $str is non-zero in length and DOES NOT
contain a NON-[A-Za-z_] character.

Another way to do it is with tr///.

  sub isValidChars {
my $str = shift;
return length($str) and ($str =~ tr/A-Za-z_//c) == 0;
  }

This time, we use length() again, but we use the tr/// operator, instead
of the m// operator.  The tr/// takes a character class, basically, and
the /c modifier at the end means "take the opposite of this class".  So
$str =~ tr/A-Za-z_//c is scanning $str for any NON-[A-Za-z_] characters.
tr/// returns the number of matching characters found.  If the number of
non-[A-Za-z_] characters is zero, and the length isn't zero, then it's a
valid string.

Which method should you use?  I'd probably use the simplest form of the
first isValidChars() I showed.

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


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



Re: patches

2003-09-29 Thread George Schlossnagle
man patch

On Monday, September 29, 2003, at 11:24  PM, Gupta, Sharad wrote:



Hi All,

Say i give one of my application to a customer. The customer runs it 
and finds a bug in there.
I don't want to give a fixed application again to the customer and ask 
him to go through the pain of installing it again.

Instead i create a patch and tell customer to install that patch.

The question is "How to i create a patch, and how customer would 
install it".

Thanx,
-Sharad

-- George Schlossnagle
-- Principal Consultant
-- OmniTI Computer Consulting, Inc.
-- +1.410.872.4910 x202
-- 1024D/1100A5A0 1370 F70A 9365 96C9 2F5E  56C2 B2B9 262F 1100 A5A0
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


patches

2003-09-29 Thread Gupta, Sharad


Hi All,

Say i give one of my application to a customer. The customer runs it and finds a bug 
in there.
I don't want to give a fixed application again to the customer and ask him to go 
through the pain of installing it again.

Instead i create a patch and tell customer to install that patch.


The question is "How to i create a patch, and how customer would install it".


Thanx,
-Sharad 



validate chars for a string

2003-09-29 Thread perl
Since, everyone is so lively today, I'm going to push my luck today with
this list. I need a little help here with validating a string to have only
characters that I want, A-z and _ (underscore).

So, this is what I'm stuck on:

#should fail because of space
$username="bob by";

if(&isValidChars($username))
 ...

#is there a better way but it isn't working anyway.
sub isValidChars
{ my $retVal;

  @chars=split(//,$_[0]);

  for(@chars)
  {
if($_ =~ /A-z/) { print "good [" . $_ . "]\n"; $retVal=1; }
else { print "bad [" . $_ . "]\n"; $retVal=0; break; }
  }
  return $retval;
}


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



RE: remove blanks

2003-09-29 Thread Jeff 'japhy' Pinyan
On Sep 29, Hanson, Rob said:

>I ran some benchmarks.
>
>The two-liner outperformed the one-liners by a 10 to 1 ratio.  Code and
>results below.
>
>Benchmark: timing 10 iterations of OneLine, OneLine2, TwoLines...
>  OneLine: 41 wallclock secs (39.30 usr +  0.00 sys = 39.30 CPU) @ 2544.79/s
>  OneLine2: 34 wallclock secs (32.58 usr +  0.00 sys = 32.58 CPU) @
>3069.56/s
>  TwoLines:  3 wallclock secs ( 2.58 usr +  0.00 sys =  2.58 CPU) @
>38789.76/s

You'll get a better representation with the following benchmark:

  #!/usr/bin/perl

  use Benchmark 'cmpthese';

  my $s = "   " . join("  ", ('foo') x 100) . "   ";

  cmpthese(-5, {
capture => \&capture,
alt => \&alt,
two => \&two,
two_rev => \&two_rev,
  });

  sub capture {
my $copy = $s;
$copy =~ s/^\s*(.*?)\s*$/$1/s;
  }

  sub alt {
my $copy = $s;
$copy =~ s/^\s+|\s+$//g;
  }

  sub two {
my $copy = $s;
s/^\s+//, s/\s+$// for $copy;
  }

  sub two_rev {
my $copy = $s;
$copy =~ s/^\s+//;
($copy = reverse $copy) =~ s/^\s+//;
$copy = reverse $copy;
  }

The output is thus:

Benchmark: running alt, capture, two, two_rev for at least 5 CPU seconds
   alt:  5 wallclock secs @   4163.86/s (n= 21777)
   capture:  5 wallclock secs @   4876.60/s (n= 25846)
   two:  6 wallclock secs @  24841.44/s (n=130666)
   two_rev:  5 wallclock secs @ 148958.27/s (n=774583)

Rate alt capture two two_rev
alt   4164/s  ---15%-83%-97%
capture   4877/s 17%  ---80%-97%
two  24841/s497%409%  ---83%


Notice the string this time.  It's got embedded whitespace.  This causes
the '\s+$' regex to perform HORRIBLY.  If you want to see why, try this:

  perl -mre=debug -e '"abc  def  ghi  jkl  mno" =~ /\s+$/'

Notice that the string "abc  def...  mno" doesn't end in whitespace, but
that the engine checks for /\s+$/ at each chunk of whitespace.  Icky
awful.

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



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



Re: building module/package

2003-09-29 Thread Daniel Staal


--On Monday, September 29, 2003 19:04 -0700 "[EMAIL PROTECTED]" 
<[EMAIL PROTECTED]> wrote:

test.pl
---
use mystuff;
print mystuff::trim($username);

mystuff.pm
--
# do i need any declaration line here
# is sub here or what?
# and where do i put this pm file?
sub trim
{ my $z = $_[0];
  $z =~ s/^\s+//;
  $z =~ s/\s+$//;
  return $z;
}
You're almost good.  Add '1;' to the end of mystuff.pm, just to 
return a true value when it compiles, and 'package mystuff;' to the 
beginning of the same so Perl knows it is a package.  Also 'use 
warnings' and 'use strict' would be good in both...

As for where you put it: wherever you want.  Just make sure that it 
gets included in the @INC path.  The easiest is in the same folder as 
test.pl (assuming you always run test.pl from there), since the 
current folder is in the path.

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]


building module/package

2003-09-29 Thread perl
Can someone help with build a simple module with one function in it?
Can't seem to get anythign working.

I guess something like:

test.pl
---
use mystuff;

print mystuff::trim($username);

mystuff.pm
--
#do i need any declaration line here
#is sub here or what?
#and where do i put this pm file?

sub trim
{ my $z = $_[0];
  $z =~ s/^\s+//;
  $z =~ s/\s+$//;
  return $z;
}

thanks,
-rkl

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



RE: remove blanks

2003-09-29 Thread perl
This is the correct reply.

That's some good stuff.

can you run a benchmark against these, contributed by others on this list,
as well?

$username =~ s/^\s*(.*?)\s*$/$1/;
s/^\s+//, s/\s+$// $username;

thanks,
-rkl

> I ran some benchmarks.
>
> The two-liner outperformed the one-liners by a 10 to 1 ratio.  Code and
> results below.
>
>
> Benchmark: timing 10 iterations of OneLine, OneLine2, TwoLines...
>   OneLine: 41 wallclock secs (39.30 usr +  0.00 sys = 39.30 CPU) @
> 2544.79/s
>   OneLine2: 34 wallclock secs (32.58 usr +  0.00 sys = 32.58 CPU) @
> 3069.56/s
>   TwoLines:  3 wallclock secs ( 2.58 usr +  0.00 sys =  2.58 CPU) @
> 38789.76/s
>
>
> use strict;
> use Benchmark;
>
> my $val = "" . ("foo" x 200) . "";
>
> timethese(100_000, {
> 'OneLine' => sub{trimOne($val)},
> 'OneLine2' => sub{trimOne2($val)},
> 'TwoLines' => sub{trimTwo($val)},
> });
>
> sub trimOne {
>   my $s = shift;
>   $s =~ s/^\s+|\s+$//g;
>   die $s unless ($s eq ("foo"x200));
> }
>
> sub trimOne2 {
>   my $s = shift;
>   $s =~ s/^\s*(.*?)\s*$/$1/g;
>   die unless ($s eq "foo"x200);
> }
>
> sub trimTwo {
>   my $s = shift;
>   $s =~ s/^\s+//;
>   $s =~ s/\s+$//;
>   die unless ($s eq "foo"x200);
> }
>
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Monday, September 29, 2003 8:04 PM
> To: [EMAIL PROTECTED]
> Subject: remove blanks
>
>
> Is there a func or a onliner for removing blanks from both ends?
>
> I'm using these:
>
> $username =~ s/^\s+//;
> $username =~ s/\s+$//;
>
> There got to be one out there!
>
> thanks,
> -rkl
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


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



RE: remove blanks

2003-09-29 Thread perl
That's some good stuff.

can you run a benchmark against these, contributed by others on this list,
as well?

$username =~ s/^\s*(.*?)\s*$/$1/;
$username =~ s/^\s*(.*?)\s*$/$1/;

thanks,
-rkl

> I ran some benchmarks.
>
> The two-liner outperformed the one-liners by a 10 to 1 ratio.  Code and
> results below.
>
>
> Benchmark: timing 10 iterations of OneLine, OneLine2, TwoLines...
>   OneLine: 41 wallclock secs (39.30 usr +  0.00 sys = 39.30 CPU) @
> 2544.79/s
>   OneLine2: 34 wallclock secs (32.58 usr +  0.00 sys = 32.58 CPU) @
> 3069.56/s
>   TwoLines:  3 wallclock secs ( 2.58 usr +  0.00 sys =  2.58 CPU) @
> 38789.76/s
>
>
> use strict;
> use Benchmark;
>
> my $val = "" . ("foo" x 200) . "";
>
> timethese(100_000, {
> 'OneLine' => sub{trimOne($val)},
> 'OneLine2' => sub{trimOne2($val)},
> 'TwoLines' => sub{trimTwo($val)},
> });
>
> sub trimOne {
>   my $s = shift;
>   $s =~ s/^\s+|\s+$//g;
>   die $s unless ($s eq ("foo"x200));
> }
>
> sub trimOne2 {
>   my $s = shift;
>   $s =~ s/^\s*(.*?)\s*$/$1/g;
>   die unless ($s eq "foo"x200);
> }
>
> sub trimTwo {
>   my $s = shift;
>   $s =~ s/^\s+//;
>   $s =~ s/\s+$//;
>   die unless ($s eq "foo"x200);
> }
>
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Monday, September 29, 2003 8:04 PM
> To: [EMAIL PROTECTED]
> Subject: remove blanks
>
>
> Is there a func or a onliner for removing blanks from both ends?
>
> I'm using these:
>
> $username =~ s/^\s+//;
> $username =~ s/\s+$//;
>
> There got to be one out there!
>
> thanks,
> -rkl
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


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



Re: Question on handling files.

2003-09-29 Thread Bob Showalter
Bob Showalter wrote:
>   for (1..$y) {
>   print "$_\n" unless $_ % 1000;

Whoops! You can leave the line above out. I just stuck it in there so I
could see the progress through the loop.

>   my $i = int(rand($x)) + 1;
>   exists $h{$i} and redo;
>   $h{$i}++;
>   }



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



Re: remove blanks

2003-09-29 Thread perl
this looks convenience

thanks,
-rkl

> [EMAIL PROTECTED] wrote:
>> Is there a func or a onliner for removing blanks from both ends?
>>
>> I'm using these:
>>
>> $username =~ s/^\s+//;
>> $username =~ s/\s+$//;
>>
>> There got to be one out there!
>
> Doing it in two steps is the way to go. Don't try to make one regex out of
> it.
>
> I usually write it this way, so I can process several variables at once:
>
>s/^\s+//, s/\s+$// for $foo, $bar, $baz;
>
>
>


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



Re: remove blanks

2003-09-29 Thread Bob Showalter
[EMAIL PROTECTED] wrote:
> Is there a func or a onliner for removing blanks from both ends?
>
> I'm using these:
>
> $username =~ s/^\s+//;
> $username =~ s/\s+$//;
>
> There got to be one out there!

Doing it in two steps is the way to go. Don't try to make one regex out of
it.

I usually write it this way, so I can process several variables at once:

   s/^\s+//, s/\s+$// for $foo, $bar, $baz;



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



Re: Question on handling files.

2003-09-29 Thread Bob Showalter
Douglas Holeman wrote:
> I have had a request to pull 100,000+ names from a mailing list of
> 600,000+. I was hoping to figure out a way to get perl to help me do
> this.
>
> I stumbled through this code but the problem is I just wanted to know
> how to delete a line from the first list so I can be sure I dont pull
> the same 'random' line twice.
>
> Any help would be appreciated.  I know this code sucks but I am not a
> programmer.
>
>
>
>
> open FEDOUT, ">c:\\perl\\bin\\129out.csv" or die "The Program has
> failed opening 129Out.csv: $!";
>
> $x=1;
> $z=633856;
> print "1";
>
> while ($x <= 129000) {
> open(FEDUP, "All.csv") or die "Can't find All.csv: $!\n";
>
>  $y = int(rand($z)+1);
>
>  $a=1;
>
>
>  while ($a < $y) {
>   $line = ;
> #  print $a,"  ",$y,"Z=", $z, "\n";
>   $a=$a+1;
>
>  }
>
>
>  print $x,"...", $y,"...", $z,"...", $a,"...", $line,"...","\n";
>  print (FEDOUT $line);
>  $a=1;
>  $y=1;
>
>  $x=$x+1;
> close FEDUP;
>
> }
>
> print $x;
> close FEDOUT;
> close FEDUP;

This code is going to be *extremely* slow, because you are making many,
many, many passes over the huge 600K row file.

Here's a fairly efficient algorithm that requires only one pass through the
large file (after you know how many lines are in it). Pass the name of the
large file as the first command line argument:

  #!/usr/bin/perl
  use strict;
  my $x = 633_856;# no. of rows in big file
  my $y = 129_000;# no. of rows to select
  my %h;
  for (1..$y) {
  print "$_\n" unless $_ % 1000;
  my $i = int(rand($x)) + 1;
  exists $h{$i} and redo;
  $h{$i}++;
  }
  while(<>) {
  exists $h{$.} and print;
  }

Here I'm basically creating a hash with 129k entries with keys randomly
selected from the range 1..633k. Then as we read through the file, we just
print each line whose number exists as a key in the hash.

Important: make sure your Perl has enough randbits. or you won't get a
distribution over this range. You'll need at least 20 bits and preferrably
31 or more. Use "perl -V:randbits" to check the figure.



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



RE: remove blanks

2003-09-29 Thread Hanson, Rob
I ran some benchmarks.

The two-liner outperformed the one-liners by a 10 to 1 ratio.  Code and
results below.


Benchmark: timing 10 iterations of OneLine, OneLine2, TwoLines...
  OneLine: 41 wallclock secs (39.30 usr +  0.00 sys = 39.30 CPU) @ 2544.79/s
  OneLine2: 34 wallclock secs (32.58 usr +  0.00 sys = 32.58 CPU) @
3069.56/s
  TwoLines:  3 wallclock secs ( 2.58 usr +  0.00 sys =  2.58 CPU) @
38789.76/s


use strict;
use Benchmark;

my $val = "" . ("foo" x 200) . "";

timethese(100_000, {
'OneLine' => sub{trimOne($val)},
'OneLine2' => sub{trimOne2($val)},
'TwoLines' => sub{trimTwo($val)},
});

sub trimOne {
  my $s = shift;
  $s =~ s/^\s+|\s+$//g;
  die $s unless ($s eq ("foo"x200));
}

sub trimOne2 {
  my $s = shift;
  $s =~ s/^\s*(.*?)\s*$/$1/g;
  die unless ($s eq "foo"x200);
}

sub trimTwo {
  my $s = shift;
  $s =~ s/^\s+//;
  $s =~ s/\s+$//;
  die unless ($s eq "foo"x200);
}


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, September 29, 2003 8:04 PM
To: [EMAIL PROTECTED]
Subject: remove blanks


Is there a func or a onliner for removing blanks from both ends?

I'm using these:

$username =~ s/^\s+//;
$username =~ s/\s+$//;

There got to be one out there!

thanks,
-rkl

-- 
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: Generic database access?

2003-09-29 Thread Mark G
Rob,

why not try one of r-desktops. I use TridiaVNC, which you can carry with
ssh.

Mark G
- Original Message - 
From: "Rob Richardson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, September 29, 2003 3:33 PM
Subject: Re: Generic database access?


> Sam,
>
> There's a lot of products named "Webmon".  The ones I found on Google
> didn't do what I want.  Which one are you thinking of?  Can you give me
> a company name?
>
> Thanks again!
>
> Rob
>
>
>
> __
> Do you Yahoo!?
> The New Yahoo! Shopping - with improved product search
> http://shopping.yahoo.com
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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



Re: remove blanks

2003-09-29 Thread James Edward Gray II
On Monday, September 29, 2003, at 07:04  PM, [EMAIL PROTECTED] wrote:

Is there a func or a onliner for removing blanks from both ends?

I'm using these:

$username =~ s/^\s+//;
$username =~ s/\s+$//;
We could combine those:

$username =~ s/^\s*(.*?)\s*$/$1/;

Hope that helps.

James

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


RE: remove blanks

2003-09-29 Thread Hanson, Rob
That is what you want to use.

You could do it in a single regex:
## NOT RECOMMENDED - SEE NOTE BELOW ##
$username =~ s/^\s+|\s+$//g;

The downside is that this is not efficient and actually takes Perl longer to
perform the operation.  If you want to know why you need to know a little
about how Perl stores strings internally.

Rob

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, September 29, 2003 8:04 PM
To: [EMAIL PROTECTED]
Subject: remove blanks


Is there a func or a onliner for removing blanks from both ends?

I'm using these:

$username =~ s/^\s+//;
$username =~ s/\s+$//;

There got to be one out there!

thanks,
-rkl

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



remove blanks

2003-09-29 Thread perl
Is there a func or a onliner for removing blanks from both ends?

I'm using these:

$username =~ s/^\s+//;
$username =~ s/\s+$//;

There got to be one out there!

thanks,
-rkl

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



Re: Replacing variable data between fields - Revisited.

2003-09-29 Thread perlwannabe
> Perlwannabe wrote:
>>
>> I originally tried to do this, but it won't work.  The data doesn't
>> _always_ have a  before address, sometimes (although seldom) it
>> has a .  With grep I would miss the entire address.  However,
>> if I were to just select everything and replace it with nothing, that
>> would be the answer.  BTW...your solution above is right on the money
>> for about 98% of the file.  However, by simply scanning the line and
>> deleting everything between between HOW and NUMBER: that would give
>> me 100%.  Any ideas?
>
> You could try this:
>
> s/\tHOW.+?\sNUMBER:\s*\S+\t/\t/;

Hah!!! I got it.  FINALLY!!!  Thank you so much for the help.  It was a
simple  matter of using s/// instead of tr///.  I am not sure why, but
it works...The tr/// function does not work at all...Any ideas why?

s{ (?<=HOW) (.+?) (?<=NUMBER\t) } { ( $a = $1 ) =~ s/$a/ /; $a   }ex;




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



Re: Should loops return a value?

2003-09-29 Thread John W. Krahn
Steve Grazzini wrote:
> 
> On Mon, Sep 29, 2003 at 11:04:46PM +0300, Ville Jungman wrote:
> > This is real example from what i was doing yesterday:
> >   if($subs->anna_tilavuus($x+$lisax,$y+$lisay,$z) < 100){
> >  $subs->paivita($x);
> >  $udat{x}=$lisax;
> >  $udat{y}=$lisay;
> >   }elsif($subs->anna_tilavuus($x,$y+$lisay,$z) < 100){
> >  $udat{y}=$lisay;
> >   }
> >
> > If using return values, this could be wrote as:
> >   ($udat{x},$udat{y})=
> >  if($subs->anna_tilavuus($x+$lisax,$y+$lisay,$z) < 100){
> > $subs->paivita($x);
> > retlast($lisax,$lisay)
> >  }elsif($subs->anna_tilavuus($x,$y+$lisay,$z) < 100){
> > retlast(undef,$lisay);
> >  }
> >   ;
> 
> You can do this already with "do" blocks.
> 
>   my $condition = 1;
> 
>   ($x, $y) = do {
> if ($condition) { 42, 43 }
> else{ 44, 45 }
>   };

You don't need a do block, the conditional operator can handle it.

@udat{ 'x', 'y' } = $subs->anna_tilavuus( $x + $lisax, $y + $lisay, $z )
< 100
  ? do { $subs->paivita( $x ); ( $lisax, $lisay ) }
  : $subs->anna_tilavuus( $x, $y + $lisay, $z ) < 100
  ? ( undef, $lisay )
  : ();


John
-- 
use Perl;
program
fulfillment

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



Question on handling files.

2003-09-29 Thread Douglas Holeman
I have had a request to pull 100,000+ names from a mailing list of
600,000+. I was hoping to figure out a way to get perl to help me do
this.
 
I stumbled through this code but the problem is I just wanted to know
how to delete a line from the first list so I can be sure I dont pull
the same 'random' line twice.
 
Any help would be appreciated.  I know this code sucks but I am not a
programmer.
 
 
 
 
open FEDOUT, ">c:\\perl\\bin\\129out.csv" or die "The Program has failed
opening 129Out.csv: $!";
 
$x=1;
$z=633856;
print "1";
 
while ($x <= 129000) {
open(FEDUP, "All.csv") or die "Can't find All.csv: $!\n";
 
 $y = int(rand($z)+1);
 
 $a=1;
 

 while ($a < $y) {
  $line = ;
#  print $a,"  ",$y,"Z=", $z, "\n";
  $a=$a+1;
 
 }
 

 print $x,"...", $y,"...", $z,"...", $a,"...", $line,"...","\n";
 print (FEDOUT $line);
 $a=1;
 $y=1;
 
 $x=$x+1;
close FEDUP;
 
}
 
print $x;
close FEDOUT;
close FEDUP;
 
 
Douglas Holeman
Prepress Manager
 


Re: Is there a *nix shell variable for the path to perl?

2003-09-29 Thread Jeff Westman
Dan Anderson <[EMAIL PROTECTED]> wrote:
> Is there a (BA)SH/CSH/TSH/KSH variable to the Perl path?
> 
> I am creating a script that uses Perl I want to be able to share over
> several servers.  Instead of having my users edit the file manually
> (because I assume they would do something dumb) I want to create a shell
> script to edit the script for them.

No, but you can create your own.  Use something like:

PERL=`which perl`

Alternative, just call perl from the command line, such as

$ perl yourScript.pl

instead of 

$ yourScript.pl

In the last case you would have to use a 'shebang' #!/path in the file
itself, whereas calling it from the command line, it takes it from the $PATH.


-Jeff


__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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



Re: extending modules

2003-09-29 Thread Jeff 'japhy' Pinyan
On Sep 29, Kevin Pfeiffer said:

>I'm working on a nice frontend to the Unix::AliaseFile module for managing
>'aliases'. In the process I've extended a couple methods in the module and
>added a new one.
>
>There is a show_user method that returns all aliases of which a user is a
>member; there's also a "Toggle on/off" that uses commenting to deactive but
>not delete an alias (our sysadmin likes to do this); rename_user can also
>now rename aliases, too, (since an alias might be a member of another alias
>list).
>
>My working copy is now called AliasFilePlus.
>
>What do I do with this if I try to share it? The changes to the module
>seemed too great (and too complex) for me to place them in the main program
>and too little for a submodule. I've updated the docs and wrote "...based
>on version xxx of Unix::AliasFile by Steve Snodgrass...", etc.

Typically, you create a sub-module.

  package Unix::AliasFile::Extended;
  use base 'Unix::AliasFile';

  sub changed_method { ... }
  sub new_method { ... }

  1;

Then you just use Unix::AliasFile::Extended in any program where you would
have used Unix::AliasFile.

If you want to contact the author and ask him if he'd like to release a
new version of the Unix::AliasFile module with your code in it, go right
ahead.  Should that fail, the sub-class approach above is fine.

>(After I clean up a couple things I'll post a link to it in case anyone is
>interested in sharing critique).

I'd be happy to do that for you.

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


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



Re: extending modules

2003-09-29 Thread Rob Dixon
Kevin wrote:
>
>
> I've updated the docs and wrote "...based on version
> xxx of Unix::AliasFile by Steve Snodgrass...", etc.

Mister Snodgrass is a character in The Pickwick Papers
invented by Charles Dickens. He is no "Foo" or "Bar".

Proud of the soil on which I stand :)

Rob Dixon
Leicester
ENGLAND



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



Re: Should loops return a value?

2003-09-29 Thread Steve Grazzini
On Mon, Sep 29, 2003 at 11:04:46PM +0300, Ville Jungman wrote:
> This is real example from what i was doing yesterday:
>   if($subs->anna_tilavuus($x+$lisax,$y+$lisay,$z) < 100){
>  $subs->paivita($x);
>  $udat{x}=$lisax;
>  $udat{y}=$lisay;
>   }elsif($subs->anna_tilavuus($x,$y+$lisay,$z) < 100){
>  $udat{y}=$lisay;
>   }
> 
> If using return values, this could be wrote as:
>   ($udat{x},$udat{y})=
>  if($subs->anna_tilavuus($x+$lisax,$y+$lisay,$z) < 100){
> $subs->paivita($x);
> retlast($lisax,$lisay)
>  }elsif($subs->anna_tilavuus($x,$y+$lisay,$z) < 100){
> retlast(undef,$lisay);
>  }
>   ;

You can do this already with "do" blocks.

  my $condition = 1;

  ($x, $y) = do {
if ($condition) { 42, 43 }
else{ 44, 45 }
  };

  print "$x : $y\n";

If it makes you happy, you can even add -->

  sub retlast { @_ }

But the analogy with return/last is likely to confuse -- why can
you use retlast() in places where neither return() or last() make
any sense?

-- 
Steve

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



Is there a *nix shell variable for the path to perl?

2003-09-29 Thread Dan Anderson
Is there a (BA)SH/CSH/TSH/KSH variable to the Perl path?

I am creating a script that uses Perl I want to be able to share over
several servers.  Instead of having my users edit the file manually
(because I assume they would do something dumb) I want to create a shell
script to edit the script for them.

Thanks in advance,

-Dan


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



RE: Should loops return a value?

2003-09-29 Thread Ville Jungman
From: "TN" <[EMAIL PROTECTED]>
1. You can pipe into and out of control constructs in the sh-ksh-bash
family, including for and while loops.  This can be convenient and
elegant, but not absolutely necessary logically.
You thought possible IO-constructs with this but it isn't very clear to me 
what it'd mean. I think that constructs would just return values because 
would it be too complicated if they inherit something from their user (or 
elsewhere?)? I really don't know at this moment - perhaps there's a clever 
way to do it.

How would it be possible to apply this to loops such that
only in certain contexts they would return a value and what would those
contexts be?
I think that loops maybe shouldn't be considered as filters although it 
would be possible to use them like it. I think there shouldn't be automatic 
return values always.

@array=while(...){
  ...
  retnext;   #shouldn't be added automatically here
}
That enables a
maximum degree of "recursivability" that can lead to impressive
solutions some areas,
This is exactly what i'm looking for! Now loops, if's etc make the code 
break every time - even when it's not neccessary.

Perhaps, for example, it would be useful to implement a tagging system
on all control constructs such that if they were tagged in a certain way
all of their output (if any) was returned using a commonly accessible
read-write communication channel analogous to STDIN and STDOUT for
sh-ksh-bash scripts.  An advantage of this would be to make it easier to
write perl programs that do more complex processing in a way that is
more natural, flowing and intuitive for people.
IO starts finally to make more sense if there was such a tagging system. As 
a student of two languages (engl & perl), it's a real pity that i can't 
fully follow Your text and text in those links You wrote but i'm optimistic 
i got the point.

This is real example from what i was doing yesterday:
  if($subs->anna_tilavuus($x+$lisax,$y+$lisay,$z) < 100){
 $subs->paivita($x);
 $udat{x}=$lisax;
 $udat{y}=$lisay;
  }elsif($subs->anna_tilavuus($x,$y+$lisay,$z) < 100){
 $udat{y}=$lisay;
  }
If using return values, this could be wrote as:
  ($udat{x},$udat{y})=
 if($subs->anna_tilavuus($x+$lisax,$y+$lisay,$z) < 100){
$subs->paivita($x);
retlast($lisax,$lisay)
 }elsif($subs->anna_tilavuus($x,$y+$lisay,$z) < 100){
retlast(undef,$lisay);
 }
  ;
Already there's more common code in the lower example because inside if's 
there's no need to know the caller's (here: $udat{x},$udat{y}) name. I 
understood that by IO-system, it would be possible to use caller's values or 
the caller itself (maybe in same style like it was an object) inside the 
'if' with just having a reference or something to it - and have even more 
common code in several cases?

ville jungman, 2 laureston crescent, tower, blarney, cork, ireland
tel. + 353 - 21 - 451 6847, http://www.kolumbus.fi/vilmak
usko Herraan Jeesukseen, niin sinä pelastut. (apt. 16:31)




From: "TN" <[EMAIL PROTECTED]>
To: "'Ville Jungman'" <[EMAIL PROTECTED]>
CC: <[EMAIL PROTECTED]>
Subject: RE: Should loops return a value?
Date: Sat, 27 Sep 2003 20:01:20 -0400
I've been thinking about this issue more generally.  Programming
language enhancement does not seem to be especially a beginner's topic.
But a beginner may not have biases that inhibit greater insight; and
such insight could also be well served by a sufficient conceptual basis
and historical knowledge - to ensure that something new and significant
is really introduced.  After all, programming experts have been mulling
over "new" developments for over 40 years!
Here are few considerations that your discussion stimulated in me.  They
lead to a question for possible enhancement of pearl that I pose at the
end:
1. You can pipe into and out of control constructs in the sh-ksh-bash
family, including for and while loops.  This can be convenient and
elegant, but not absolutely necessary logically.  It shows a sense in
which every control construct "returns" a value including loops.  In
this case that facility is based on a common underlying "medium" of
communication, namely the STDIN and STDOUT streams of chars.  This
"medium" can also be used to link scripts externally, a rudimentary but
powerful form of interprocess communication!  The basic idea has
appeared in several more elaborate forms of greater generality or for
certain application domains including:
A. The "communicating sequential processes" model and language (CSP) of
Tony Hoare.  CSP is a general model for concurrency and a widely and
well regarded useful way to achieve parallelism for non-trivial, real
world and often real time problems.  See http://www.usingcsp.com/.  CSP
has been instantiated in Java and has had active participation in
specialized conferences for 7 years.
B. The use of threads in programming, lightweight and otherwise, in an
effort to make complex systems development more efficient and affordable
/* The

Re: Passing a variable to a package function vs. a local function

2003-09-29 Thread Steve Grazzini
On Sun, Sep 28, 2003 at 11:48:19PM -0700, Dan Fish wrote:
> sub myfunc{ my ($query) = @_;
> $foo=$query->param("foo");
>  ...more...blah...blah...
> }
> 
> Everything works fine as is, but I'm trying to take the function "myfunc"
> out and put it in a separate .pm file because I need to call it from several
> cgi scripts.  When I put it in the .pm file, I get something like:   
> 
>   Can't locate object method "param" via package "Trend" at
> /usr/local/lib/perl5/site_perl/5.005/MMC/Dex.pm line 253,  chunk
> 1150.

Either use the pure subroutine call instead of the method call.

  Trend::myfunc( $query );

Or use the method call, and know that the first argument will
be the class/object on which the method was invoked.

  package Trend;
  sub myfunc {
my ($package, $query) = @_;
...
  }

  package main;
  Trend->myfunc( $query );

-- 
Steve

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



Re: Generic database access?

2003-09-29 Thread Rob Richardson
Sam,

There's a lot of products named "Webmon".  The ones I found on Google
didn't do what I want.  Which one are you thinking of?  Can you give me
a company name?

Thanks again!

Rob



__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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



Re: Objects, threads and so on

2003-09-29 Thread david
Lists Perl Org wrote:

> Hi all,
> 
> I'm quite new to Perl so please bear with me :)
> 
> I've experience in Delphi so I thought I knew about objects... it
> seems I don't :(
> 
> I want to have a class I won't instanciate (static members and
> variables), with global vars so I can access them and change them from
> withing threads/forks.

not sure what you mean by that but looks like you want to have a global 
variable where the threads can manipulate and all the threads will see the 
same value once a thread modified the vairable. if so you need to lock the 
variable before letting the threads to access that variable. 

> 
> -- FILE test.pl
> 
> use FOO;
> 
> FOO->make();
> FOO->make();
> 
> use Thread;
> 
> my $t = new Thread \&th1;
> my $u = new Thread \&th2;
> 
> sub th1() { while (1) { FOO->make(); sleep(1); } }
> sub th2() { while (1) { print "\t"; FOO->make(); sleep(2); } }

threads->yield is usually a better choice to than sleep if you want the OS 
to know that it should pay attention to another thread.

> 
> while (1) {}
> 
> -- FILE FOO.pm
> 
> package FOO;
> 
> %FOO::e = {};
> 
> sub make {
>   my $self = shift;
>   %FOO::e->{'something'} = %FOO:e->{'something'} + 1;
>   print %FOO::e->{'something'}."\n";
> }
> 
> -- RESULTS --
> 
> 1
> 2
> 3
>3
> 4
> 5
>4
> 6
> 7
>5
> 8
> ...
> 
> Obviously it doesn't work.
> 
> I have tried a lot more of things and I don't know how to make it
> work. The same applies if I use fork() instead threads.

forking a different process is different than making a new thread. 
obviously, very little is shared between a parent and a child process which 
makes sharing a global variables before multiple process a bit difficult. 

> 
> Is there any way to make this work?
> 

if i understand your question correctly, see if the following helps:

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

use threads;
use threads::shared;

package AnotherNameSpace;

#--
#-- $var is global to AnotherNameSpace and will 
#-- be shared among all threads
#--
my $var : shared = 1;

sub inc{

#--
#-- let only one thread access $var at a time
#--
{

lock($var);
$var++;
print STDERR "$_[0]$var\n";

}
}

package main;

sub get1{

while(1){
AnotherNameSpace::inc('');
threads->yield;
}
}
sub get2{

while(1){
AnotherNameSpace::inc("\t");
threads->yield;
}
}

my $t1 = threads->new(\&get1);
my $t2 = threads->new(\&get2);

$t1->join;
$t2->join;

__END__

prints:

10
11
12
13
14
15
...
538
539
540
541
542
543
...

lines begin with a tab is printed by one thread and those that do not being 
with the tab are printed by another thread. as you can see, they all syn 
up. without the locking, you might see something like:

601
598
602
599
603
600
604
601

which probably isn't what you expect.

david
-- 
$_=q,015001450154015401570040016701570162015401440041,,*,=*|=*_,split+local$";
map{~$_&1&&{$,<<=1,[EMAIL PROTECTED]||3])=>~}}0..s~.~~g-1;*_=*#,

goto=>print+eval

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



Regarding Mail::Bulkmail 3.09 module

2003-09-29 Thread Chinku Simon
Hi,

I am facing a problem in using the Mail::Bulkmail 3.09 module.

I am using the following method to specify the configuration files.

Mail::Bulkmail->conf_files('C:/Perl/lib/Bulkmail.cfg');

and I have converted the script to an '.exe ' file. While I run the .exe file
I get the error 
"Can't call method "header" on an undefined value at notessyncv6.pl line 825,  line 82."

The script runs fine when it is run as a ".pl" file

Thanks
Chinku 

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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



How to draw lines with different line width?

2003-09-29 Thread Yi Chu
I am usiing GD::Graph::lines to draw a graph with multiple lines.  How do I specify so 
that lines can be of different width?
 
yi


-
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search

Re: Generic database access?

2003-09-29 Thread Sam Harris
search google for "Webmon".
also check out phpadmin.

good luck

Sam Harris, 
Systems Administrator
Franklin University
201 S. Grant Avenue
Columbus, Ohio  43215-5399
Work: (614)-744-8322
Toll free: 1-877-341-6300 ext. 8322
[EMAIL PROTECTED]
http://www.franklin.edu/
>>> [EMAIL PROTECTED] 09/29/03 09:56 AM >>>
Greetings!

Is there a Perl module --

"Don't be silly!", I hear you reply.  "There's a Perl module for
everything!"

OK, let me rephrase that.  I would like a program, probably but not
necessarily in Perl, that can run on a Perl-equipped Unix server that
will give me remote access through the Internet to a database system in
a way similar to how Microsoft Access provides a GUI for creating and
editing databases.  What would you recommend?

Thanks!

Rob

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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



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



extending modules

2003-09-29 Thread Kevin Pfeiffer
Hi,

I'm working on a nice frontend to the Unix::AliaseFile module for managing
'aliases'. In the process I've extended a couple methods in the module and
added a new one. 

There is a show_user method that returns all aliases of which a user is a
member; there's also a "Toggle on/off" that uses commenting to deactive but
not delete an alias (our sysadmin likes to do this); rename_user can also
now rename aliases, too, (since an alias might be a member of another alias
list).

My working copy is now called AliasFilePlus.

What do I do with this if I try to share it? The changes to the module
seemed too great (and too complex) for me to place them in the main program
and too little for a submodule. I've updated the docs and wrote "...based
on version xxx of Unix::AliasFile by Steve Snodgrass...", etc.

Right now the main program is set up so:

use lib ".";
use AliasFilePlus;

Should I try to contact the author to ask if he's interested in the
extensions? If this fails, then what?

(After I clean up a couple things I'll post a link to it in case anyone is
interested in sharing critique).

Thanks in advance (list has some good questions lately I see; I will try to
catch up),

-Kevin


-- 
Kevin Pfeiffer
International University Bremen
Your message here

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



Re: assigning a multi-dimensional array (mda) to an mda?

2003-09-29 Thread Kevin Pfeiffer
In article <[EMAIL PROTECTED]>, R. Joseph Newton wrote:

> Kevin Pfeiffer wrote:
> 
>> I thought the easy way to do this is to first assign my entire 'en' data
>> structure to the 'de' structure and then add 'de' values as available.
>>
>> So I did this:
>>
>> $text{'main'}{'de'} =  $text{'main'}{'en'};
>>
>> $text{'main'}{'de'} = {  # German labels
>> 'alias_sub' =>  "ALIAS",
>> 'user_sub'  =>  "BENUTZER",
>> };
>>
>> But this assignment doesn't seem to work. Can I not do this?
> 
> I bet it does.  Just not the way you want it to.
[...]

I'll have to maybe try a smaller sample and then look at them with
Data::Dumper (I'm a little slow sometimes)

> *Hash-based structures do not have columns or support parallelism*

Writing it on the wall!  ;-)

> 
> I'd suggest a little restructuring:
> 
> $text{'main'} = {
> 'alias_sub'  => {'en' => 'Alias', 'de' => 'Allas'},
> 'user_sub'  => {'en'  => 'User', 'de' => 'Benutzer'},
> ...
> }

Too late for me, and I wanted something where someone could say, okay, now
lets add Bulgarian. So I keep each language separate.

> A little less elegant when it comes to accessing it, but if you see the
> potential for forgetting the German counterparts as serious, this would
> make it much less likely.

I think the better approach for me is that when my get_lang routine is
called to provide language for a prompt that if, for example,
$text{main}{de}{alias_sub} does not exist, that the other entry is
substituted. I think I can figure that out...

Thanks for the help and advice!

-- 
Kevin Pfeiffer
International University Bremen


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



Re: substr parsing mask

2003-09-29 Thread Jeff 'japhy' Pinyan
On Sep 29, [EMAIL PROTECTED] said:

>I got it to work after adding a new var in apache modperl environment.
>
>This works:
> $acct_no = $xgi->param("acct_no");
> print substr($acct_no, 0, 4, "x" x (length($acct_no)-4));
>
>This did NOT work:
> print substr($xgi->param("acct_no"), length($xgi->param("acct_no"))-4,4);

They're not the same code.

  print substr(
$xgi->param('acct_no'),
0,
4,
"x" x (length($xgi->param('acct_no')) - 4)
  );

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


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



Re: Objects, threads and so on

2003-09-29 Thread Rob Dixon
Fernando wrote:
>
> I'm quite new to Perl so please bear with me :)

We have no choice: this is, after all, perl.beginners!

> I've experience in Delphi so I thought I knew about objects... it
> seems I don't :(

Yes you do :) But you're confusing methodologies with implementations.

> I want to have a class I won't instanciate (static members and
> variables), with global vars so I can access them and change them from
> within threads/forks.

Threads and forks are something layered on top of Perl, and therefore
implicitly non-standard, beyond an explicit Perl version.

> use FOO;

Which will try to compile FOO.pm and to execute FOO::import.

> FOO->make();
> FOO->make();

The constructor for a Perl object is, traditionally, 'new'. But
this is not bound by the language and can have any name that you
want. However this looks like two instantiations, which you said
you weren't doing, and both of which are discarded (in either
Delphi or Perl) so I don't see what you're trying to do here.

> use Thread;
>
> my $t = new Thread \&th1;
> my $u = new Thread \&th2;
>
> sub th1() { while (1) { FOO->make(); sleep(1); } }
> sub th2() { while (1) { print "\t"; FOO->make(); sleep(2); } }

Again I am disconcerted, as you have an object instantion
in each of two threads, which is immediately discarded.

> while (1) {}
>
> -- FILE FOO.pm
>
> package FOO;
>
> %FOO::e = {};

This wouldn't compile if you wore the helmet of Perl
salvation, being:

  use strict;   # always
  use warnings; # usually

You're trying to set a hash (being a list of paired values)
to a single value (which is an empty hash reference).

> sub make {
>   my $self = shift;
>   %FOO::e->{'something'} = %FOO:e->{'something'} + 1;
>   print %FOO::e->{'something'}."\n";
> }

This declares 'FOO::make' because of your 'package' statement
above. Call it 'FOO::new' to make others in the Perl world
feel at home.

Any constructor parameters are values to help form the object.
Your constructor cannot have a $self parameter as, if
it is useful at all, it is to copy values from an existing
object of the same type or of a subclass. It will usually be
called 'clone'.

Back to your top line:

> So I can access them and change them from within threads/forks

Within a single thread, you could declare or require another
module containing

  package MODULE;

  our $var1;
  our $var2;

etc.

Which will be accessible externally as $MODULE::var1,
$MODULE::var2. You could also 'use' that code as an external
module which will let you access synonyms to those values
in the current package as $var1, $var2 etc. Unless you have
a comprehensive requirement IMO this is not worth considering.

Say more about your application and we will help further.

HTH,

Rob



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



Re: Perl Newbie - Need good book recommendation

2003-09-29 Thread Dan Anderson
> Big advice #2.  Ebay.  I buy all new books and expensive books through
> trusted sellers for about a 50-60% savings.  Make sure you can pay media
> rate on the shipping.  $4.00.  I routinely buy books for $15-20 here.

I do the same thing, and would add the following sites:

http://www.alibris.com
http://www.half.com
http://www.addall.com

You can get used and new books for much less then the sticker price.

I would just add a word of caution though: sometimes you can find a
really cheap perl book for $4.  Double check that the edition is
relatively new and covers Perl 5.  Otherwise you may get a great deal on
a book about Perl 1.

-Dan


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



RE: Generic database access?

2003-09-29 Thread TN
phpMyAdmin is great for managing MySQL databases remotely using a web
browser interface.  See http://www.phpmyadmin.net/

-tn


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



RE: Script runs once

2003-09-29 Thread TN
This problem looks familiar.  What will kill the first snoop?  The while
loop at the bottom assumes snoop is running and tries to run another
snoop on the same interface as the first.  I don't think that can be
done even from the command line because the first snoop will lock
/dev/ge0 (in promiscuous mode).  It will be easier and more robust to
use cron for restarting the process.

-tn

-Original Message-
From: rmck [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 29, 2003 9:56 AM
To: [EMAIL PROTECTED]
Subject: Script runs once


Hello,

I have a perl script that is to stop and start at midnight, and write to
a new log file. 

The problem is it runs once then does not run again?? 

Below is the script that I am tring to use?? 


bash-2.03#
#!/bin/perl -w
use warnings;
use strict;
 
my ( $sec, $min, $hour, $day, $mon, $year ) = localtime;
my $snoop   = '/usr/sbin/snoop -d ge0 -ta';
my $date = `date +%W`;
chop($date);
my $dir = "/var/weeks/03_week_$date";

my $logfile = sprintf '/var/weeks/03_week_%d/%02d%02d%02d%02d%02d.sno',
`date +%W`, $year % 100, $mon + 1, $day, $hour, $min;
 
# create 03_week_dir if does not exist
unless(-d $dir){
mkdir $dir,0660;
} 
 
open LOG, '>', $logfile or die "Cannot open $logfile: $!";
# set default output filehandle and autoflush
select LOG;
$| = 1;
 
print '===' . localtime . " ==\n\n";
 
open SNOOP, "$snoop |" or die "Cannot open pipe from $snoop: $!";
 
while (  ) {
print;
# restart this process if midnight
( $sec, $min, $hour ) = localtime;
exec $0 if $sec + $min + $hour == 0;
}
bash-2.03# 

Thanks,
RM

-- 
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: PERL DNS Lookup's using "Socket"

2003-09-29 Thread Dan Anderson
I don't know if you've been following the news but Verisign and some
others have funneled *.com and *.net to their web site for expired and
invalid domain names.  You should correct for such things when looking
up the IP.

-Dan


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



Re: Objects, threads and so on

2003-09-29 Thread Ramprasad A Padmanabhan
Lists Perl Org wrote:
Hi all,

I'm quite new to Perl so please bear with me :)

I've experience in Delphi so I thought I knew about objects... it
seems I don't :(
I want to have a class I won't instanciate (static members and
variables), with global vars so I can access them and change them from
withing threads/forks. 

-- FILE test.pl

use FOO;

FOO->make();
FOO->make();
use Thread;

my $t = new Thread \&th1;
my $u = new Thread \&th2;
sub th1() { while (1) { FOO->make(); sleep(1); } }
sub th2() { while (1) { print "\t"; FOO->make(); sleep(2); } }
while (1) {}

-- FILE FOO.pm

package FOO;

%FOO::e = {};

sub make {
  my $self = shift;
  %FOO::e->{'something'} = %FOO:e->{'something'} + 1;
  print %FOO::e->{'something'}."\n";
}
-- RESULTS --

1
2
3
   3
4
5
   4
6
7
   5
8
...
Obviously it doesn't work.

I have tried a lot more of things and I don't know how to make it
work. The same applies if I use fork() instead threads.
Is there any way to make this work?

Thank you very much in advance!

Fernando Najera

 



Maybe you would do better to learn perl-syntax well before you jump into 
your actual application. A common problem for people conversant with 
many languages is that they always try translate their work in all 
languages though their command on all languages is not the same

A hash array reference is always written with $sign not %
so change
%FOO::e = {};   ==> $FOO::e
in all places

I havent gone thru the entire code , But I think you can take it further

Ram



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


Re: Perl - HowTo operating with large file?

2003-09-29 Thread Ramprasad A Padmanabhan
On Mon, 2003-09-29 at 16:07, Juris wrote:

> Hi!
> 
> Thanks, your solution is one way how solve this problem! I found other ...
> 

Gr8 That is the spirit of perl. There is always a different , slightly
better way of doing things in perl.

Ram



Script runs once

2003-09-29 Thread rmck
Hello,

I have a perl script that is to stop and start at midnight, and write to a new log 
file. 

The problem is it runs once then does not run again?? 

Below is the script that I am tring to use?? 


bash-2.03#
#!/bin/perl -w
use warnings;
use strict;
 
my ( $sec, $min, $hour, $day, $mon, $year ) = localtime;
my $snoop   = '/usr/sbin/snoop -d ge0 -ta';
my $date = `date +%W`;
chop($date);
my $dir = "/var/weeks/03_week_$date";

my $logfile = sprintf '/var/weeks/03_week_%d/%02d%02d%02d%02d%02d.sno',
`date +%W`, $year % 100, $mon + 1, $day, $hour, $min;
 
# create 03_week_dir if does not exist
unless(-d $dir){
mkdir $dir,0660;
} 
 
open LOG, '>', $logfile or die "Cannot open $logfile: $!";
# set default output filehandle and autoflush
select LOG;
$| = 1;
 
print '===' . localtime . " ==\n\n";
 
open SNOOP, "$snoop |" or die "Cannot open pipe from $snoop: $!";
 
while (  ) {
print;
# restart this process if midnight
( $sec, $min, $hour ) = localtime;
exec $0 if $sec + $min + $hour == 0;
}
bash-2.03# 

Thanks,
RM

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



Generic database access?

2003-09-29 Thread Rob Richardson
Greetings!

Is there a Perl module --

"Don't be silly!", I hear you reply.  "There's a Perl module for
everything!"

OK, let me rephrase that.  I would like a program, probably but not
necessarily in Perl, that can run on a Perl-equipped Unix server that
will give me remote access through the Internet to a database system in
a way similar to how Microsoft Access provides a GUI for creating and
editing databases.  What would you recommend?

Thanks!

Rob

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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



Hylafax - Windows Client

2003-09-29 Thread Paul Kraus
For a project / learning exp. I am trying to create a windows client
that will let me interact with a Hylafax server. I don't know enough
about the special ftp protocol it uses so I am try to just parse the log
files to get similar functionality using tk.

Now how can attach to a share using login credentials without mapping a
drive.

For instance...

//hylafax/hylafax/logs

But I need it to connect as a specific user/password.


Or alternately if you have some info on the ftp protocol that Hylafax
uses that would be great to. I did see a couple cpan modules but none of
them had any docs what so ever.

Paul


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



Get email adress from AD or exchange?

2003-09-29 Thread Samuelsson, David
Has anyone done this in Perl, is there an module that can help me? I am
aware of that I can use the Win32::Ole, but what I really want is an
more easier way of asking: 

For $user
Return mailadress

This can be done in VB quite easy, but I want to try and stay "perlish"
here. Any one have an clue?

//Dave




Re: How to pass parameters to a module

2003-09-29 Thread Juris
Hi!

It's easy!
There is one sample:
sub do_somethig {
my @[EMAIL PROTECTED];
if (! ($passed_params[0]))  { print "Not passed parametrs" }
my @lines;
#Do something ...
return @lines;
}
On Thu, 25 Sep 2003 21:59:53 -0700, Rajesh Dorairajan 
<[EMAIL PROTECTED]> wrote:

Can someone explain how does one pass a parameter to a Perl Module? To
illustrate suppose I've My::Module
package My::Module;

BEGIN
{
  $scalar = $input;
}
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT = ($scalar);
In the above script is there anyway to pass the $input variable to the
package My::Module from the calling script? Please excuse me if the code 
is
horrible, just trying to simplify what I want ;)

TIA

Rajesh


--
With best regards,
Juris
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

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


Objects, threads and so on

2003-09-29 Thread lists_perl_org
Hi all,

I'm quite new to Perl so please bear with me :)

I've experience in Delphi so I thought I knew about objects... it
seems I don't :(

I want to have a class I won't instanciate (static members and
variables), with global vars so I can access them and change them from
withing threads/forks. 

-- FILE test.pl

use FOO;

FOO->make();
FOO->make();

use Thread;

my $t = new Thread \&th1;
my $u = new Thread \&th2;

sub th1() { while (1) { FOO->make(); sleep(1); } }
sub th2() { while (1) { print "\t"; FOO->make(); sleep(2); } }

while (1) {}

-- FILE FOO.pm

package FOO;

%FOO::e = {};

sub make {
  my $self = shift;
  %FOO::e->{'something'} = %FOO:e->{'something'} + 1;
  print %FOO::e->{'something'}."\n";
}

-- RESULTS --

1
2
3
   3
4
5
   4
6
7
   5
8
...

Obviously it doesn't work.

I have tried a lot more of things and I don't know how to make it
work. The same applies if I use fork() instead threads.

Is there any way to make this work?

Thank you very much in advance!

Fernando Najera

 


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



Re: Perl - HowTo operating with large file?

2003-09-29 Thread Juris
Hi!

Thanks, your solution is one way how solve this problem! I found other ...

sub remove_ary_dupes{
my @[EMAIL PROTECTED];
#Define hash
undef %saw;
@[EMAIL PROTECTED] = ();
#Hash owerwrite automaticly duplicated values! ;)
my @out = sort keys %saw;  # remove sort if undesired
return @out;
}
sub grep_log_file{
my @[EMAIL PROTECTED];
#if (undef $sparam[0]) {print "No records found with @ARGV\n"; exit 0}
my ($first, $match);
my $block_size=20480;
my ($tmp_block, $pos_corect,@ary_match, @res_ary);
open(F, "$LOG_FILE") or die "Error opening $LOG_FILE: $!";

#Read LOG file block by block
while (read(F,$first,$block_size)) {
$end_pos=rindex($first,"\n");
# $first=~/(.*)\n(.*)$/; #Not used, because so slowly for long lines!
# Compare read line length with default block size!
# If not equal, its last block in cycle
   if (length($first) ne $block_size) {
$match=$first; $match = $tmp_block . $first;
$tmp_block=""; $pos_corect=0;
} else {
$match=substr($first,0, $end_pos); $match=$tmp_block . 
$match ;
$pos_corect=$block_size-$end_pos;  
$tmp_block=substr($first,$end_pos,$block_size-$end_pos);
}
 my @log_lines=split("\n",$match);
 ##Grep all lines
 @log_lines=remove_ary_dupes(@log_lines); #Remove duplicated log 
lines!
 foreach my $j (@sparam) {
 push @ary_match, (grep /$j/, @log_lines);
 }
 #push @res_ary, @ary_match;
}
close (F);
return @ary_match;
}

Try this code, if have similar problem!

On Fri, 26 Sep 2003 20:13:21 +0530, Ramprasad A Padmanabhan 
<[EMAIL PROTECTED]> wrote:

Juris wrote:
I have one small problem!
HowTo read from large text file text in binary mode?
if i want read all file, i use this code:

my (@LOG_FILE);
open (FL, "/var/log/maillog");
@LOG_FILE=;
close (FL);
#After this code execution file contents stored in array @LOG_FILE
@LOG_FILE=grep /$something/, @LOG_FILE
I not want read all file string by struing - it's so slowly, if file is 
large and contains more than 100 records!
I need read each 50 bytes, but how?
Please, help!




When you are opening big files never do
@array = 
This essentially reads the entire file into an array and is very 
expensive on memory.

you could do something like
while(){
push @arr , $_ if(/$something/);
}
But IMHO this still that may not be the best way.

What I would do is

system("grep $something $filename > $tempfile");
# *Nothing* beats gnu grep when you parse large file
open(FILE,$tempfile);
# Now if you really want the lines in an array
@lines = 
Ram
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: To quotes or not quotes parameter

2003-09-29 Thread Thomas Bätzler
[EMAIL PROTECTED] <[EMAIL PROTECTED]> asked:
> what is the proper way to pass a parameter for something like
> $cgi-param(username)?
> 
> as far as i know it, this works for me:
> 
> $cgi-param(username);

Don't do that. Using barewords as strings can
break your code if you later on introduce a
sub with the same name in your code. Besides,
this obviously doesn't work for Perl reserved
words anyways.

Instead, use either:

> $cgi->param("username");
> $cgi->param('username');

HTH,
Thomas

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



Re: substr parsing mask

2003-09-29 Thread perl
I got it to work after adding a new var in apache modperl environment.

This works:
 $acct_no = $xgi->param("acct_no");
 print substr($acct_no, 0, 4, "x" x (length($acct_no)-4));

This did NOT work:
 print substr($xgi->param("acct_no"), length($xgi->param("acct_no"))-4,4);

Any explanation would be great.
-rkl

I tried to save a line by using
> On Sep 27, [EMAIL PROTECTED] said:
>
>>>   substr($string, 0, -4, "x" x (length($string) - 4));
>>
>>I couldn't get this to work correctly. it only returns the 4 characters
>> of
>>the string whcih is correct. But it did not replace the preceding
>>characters with .
>
> It works for me:
>
>   [EMAIL PROTECTED] [11:47am] ~ #103> perl -l
>   $string = join '',  .. 9;
>   substr($string, 0, -4, "x" x (length($string) - 4));
>   print $string;
>   __END__
>   xx6789
>
> --
> Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
> RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
>  what does y/// stand for?   why, yansliterate of course.
> [  I'm looking for programming work.  If you like my work, let me know.  ]
>
>


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



To quotes or not quotes parameter

2003-09-29 Thread perl
what is the proper way to pass a parameter for something like
$cgi-param(username)?

as far as i know it, this works for me:

$cgi-param(username);
$cgi->param("username");
$cgi->param('username');

thanks,
-rkl

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



Re: Passing a variable to a package function vs. a local function

2003-09-29 Thread Ramprasad A Padmanabhan
Dan Fish wrote:
I'm a bit new to this so please bear with me...

I've written a script that uses CGI.pm something like this:

use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:all);
$query = new CGI;

blah...blah...
&myfunc($query);
blah...blah...
sub myfunc{ my ($query) = @_;
$foo=$query->param("foo");
 ...more...blah...blah...
}
Everything works fine as is, but I'm trying to take the function "myfunc"
out and put it in a separate .pm file because I need to call it from several
cgi scripts.  When I put it in the .pm file, I get something like:   

Can't locate object method "param" via package "Trend" at
/usr/local/lib/perl5/site_perl/5.005/MMC/Dex.pm line 253,  chunk
1150.
I do have:
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:all);
In the .pm file
What am I missing?

Thanks,
-Dan
If you have name the package file as say Mypackage.pm
then in your mail program you will call the function as
Mypackage::myfunc($query).
Ram



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


RE: problem with Net::SSH::Perl using dsa key authentication

2003-09-29 Thread Haim Ashkenazi
Tn wrote:

> Hi,
> 
> As far as I can tell you are doing it right according to the manpages.
> However, I noticed that in
> http://www.squarebox.co.uk/cgi-squarebox/manServer/usr/share/man/man3/Ne
> t::SSH::Perl.3pm that $ssh->login() requires a password that you aren't
> supplying:
> 
> $ssh->login("user1", "pass1");
> 
> I believe this refers to the linux password.  Perhaps if the password is
> not supplied for an interactive login then you will be prompted for it.
> But you could disable linux password authentication as an ssh option at
> least as a possible workaround:
> 
> PasswordAuthentication=no # to be added to my %params
> 
> As I recall the default config of sshd/ssh forces password
> authentication on top of publickey authentication as an extra security
> measure.  You might take a look at your sshd and ssh config files to see
> how they are set and a combination of tweaking them and the options in
> your script may fix the problem.
> 
> The sshd/ssh setup that I prefer requires no password authentication if
> publickey authentication works, however it will use password
> authentication if publickey authentication does not work and I cut keys
> with a null passphrase for easier automation of script execution and
> interactive logins.
> 
> The error message seems to refer to a ssh_agent setup.  Ssh_agent is a
> special daemon that caches private keys and their passphrases so that
> you don't have to keep supplying the latter on the command line to start
> new sessions.  I've never bothered setting it up but using it should be
> more secure than using keys with null passphrases.
> 
> For reference:
> 
> Instructions for ssh_agent configuration are at
> http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/s1-op
> enssh-client-config.html#S3-OPENSSH-CONFIG-SSH-AGENT.
> 
> Manpages for openssh are at http://www.openssh.org/manual.html
> 
> Manpages for perl ssh modules are at
> http://www.squarebox.co.uk/cgi-squarebox/manServer/usr/share/man/man3/
> 
> I don't have a setup now for testing ssh or I would.
> 
> Please let me know what works when you find it.
> 
> -tristram
> [EMAIL PROTECTED]
Hi

I'm using ssh with only key authentication in most of my linux servers. the
problem is not in the configuration (i think). I guess it's a matter of
running ssh-agent from the perl interface (since I've entered the
Net::SSH::Perl::Auth it ignores the one that's already running as the
parent of my X session).

thanx
--
Haim

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



Re: problem with Net::SSH::Perl using dsa key authentication

2003-09-29 Thread Haim Ashkenazi
Wiggins D'Anconia wrote:
>> my %params = {
>> protocol => 2,
>> interactive => 1,
>> identity_files =>[EMAIL PROTECTED],
>> };
> 
> Right here  you are assigning a hash reference to a hash, which is
> essentially setting a key using the reference location with a value as
> undef. Then you pass the hash to the new constructor and it sees a
> single value which is why you are getting there warning/error about
> "Reference found where even sized list expected"...  Switch the braces
> in the above construct to parenthesis and it should work, or switch the
> hash to a hash dereference below and the hash to a scalar above.
well, this one did solve the even-sized list error/warning but not the
"agent" method error. I think I must run some kind of ssh-agent before, but
I have no idea how to implement this. (I actually have it running as the
parent of my X, but since I've added the Net::SSH::Perl::Auth, it just
ignores it. before I've added it, it accepted the linux ssh-agent as the
authentication and didn't prompt me for a password).

thanx
--
Haim

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



Perl Beginners Portals

2003-09-29 Thread Shlomi Fish

Hi all!

I believe learn.perl.org is very lacking:

1. Its design is ugly.

2. No links to many important online resources such as tutorials, books,
article collections, mailing lists, web forums, etc.

3. Concentration on commercial books.

4. No source code for the site is available and [EMAIL PROTECTED]
are not responsive.

5. Pretty much unmaintained for a long time.

Still, it has a pretty good Google popularity.

I did my best to resolve the problems inherent in it by setting up
http://perl-begin.berlios.de/. The site could still use some work, but
it's still better than learn.perl.org. Nevertheless, I would want to see
learn.perl.org becoming better.

When I started the perl-begin effort the beginners-workers decided I will
do a re-design of the learn.perl.org. After I was more or less finished, I
did not receive any reply when I tried to contact them. So I had no choice
but to set up my own site.

What are your opinions about the two sites? How can we make learn.perl.org
better?

Regards,

Shlomi Fish




--
Shlomi Fish[EMAIL PROTECTED]
Home Page: http://t2.technion.ac.il/~shlomif/

An apple a day will keep a doctor away. Two apples a day will keep two
doctors away.

Falk Fish

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



RE: problem with Net::SSH::Perl using dsa key authentication

2003-09-29 Thread Haim Ashkenazi
Tn wrote:

> Hi,
> 
> As far as I can tell you are doing it right according to the manpages.
> However, I noticed that in
> http://www.squarebox.co.uk/cgi-squarebox/manServer/usr/share/man/man3/Ne
> t::SSH::Perl.3pm that $ssh->login() requires a password that you aren't
> supplying:
> 
> $ssh->login("user1", "pass1");
> 
> I believe this refers to the linux password.  Perhaps if the password is
> not supplied for an interactive login then you will be prompted for it.
> But you could disable linux password authentication as an ssh option at
> least as a possible workaround:
> 
> PasswordAuthentication=no # to be added to my %params
> 
> As I recall the default config of sshd/ssh forces password
> authentication on top of publickey authentication as an extra security
> measure.  You might take a look at your sshd and ssh config files to see
> how they are set and a combination of tweaking them and the options in
> your script may fix the problem.
> 
> The sshd/ssh setup that I prefer requires no password authentication if
> publickey authentication works, however it will use password
> authentication if publickey authentication does not work and I cut keys
> with a null passphrase for easier automation of script execution and
> interactive logins.
> 
> The error message seems to refer to a ssh_agent setup.  Ssh_agent is a
> special daemon that caches private keys and their passphrases so that
> you don't have to keep supplying the latter on the command line to start
> new sessions.  I've never bothered setting it up but using it should be
> more secure than using keys with null passphrases.
> 
> For reference:
> 
> Instructions for ssh_agent configuration are at
> http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/s1-op
> enssh-client-config.html#S3-OPENSSH-CONFIG-SSH-AGENT.
> 
> Manpages for openssh are at http://www.openssh.org/manual.html
> 
> Manpages for perl ssh modules are at
> http://www.squarebox.co.uk/cgi-squarebox/manServer/usr/share/man/man3/
> 
> I don't have a setup now for testing ssh or I would.
> 
> Please let me know what works when you find it.
> 
> -tristram
> [EMAIL PROTECTED]
Hi

I'm using ssh with only key authentication in most of my linux servers. the
problem is not in the configuration (i think). I guess it's a matter of
running ssh-agent from the perl interface (since I've entered the
Net::SSH::Perl::Auth it ignores the one that's already running as the
parent of my X session).

thanx
--
Haim

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



Re: problem with Net::SSH::Perl using dsa key authentication

2003-09-29 Thread Haim Ashkenazi
Wiggins D'Anconia wrote:
>> my %params = {
>> protocol => 2,
>> interactive => 1,
>> identity_files => [EMAIL PROTECTED],
>> };
> 
> Right here  you are assigning a hash reference to a hash, which is
> essentially setting a key using the reference location with a value as
> undef. Then you pass the hash to the new constructor and it sees a
> single value which is why you are getting there warning/error about
> "Reference found where even sized list expected"...  Switch the braces
> in the above construct to parenthesis and it should work, or switch the
> hash to a hash dereference below and the hash to a scalar above.
well, this one did solve the even-sized list error/warning but not the
"agent" method error. I think I must run some kind of ssh-agent before, but
I have no idea how to implement this. (I actually have it running as the
parent of my X, but since I've added the Net::SSH::Perl::Auth, it just
ignores it. before I've added it, it accepted the linux ssh-agent as the
authentication and didn't prompt me for a password).

thanx
--
Haim

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