Re: accessing ACCESS database

2002-11-13 Thread Douglas Gardiner

- Original Message -
From: "Beau E. Cox" <[EMAIL PROTECTED]>
To: "Angel Iliev Kafazov" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, November 13, 2002 6:55 PM
Subject: RE: accessing ACCESS database


> Hi -
>
> I have never heard of the "Sql" method in DBI. Something like this works:
>
That's because he's using a different module and not the DBI module.  It's
Win32:ODBC

>From what I remember, been a long time.  Unless you check that the object
was called correctedly at the beginning, you will get that error.  Few
things to check are:

make sure DSN is setup and the name is the same.
make sure you have the module installed
the ever so popular constant error checking to make sure not only that it
connects but also a graceful exit upon error or some kind of error trapping
in case the SQL statements or anything else fail.

Alos with this setup the datbase must be on that machine otherwise you need
to use the proxy module for connection.  Either way, the initial call must
be checked when using Win32:ODBC to make sure it connects.  It doesn't
complain until you make another call otherwise.

something like:

$db = new Win32::ODBC("db1") || die "cannot open database";

at least you will know if it connects.  There are other methods to use, but
I do not remember since I personally use DBI so much.

> use strict;
> use warnings;
> use DBI;
>
>  my $dbh = DBI->connect("DBI:ODBC:cpan")
>|| die "could not connect to ODBC:MyDatabase:\n$DBI::errstr\n";
>
>  my $stmt = "select * from modules;";
>
>   my $sth = $dbh->prepare($stmt);
>  $sth ||
>die "could not prepare ($stmt):\n$DBI::errstr\n";
>
>  my $rv = $sth->execute
>|| die "could not execute ($stmt):\n$DBI::errstr\n";
>
>  while (my $row_ref = $sth->fetchrow_arrayref) {
>print "$_\t" for (@ { $row_ref } );
>print "\n";
>}
>
>  $sth->finish;
>  $dbh->disconnect
>|| die "could not disconnect to ODBC:MyDatabase:\n$DBI::errstr\n";
>
> Check out DBI.html in your /perl_install_dir/html/site/lib (jf you are
> using ActivePerl).
>
> Aloha => Beau.
>
> -Original Message-
> From: Angel Iliev Kafazov [mailto:angel.kafazov@;mail.bg]
> Sent: Wednesday, November 13, 2002 1:04 PM
> To: '[EMAIL PROTECTED]'
> Subject: accessing ACCESS database
>
>
> Hi,
>
> I am trying to write a script that copies an information from ACCESS but
> it gives me the following error:
>
> Can't call method "Sql" on an undefined value at franowner.pl.txt line 4.
>
> Here's the script:
>
>
> use Win32::ODBC;
> $DSN="db1";
> $db = new Win32::ODBC("db1");
> $db->Sql("SELECT owner_first_name, owner_last_name FROM Owners WHERE
> ID=11");
> if ($db->Error()) {
> print "Error: $db->Error";
> }
> statement:\n$DBI:errstr\n";
> ($ownerfname,$ownerlname) = $db->FetchRow();
> print "Database results: first name $ownerfname and last name
> $ownerlname\n";
> $db->finish;
> $db->disconnect || die "Cannot disconnect from database";
>
> Please, help me with this problem.
> 
> Êàêâî å ðåêëàìà â Èíòåðíåò? - http://reklama.mail.bg
>
>
> --
> 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]




Subject: RE: file editting

2002-11-13 Thread Alfred Vahau
The equivalent one-liner for Aman's suggestion is:

perl -p -i -e's/(?:!|SUB-TOTAL)//' yourfile.txt

The above will seek out ! or SUB-TOTAL, replace them and write the
results to the current file i.e overwirte the file.

If you want to back up the current file, use the one-liner as follows:

perl -p -i '.bak' -e 's/(?:!|SUB-TOTAL)//' yourfile.txt.

The back up will be to the file yourfile.txt.bak.

You will sometimes see the -p -i switches shown as -pi which has the
same effect.

I use these oneliners a lot to make quick changes on the fly.

Alfred Vahau
IT Services
Uni. PNG

---

Hi Thomas

File editing is particularly easy in perl.
Herez some sample code to get you started :



--

@ARGV='C:\Documents and Settings\athind\Desktop\test\File2Edit.txt'; #
path
to the file you want to edit

$^I=".bak";  # this will be appended to the original
filename
and will act as BackUp.

while (<>)
{
s/!//;   # will replace ! with nothing i.e. all
instances of
! will be removed.
s/SUB-TOTAL://;  # same as above for SUB-TOTAL:
print;   # writes the new file line by line

}





Try this on the file you want to edit.
Anything else you want to edit\replace can be done by the
s/what2replace/bywhat2replace/;

-aman

-Original Message-
From: Thomas Browner [mailto:thomas.browner@;digidyne.com]
Sent: Wednesday, November 13, 2002 7:33 PM
To: [EMAIL PROTECTED]
Subject: file editting






I there away to edit a file in perl? This is what is I am trying to do.
I have a file that I want to remove some content. This is an example of
a line:



! 6134.21   3200  SUB-TOTAL: M:\alvin



I want to remove the ! and SUB-TOTAL. I hope some one can tell me an
simple way of doing this sine I am a new to perl.



Thank you,



Thomas








Re: query string into hash?

2002-11-13 Thread Ovid
--- Matt Simonsen <[EMAIL PROTECTED]> wrote:
> I need to get all the words in a query (q=___) out of a (URL, I think)
> encoded string. 
> 
> Example line and my current plan:
> 
> $queryString =
> 'pp=20&q=Finance/Banking/Insurance&qField=All&qMatch=any&qSort=smart&view=1'
> 
> my %querys = $queryString =~ /(\S+)=(\S+)&?/g ;
> 
> #Here I could use a tip on how to split counting the encoding
> @words = split ($querys{q}) ; 
> 
> I have to do this for millions of lines per month so any tips to help me
> optimize this would be appreciated.

There are a variety of ways to do this.  If you are receiving the query string from a 
Web form:

1.  If all names occur only once in the query string (e.g., no 'color=red&color=blue')

  use CGI qw(:standard);
  my %data;
  foreach my $name ( param() ) {
$data{$name} = param($name);
  }

2.  If you know the names might occur more than once in a query string and you are 
comfortable
with array references:


  use CGI qw(:standard);
  my %data;
  foreach my $name ( param() ) {
$data{$name} = [param($name)];
  }

3.  If some people prefer string not to use array references if you only have a single 
value and
use array references for multiple values:

  use CGI qw(:standard);
  my %data;
  foreach my $name ( param() ) {
my @values = param($name);
$data{$name} = 1 == @values
  ? param($name);
  : [param($name)];
  }

However, if you already have a query string in the program (read from a parsed HTML 
doc, for
example), the you switch to the OO form of CGI.pm.  Using the first example:

  use CGI;
  my $cgi = CGI->new( $query_string );
  my %data;
  foreach my $name ( $cgi->param() ) {
$data{$name} = $cgi->param($name);
  }

