Re: Help on Arrays - Beginner

2002-09-20 Thread david

try this:

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

print join("\n",sort map { join(', ',reverse split); } );

__DATA__
abcd apply
xxx peach
yyy dog
zzz cat

prints:

apply, abcd
cat, zzz
dog, yyy
peach, xxx

david

"Grant Hansen" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Hello All,

I am new to Perl and I will admit up front this is for a Perl course.
However, the course is online and thus timely communication from the
instructor is not always possible, so I am hoping someone will steer me in
the right direction.

The assignment has to do with taking a file, and reading it to ,
modifying each line, sort and then print.

Here is the Input:

Grant Hansen
Dave Thomas
Roger Starbauch

Here is the intended output:

Hansen, Grant
Starbauch, Roger
Thomas, Dave

Here is my code:

while() {
 chomp(@lines = split);
 @lines1 = $lines[1] . ", " .  $lines[0];
 @lines2 = sort (@lines1);
 print "@lines2 \n";
}

My code is not sorting correctly and I know why (I sort after each line of
input), I just don't know how to fix it.

Any help is appreciated.



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




RE: Help on Arrays - Beginner

2002-09-20 Thread Timothy Johnson


Okay, then, are you familiar with for/foreach?  Once you've started the
loop, it's essentially the same as your original while().

my @array = ;
foreach(@array){
   do your name sort with $_...
}

@array = sort @array;

(See below if this doesn't click for you, I haven't tested them, but
something similar should work.)
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
use strict;
use warnings;
open(INFILE,"myfile.txt") || die "Could not open \"myfile.txt\"!";
my @array = ;
foreach(@array){
  chomp $_;
  $_ =~ /^(\w+)\s+(\w+)$/;
  $_ = "$2,$1";
}
@array = sort @array;
print @array;


use strict;
use warnings;
open(INFILE,"myfile.txt") || die "Could not open \"myfile.txt\"!";
my @array = ;
foreach(@array){
  chomp $_;
  ($fname,$lname) = split / /,$_;
  $_ = "lname,fname";
}
@array = sort @array;
print @array;