You should be able to extend that to the other examples.

If you use the last example, don't use that with a Web submission because that implies 
that you
are grabbing $ENV{ QUERY_STRING } yourself.  Don't do that.  Let CGI.pm handle it for 
you because
if you ever need to change that in the future (using POST and reading from standard 
input), CGI.pm
will handle that transparently for you and you won't have to update your code.

Cheers,
Ovid

Cheers,
Ovid

=
"Ovid" on http://www.perlmonks.org/
Web Programming with Perl:  http://users.easystreet.com/ovid/cgi_course/
Silence Is Evil: http://users.easystreet.com/ovid/philosophy/decency.txt

__
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2

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




RE: query string into hash?

2002-11-13 Thread Toby Stuart
> I need to get all the words in a query (q=___) out of a (URL, I think)
> encoded string. 
> 
> Example line and my current plan:
> 
> $queryString =
> 'pp=20&q=Finance/Banking/Insurance&qField=All&qMatch=any&qSort
> =smart&view=1'
> 
> my %querys = $queryString =~ /(\S+)=(\S+)&?/g ;
> 
> #Here I could use a tip on how to split counting the encoding
> @words = split ($querys{q}) ; 
> 
> I have to do this for millions of lines per month so any tips 
> to help me
> optimize this would be appreciated.

Maybe CGI.pm would help with this?
Anyhoo, if what you are trying to do is get the query string item/value
pairs into a hash, then the following works:


use strict;
use warnings;

my $queryString
='pp=20&q=Finance/Banking/Insurance&qField=All&qMatch=any&qSort=smart&view=1
';

# Split the query string on ampersand
my @pairs = split(/&/,$queryString);

my %queries;
my $item;
my $value;

# Store the item/value pairs in a hash
foreach (@pairs)
{
my ($item,$value) = split(/=/,$_);
$queries{$item} = $value;
}

# Uncomment this block to print the hash
#while (($item,$value) = each %queries)
#{
#   print "$item=$value\n";
#}


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




Re: query string into hash?

2002-11-13 Thread Wiggins d'Anconia
perldoc CGI

Or look at the code for that module...

http://danconia.org

Matt Simonsen wrote:

I need to get all the words in a query (q=___) out of a (URL, I think)
encoded string. 

Example line and my current plan:

$queryString =
'pp=20&q=Finance/Banking/Insurance&qField=All&qMatch=any&qSort=smart&view=1'

my %querys = $queryString =~ /(\S+)=(\S+)&?/g ;

#Here I could use a tip on how to split counting the encoding
@words = split ($querys{q}) ; 

I have to do this for millions of lines per month so any tips to help me
optimize this would be appreciated.

Thanks
Matt






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




query string into hash?

2002-11-13 Thread Matt Simonsen
I need to get all the words in a query (q=___) out of a (URL, I think)
encoded string. 

Example line and my current plan:

$queryString =
'pp=20&q=Finance/Banking/Insurance&qField=All&qMatch=any&qSort=smart&view=1'

my %querys = $queryString =~ /(\S+)=(\S+)&?/g ;

#Here I could use a tip on how to split counting the encoding
@words = split ($querys{q}) ; 

I have to do this for millions of lines per month so any tips to help me
optimize this would be appreciated.

Thanks
Matt




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




RE: accessing ACCESS database

2002-11-13 Thread Toby Stuart
> Hi,
> 
> I am trying to write a script that copies an information from 
> ACCESS but
> it gives me the following error:
> 
> Can't call method "Sql" on an undefined value at 
> franowner.pl.txt line 4.
> 
> Here's the script:
> 
> 
> use Win32::ODBC;
> $DSN="db1";
> $db = new Win32::ODBC("db1");

you should check if $db is defined, otherwise there has been an error

die "Error: " . Win32::OLE->LastError if  !$db;


> $db->Sql("SELECT owner_first_name, owner_last_name FROM Owners WHERE
> ID=11");
> if ($db->Error()) {
> print "Error: $db->Error";
> }
> statement:\n$DBI:errstr\n";
> ($ownerfname,$ownerlname) = $db->FetchRow();
> print "Database results: first name $ownerfname and last name
> $ownerlname\n";
> $db->finish;
> $db->disconnect || die "Cannot disconnect from database";
> 
> Please, help me with this problem.
> 
> Êàêâî å ðåêëàìà â Èíòåðíåò? - http://reklama.mail.bg
> 
> 
> --
> 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: accessing ACCESS database

2002-11-13 Thread Beau E. Cox
Hi -

I have never heard of the "Sql" method in DBI. Something like this works:

use strict;
use warnings;
use DBI;

 my $dbh = DBI->connect("DBI:ODBC:cpan")
   || die "could not connect to ODBC:MyDatabase:\n$DBI::errstr\n";

 my $stmt = "select * from modules;";

  my $sth = $dbh->prepare($stmt);
 $sth ||
   die "could not prepare ($stmt):\n$DBI::errstr\n";

 my $rv = $sth->execute
   || die "could not execute ($stmt):\n$DBI::errstr\n";

 while (my $row_ref = $sth->fetchrow_arrayref) {
   print "$_\t" for (@ { $row_ref } );
   print "\n";
   }

 $sth->finish;
 $dbh->disconnect
   || die "could not disconnect to ODBC:MyDatabase:\n$DBI::errstr\n";

Check out DBI.html in your /perl_install_dir/html/site/lib (jf you are
using ActivePerl).

Aloha => Beau.

-Original Message-
From: Angel Iliev Kafazov [mailto:angel.kafazov@;mail.bg]
Sent: Wednesday, November 13, 2002 1:04 PM
To: '[EMAIL PROTECTED]'
Subject: accessing ACCESS database


Hi,

I am trying to write a script that copies an information from ACCESS but
it gives me the following error:

Can't call method "Sql" on an undefined value at franowner.pl.txt line 4.

Here's the script:


use Win32::ODBC;
$DSN="db1";
$db = new Win32::ODBC("db1");
$db->Sql("SELECT owner_first_name, owner_last_name FROM Owners WHERE
ID=11");
if ($db->Error()) {
print "Error: $db->Error";
}
statement:\n$DBI:errstr\n";
($ownerfname,$ownerlname) = $db->FetchRow();
print "Database results: first name $ownerfname and last name
$ownerlname\n";
$db->finish;
$db->disconnect || die "Cannot disconnect from database";

Please, help me with this problem.

Êàêâî å ðåêëàìà â Èíòåðíåò? - http://reklama.mail.bg


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




Sending Mail

2002-11-13 Thread Jessee Parker
I've tried a few different methods of trying to send out e-mails for the
company I work for but I've run into a number of obstacles. Each way I've
tried, I've noticed that the script hits these periods of inactivity which I
don't exactly know is the cause. I've used 3 different modules and I even
wrote to Sendmail itself yet I still hit these time snags.

The company I work for does opt-in e-mailing. I've tried using the
Bulkmail module but the clients did not like seeing the "from" or "to"
(can't remember which) as coming from a list. They wanted things more
personalized. Next I tried sending mail by opening a pipe into Sendmail
itself (with the queue only and no DNS lookup flags set) and it still bogged
down -- meaning it took longer than our current way of sending (we currently
use an ActiveX component on a Windows machine and relay to our mailservers).
I've also tried the Sender and SMTP modules with mixed results. With the
Sender module I hit a 10k mark one hour then the next it dropped all the way
down to 2-3k.

The basic concept of my script is to open a database that contains the
info and read in each e-mail to process at a time. Next it customizes the
e-mail and finally sends it out using the Sender module. When the call to
the Sender module finishes, it removes the entry from the database and
continues.

So after this long beginning, can anyone tell me if it is possible to
send out somewhere around 15k email messages in an hours time? I know there
are certain limitations placed on the ability to send such as connection,
operating system and hardware. We are currently running Redhat 7.3, with a
T1 connection (exact throughput I don't know off the top of my head) and I'm
using Perl 5.8.0. Any help would be appreciated since I seem to be getting
nowhere fast.

Jessee



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




accessing ACCESS database

2002-11-13 Thread Angel Iliev Kafazov
Hi,

I am trying to write a script that copies an information from ACCESS but 
it gives me the following error:

Can't call method "Sql" on an undefined value at franowner.pl.txt line 4.

Here's the script:


use Win32::ODBC;
$DSN="db1";
$db = new Win32::ODBC("db1");
$db->Sql("SELECT owner_first_name, owner_last_name FROM Owners WHERE 
ID=11");
if ($db->Error()) {
print "Error: $db->Error";
}
statement:\n$DBI:errstr\n";
($ownerfname,$ownerlname) = $db->FetchRow();
print "Database results: first name $ownerfname and last name 
$ownerlname\n";
$db->finish;
$db->disconnect || die "Cannot disconnect from database";

Please, help me with this problem.

Êàêâî å ðåêëàìà â Èíòåðíåò? - http://reklama.mail.bg


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




Re: code ref and objects

2002-11-13 Thread Jason Tiller
Hi, Todd (and Wiggins!), :)

On Wed, 13 Nov 2002, todd shifflett wrote:

> I am trying to use a code reference from within a function to
> recursively call a given separate function...

> #--- LIKE THIS --vv
> sub hello {
>   my $name = shift;
>   return "Hello, $name!\n";
> }
>
>   sub foo {
>   my($f, @args) = @_;
>   return &$f(@args);
> }
>
> print foo(\&hello, "world");
> #---^^

> the above works.  Now I would like to be able to pass in a
> subroutine from a declared object.

> # This does not work --vv
> use Math::FFT;
>
> my @nums = qw(3 4 5 7 10 8 7 9);
> my $fft = new Math::FFT(\@nums);
>
> # this is fine
> my $stdev = $fft->stdev(\@nums);
>
> # this is not...  ERROR:  Undefined subroutine &main::fft->stdev called
> at ...
> print foo(\&{'fft->stdev'},\@nums);
> #---^^

> So how do I pass in the subroutine for a given object into my
> function to be called later?

>From _The Perl Cookbook_, Recipe 11.8:

"When you ask for a reference to a method, you're asking for more than
just a raw function pointer.  You also need to record which object the
method needs to be called upon as the object contains the data the
method will work with.  The best way to do this is using a closure.
Assuming $obj is lexically scoped, you can say:

$mref = sub { $obj->method( @_ ) };
# [and then] later...
$mref->( "args", "go", "here" );
"

Make sense?  Using this strategy, I rewrote your little test to look
like:

#!/usr/bin/perl

use strict;
use warnings;

use Math::FFT;

my @nums = qw(3 4 5 7 10 8 7 9);
my $fft = new Math::FFT( \@nums );

my $stdev = sub { $fft->stdev( @_ ) };

print foo($stdev, \@nums);

sub hello {
   my $name = shift;
   return "Hello, $name!\n";
}

sub foo {
   my $f = shift;
   return $f->( @_ );
}

(Notice the rewrite of the actual method call in 'foo' - the "&$f"
syntax is deprecated, I believe.)

After running this, I got:

2.44584195260913

which I assume is correct. ;)

Hope that helps!  The Cookbook is a great book...

---Jason


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




Re: code ref and objects

2002-11-13 Thread Wiggins d'Anconia
This is a guess but I think you can't 'my' the fft variable and then use 
it as a reference.  Because it is looking for main:: which your my'd 
variable will not be in that namespace, or any namespace for that 
matter.  If you are working under use strict trying our'ing it instead, 
or just removing the my without use strict.  this is just a guess.. 
I defer to the other gurus

http://danconia.org

todd shifflett wrote:


I am trying to use a code reference from within a function to 
recursively call a given separate function...

#--- LIKE THIS --vv
sub hello {
my $name = shift;
return "Hello, $name!\n";
}

 sub foo {
my($f, @args) = @_;
return &$f(@args);
}

print foo(\&hello, "world");
#---^^

the above works.  Now I would like to be able to pass in a subroutine 
from a declared object.

# This does not work --vv
use Math::FFT;

my @nums = qw(3 4 5 7 10 8 7 9);
my $fft = new Math::FFT(\@nums);

# this is fine
my $stdev = $fft->stdev(\@nums);

# this is not...  ERROR:  Undefined subroutine &main::fft->stdev called 
at ...
print foo(\&{'fft->stdev'},\@nums);
#---^^

So how do I pass in the subroutine for a given object into my function 
to be called later?

-todd




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




RE: uptime

2002-11-13 Thread Timothy Johnson

Here's one way:

$delta = 264200;
$daysPassed = int($delta / 86400);
$deltaDays = $delta % 86400;
$hoursPassed = int($deltaDays / 3600);
$deltaHours = $deltaDays % 3600;
$minsPassed = int($deltaHours / 60);
$deltaMins = $deltaHours % 60;
$secsPassed = $delta;
$deltaSecs = $deltaMins % 60;

print "$daysPassed Days, $hoursPassed Hours, $minsPassed Minutes, and
$secsPassed Seconds have passed.";

That will work up to weeks.  If you need to calculate months you will have
to look into Date::Manip or Date::Calc.


-Original Message-
From: dan [mailto:perl@;danneh.demon.co.uk]
Sent: Wednesday, November 13, 2002 12:41 PM
To: [EMAIL PROTECTED]
Subject: uptime


how may it be possible to say how long it was before a certain time?
say for instance i have the variable
$starttime = time();
then, later an uptime was called. the time of the uptime being
$timenow = time();
$runningtime = $runningtime - $timenow;
now i have the amount of time the program has been running in seconds, but
how do i convert that to days, hours, mins, secs, etc..?

dan



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

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




Re: md5 encryption.

2002-11-13 Thread dan
look up Crypt::PasswdMD5 on CPAN. I use the same module, no problems.

dan
"Christopher Burger" <[EMAIL PROTECTED]> wrote in message
news:!~!UENERkVCMDkAAQACABgAQQZ01V1XZUy+ZLRflK79TcKA
[EMAIL PROTECTED]
Just a quick question.  How can encrypt something with md5 encryption.
I have passwords in a mysql database that are md5 encrypted.  I was
wondering if I can use something like

$password = md5($input{'password'};

to get the input encrypted and then check against the sql field for
proper login.

Appreciate any help, thanks.

Chris Burger



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




uptime

2002-11-13 Thread dan
how may it be possible to say how long it was before a certain time?
say for instance i have the variable
$starttime = time();
then, later an uptime was called. the time of the uptime being
$timenow = time();
$runningtime = $runningtime - $timenow;
now i have the amount of time the program has been running in seconds, but
how do i convert that to days, hours, mins, secs, etc..?

dan



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




code ref and objects

2002-11-13 Thread todd shifflett


I am trying to use a code reference from within a function to 
recursively call a given separate function...

#--- LIKE THIS --vv
sub hello {
	my $name = shift;
	return "Hello, $name!\n";
}

 sub foo {
	my($f, @args) = @_;
	return &$f(@args);
}

print foo(\&hello, "world");
#---^^

the above works.  Now I would like to be able to pass in a subroutine 
from a declared object.

# This does not work --vv
use Math::FFT;

my @nums = qw(3 4 5 7 10 8 7 9);
my $fft = new Math::FFT(\@nums);

# this is fine
my $stdev = $fft->stdev(\@nums);

# this is not...  ERROR:  Undefined subroutine &main::fft->stdev called 
at ...
print foo(\&{'fft->stdev'},\@nums);
#---^^

So how do I pass in the subroutine for a given object into my function 
to be called later?

-todd


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



File::Find ?

2002-11-13 Thread Steve Main

Hello list,

I am trying to find a way in Perl to select all files in a directory
but the most current.

In shell I can do `find . -name *.arc | sort | tail -1` to get
the most current file and then exclude it from processing.

I was hoping someone could point out a way to do it entirely 
in Perl.

thanks

S

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




Re: md5 encryption.

2002-11-13 Thread Felix Geerinckx
on wo, 13 nov 2002 18:23:15 GMT, Christopher Burger wrote:

> Just a quick question.  How can encrypt something with md5 encryption.
> I have passwords in a mysql database that are md5 encrypted.  I was
> wondering if I can use something like 
> 
> $password = md5($input{'password'};
> 
> to get the input encrypted and then check against the sql field for
> proper login.

You could use the md5_hex function from Digest::MD5, but there is another 
way without the need for this module.

Suppose you have the following table definition:

CREATE TABLE users (
username CHAR(10) NOT NULL PRIMARY KEY,
password CHAR(32) NOT NULL
);

You can then insert new users with

my $sth_add_user = $dbh->prepare( qq{
INSERT INTO users 
VALUES (?, md5(?))')
});
$sth_add_user->execute('Chris', 'Burger');

And you can check whether ($user, $pass) is a valid combination with

my $sql_check_password = qq{
SELECT 
username 
FROM user 
WHERE 
username = ?
AND md5(?) = password
};

my ($username) = $dbh->selectrow_array($sql_check_password, undef, 
   $user, $pass);
if (defined $username) {
   # OK
} else {
   # Not OK
}

-- 
felix

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




RE: fork?

2002-11-13 Thread Daryl J. Hoyt
I think what you want is 

#!/usr/bin/perl
use strict;
use warnings;

$SIG{CHLD} = sub {wait ()}; #wait to avoid zombies

my $pid = fork ();
die "cannot fork: $!" unless defined($pid);
if  ($pid == 0) {
 #do some perl stuff
   }
elsif($pid < 0) {
 #do some other perl stuff
   exit(0);
}
waitpid($pid,0);


Daryl J. Hoyt
Software Engineer
Geodesic Systems
312-832-2010
< http://www.geodesic.com>
< mailto:djh@;geodesic.com>




-Original Message-
From: chad kellerman [mailto:ckellerman@;alabanza.com]
Sent: Wednesday, November 13, 2002 2:32 PM
To: [EMAIL PROTECTED]
Subject: fork?


Hey guys,

 I maybe misunderstanding what a fork can do, so I thought I would
write in to verify.  Because it doesn't appear to be doing what I want
(think it should).

I have a script that tars (unix) directories.  I want the script to tar
directories [a-n] as it is tarrring up [a-n] I want it to tar [o-z].  At
the same time.  So that two tars would be running st the same time.

   what I did was

#!/usr/bin/perl
use strict;
use warnings;

$SIG{CHLD} = sub {wait ()}; #wait to avoid zombies

my $pid = fork ();
die "cannot fork: $!" unless defined($pid);
if  ($pid == 0) {
 #do some perl stuff
   }
   exit(0);
}
waitpid($pid,0);

#do some other perl stuff while above is running.


  I want the perl script to "multi task".  

Am I missing something??

thanks,
Chad





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




RE: md5 encryption.

2002-11-13 Thread Timothy Johnson

perldoc Digest::MD5

This is the module you want to use.

-Original Message-
From: Christopher Burger [mailto:chris@;burgerfamily.net]
Sent: Wednesday, November 13, 2002 10:23 AM
To: [EMAIL PROTECTED]
Subject: md5 encryption.


Just a quick question.  How can encrypt something with md5 encryption.
I have passwords in a mysql database that are md5 encrypted.  I was
wondering if I can use something like 

$password = md5($input{'password'};

to get the input encrypted and then check against the sql field for
proper login.

Appreciate any help, thanks.

Chris Burger



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




fork?

2002-11-13 Thread chad kellerman
Hey guys,

 I maybe misunderstanding what a fork can do, so I thought I would
write in to verify.  Because it doesn't appear to be doing what I want
(think it should).

I have a script that tars (unix) directories.  I want the script to tar
directories [a-n] as it is tarrring up [a-n] I want it to tar [o-z].  At
the same time.  So that two tars would be running st the same time.

   what I did was

#!/usr/bin/perl
use strict;
use warnings;

$SIG{CHLD} = sub {wait ()}; #wait to avoid zombies

my $pid = fork ();
die "cannot fork: $!" unless defined($pid);
if  ($pid == 0) {
 #do some perl stuff
   }
   exit(0);
}
waitpid($pid,0);

#do some other perl stuff while above is running.


  I want the perl script to "multi task".  

Am I missing something??

thanks,
Chad






signature.asc
Description: This is a digitally signed message part


RE: [OT]: URGENT virus warning - Virus from msg: [Fireworks] OT: (Kind of) Font used in MX panels?

2002-11-13 Thread Perl
My antivirus (NA2002) found a bugbear virus sent to this beginners list (or
my perllist email address - I'm not sure what to make of the headers).

Did anyone else get this email? (virus has been removed of course):

If it helps anyone, I've included the culprit email and the headers:

===

-Original Message-
From: Les Hall [mailto:les@;yahoogroups.com]
Sent: Tuesday, November 12, 2002 2:12 AM
Subject: [Fireworks] OT: (Kind of) Font used in MX panels


Does anyone know what the teeny-weeny font is that Macromedia uses in
the panels for MX - I'm thinking in particular of the font used for the
Dreamweaver Answers panelet.

It's a non-aliased font about 8pt.

Thanks, Les

__

http://www.leshall.com
W 3 / f 6 4 / 1 / 2 5 0 t h



Yahoo! Groups Sponsor
ADVERTISEMENT


To unsubscribe, send a blank email to [EMAIL PROTECTED]

Direct link to the Fireworks site:
http://www.yahoogroups.com/group/Fireworks

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
===

If you want to see what the headers say:
=== Headers ===
Received: from mail023.syd.optusnet.com.au [210.49.20.162] by
codyartsupply.com with ESMTP
  (SMTPD32-6.06) id A6454F4011A; Tue, 12 Nov 2002 04:13:41 -0500
Received: from chopper (newax7-156.dialup.optusnet.com.au [198.142.199.156])
by mail023.syd.optusnet.com.au (8.11.1/8.11.1) with SMTP id gAC9Bsi30082;
Tue, 12 Nov 2002 20:11:54 +1100
Date: Tue, 12 Nov 2002 20:11:54 +1100
Message-Id: <[EMAIL PROTECTED]>
From: Les Hall <[EMAIL PROTECTED]>
Subject:  [Fireworks] OT: (Kind of) Font used in MX panels
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="--DJR53R02EA0JXRT"
X-RCPT-TO: <[EMAIL PROTECTED]>
X-UIDL: 18039
Status: U
===




-Original Message-
From: Felix Geerinckx [mailto:felix_geerinckx@;hotmail.com]
Sent: Tuesday, November 12, 2002 6:36 AM
To: [EMAIL PROTECTED]
Subject: [OT]: URGENT virus warning


Through private communication I've been informed that another list
member has received an email message from

'[EMAIL PROTECTED]'

with a subject line of

'Weekly postins statitistics - 37/2002'.

This email message contained the so-called 'W32.Bugbear@mm' virus.

I posted this message from '[EMAIL PROTECTED]' on September
16, through perl.beginners nntp-interface (and without a virus
attached).

After studying the virus information at



the following quote from this webpage:

   "The worm also can construct addresses for the "From:" field using
information that it harvests from the infected computer. For
example, the worm may find the addresses [EMAIL PROTECTED], [EMAIL PROTECTED] and
[EMAIL PROTECTED] The worm could create an email message addressed to
[EMAIL PROTECTED] and spoof the "From:" address, so that it appears to come
from [EMAIL PROTECTED] The spoofed address can also be a valid email
address that the worm finds on the system.

In addition to the following list of subjects, the worm can
create a new message as a reply to or forward of an existing
message on the infected system."


makes me conclude that the system of at least one of the list members
is infected by this virus.

I therefore advise all fellow list members who use Windows
(especially those who correspond with the 'sprocket.lockergnome.com'
domain) to go to the above-mentioned webpage and download and run the
removal tool.

Please stay alert. The infected computer probably contains other
email adresses from 'perl.beginners' list members, so everybody on
the list could receive the virus, and not necessarily with a subject
or (part of) an email address related to Perl!

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

2002-11-13 Thread Aman Thind
Hi Ray

$sec = (localtime())[0];
$min = (localtime())[1];
$hour = (localtime())[2];
print "Time => $hour : $min : $sec\n";

$day = (localtime())[3];
$month = (localtime())[4] + 1;
$year = (localtime())[5];
$year = $year + 1900;
print "Date => $month \\ $day \\ $year";

-aman.

-Original Message-
From: Olympio Raymond [mailto:rayoly@;free.fr]
Sent: Wednesday, November 13, 2002 10:36 PM
To: [EMAIL PROTECTED]
Subject: date


How can you write the date and our of the system with a perl command ?


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

2002-11-13 Thread [EMAIL PROTECTED]
my $loc_time = scalar(localtime);

Olympio Raymond wrote:


How can you write the date and our of the system with a perl command ?





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




date

2002-11-13 Thread Olympio Raymond
How can you write the date and our of the system with a perl command ?


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




RE: comparing arrays

2002-11-13 Thread wiggins
perldoc -f grep

Essentially you would need to open each file, read each line and grab the name somehow 
(regex, split, etc.). Then store the name to an array for the file (consider hash of 
arrays with key being the filename and the value the array of names for that file). 
Then store the name to a mega list of all names, making sure not to include duplicates 
(this is where grep comes in the first time). Then you step through your unique list 
and foreach your hash of arrays checking for the name in each one (grep again), if 
they all succeed then your name is in all the files.

I bet there is a better way using hashes and storing the names that way, but the above 
is definitely a quick and dirty way to one off it.

http://danconia.org


On 13 Nov 2002 16:27:09 +0100, Diego Riano <[EMAIL PROTECTED]> wrote:

> Hello folks
> 
> I want to ask for your help about the following thing:
> 
> I have several files, like this one:
> 
> Katrin12334   lsksol  094059
> Karen 29383   skdjsk  092831
> Paul  21928   lskdiw  029384
> 
> I want to compare all the files to know which names are in all of them.
> 
> could you give some hints?
> 
> Thanks in advance
> -- 
> ___
> Diego Mauricio Riano Pachon
> Biologist
> Institute of Biology and Biochemistry
> Potsdam University
> Karl-Liebknecht-Str. 24-25
> Haus 20
> 14476 Golm
> Germany
> Tel:0331/977-2809
> http://bioinf.ibun.unal.edu.co/~gotem
> http://www.geocities.com/dmrp.geo/
> 
> 
> -- 
> 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]




DBD::Sybase Question

2002-11-13 Thread gkhgkh
I am relatively new and always trying new things and now I am trying to print 
the output of a select statement to a file.  However I am having issues, the 
print statement just prints the IN file to the outfile and not the results of 
the select statement.  Inserts, deletes, updates etc work fine.  Any 
suggestions?

Thanks

#!/usr/bin/perl -w

#use strict; #uses strict perl coding rule

use DBI;
use DBD::Sybase;

my $server = 'Development';
my $db = 'mm_dev';
my $file = 'new_objects1.txt';
my $file1 = 'new_objects_sec.txt';
my $table = 'al_sec_window_id';

open IN, "$file";
open OUT, ">>$file1";
select OUT;

while () {
chomp(@_ = split);
my $dbh = DBI->connect("dbi:Sybase:server=$server", "ghansen", "jshjsh99" )
or die "Can't Connect:  $DBI::errstr\n";

$dbh->do("use $db");

my $sth = $dbh->prepare( "select *
from $table
where w_id = '$_[0]'" );

$sth->execute();
print "$dbh";

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




comparing arrays

2002-11-13 Thread Diego Riano
Hello folks

I want to ask for your help about the following thing:

I have several files, like this one:

Katrin  12334   lsksol  094059
Karen   29383   skdjsk  092831
Paul21928   lskdiw  029384

I want to compare all the files to know which names are in all of them.

could you give some hints?

Thanks in advance
-- 
___
Diego Mauricio Riano Pachon
Biologist
Institute of Biology and Biochemistry
Potsdam University
Karl-Liebknecht-Str. 24-25
Haus 20
14476 Golm
Germany
Tel:0331/977-2809
http://bioinf.ibun.unal.edu.co/~gotem
http://www.geocities.com/dmrp.geo/


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




RE: file editting

2002-11-13 Thread Aman Thind
Hi Thomas

File editing is particularly easy in perl.
Herez some sample code to get you started :


--

@ARGV='C:\Documents and Settings\athind\Desktop\test\File2Edit.txt'; # path
to the file you want to edit

$^I=".bak";  # this will be appended to the original filename
and will act as BackUp.

while (<>) 
{
s/!//;   # will replace ! with nothing i.e. all instances of
! will be removed.
s/SUB-TOTAL://;  # same as above for SUB-TOTAL:  
print;   # writes the new file line by line  

}




Try this on the file you want to edit.
Anything else you want to edit\replace can be done by the
s/what2replace/bywhat2replace/;

-aman

-Original Message-
From: Thomas Browner [mailto:thomas.browner@;digidyne.com]
Sent: Wednesday, November 13, 2002 7:33 PM
To: [EMAIL PROTECTED]
Subject: file editting


 

 

I there away to edit a file in perl? This is what is I am trying to do.
I have a file that I want to remove some content. This is an example of
a line:

 

! 6134.21   3200  SUB-TOTAL: M:\alvin 

 

I want to remove the ! and SUB-TOTAL. I hope some one can tell me an
simple way of doing this sine I am a new to perl.

 

Thank you,

 

Thomas 

 


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




file editting

2002-11-13 Thread Thomas Browner
 

 

I there away to edit a file in perl? This is what is I am trying to do.
I have a file that I want to remove some content. This is an example of
a line:

 

! 6134.21   3200  SUB-TOTAL: M:\alvin 

 

I want to remove the ! and SUB-TOTAL. I hope some one can tell me an
simple way of doing this sine I am a new to perl.

 

Thank you,

 

Thomas 

 




RE: Sending mail under Windows 95/2000

2002-11-13 Thread Kipp, James
access may have access to the exchange server just like OUtlook does. I
think the problem is that you are behind a firewall. I myself can send
external email with outlook and using an ASP page, but CAN NOT do it with
any of the perl modules, like Net::SMTP

-Original Message-
From: Tin-Shan Chau [mailto:tchau@;shaw.ca]
Sent: Tuesday, November 12, 2002 9:07 PM
To: Timothy Johnson; 'Kipp, James'; 'Help on PERL'
Subject: Re: Sending mail under Windows 95/2000


I did find out that the problem is with:

$smtp = Net::SMTP->new('shaw.ca');

by adding "or die...".  However, I am able to send e-mail to myself using MS
Access.  Any other idea what my problem might be?

Thanks.


- Original Message -
From: "Timothy Johnson" <[EMAIL PROTECTED]>
To: "'Kipp, James'" <[EMAIL PROTECTED]>; "'Tin-Shan Chau'"
<[EMAIL PROTECTED]>; "'Help on PERL'" <[EMAIL PROTECTED]>
Sent: Monday, November 11, 2002 12:26 PM
Subject: RE: Sending mail under Windows 95/2000


>
> Make sure that your sysadmin is allowing internal clients to connect to
the
> mail server via SMTP.  You might be set up on Exchange, in which case you
> might not be using SMTP to connect.
>
> -Original Message-
> From: Kipp, James [mailto:James.Kipp@;mbna.com]
> Sent: Monday, November 11, 2002 12:16 PM
> To: 'Tin-Shan Chau'; 'Help on PERL'
> Subject: RE: Sending mail under Windows 95/2000
>
>
>
>   $smtp = Net::SMTP->new('shaw.ca'); # connect to an
> > SMTP server
> > > $smtp->mail( '[EMAIL PROTECTED]' );# use the sender's
> > > address here
> > > $smtp->to('[EMAIL PROTECTED]');# recipient's address
> > > $smtp->data(); # Start the mail
> > >
> > > connection
> > > >>>
> > > It kept giving me "Can't call method 'mail' on an undefined
> > > value at test1.pl line 4"
> > >
> > > Does anyone have any idea how to fix this?  Or has anyone had
> > > a successful experience doing what I am trying to do?
> > >
> > > Thanks.
> > >
> >
> > try using $smtp->recipient instead of mail()
>
> woops, scratch that. i misread something.
> try a die statement when you intialize the ojbect
> $smtp = Net::SMTP->new('shaw.ca') or die "blah, blah"; # connect
> # looks like you may not be connecting
>
>
>
>
> --
> 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: map EXPR, LIST

2002-11-13 Thread Kipp, James
I think somebody posted to swap the map and print statments.

-Original Message-
From: Deb [mailto:deb@;tickleme.llnl.gov]
Sent: Tuesday, November 12, 2002 4:13 PM
To: Kipp, James
Cc: Perl List
Subject: Re: map EXPR, LIST


Hmmm, that's a useful work-around.  

I may use it, but I'm really interested in finding out what the correct
invocaton of "map EXPR, LIST" would be.

Anyone know?

Thanks,

deb




Kipp, James <[EMAIL PROTECTED]> had this to say,
> if you wanted to keep the use warnings pragma in there you could use the
CGI
> carp method to send errors off to to wherever:
> 
> # at the top of the script
> use CGI::Carp qw(carpout);
> # redirect STDERR
> # could also send errs and warning to /dev/null
> open (ERRLOG, ">/tmp/err.out") or die "can't open error file\n";
> carpout(\*ERRLOG);
> 
> -Original Message-
> From: Deb [mailto:deb@;tickleme.llnl.gov]
> Sent: Tuesday, November 12, 2002 2:12 PM
> To: Perl List
> Subject: map EXPR, LIST
> 
> 
> Using 
>   perl v5.6.1 on Solaris.
>   use warnings;
>   use strict;
> 
> 
> I've got a hash of lists that I'm looping through:
> 
> 
> foreach $List (sort keys %HashofLists)
> {
>print "Values for key \"$List\":\n";
>map print ("\t\"$_\"\n"), @{$HashofLists{$List} };
> }
> 
> 
> This works just fine, except that I am getting the following complaint
> when I run the program,
> 
>print (...) interpreted as function at verify_lists.pl line 55.
> 
> Line 55 is the "map print" line, above.  
> 
> This worked w/o complaint (I think!) back in perl 5.001, so my assumption 
> is that v5.6.1 now requires a syntactically different way of writing this
> out?
> 
> Since it works as expected, and I don't want the complaint to
stdout/stderr,
> 
> how would I write this such that perl will not complain?
> 
> Thanks,
> deb
> 
> 

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=-=-
  There are 010 types of people in the world:
  those that understand binary, and those that don't.
ô¿ô
 ~ 


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




RE: Sending mail under Windows 95/2000

2002-11-13 Thread Jenda Krynicky
From:   Aman  Thind <[EMAIL PROTECTED]>
> Just use "shaw" instead of "shaw.ca" as in :
> 
> $smtp = Net::SMTP->new('shaw')||die("my woes are never ending :(");
> 
> You are supposed to use only the name of the mail server.
> shaw.ca is an invalid argument to Net::SMTP as you will find if you
> use  : print "$!"; after trying to connect to the server as you do.

There is nothing "syntacticaly" invalid about "shaw.ca". You can (and 
probably should) use the full DNS name of the server.

Of course if the name doesn't exist or the server doesn't accept SMTP 
(port 25) connections "new Net::SMTP" fails.

If you use just the name (without the domain) you just ask the DNS to 
find the server in whatever default domains are set for your 
computer. 

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


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




RE: use of my: why?

2002-11-13 Thread Beau E. Cox
Hi -

'my' sets up a variable valid in the enclosing block only.
In your exmaple, func1 creates an array @array, plays with
it, and discards it when the function ends.

Aloha => Beau.

-Original Message-
From: Duarte Cordeiro [mailto:duarte.cordeiro@;neoris.com]
Sent: Wednesday, November 13, 2002 1:09 AM
To: [EMAIL PROTECTED]
Subject: use of my: why?


in this block:

sub func1{
my @array=(0,0,0);
func2();
print "it's not working" if ($array[1]==0);
}

Sub func2(){
return if($array[1]==1);
$array[1]=1 if($array[1]==0);
func2();
}

This doesn't do nothing :) but I came across this problem in a script I
wrote.
I can access @array inside func2 and modify it. Also, recursively called
func2 sees the changed values.
But, after returning to func1, @array is still as before.
What's wrong ?


--
Duarte Manuel Cordeiro
Manager - IT - Security & Communications
mailto:duarte.cordeiro@;neoris.com |  msn: [EMAIL PROTECTED] |
http://www.neoris.com/
--
Neoris Portugal
Edificio Inovação IV - Sala 819 - Taguspark * 2780-920 Oeiras * Portugal
Tel: +351 21 423-8350  |  Fax: +351 21 421-7626  | Mob: +35191 613-5706
--
Privileged/Confidential Information may be contained in this message. If you
are not the addressee indicated in this message (or responsible for delivery
of the message to such person), you may not copy or deliver this message to
anyone. In such case, you should destroy this message and kindly notify the
sender by reply email. Please advise immediately if you or your employer
does not consent to Internet email for messages of this kind. Opinions,
conclusions and other information in this message that do not relate to the
official business of my firm shall be understood as neither given nor
endorsed by it.

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




use of my: why?

2002-11-13 Thread Duarte Cordeiro
in this block:

sub func1{
my @array=(0,0,0);
func2();
print "it's not working" if ($array[1]==0);
}

Sub func2(){
return if($array[1]==1);
$array[1]=1 if($array[1]==0);
func2();
}

This doesn't do nothing :) but I came across this problem in a script I wrote.
I can access @array inside func2 and modify it. Also, recursively called func2 sees 
the changed values. 
But, after returning to func1, @array is still as before.
What's wrong ?


-- 
Duarte Manuel Cordeiro 
Manager - IT - Security & Communications 
mailto:duarte.cordeiro@;neoris.com |  msn: [EMAIL PROTECTED] |  
http://www.neoris.com/ 
-- 
Neoris Portugal 
Edificio Inovação IV - Sala 819 - Taguspark * 2780-920 Oeiras * Portugal 
Tel: +351 21 423-8350  |  Fax: +351 21 421-7626  | Mob: +35191 613-5706 
-- 
Privileged/Confidential Information may be contained in this message. If you are not 
the addressee indicated in this message (or responsible for delivery of the message to 
such person), you may not copy or deliver this message to anyone. In such case, you 
should destroy this message and kindly notify the sender by reply email. Please advise 
immediately if you or your employer does not consent to Internet email for messages of 
this kind. Opinions, conclusions and other information in this message that do not 
relate to the official business of my firm shall be understood as neither given nor 
endorsed by it.

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




Re: string can not be printed

2002-11-13 Thread John W. Krahn
Ramprasad A Padmanabhan wrote:
> 
> do this
> 
> $header=~s/\r+//g;
> 
> and then try parsing it
> Also
> You need not use /\nFrom:\s*(.*)/m
> You can use /^From:\s*(.*)$/m
> ( 'm' treats every new line a full string individually)

/m causes the ^ and $ anchors to match the beginning and end of a line
in a string instead of the beginning and end of the string.

$ perl -le'
$_ = "onethis\ntwothat\nthreethe other\n";
print "1 >$1<" if /\ntwo\s*(.*)/;
print "2 >$1<" if /^two\s*(.*)/;
print "3 >$1<" if /^two\s*(.*)/m;
'
1 >that<
3 >that<



John
-- 
use Perl;
program
fulfillment

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




Re: match only a-z or 0-9

2002-11-13 Thread John W. Krahn
David Buddrige wrote:
> 
> Alex Cheung Tin Ka wrote:
> >
> > Could anyone tell me how to make a regular expression for match a string only 
>[a-z0-9] ?
> 
> [a-z0-9]+ will match a sequence of characters containing one or more of
> the set [a-z0-9].
> 
> If you want to match a line of characters that contains NOTHING BUT
> [a-z0-9] then you could use:
> 
> ^[a-z0-9]+$
> 
> If you want to match a sequence of characters that must start with [a-z]
>  and contain any number of [a-z0-9] thereafter, you could use the regex:
> 
> [a-z][a-z0-9]*

And if you want to match all lowercase characters in the current
character set:

^[[:lower:]\d]+$



John
-- 
use Perl;
program
fulfillment

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




RE: Sending mail under Windows 95/2000

2002-11-13 Thread Aman Thind
Hi

Just use "shaw" instead of "shaw.ca" as in :

$smtp = Net::SMTP->new('shaw')||die("my woes are never ending :(");

You are supposed to use only the name of the mail server.
shaw.ca is an invalid argument to Net::SMTP as you will find if you use  :
print "$!"; after trying to connect to the server as you do.

Bon Mailing :)

-aman.


-Original Message-
From: Tin-Shan Chau [mailto:tchau@;shaw.ca]
Sent: Wednesday, November 13, 2002 7:37 AM
To: Timothy Johnson; 'Kipp, James'; 'Help on PERL'
Subject: Re: Sending mail under Windows 95/2000


I did find out that the problem is with:

$smtp = Net::SMTP->new('shaw.ca');

by adding "or die...".  However, I am able to send e-mail to myself using MS
Access.  Any other idea what my problem might be?

Thanks.


- Original Message -
From: "Timothy Johnson" <[EMAIL PROTECTED]>
To: "'Kipp, James'" <[EMAIL PROTECTED]>; "'Tin-Shan Chau'"
<[EMAIL PROTECTED]>; "'Help on PERL'" <[EMAIL PROTECTED]>
Sent: Monday, November 11, 2002 12:26 PM
Subject: RE: Sending mail under Windows 95/2000


>
> Make sure that your sysadmin is allowing internal clients to connect to
the
> mail server via SMTP.  You might be set up on Exchange, in which case you
> might not be using SMTP to connect.
>
> -Original Message-
> From: Kipp, James [mailto:James.Kipp@;mbna.com]
> Sent: Monday, November 11, 2002 12:16 PM
> To: 'Tin-Shan Chau'; 'Help on PERL'
> Subject: RE: Sending mail under Windows 95/2000
>
>
>
>   $smtp = Net::SMTP->new('shaw.ca'); # connect to an
> > SMTP server
> > > $smtp->mail( '[EMAIL PROTECTED]' );# use the sender's
> > > address here
> > > $smtp->to('[EMAIL PROTECTED]');# recipient's address
> > > $smtp->data(); # Start the mail
> > >
> > > connection
> > > >>>
> > > It kept giving me "Can't call method 'mail' on an undefined
> > > value at test1.pl line 4"
> > >
> > > Does anyone have any idea how to fix this?  Or has anyone had
> > > a successful experience doing what I am trying to do?
> > >
> > > Thanks.
> > >
> >
> > try using $smtp->recipient instead of mail()
>
> woops, scratch that. i misread something.
> try a die statement when you intialize the ojbect
> $smtp = Net::SMTP->new('shaw.ca') or die "blah, blah"; # connect
> # looks like you may not be connecting
>
>
>
>
> --
> 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: string can not be printed

2002-11-13 Thread Ramprasad A Padmanabhan
do this

$header=~s/\r+//g;

and then try parsing it
Also
You need not use /\nFrom:\s*(.*)/m
You can use /^From:\s*(.*)$/m ( 'm' treats every new line a full string 
individually)


I think you are getting a carriage return.


Julien Motch wrote:
Hi ,

I am again experiencing problem with regular expressions and how to
print them .My program retrieves some mail headers and the extract two
strings : the subject ($subject) and the sender of the mail ($who) .Then
the program has to print them .

Here is the programm :

#Print subject and sender for the unreaded mail
for($i=0;$i<$unreaded_mails;$i++){
	$header = $pop->Head($last_mail +$i + 1);
	my ($who) =  $header =~ /\nFrom:\s*(.*)/m;
	my ($subject) = $header =~ /\nSubject:\s*(.*)/m;
	#Here is the strange line
	print("$who");
	print(" has sended to you an email whom subject is $subject\n");
} 


As it is now ,the program does not print the message sender but if
instead of `print("$who")` I write a `print("$who\n")` the sender is
correctly written .

And if I write `print("$who\t")` only the half of the string is
displayed end ends up with a `<`.

I suppose the `<` and `>` characters in the sender name are responsible
of my problem as the subject is correctly displayed .

Would anyone know how to fix the problem ?

Thanks ,Julien




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




Re: Newbie - Help with writing a memory leak script for an application...

2002-11-13 Thread Ramprasad A Padmanabhan
use tools like memprof for finding memory leaks
why bother writing your own

Alex Yuen wrote:

Hi,

I am still a newbie to Perl.

I am assigned to write a Perl program to monitor a memory leak on an
application running on a Sun system - Solaris. Now, I'm a Windows NT System
Administrator...so, I am trying to transition over to Unix and don't know
where to start. Can someone point me in the right direction to start? What
modules to use for Unix?

The Perl script will be grabbing the information from a log files. The
script will run automatically, by cron, every hour and compares to the
previous hour, then records the difference. If the difference reaches a
critical level, an e-mail notification is sent.

I have ActiveState Perl v5.6.a build 633 installed on my Windows
workstation.

Thanks in advance.

Alex Yuen



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




Re: Sending mail under Windows 95/2000

2002-11-13 Thread Tin-Shan Chau
I did find out that the problem is with:

$smtp = Net::SMTP->new('shaw.ca');

by adding "or die...".  However, I am able to send e-mail to myself using MS
Access.  Any other idea what my problem might be?

Thanks.


- Original Message -
From: "Timothy Johnson" <[EMAIL PROTECTED]>
To: "'Kipp, James'" <[EMAIL PROTECTED]>; "'Tin-Shan Chau'"
<[EMAIL PROTECTED]>; "'Help on PERL'" <[EMAIL PROTECTED]>
Sent: Monday, November 11, 2002 12:26 PM
Subject: RE: Sending mail under Windows 95/2000


>
> Make sure that your sysadmin is allowing internal clients to connect to
the
> mail server via SMTP.  You might be set up on Exchange, in which case you
> might not be using SMTP to connect.
>
> -Original Message-
> From: Kipp, James [mailto:James.Kipp@;mbna.com]
> Sent: Monday, November 11, 2002 12:16 PM
> To: 'Tin-Shan Chau'; 'Help on PERL'
> Subject: RE: Sending mail under Windows 95/2000
>
>
>
>   $smtp = Net::SMTP->new('shaw.ca'); # connect to an
> > SMTP server
> > > $smtp->mail( '[EMAIL PROTECTED]' );# use the sender's
> > > address here
> > > $smtp->to('[EMAIL PROTECTED]');# recipient's address
> > > $smtp->data(); # Start the mail
> > >
> > > connection
> > > >>>
> > > It kept giving me "Can't call method 'mail' on an undefined
> > > value at test1.pl line 4"
> > >
> > > Does anyone have any idea how to fix this?  Or has anyone had
> > > a successful experience doing what I am trying to do?
> > >
> > > Thanks.
> > >
> >
> > try using $smtp->recipient instead of mail()
>
> woops, scratch that. i misread something.
> try a die statement when you intialize the ojbect
> $smtp = Net::SMTP->new('shaw.ca') or die "blah, blah"; # connect
> # looks like you may not be connecting
>
>
>
>
> --
> 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: match only a-z or 0-9

2002-11-13 Thread Timothy Johnson
 
Correction:  That should be [a-z0-9]+. (note the plus)

-Original Message-
From: Timothy Johnson
To: 'Alex Cheung Tin Ka '; '[EMAIL PROTECTED] '
Sent: 11/13/02 12:01 AM
Subject: RE: match only a-z or 0-9

 
You've essentially already done it.  [a-z0-9] is a character class that
includes all characters within that range.  So something like this would
work:

if($string =~ /^[a-z0-9]$/){
  print "It's only letters and digits.\n";
}else{
  print "There's something else in there.\n";
}

-Original Message-
From: Alex Cheung Tin Ka
To: [EMAIL PROTECTED]
Sent: 11/12/02 11:14 PM
Subject: match only a-z or 0-9

Dear All,
Could anyone tell me how to make a regular expression for match a
string only [a-z0-9] ?

Thanks

-- 
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: match only a-z or 0-9

2002-11-13 Thread Timothy Johnson
 
You've essentially already done it.  [a-z0-9] is a character class that
includes all characters within that range.  So something like this would
work:

if($string =~ /^[a-z0-9]$/){
  print "It's only letters and digits.\n";
}else{
  print "There's something else in there.\n";
}

-Original Message-
From: Alex Cheung Tin Ka
To: [EMAIL PROTECTED]
Sent: 11/12/02 11:14 PM
Subject: match only a-z or 0-9

Dear All,
Could anyone tell me how to make a regular expression for match a
string only [a-z0-9] ?

Thanks

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