-Original Message-
From: Grant Hansen [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 20, 2002 6:29 PM
To: Timothy Johnson
Cc: Perl Beginners
Subject: Re: Help on Arrays - Beginner


I thought about that and I understand how that works, however the piece that
I 
am missing and don't understand is how to access each element of the array, 
reverse the data and put the comma in.  I know how to access the elements,
it 
is the manipulating and putting back into the array for further processing 
that I am confused on.

Thanks


On Friday 20 September 2002 08:06 pm, Timothy Johnson wrote:
> I'll give you a hint.  This is perfectly legal:
>
> my @array = ;
>
> Let me know if you still can't figure it out.
>
> -Original Message-
> From: Grant Hansen [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 20, 2002 6:03 PM
> To: [EMAIL PROTECTED]
> Subject: Help on Arrays - Beginner
>
>
> Hello All,
>
> I am new to Perl and I will admit up front this is for a Perl course.
> However, the course is online and thus timely communication from the
> instructor is not always possible, so I am hoping someone will steer me in
> the right direction.
>
> The assignment has to do with taking a file, and reading it to ,
> modifying each line, sort and then print.
>
> Here is the Input:
>
> Grant Hansen
> Dave Thomas
> Roger Starbauch
>
> Here is the intended output:
>
> Hansen, Grant
> Starbauch, Roger
> Thomas, Dave
>
> Here is my code:
>
> while() {
>  chomp(@lines = split);
>  @lines1 = $lines[1] . ", " .  $lines[0];
>  @lines2 = sort (@lines1);
>  print "@lines2 \n";
> }
>
> My code is not sorting correctly and I know why (I sort after each line of
> input), I just don't know how to fix it.
>
> Any help is appreciated.

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




Re: Missing (defined($exe) mail prog on WINNT

2002-09-20 Thread rob

Hi Tim

Thanks for helping out 

>r> $fh = $msg->open;   # some default mailer
>r> # $fh = $msg->open('sendmail'); # explicit
>
>I am guessing this is where your problem is.  It looks like the above
>is specifying the MTA to deliver the message.  What are you setting it
>to?  Guessing it would be something like smtp.server.com
>
>r> print $fh "Body of message";
>
>r> $fh->close; # complete the message and send it
>
>r> $fh->cancel;# not yet implemented
>

I guess thats the question... I tried to pass it smtp.validserver.com

eg  $fh = $msg->open('smtp.validserver.com');

Warning: Use of "require" without parens is ambiguous at (eval 1) line 1.
Bareword "validserver" not allowed while "strict subs" in use at (eval 
1) line 1.
Bareword "com" not allowed while "strict subs" in use at (eval 1) line 1.

Ive tried
eg  $fh = $msg->open('smtp');

I understand what your saying that its looking for a valid smtp server 
but it seems like it wants a mail program

if I use
$fh = $msg->open('mail');

C:\1myperl>amail.pl
No mailer type specified (and no default available), thus can not find executable 
program. at F:/Perl/site/lib/
Mail/Send.pm line 52

It looks like my "executable" mail types are in

 F:\Perl\site\lib\Mail\Mailer>
r> mail.pm
r> qmail.pm
r> rfc822.pm
r> sendmail.pm
r> smtp.pm
r> test.pm

But I dont know how to hook them up???

thanks
rob

-- 
Those who would become Rocket Scientists should first master Common 
Sense... '



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




file upload to MySql

2002-09-20 Thread Mariusz

I need to upload a file to a database. Could someone tell me how to do it? I know how 
to insert values into a table and upload files to a directory but how to combine the 
two correctly so the file gets uploaded to my MySql DB and I don't get any errors. A 
part of a script that does that would be a great help...

thank you,
M



Re: Help on Arrays - Beginner

2002-09-20 Thread Grant Hansen

I thought about that and I understand how that works, however the piece that I 
am missing and don't understand is how to access each element of the array, 
reverse the data and put the comma in.  I know how to access the elements, it 
is the manipulating and putting back into the array for further processing 
that I am confused on.

Thanks


On Friday 20 September 2002 08:06 pm, Timothy Johnson wrote:
> I'll give you a hint.  This is perfectly legal:
>
> my @array = ;
>
> Let me know if you still can't figure it out.
>
> -Original Message-
> From: Grant Hansen [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 20, 2002 6:03 PM
> To: [EMAIL PROTECTED]
> Subject: Help on Arrays - Beginner
>
>
> Hello All,
>
> I am new to Perl and I will admit up front this is for a Perl course.
> However, the course is online and thus timely communication from the
> instructor is not always possible, so I am hoping someone will steer me in
> the right direction.
>
> The assignment has to do with taking a file, and reading it to ,
> modifying each line, sort and then print.
>
> Here is the Input:
>
> Grant Hansen
> Dave Thomas
> Roger Starbauch
>
> Here is the intended output:
>
> Hansen, Grant
> Starbauch, Roger
> Thomas, Dave
>
> Here is my code:
>
> while() {
>  chomp(@lines = split);
>  @lines1 = $lines[1] . ", " .  $lines[0];
>  @lines2 = sort (@lines1);
>  print "@lines2 \n";
> }
>
> My code is not sorting correctly and I know why (I sort after each line of
> input), I just don't know how to fix it.
>
> Any help is appreciated.


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




Re: Missing (defined($exe) mail prog on WINNT

2002-09-20 Thread Tim Musson

Hey rob, 

My MUA believes you used Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.0) 
Gecko/20020530
to write the following on Friday, September 20, 2002 at 7:36:37 PM.

r> When the program runs I get the following error, which seems to be
r> saying I need a system mail program... something like blat or
r> sendmail, qmail if it were Linux.

Well, blat will only do a small part of what sendmail will do, but you
should not need for what you are trying.

r> Im on NT 4 Server and currently using cdonts but I'd like to
r> implement perl instead. what do I need to do? Id *really * rather
r> not install blat as thats just another level of complexity...

Agreed.

C:\1myperl>>amail.pl
r> Died at F:/Perl/site/lib/Mail/Mailer.pm line 290.

r> line 290 # Fork and start a mailer
r> (defined($exe) && open($self,"|-"))
r> || $self->exec($exe, $args, \@to)
r> || die $!;


r> now on the other hand... if I
C:\1myperl>>perl -MMAIL -le "print(MAIL->VERSION)"

r> Can't locate MAIL.pm in @INC (@INC contains: F:/Perl/lib 
r> F:/Perl/site/lib .).
r> BEGIN failed--compilation aborted.

r> I do have

r> F:\Perl\site\lib\Mail\Mailer>dir /b > dir.txt which produces
r> mail.pm
r> qmail.pm
r> rfc822.pm
r> sendmail.pm
r> smtp.pm
r> test.pm


r> Thanks rob
r>  amail.pl 
r>   require Mail::Send;

r> $msg = new Mail::Send;

r> $msg = new Mail::Send Subject=>'the subject', To=>'me';

r> $msg->to('[EMAIL PROTECTED]');
r> $msg->subject('example subject');
r> $msg->cc('');
r> $msg->bcc('');

r> $msg->set($header, @values);
r> $msg->add($header, @values);
r> $msg->delete($header);

r> # Launch mailer and set headers. The filehandle returned
r> # by open() is an instance of the Mail::Mailer class.
r> # Arguments to the open() method are passed to the Mail::Mailer
r> # constructor.

r> $fh = $msg->open;   # some default mailer
r> # $fh = $msg->open('sendmail'); # explicit

I am guessing this is where your problem is.  It looks like the above
is specifying the MTA to deliver the message.  What are you setting it
to?  Guessing it would be something like smtp.server.com

r> print $fh "Body of message";

r> $fh->close; # complete the message and send it

r> $fh->cancel;# not yet implemented

-- 
[EMAIL PROTECTED]
Flying with The Bat! eMail v1.61
Windows 2000 5.0.2195 (Service Pack 2)
If you drink, don't park.  Accidents cause people.


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




RE: Help on Arrays - Beginner

2002-09-20 Thread Timothy Johnson


I'll give you a hint.  This is perfectly legal:

my @array = ;

Let me know if you still can't figure it out.

-Original Message-
From: Grant Hansen [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 20, 2002 6:03 PM
To: [EMAIL PROTECTED]
Subject: Help on Arrays - Beginner


Hello All,

I am new to Perl and I will admit up front this is for a Perl course.  
However, the course is online and thus timely communication from the 
instructor is not always possible, so I am hoping someone will steer me in 
the right direction.

The assignment has to do with taking a file, and reading it to , 
modifying each line, sort and then print.

Here is the Input:

Grant Hansen
Dave Thomas
Roger Starbauch

Here is the intended output:

Hansen, Grant
Starbauch, Roger
Thomas, Dave

Here is my code:

while() {
 chomp(@lines = split);
 @lines1 = $lines[1] . ", " .  $lines[0];
 @lines2 = sort (@lines1);
 print "@lines2 \n";
}

My code is not sorting correctly and I know why (I sort after each line of 
input), I just don't know how to fix it.

Any help is appreciated.

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

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




Help on Arrays - Beginner

2002-09-20 Thread Grant Hansen

Hello All,

I am new to Perl and I will admit up front this is for a Perl course.  
However, the course is online and thus timely communication from the 
instructor is not always possible, so I am hoping someone will steer me in 
the right direction.

The assignment has to do with taking a file, and reading it to , 
modifying each line, sort and then print.

Here is the Input:

Grant Hansen
Dave Thomas
Roger Starbauch

Here is the intended output:

Hansen, Grant
Starbauch, Roger
Thomas, Dave

Here is my code:

while() {
 chomp(@lines = split);
 @lines1 = $lines[1] . ", " .  $lines[0];
 @lines2 = sort (@lines1);
 print "@lines2 \n";
}

My code is not sorting correctly and I know why (I sort after each line of 
input), I just don't know how to fix it.

Any help is appreciated.

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




Re: reading /var/spool/mail

2002-09-20 Thread Michael Fowler

On Fri, Sep 20, 2002 at 06:39:33PM +0700, Hengky wrote:
> the basic is i like to create my own webmail,
> and read from /var/spool/mail

If you insist on writing your own web mail application (there are free and
commercial ones available, have you checked them out?) the best thing I can
think of is not to access the spool directly but through an intermediary,
such as POP3 or IMAP.  This has several benefits: you don't have to deal
with the underlying storage details, you have a structured and
well-documented method of getting to the email, and your solution will prove
more flexible because it won't necessarily need to run on the same server as
the mail resides.


> how to change the permission of the script so when people login he can
> read from /var/spool/mail ( they own mailbox )

The only way to change your uid is to run as root and call setuid (or Perl's
equivalent, assign to $>).  This raises all sorts of issues.  If your
application spawns a sub-application that is setuid root then it has to
communicate with that program via IPC (inter-process communication).  If
your application does everything it will need to run as root (not
recommended for large applications; small easily audited code is preferable
for applications running as root) then the web server will have to be
running as root; the web server may not be properly secured for this.

There is one additional method I can think of; have a daemon, running as
root, that communicates over the network.  This is POP3 and IMAP.


> my perl not compile with suid ( for security problem, plz understand this)

I expect you mean your Perl is not compiled with setuid bit support; that
is, it doesn't set its uid if the script's setuid bit is set.  This is only
a problem if you go with the sub-application solution, and you want the
sub-application to be written in Perl.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

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




Missing (defined($exe) mail prog on WINNT

2002-09-20 Thread rob

Hello list

Ive tried to experiment with using perl for mail (calling form another 
program -Excel sheet macro) So I installed
**MailTools-1.50**

and used an example form Mail::Mailer at CPAN.
http://search.cpan.org/author/MARKOV/MailTools-1.50/Mail/Send.pm

When the program runs I get the following error, which seems to be 
saying I need a system mail program... something like blat or sendmail, 
qmail if it were Linux.

Im on NT 4 Server and currently using cdonts but I'd like to implement 
perl instead. what do I need to do? Id *really * rather not install blat 
as thats just another level of complexity...


C:\1myperl>amail.pl
Died at F:/Perl/site/lib/Mail/Mailer.pm line 290.

line 290 # Fork and start a mailer
(defined($exe) && open($self,"|-"))
|| $self->exec($exe, $args, \@to)
|| die $!;


now on the other hand... if I
C:\1myperl>perl -MMAIL -le "print(MAIL->VERSION)"

Can't locate MAIL.pm in @INC (@INC contains: F:/Perl/lib 
F:/Perl/site/lib .).
BEGIN failed--compilation aborted.

I do have

F:\Perl\site\lib\Mail\Mailer>dir /b > dir.txt which produces
mail.pm
qmail.pm
rfc822.pm
sendmail.pm
smtp.pm
test.pm


Thanks rob
 amail.pl 
  require Mail::Send;

$msg = new Mail::Send;

$msg = new Mail::Send Subject=>'the subject', To=>'me';

$msg->to('[EMAIL PROTECTED]');
$msg->subject('example subject');
$msg->cc('');
$msg->bcc('');

$msg->set($header, @values);
$msg->add($header, @values);
$msg->delete($header);

# Launch mailer and set headers. The filehandle returned
# by open() is an instance of the Mail::Mailer class.
# Arguments to the open() method are passed to the Mail::Mailer
# constructor.

$fh = $msg->open;   # some default mailer
# $fh = $msg->open('sendmail'); # explicit

print $fh "Body of message";

$fh->close; # complete the message and send it

$fh->cancel;# not yet implemented


-- 
   For perfect happiness, remember two things:(1) Be content with what you've got.(2) 
Be sure you've got plenty.  



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




Re: is every sub know to a child?

2002-09-20 Thread John W. Krahn

Angerstein wrote:
> 
> I have a programm build with a lot of subs.
> 
> Normally it should be possible to call every declared sub in the (fork)
> child process, right?


$ perl -e' 
sub one { print " one" }
sub two { print " two" }

die "fork error\n" unless defined( $pid = fork );
if ( $pid ) { sleep 1; print "Parent:"; one(); two(); print "\n" }
else{  print "Child:";  one(); two(); print "\n" }
'
Child: one two
Parent: one two


It seems to work here (on Linux)  :-)



John
-- 
use Perl;
program
fulfillment

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




Re: Mail::Send

2002-09-20 Thread Tom Allison

david wrote:
> Tom Allison wrote:
> 
> 
>>I was trying to use the Mail::Send module for shipping out some
>>email, but I'm getting nothing.
>>
>>No errors, event with lots of die opportunities.
>>No logs registering an attempt.
>>
>>Nothing.
>>
>>help?
> 
> 
> any code? maybe you are using the module in a wrong way? maybe your mail 
> server is down? a lot of guess but no answer unless you provide something 
> for us to check.
> 
> david
> 

I found some obscure notes work, but don't make sense

Mail::Send says that the method of creating an email body is:
$fh=$msg->open;
And being based on Mail::Mailer, it will query for Mailx, mail, 
Mail first for a mail processing application.
Failing that, it will move to sendmail...qmail and others.

Well, 'mail' exists, but it doesn't work with Mail::Send.

I have to use the command:

$fh = $msg->open("sendmail");

And use the postfix alias/compatability program called sendmail to 
get this to work.

It's working, but I wish I knew more about why?

-- 
All programmers are playwrights and all computers are lousy actors.


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




Re: how to find memory leaks?

2002-09-20 Thread chad kellerman

Frank-
   I think he believes it's more of a security issue then anything
else.  We only have three os's here.  Solaris x86, Solaris sparc, and
linux. So I don't think it's a port issue.

--chad

  

On Fri, 2002-09-20 at 15:49, Frank Wiles wrote:
>  .--[ chad kellerman wrote (2002/09/20 at 15:32:11) ]--
>  | 
>  |  I tried doing the same thing but my supervisor got mad.  We aren't
>  |  allowed to use any type of system call in our scripts.  If the system
>  |  call is in a perl module it's one thing but not in our code.
>  |  
>  |  system or exec anything that executes from /bin/sh
>  |  
>  |  even though it is so much nicer to do that, especially using find..
>  |  
>  `-
> 
> Does he have a sound reason for this or is he just thinking it
> somehow makes your program more secure or more easily ported, etc? 
> 
>  -
>Frank Wiles <[EMAIL PROTECTED]>
>http://frank.wiles.org
>  -
> 
-- 
Chad Kellerman
Jr. Systems Administrator
Alabanza Inc
410-234-3305



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


RE: how to find memory leaks?

2002-09-20 Thread david

Chad Kellerman wrote:

> I tried doing the same thing but my supervisor got mad.  We aren't
> allowed to use any type of system call in our scripts.  If the system
> call is in a perl module it's one thing but not in our code.
> 
> system or exec anything that executes from /bin/sh
> 
> even though it is so much nicer to do that, especially using find..
> 

i actually agree with your supervisor. i didn't code the share memory 
project that i mention in the previous reply. i am one of those that really 
trying hard to avoid any sort of system(), exec(), ``... etc in Perl code. 
i am trying to convince the other developers not to use those as well. i 
won't got in a debate of the pros and cons of using those. personally, i 
think they are not portable, unreliable and unsafe.

david

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




RE: how to find memory leaks?

2002-09-20 Thread chad kellerman

I tried doing the same thing but my supervisor got mad.  We aren't
allowed to use any type of system call in our scripts.  If the system
call is in a perl module it's one thing but not in our code.

system or exec anything that executes from /bin/sh

even though it is so much nicer to do that, especially using find..

-chad





On Fri, 2002-09-20 at 15:01, david wrote:
> Chad Kellerman wrote:
> 
> > Dave,
> > 
> >  Actually in each fork.  I was tarring up information from another
> > server with Net::SSH::Perl.  The full tar ball was written to stdout and
> > I would gzip in on the originating server.  If I did not fork each tar
> > the server would crash in a matter of minutes.  But with the forks I
> > actually contected adn grabbed tar balls from a 100 servers, 8 at a
> > time.
> > 
> 
> yes, now that it make sense to me. the tarring portion of your code is 
> likely to create huge heap (like the share memory module, i think it's call 
> ShareLite or something like that, everytime it pull something back from the 
> share memory, it creates a heap for it. the heap will not go away (because 
> Perl does it's own memory management) until the client exit.). you should 
> verify that if Net::SSH::Perl does something similar. it seems like it can 
> be the case. now, if you create a child process for that, it's the child 
> process that creates the heap, not the parent, so when the child process 
> exit, everything is destoried(code, data stack,heap, etc). that's why you 
> don't see your parent eating up a lot of memory.
> 
> i could be totally wrong but with my experience with ShareLit, the situation 
> is similiar. indeed, we use similar solution as your forking except that we 
> don't fork, we simply exec().
> 
> david
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
-- 
Chad Kellerman
Jr. Systems Administrator
Alabanza Inc
410-234-3305



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


RE: how to find memory leaks?

2002-09-20 Thread david

Chad Kellerman wrote:

> Dave,
> 
>  Actually in each fork.  I was tarring up information from another
> server with Net::SSH::Perl.  The full tar ball was written to stdout and
> I would gzip in on the originating server.  If I did not fork each tar
> the server would crash in a matter of minutes.  But with the forks I
> actually contected adn grabbed tar balls from a 100 servers, 8 at a
> time.
> 

yes, now that it make sense to me. the tarring portion of your code is 
likely to create huge heap (like the share memory module, i think it's call 
ShareLite or something like that, everytime it pull something back from the 
share memory, it creates a heap for it. the heap will not go away (because 
Perl does it's own memory management) until the client exit.). you should 
verify that if Net::SSH::Perl does something similar. it seems like it can 
be the case. now, if you create a child process for that, it's the child 
process that creates the heap, not the parent, so when the child process 
exit, everything is destoried(code, data stack,heap, etc). that's why you 
don't see your parent eating up a lot of memory.

i could be totally wrong but with my experience with ShareLit, the situation 
is similiar. indeed, we use similar solution as your forking except that we 
don't fork, we simply exec().

david

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




Re: Redirecting output

2002-09-20 Thread david

Jason Frisvold wrote:

> Is there a way to redirect all the output (anything printed by the
> program itself and any error output) back into the program so the
> program can handle it?
> 
> I'd like to be able to redirect it to itself so if there are any errors
> or unexpected output during a cron job, it'll all get mailed to me...
> 
> Make sense?
> 

yes, you can do something like:

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

set_it_up();
print "from set_it_up(), i got: ", scalar ;
close(STDOUT);

sub set_it_up{
my $pid;
return if $pid = open(STDOUT,"|-");
die("Unable to attache to STDOUT by fork: $!") unless(defined $pid);
print "hello world\n";
}

__END__

inside set_it_up() you are redirecting STDOUT back to your script. see if 
that's what you need.

david

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




Re: Problems with hash of hash referenzes

2002-09-20 Thread david

Theuerkorn Johannes wrote:

> Hello List,
> 
> i just got stuck with hashes, hashes of hashes and referenzes... I know i
> have to study a bit about all of that... :-( So i hope theres somebody who
> can tell me the way (or direction...) :-)
> 
> I have a mysql Table and want the values out of the table in a hash of a
> hash:
> 
> I have a timestamp in the table for each dataset and i want to be able to
> access each part of the dataset, ordered by timestamp and column name.
> Thats my Script:
> 
> #!/usr/bin/perl -w
> # Johannes Theuerkorn for use with Teres, SieMo etc
> # 06-2002 Bruchsal
> #
> 
> # strict for not making failures :-)
> use strict;
> # use DBI mod
> use DBI;
> 
> my $db = "DiREx";
> my $user = "username";
> my $pwd = "password";
> my $debug =0;
> 
> 
> # Datenbank-Verbindung aufbauen
> #my $dbh = DBI->connect( 'dbi:mysql:'.$db,$user,$pwd) ||
> my $dbh = DBI->connect( 'dbi:mysql:'.$db,$user,$pwd) ||
>  die "Can´t connect to MySQL-Server: $DBI::errstr\n";
> 
> my %test_timestamp;
> my %values;
> 
> my $sth=$dbh->prepare ("select tstamp,serial,retests,passfail from
> nt5340.board where serial='CN+/P8100672'");
> 
> $sth->execute;
> 
> while (my ($tstamp,$serial,$retests,$passfail)=$sth-> fetchrow_array){
> 
> %values=();

your problem is the above line! you have only one hash and your reference to 
it later in the code still refers to just one hash so once this is clear 
for each row, the previous content is gone so after the while loop, you 
will only see one (the last one) row in your foreach loop. if you were to 
say something like:

$test_timestamp{$tstamp} = { 
tstamp=>$tstamp,serial=>$serial,retests=>$retests,passfail=>$passfail };

i bet it will work the magic because you are creating one hash reference for 
each row instead of creating just one hash for all the rows.

david

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




Re: AW: AW: Problems with hash of hash referenzes

2002-09-20 Thread Jeff 'japhy' Pinyan

On Sep 20, Theuerkorn Johannes said:

>btw, what is the 3D thing in "$n =3D $_;" ? I saw it quite often, but
>never knew...

Your mail client doesn't like rendering certain characters.  It turns a
single apostrophe into "=B4" (that should be an equals sign followed by
"B4"), because character 0xB4 is an apostrophe.  In the same way, an
equals sign is rendered as "=3D" (an equals sign followed by "3D").

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 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: how to find memory leaks?

2002-09-20 Thread chad kellerman

Dave,

 Actually in each fork.  I was tarring up information from another
server with Net::SSH::Perl.  The full tar ball was written to stdout and
I would gzip in on the originating server.  If I did not fork each tar
the server would crash in a matter of minutes.  But with the forks I
actually contected adn grabbed tar balls from a 100 servers, 8 at a
time.

The os was solaris x86 but I find that the script runs better on Red Hat
7.3.

   I did not use top when monitoring the script I actually used 
vmstat 1

   I kinda new with perl.  The script was my first script over 200
lines.  And like I said id would crash in a under an hour with out the
forks.

   It just made sense that when that child did die the memory the child
held for the tar was released.  I actually saw memory drop real low then
after the write to disk it would jump up.

Sound right to you?  Or am I missing something?

--chad   

On Fri, 2002-09-20 at 14:07, david wrote:
> Chad Kellerman wrote:
> 
> > 
> > here's my $.02 on this subject.  Correct me if I am wrong.
> > Once perl uses memory it does not want to let it go back to the system.
> > I believe I have read the the developers are working on this.  Since you
> > have your script running as a daemon.  It will not release a lot of
> > memory back to the system, if any at all.
> 
> currently, the memory will not be released back to the OS. your OS mostly 
> likely do not support that. many langugages that handles memory management 
> internally have the same problem. in C/C++, memory management is the job of 
> the programmer but if you put your data on the stack, they won't be 
> released back to the OS until your program exit. if, however, you request 
> something from the heap, you will have the chance to relese them back to 
> the OS. that's nice because you actually release what you don't need back 
> to the OS, not just your process pool.
> 
> > 
> > I had a similar problem.  The way I worked around it is:
> > I knew where my script was eating up memory.  So at these point I fork()
> > children.  Once the child completes and dies the memory is released back
> > into the system.
> > 
> 
> i don't know if what you describle really works. when you fork, you are 
> making an exact copy of the process running. the child process will include 
> the parent process's code, data, stack etc. if the fork success, you will 
> have 2 pretty much identical process. they are not related other than the 
> parent-child relation the kernal keeps track. so if your child process 
> exit, it should release all the memory of it's own but shouldn't take 
> anything with it from it's parent. this means your child process's exit 
> should not cause your parent process's memory pool to be returned back to 
> the OS.
> 
> but you said you really see a dramatic decrease in memory consumption but if 
> you check your process's memory foot print(let say, simply look at it from 
> the top command), does it's size reduce at all?
> 
> david
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
-- 
Chad Kellerman
Jr. Systems Administrator
Alabanza Inc
410-234-3305



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


Re: Parse XML

2002-09-20 Thread david

Dermot Paikkos wrote:

> Hi,
> 
> I am trying to parse the data out of am XML file. The file is below.
> Most of the data is easily grabbed but the keywords stretch over
> several newlines and there can anywhere between 0 and 20 entries. I
> have tried using /m and /s but these don't seem to work. I have set
> $/="", I don't know if this is impacting on my attempts. But
> changing it does help either.
> 
> Here is what I am using at the moment:
> ==
> my $datafile = "news.xml";
> open(FH,$datafile)|| die "Can't open $datafile: $!\n";
> while (defined($i=)) {
> $/ = ;
> if ( $i =~ /\?xml version*/ ) {
> next;
> }
> (my $splnum) = ($i =~ / (my $title) = ($i =~ /(.*)<\/title>/);
> (my $date ) = ($i =~ /(.*)<\/date>/);
> (my $credit) = ($i =~ /(.*)<\/credit>/);
> (my $caption) = ($i =~ /(.*)<\/caption>/);
> (my $keywords) = ($i =~ /(.*)<\/keyword>/);
> chomp($splnum,$title,$date,$credit);
> print "$splnum $title $date $credit $keywords\n";
>  }
> ===
> 
> This only grabs the first keyword (NERVE FIBRE, OVERLAPPING) and I
> need them all. Also the processing seems to stop after to records
> when there are 470 in $datafile!!. I can't work that out either.
> 
> Any ideas? There are a lot of xml modules out there butI don't know if
> any would help.
> Thanx.
> Dp.
> 
> 
> === news.xml 
> 
> 
> 
> Coloured SEM of two overlapping nerve fibres
> 09-Jul-98
> CREDIT: JUERGEN BERGER, MAX-PLANCK
> INSTITUTE/SCIENCE PHOTO LIBRARY
> CREDIT: JUERGEN BERGER, MAX-PLANCK INSTITUTE/
> SCIENCE PHOTO LIBRARY Nerve fibres. Coloured scanning electron
> micrograph (SEM) of overlapping nerve fibres. Each fibre is made up
> of several individual axons. An axon is a long extension from a nerve
> cell (or neurone) which is the main output process of the cell. Some
> small neurone cell bodies (rounded) can be seen here alongside the
> axons. Nerve fibres rapidly relay signals between the central nervous
> system (the brain and spinal cord) and muscles and organs in the
> body. This allows the body to react quickly to any situation.
> Magnification unknown.
> 
> NERVE FIBRE, OVERLAPPING
> AXON, NERVE FIBRE, OVERLAPPING
> FIBRE, NERVE, OVERLAPPING
> NERVE CELL, WITH FIBRES
> NEURONE, WITH NERVE FIBRES
> HUMAN BODY, ANATOMY, NERVOUS
> SYSTEM, NERVE FIBRE, FIBRES
> 
> 
> 
> ~~
> Dermot Paikkos * [EMAIL PROTECTED]
> Network Administrator @ Science Photo Library
> Phone: 0207 432 1100 * Fax: 0207 286 8668

trying to do this with a reg. expression is unwise. there are a number of 
module out there that can help you quickly find what you need in a XML 
file. one of those module is XML::Parser. you can use it like:

#!/usr/bin/perl -w
use strict;
use XML::Parser;

my $kw = 0;
my $kws = '';
my $xml = new XML::Parser(Handlers => {Start => \&start, 
   End => \&end, 
   Char => \&string});
open(XML,'your.xml') || die $!;
$xml->parse(*XML);
close(XML);

sub start{
$kw = 1 if($_[1] eq 'keyword');
}

sub end{
if($_[1] eq 'keyword'){
print "get one keyword: $kws\n";
$kws = '';
$kw = 0;
}
}

sub string{
$kws .= $_[1] if($kw && $_[1] =~ /\S/);
}

__END__

the above only extract things inside the  tag from the XML file. 
but you can apply the same technique to the other tags. i didn't really 
teset the above but hope that should give you something to look into.

much easier than writing tons of reg. exp. right? :-)

david

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




Re: Mail::Send

2002-09-20 Thread david

Tom Allison wrote:

> I was trying to use the Mail::Send module for shipping out some
> email, but I'm getting nothing.
> 
> No errors, event with lots of die opportunities.
> No logs registering an attempt.
> 
> Nothing.
> 
> help?

any code? maybe you are using the module in a wrong way? maybe your mail 
server is down? a lot of guess but no answer unless you provide something 
for us to check.

david

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




RE: how to find memory leaks?

2002-09-20 Thread david

Chad Kellerman wrote:

> 
> here's my $.02 on this subject.  Correct me if I am wrong.
> Once perl uses memory it does not want to let it go back to the system.
> I believe I have read the the developers are working on this.  Since you
> have your script running as a daemon.  It will not release a lot of
> memory back to the system, if any at all.

currently, the memory will not be released back to the OS. your OS mostly 
likely do not support that. many langugages that handles memory management 
internally have the same problem. in C/C++, memory management is the job of 
the programmer but if you put your data on the stack, they won't be 
released back to the OS until your program exit. if, however, you request 
something from the heap, you will have the chance to relese them back to 
the OS. that's nice because you actually release what you don't need back 
to the OS, not just your process pool.

> 
> I had a similar problem.  The way I worked around it is:
> I knew where my script was eating up memory.  So at these point I fork()
> children.  Once the child completes and dies the memory is released back
> into the system.
> 

i don't know if what you describle really works. when you fork, you are 
making an exact copy of the process running. the child process will include 
the parent process's code, data, stack etc. if the fork success, you will 
have 2 pretty much identical process. they are not related other than the 
parent-child relation the kernal keeps track. so if your child process 
exit, it should release all the memory of it's own but shouldn't take 
anything with it from it's parent. this means your child process's exit 
should not cause your parent process's memory pool to be returned back to 
the OS.

but you said you really see a dramatic decrease in memory consumption but if 
you check your process's memory foot print(let say, simply look at it from 
the top command), does it's size reduce at all?

david

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




AW: AW: Problems with hash of hash referenzes

2002-09-20 Thread Theuerkorn Johannes

I guess i DO understand now! Thats really cool, was wondering about that for quite a 
while... I i did understand it right, i have a new scope inside the loop, but if i 
roll through the array, or hash i alwas!! refer to the variable defined in the main 
program, right? 

Nice of you! It´s been a real Help! 

btw, what is the 3D thing in "$n =3D $_;" ? I saw it quite often, but never knew...

If you can describe it to me, you are my "king of the week" and i won´t bother you 
again...

Greets Johannes

p.s.: have a nice weekend!

On Sep 20, Theuerkorn Johannes said:

>wow, it=B4s been only the my %values declared outside the loop... But why
>has it to be declared inside, i thougt its "global" if I use it outside?
>Isn,t it?

The problem is with using a reference to %values.

Here's an example:

  my ($n, @list);

  for (1, 2, 3, 4) {
$n =3D $_;
push @list, \$n;
  }

  for (@list) {
print "$$_ ";  # prints 4 4 4 4
  }

The reasons each element of @list holds the SAME reference is because
they're ALL references to the SAME $n.  If you move the declaration of $n
into the loop, Perl will allocate a new $n each time:

  my @list;

  for (1, 2, 3, 4) {
my $n =3D $_;
push @list, \$n;
  }

  for (@list) {
print "$$_ ";  # prints 1 2 3 4
  }

--=20
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 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]




Problems with hash of hash referenzes

2002-09-20 Thread Theuerkorn Johannes

Hi Japhy,

wow, it´s been only the my %values declared outside the loop... But why has it to be 
declared inside, i thougt its "global" if I use it outside? Isn,t it?

The Solution without %values at all is also pretty cool! Thanks!

>my %values = ( tstamp => $tstamp, ... );

This seems to be also OK like my %values=( tstamp=>$tstamp,... ); since the script 
works if I change only the declaration inside the loop... But I am not shure so I ´ll 
change it.

If the DBI offers that out off the box i don´t know, always used fetchrow_array... 
I´ll have a look at it...

Thank you so far... 

Johannes

>i just got stuck with hashes, hashes of hashes and referenzes... I know i
>have to study a bit about all of that... :-( So i hope theres somebody
>who can tell me the way (or direction...) :-)

>my %values;

This should be declared INSIDE the while loop below:

>while (my ($tstamp,$serial,$retests,$passfail)=$sth-> fetchrow_array){

>  %values=();
>  %values=(tstamp=>$tstamp,serial=>$serial,retests=>$retests,passfail=>$passfail);

This should read:

  my %values = ( tstamp => $tstamp, ... );

>  print "$values{tstamp} $values{serial} $values{retests} $values{passfail}\n";
>  $test_timestamp{$tstamp}=\%values;
>  print "$test_timestamp{$tstamp}{tstamp}\n";
>}

In fact, you can do without %values at all:

  $test_timestamp{$tstamp} = {
tstamp => $tstamp,
serial => $serial,
...,
  };

But doesn't DBI over a fetchrow_hashref method that basically DOES this?

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 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: Breaking up a large source file into several pieces

2002-09-20 Thread drieux


On Friday, Sep 20, 2002, at 05:50 US/Pacific, Cricker wrote:
[..]
> So what I was thinking of doing was something like:
>
> my ($a,$b);
>
> # main code
> ...
>
> #include "subs1.pl"
> ...
>
> where code in subs1.pl made reference to $a and $b.  I realize that I 
> can do
> this with globals.  So that's what I'll do.

As an initial solution - I think that would work.

you may want to think about

http://perl.plover.com/FAQs/Namespaces.html

and that in the longer run having a clean API for your subs
that do not rely upon global side effects will be simpler to
maintain... I concede that there are a lot of times when one
needs to have functions that cause a global side effect - such
as signal handlers

my $run_flag = 1;
$SIG{HUP} = sub { $run_flag = 0};

while($run_flag) {
# do our main loop
}

Which I think is one of the rules that I general use about
deciding if a given function needs/can/should_be moved into
a perl module...

ciao
drieux

---


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




RE: Redirecting output

2002-09-20 Thread Bob Showalter

> -Original Message-
> From: Jason Frisvold [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 20, 2002 11:52 AM
> To: [EMAIL PROTECTED]
> Subject: Redirecting output
> 
> 
> Is there a way to redirect all the output (anything printed by the
> program itself and any error output) back into the program so the
> program can handle it?
> 
> I'd like to be able to redirect it to itself so if there are 
> any errors
> or unexpected output during a cron job, it'll all get mailed to me...
> 
> Make sense?

cron will mail you the standard output of the command. To get the errors to,
you normally just dup stderr onto stdout:

   myscript 2>&1

I don't know what you mean by "redirect it to itself"

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




Re: Installing DBD::mysql without installing mysql on local machine

2002-09-20 Thread Jason Frisvold

If you use the RPM's, then you should be able to just install the client
and shared rpm's ...  I believe they have the needed files.

On Fri, 2002-09-20 at 06:04, Priss wrote:
> Hi,
> 
> Wonder if someone could help me, I am trying to
> install DBD::mysql module to access a remote mysql
> database.  I am getting errors when running
> Makefile.PL:
> 
> Can't exec "mysql_config": No such file or directory
> at Makefile.PL line 169.
> 
> I think I need to download some libraries?  Do you
> know where I can get them? The version of
> mysql installed on the remote machine is 3.22.25.
> 
> Many thanks in advance.
> 
> Priss
> 
> __
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
-- 
---
Jason 'XenoPhage' Frisvold
Senior ATM Engineer
Penteledata Engineering
[EMAIL PROTECTED]
RedHat Certified - RHCE # 807302349405893
---
"Something mysterious is formed, born in the silent void. Waiting alone
and unmoving, it is at once still and yet in constant motion. It is the
source of all programs. I do not know its name, so I will call it the
Tao of Programming."


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




Redirecting output

2002-09-20 Thread Jason Frisvold

Is there a way to redirect all the output (anything printed by the
program itself and any error output) back into the program so the
program can handle it?

I'd like to be able to redirect it to itself so if there are any errors
or unexpected output during a cron job, it'll all get mailed to me...

Make sense?

-- 
---
Jason 'XenoPhage' Frisvold
Senior ATM Engineer
Penteledata Engineering
[EMAIL PROTECTED]
RedHat Certified - RHCE # 807302349405893
---
"Something mysterious is formed, born in the silent void. Waiting alone
and unmoving, it is at once still and yet in constant motion. It is the
source of all programs. I do not know its name, so I will call it the
Tao of Programming."


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




RE: Time change

2002-09-20 Thread Bob Showalter

> -Original Message-
> From: Johnson, Fred [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 20, 2002 10:13 AM
> To: [EMAIL PROTECTED]
> Subject: Time change
> 
> 
> Hello all,
>   I am working on a script to monitor the size of a 
> particular file and the time stamp of the file. My objective 
> is to alert some individuals via email when the file reaches 
> a certain size and/or when the time stamp of the file does 
> not match the current time. I'm stuck on how I can test for 
> the time stamp. I have been looking at the file test 
> operators, specifically, the -M. Some suggestions would be helpful.

What's the specific question?

  (stat $logFile)[9] gives the mtime for the file, in epoch seconds
  time() gives the current time, in epoch seconds

If those two are equal, the file time stamp matches the current time. But
that seems an odd thing to check for.

-M will subtract the mtime of the file from $^T, which is the value of
time() when your script started (unless you set $^T yourself to something
else). This value is then converted to *days*. This makes it quick to see if
a file is older than 30 days, for example:

   print "Old file" if -M $file > 30;

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




Re: file execution from a perl file

2002-09-20 Thread zentara

On Thu, 19 Sep 2002 15:01:08 +0200, [EMAIL PROTECTED] (Willem
Pretorius) wrote:

>ok, now i have gotten the file to be executed from shell if i type : perl
>myfile.pl , and it work perfectly, but now, if i try and execute the same
>file from the web, i get the 'internal server error'.. what can be causing
>this, why, and how do i fix it?

In addition to what David has said, you also need to remember that when
running a cgi script, you are user "wwwrun" or "nobody". You are NOT
the same user as when running from the commandline. So scripts will
fail if you try to open or write files without the right permissions.


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




Re: Removing duplicate entries from an array

2002-09-20 Thread Robin Cragg

How about..

   if(/\[(\d+\.\d+\.\d+\.\d+)\].+reject=550/) {
 $IP{$1}++;
}

the your array of unique IPs is just keys %IP


R

At 14:14 20/09/2002 +0100, Griggs Rob wrote:
>Hi All,
>
>Whats the easiest way to remove duplicate entries from an array. Below is a
>script that removes ip addresses from a log file and adds them to an array.
>I then check the array to see if the value is already present and if it is i
>set a flag($exists) and then push that value into the array if $exists is
>false.
>
>Is there an easier way?
>
>_START_
>
>open(ADD_FIRE,"+
>open(LOG,"/var/log/testlog") || die "Unable to open file\n";
>
> while() {
> chomp;
> $exists = 0;
>
> if(/\[(\d+\.\d+\.\d+\.\d+)\].+reject=550/) {
> $address = $1;
> foreach(@ipadds) {
> $exists = 1 if($_ eq $address);
>
>}
> push(@ipadds,$address) if !$exists;
>
>}
>}
>close(LOG);
>close(ADD_FIRE);
>
> foreach(@ipadds) {
> print "$_\n";
>}
>
>___END___
>
>
>--
>Email Disclaimer can be viewed at:
>http://www.netscalibur.co.uk/email.html
>--
>
>--
>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]




Time change

2002-09-20 Thread Johnson, Fred

Hello all,
I am working on a script to monitor the size of a particular file and the time 
stamp of the file. My objective is to alert some individuals via email when the file 
reaches a certain size and/or when the time stamp of the file does not match the 
current time. I'm stuck on how I can test for the time stamp. I have been looking at 
the file test operators, specifically, the -M. Some suggestions would be helpful.

#!/opt/bin/perl -w
#
## @(#) Checks event.log file for size and reports if file execeeds 1.5GB limit
#
use strict;
#my $now = localtime;
my $now = time();
my $logFile = "/var/adm/snm/event.log";
my $logSize = (stat($logFile))[7];
my $readtime = (stat($logFile))[9];
my $compareTime = scalar(localtime($readtime));

if ( $logSize > 1538118232 ) {
$sendmail = "/usr/lib/sendmail";
open(EMAIL, "| $sendmail -t") || die "Failed to open pipe";
print EMAIL "Importance: high\n";
print EMAIL "X-Priority: 1\n";
print EMAIL "X-Message-Flag: For Your Information\n";
print EMAIL "Content-Type: text/html\n";
 print EMAIL "From:root\n";
print EMAIL "To: "email address"\n";
print EMAIL "To: "email address"\n";
print EMAIL "Subject: Event.log file has exceeded the 1.5GB 
limit \n";
close(EMAIL);
  }
exit;


Fred Johnson
Systems Engineer
Storagenetworks
225 Wyman Street
Waltham, MA
(781)622-6425(o)
(781)983-1170(m)
[EMAIL PROTECTED]


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




Re: Problems with hash of hash referenzes

2002-09-20 Thread Jeff 'japhy' Pinyan

On Sep 20, Theuerkorn Johannes said:

>i just got stuck with hashes, hashes of hashes and referenzes... I know i
>have to study a bit about all of that... :-( So i hope theres somebody
>who can tell me the way (or direction...) :-)

>my %values;

This should be declared INSIDE the while loop below:

>while (my ($tstamp,$serial,$retests,$passfail)=$sth-> fetchrow_array){

>  %values=();
>  %values=(tstamp=>$tstamp,serial=>$serial,retests=>$retests,passfail=>$passfail);

This should read:

  my %values = ( tstamp => $tstamp, ... );

>  print "$values{tstamp} $values{serial} $values{retests} $values{passfail}\n";
>  $test_timestamp{$tstamp}=\%values;
>  print "$test_timestamp{$tstamp}{tstamp}\n";
>}

In fact, you can do without %values at all:

  $test_timestamp{$tstamp} = {
tstamp => $tstamp,
serial => $serial,
...,
  };

But doesn't DBI over a fetchrow_hashref method that basically DOES this?

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 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: regex and ip address extraction

2002-09-20 Thread Dharmender Rai

try out 
 (\d+\.){3}(\d+)
but it won't take CIDR addresses and will not check
the validity of the addresses.



 --- Griggs Rob <[EMAIL PROTECTED]> wrote:
> Hi Guys,
> 
> The code below extracts an ip address from the
> /var/log/maillog file in the
> event of the line containing the words "reject=550".
> It works fine, but is
> there a way of shortening that regular expression?
> 
> open(LOG,"/var/log/maillog");
> 
> while() {
> chomp;
> if($_ =~ /reject=550/) {
> 
> if($_ =~ /\[(\d+\.\d+\.\d+\.\d+)\]/)
> {
> $address = $1;
> 
> # Add address to firewall filtering here
>  }
> 
>   }
> 
> }
> close(LOG);
> 
> 
> Thanks
> 
> Rob
> 
> 
> -- 
> Email Disclaimer can be viewed at: 
> http://www.netscalibur.co.uk/email.html 
> --
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>  

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

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




Re: Removing duplicate entries from an array

2002-09-20 Thread Sudarshan Raghavan

On Fri, 20 Sep 2002, Griggs Rob wrote:

> Hi All,
> 
> Whats the easiest way to remove duplicate entries from an array. Below is a
> script that removes ip addresses from a log file and adds them to an array.
> I then check the array to see if the value is already present and if it is i
> set a flag($exists) and then push that value into the array if $exists is
> false.
> 
> Is there an easier way? 

This is a faq
perldoc -q 'How can I remove duplicate elements from a list or array?'


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




Removing duplicate entries from an array

2002-09-20 Thread Griggs Rob

Hi All,

Whats the easiest way to remove duplicate entries from an array. Below is a
script that removes ip addresses from a log file and adds them to an array.
I then check the array to see if the value is already present and if it is i
set a flag($exists) and then push that value into the array if $exists is
false.

Is there an easier way? 

_START_

open(ADD_FIRE,"+) {
chomp;
$exists = 0;

if(/\[(\d+\.\d+\.\d+\.\d+)\].+reject=550/) {
$address = $1;
foreach(@ipadds) {
$exists = 1 if($_ eq $address);

}
push(@ipadds,$address) if !$exists;

}
}
close(LOG);
close(ADD_FIRE);

foreach(@ipadds) {
print "$_\n";
}

___END___


-- 
Email Disclaimer can be viewed at: 
http://www.netscalibur.co.uk/email.html 
--

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




Problems with hash of hash referenzes

2002-09-20 Thread Theuerkorn Johannes

Hello List,

i just got stuck with hashes, hashes of hashes and referenzes... I know i have to 
study a bit about all of that... :-( So i hope theres somebody who can tell me the way 
(or direction...) :-)

I have a mysql Table and want the values out of the table in a hash of a hash:

I have a timestamp in the table for each dataset and i want to be able to access each 
part of the dataset, ordered by timestamp and column name. Thats my Script:

#!/usr/bin/perl -w
# Johannes Theuerkorn for use with Teres, SieMo etc
# 06-2002 Bruchsal
#

# strict for not making failures :-)
use strict;
# use DBI mod
use DBI;

my $db = "DiREx";
my $user = "username";
my $pwd = "password";
my $debug =0;


# Datenbank-Verbindung aufbauen
#my $dbh = DBI->connect( 'dbi:mysql:'.$db,$user,$pwd) ||
my $dbh = DBI->connect( 'dbi:mysql:'.$db,$user,$pwd) ||
 die "Can´t connect to MySQL-Server: $DBI::errstr\n";

my %test_timestamp;
my %values;

my $sth=$dbh->prepare ("select tstamp,serial,retests,passfail from nt5340.board where 
serial='CN+/P8100672'");

$sth->execute;

while (my ($tstamp,$serial,$retests,$passfail)=$sth-> fetchrow_array){

%values=();

%values=(tstamp=>$tstamp,serial=>$serial,retests=>$retests,passfail=>$passfail);

print "$values{tstamp} $values{serial} $values{retests} $values{passfail}\n";

$test_timestamp{$tstamp}=\%values;

print "$test_timestamp{$tstamp}{tstamp}\n";
}

foreach my $keys (keys %test_timestamp){
print "$keys\n";
print "$test_timestamp{$keys}{tstamp}\n";
print "$test_timestamp{$keys}{serial}\n";
print "$test_timestamp{$keys}{retests}\n";
print "$test_timestamp{$keys}{passfail}\n";

}
$sth->finish;
$dbh->disconnect;


This works so far, in the while fetchrow_array Loop it prints the values it should, 
but later in the foreach loop it only prints the last entry from the Database.
Wheres that error from and how can I get rid of it?

Greets Johannes

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




Re: Breaking up a large source file into several pieces

2002-09-20 Thread Cricker

Yes, I think I'm clear on this; at least I hope so after banging my head
against Programming Perl 3.  Globals are dynamically-scoped whereis lexicals
only exist in the file where they are declared with my.  Page 57 says:

"Because the file is the largest possible lexical scope, a lexically-scoped
variable can never be visible outside the file in which it's declared. File
scopes do not nest".

So what I was thinking of doing was something like:

my ($a,$b);

# main code
...

#include "subs1.pl"
...

where code in subs1.pl made reference to $a and $b.  I realize that I can do
this with globals.  So that's what I'll do.

"Michael Fowler" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Thu, Sep 19, 2002 at 10:33:05AM -, Cricker wrote:
> > If I may summarize -- and please correct me if this is wrong -- there is
> > indeed no way to textually include one file inside another, like
#include
> > in C.
>
> As I mentioned previously in this thread, C is able to share its variables
> between include files because they are global variables.  In this sense,
> Perl can do the same thing with use or require as C does with include.
>
>
> > The text file is the compilation (lexical) unit, and the only way to
> > import lexical symbols is via the module (package) mechanism.
>
> The file is indeed a new lexical scope.  However, you cannot import or
> export lexically-scoped variables (symbols isn't the appropriate term in
> this context).  You can only import and export package globals.
>
> I'm sensing some confusion between lexical and global variables.  Are you
> certain what the differences are?
>
>
> Michael
> --
> Administrator  www.shoebox.net
> Programmer, System Administrator   www.gallanttech.com
> --



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




RE: Encryption/Decryption

2002-09-20 Thread Nikola Janceski

I don't know how good the PGP module on CPAN is, but it looks promising the
last time I looked.

> -Original Message-
> From: Rob Das [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 20, 2002 8:25 AM
> To: [EMAIL PROTECTED]
> Subject: Encryption/Decryption
> 
> 
> Hi List:
> 
> Can anyone suggest a way/module to encrypt the contents of a file then
> decrypt it to get the contents back? I see many different 
> modules on CPAN,
> but wondered if anyone can recommend one. I would be doing 
> the encryption in
> one program, and the decryption in  a different program.
> 
> Any ideas would be welcome!
> 
> Thanks
> 
> Rob
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 



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


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




Encryption/Decryption

2002-09-20 Thread Rob Das

Hi List:

Can anyone suggest a way/module to encrypt the contents of a file then
decrypt it to get the contents back? I see many different modules on CPAN,
but wondered if anyone can recommend one. I would be doing the encryption in
one program, and the decryption in  a different program.

Any ideas would be welcome!

Thanks

Rob


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




Re: Parse XML

2002-09-20 Thread Jenda Krynicky

From: "Dermot Paikkos" <[EMAIL PROTECTED]>
> I am trying to parse the data out of am XML file. The file is below.
> Most of the data is easily grabbed but the keywords stretch over
> several newlines and there can anywhere between 0 and 20 entries. I
> have tried using /m and /s but these don't seem to work. I have set
> $/="", I don't know if this is impacting on my attempts. But
> changing it does help either.

It's better to use one of the modules available in CPAN than to try 
to parse XML yourself.

If the XML file is not t big I'd recommend XML::Simple. It's 
really simple.

Jenda


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


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




Re: is every sub know to a child?

2002-09-20 Thread Jenda Krynicky

From:   "Angerstein" <[EMAIL PROTECTED]>

> I have a programm build with a lot of subs.
> 
> Normally it should be possible to call every declared sub in the
> (fork) child process, right?

Yes.

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


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




Parse XML

2002-09-20 Thread Dermot Paikkos

Hi,

I am trying to parse the data out of am XML file. The file is below.
Most of the data is easily grabbed but the keywords stretch over 
several newlines and there can anywhere between 0 and 20 entries. I 
have tried using /m and /s but these don't seem to work. I have set 
$/="", I don't know if this is impacting on my attempts. But 
changing it does help either.

Here is what I am using at the moment:
==
my $datafile = "news.xml";
open(FH,$datafile)|| die "Can't open $datafile: $!\n";
while (defined($i=)) {
$/ = ;
if ( $i =~ /\?xml version*/ ) {
next;
}
(my $splnum) = ($i =~ /(.*)<\/title>/);
(my $date ) = ($i =~ /(.*)<\/date>/);
(my $credit) = ($i =~ /(.*)<\/credit>/);
(my $caption) = ($i =~ /(.*)<\/caption>/);
(my $keywords) = ($i =~ /(.*)<\/keyword>/);
chomp($splnum,$title,$date,$credit);
print "$splnum $title $date $credit $keywords\n";
 }
===

This only grabs the first keyword (NERVE FIBRE, OVERLAPPING) and I 
need them all. Also the processing seems to stop after to records 
when there are 470 in $datafile!!. I can't work that out either.

Any ideas? There are a lot of xml modules out there butI don't know if 
any would help.
Thanx.
Dp.


=== news.xml 



Coloured SEM of two overlapping nerve fibres
09-Jul-98
CREDIT: JUERGEN BERGER, MAX-PLANCK 
INSTITUTE/SCIENCE PHOTO LIBRARY
CREDIT: JUERGEN BERGER, MAX-PLANCK INSTITUTE/ 
SCIENCE PHOTO LIBRARY Nerve fibres. Coloured scanning electron 
micrograph (SEM) of overlapping nerve fibres. Each fibre is made up 
of several individual axons. An axon is a long extension from a nerve 
cell (or neurone) which is the main output process of the cell. Some 
small neurone cell bodies (rounded) can be seen here alongside the 
axons. Nerve fibres rapidly relay signals between the central nervous 
system (the brain and spinal cord) and muscles and organs in the 
body. This allows the body to react quickly to any situation. 
Magnification unknown.

NERVE FIBRE, OVERLAPPING
AXON, NERVE FIBRE, OVERLAPPING
FIBRE, NERVE, OVERLAPPING
NERVE CELL, WITH FIBRES
NEURONE, WITH NERVE FIBRES
HUMAN BODY, ANATOMY, NERVOUS
SYSTEM, NERVE FIBRE, FIBRES



~~
Dermot Paikkos * [EMAIL PROTECTED]
Network Administrator @ Science Photo Library
Phone: 0207 432 1100 * Fax: 0207 286 8668


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




reading /var/spool/mail

2002-09-20 Thread Hengky


hello guys,

the basic is i like to create my own webmail,
and read from /var/spool/mail

i've already create the script to split and etc...

but the problem is if i login as another user i cannot read from
/var/spool/mail because the permission script...

what i like to ask is...
how to change the permission of the script so when people login he can
read from /var/spool/mail ( they own mailbox )

my perl not compile with suid ( for security problem, plz understand this)

so there is another way...

pleaze send me with the sample of the script...

thx




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




Mail::Send

2002-09-20 Thread Tom Allison

I was trying to use the Mail::Send module for shipping out some 
email, but I'm getting nothing.

No errors, event with lots of die opportunities.
No logs registering an attempt.

Nothing.

help?
-- 
A mouse is an elephant built by the Japanese.


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




is every sub know to a child?

2002-09-20 Thread Angerstein

I have a programm build with a lot of subs.

Normally it should be possible to call every declared sub in the (fork)
child process, right?


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




Installing DBD::mysql without installing mysql on local machine

2002-09-20 Thread Priss

Hi,

Wonder if someone could help me, I am trying to
install DBD::mysql module to access a remote mysql
database.  I am getting errors when running
Makefile.PL:

Can't exec "mysql_config": No such file or directory
at Makefile.PL line 169.

I think I need to download some libraries?  Do you
know where I can get them? The version of
mysql installed on the remote machine is 3.22.25.

Many thanks in advance.

Priss

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

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




Re: Arg... what about $#hash $#array

2002-09-20 Thread Sudarshan Raghavan

On Sun, 22 Sep 2002, Sudarshan Raghavan wrote:

> my $hashcnt = keys(%hash) + values(%hash);

Bad! my $hashcnt = keys(%hash) * 2; should do


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




Re: Arg... what about $#hash $#array

2002-09-20 Thread Sudarshan Raghavan

On Fri, 20 Sep 2002, Angerstein wrote:

> I noticed if I want to print out the number of elements which should be
> stored in $#hash,
> but if i print it out i just get -1 !!

$#array (assuming the variable array is a perl array) will give you the 
last index of @array. For number of elements
my $arrcnt = @array;

By $#hash I assume you are trying this on a hash. Well, it will not work
Just saw your other post scalar(%hash) will not work either you will get 
a value like 3/8 or 9/16 or something like that. This will work
my $hashcnt = keys(%hash) + values(%hash);

Also you have not enabled the strict pragma, $#hash will result in a 
compilation error (i.e. if you don't have a variable @hash) if the strict
had been enabled.



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




RE: Arg... what about $#hash $#array

2002-09-20 Thread nkuipers

>scalar (@array);
>scalar (%hash);
>
>can be used to get the number of elements.

For arrays, yes.  For hashes, no.  scalar %hash produces something that looks 
like this: 3/8, which is some measure of the number of buckets used by the 
hashing algo (efficiency).

print scalar keys %hash, "\n";

will give you the number of keys.

cheers,

nathanael


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




AW: Arg... what about $#hash $#array

2002-09-20 Thread Angerstein

ok...
scalar (@array);
scalar (%hash);

can be used to get the number of elements.


> -Ursprüngliche Nachricht-
> Von: Angerstein [mailto:[EMAIL PROTECTED]]
> Gesendet am: Freitag, 20. September 2002 11:12
> An: [EMAIL PROTECTED]
> Betreff: Arg... what about $#hash $#array
>
> I noticed if I want to print out the number of elements which should be
> stored in $#hash,
> but if i print it out i just get -1 !!
>
> What else can i do???
>
>
> --
> 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]




Arg... what about $#hash $#array

2002-09-20 Thread Angerstein

I noticed if I want to print out the number of elements which should be
stored in $#hash,
but if i print it out i just get -1 !!

What else can i do???


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




RE: how to find memory leaks?

2002-09-20 Thread chad kellerman


here's my $.02 on this subject.  Correct me if I am wrong.
Once perl uses memory it does not want to let it go back to the system. 
I believe I have read the the developers are working on this.  Since you
have your script running as a daemon.  It will not release a lot of
memory back to the system, if any at all.

I had a similar problem.  The way I worked around it is:
I knew where my script was eating up memory.  So at these point I fork()
children.  Once the child completes and dies the memory is released back
into the system.

at least I saw a dramatic decrease in memory consumption.

--chad

On Fri, 2002-09-20 at 04:08, Timothy Johnson wrote:
> 
> Instead of delete()ing it, try lexically scoping your hashes using my().
> You may find that letting the data structures go out of scope releases some
> memory to be reused by perl that you were missing.
> 
> -Original Message-
> From: Angerstein [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 20, 2002 12:30 AM
> To: [EMAIL PROTECTED]
> Subject: how to find memory leaks?
> 
> 
> Hi,
> I have a deamon like programm, which runs tasks at give timestamps.
> This is in a while (1) {}  if startjobx == time loop.
> 
> Now i have the problem that one or more of my datastructures eats more and
> more memory.
> I "delete" every value after using it from my hashes or array from arrays,
> but it still not getting better. any idea?
> 
> 
> -- 
> 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]
> 
-- 
The instructions said to use windows 98 or better, so  I installed
slackware.



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


Re: use of s///

2002-09-20 Thread Robert Rendler

On Fri, 20 Sep 2002 10:02:18 +0300
"Igor Kutsyy" <[EMAIL PROTECTED]> wrote:

> My script analizes .html text were a lot of tags. I need to delete tag:  ...>. The problem is that it writen in mixed ways:("äÅÎØ" 18.09.02)
> ***ðáòô  ; ì
> äåòÉ
> ##
> 
> if I execute a command: $string=~ s/ SIZE=2>//ig; it does not delete tags like this:  because in it different words in Upper and Lowercase. So what
> can you advise me:
>   how to specify a patern to delete tag, written in Upper/Lower/Mixed way.
>   How to specify a patern to delete all font tags  and .
> 

You should really use one of the HTML::* modules for this but... s/<\/?font.*?>//gi;
--
print`$^Xdoc -qj`=~/"(.*)"/

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




RE: how to find memory leaks?

2002-09-20 Thread Timothy Johnson


Instead of delete()ing it, try lexically scoping your hashes using my().
You may find that letting the data structures go out of scope releases some
memory to be reused by perl that you were missing.

-Original Message-
From: Angerstein [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 20, 2002 12:30 AM
To: [EMAIL PROTECTED]
Subject: how to find memory leaks?


Hi,
I have a deamon like programm, which runs tasks at give timestamps.
This is in a while (1) {}  if startjobx == time loop.

Now i have the problem that one or more of my datastructures eats more and
more memory.
I "delete" every value after using it from my hashes or array from arrays,
but it still not getting better. any idea?


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




WG: how to find memory leaks?

2002-09-20 Thread Angerstein



-Ursprüngliche Nachricht-
Von: Angerstein [mailto:[EMAIL PROTECTED]]
Gesendet am: Freitag, 20. September 2002 09:30
An: [EMAIL PROTECTED]
Betreff: how to find memory leaks?

Hi,
I have a deamon like programm, which runs tasks at give timestamps.
This is in a while (1) {}  if startjobx == time loop.

Now i have the problem that one or more of my datastructures eats more and
more memory.
I "delete" every value after using it from my hashes or array from arrays,
but it still not getting better. any idea?


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




RE: use of s///

2002-09-20 Thread Timothy Johnson


Try this:

$_ =~ s///gi;

I can't test it, but in theory it should grab the shortest number of
characters starting with  irregardless of case
and replace them with nothing.

-Original Message-
From: Igor Kutsyy [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 20, 2002 12:02 AM
To: [EMAIL PROTECTED]
Subject: use of s///


My script analizes .html text were a lot of tags. I need to delete tag:
. The problem is that it writen in mixed ways:
("äÅÎØ" 18.09.02)

***ðáòô  ; ì
äåòÉ

##

if I execute a command: $string=~ s///ig; 
it does not delete tags like this:  because in it different words in Upper and Lowercase.
So what can you advise me:
  how to specify a patern to delete tag, written in Upper/Lower/Mixed way.
  How to specify a patern to delete all font tags  and .

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




how to find memory leaks?

2002-09-20 Thread Angerstein

Hi,
I have a deamon like programm, which runs tasks at give timestamps.
This is in a while (1) {}  if startjobx == time loop.

Now i have the problem that one or more of my datastructures eats more and
more memory.
I "delete" every value after using it from my hashes or array from arrays,
but it still not getting better. any idea?


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