Capturing PID of Shell Calls
I wonder if anyone has run into this issue before. I am attempting to collect the PIDs of system/backtick calls ( up to 40 of them ) and revisit them to ensure that they completed. The frontend interface is CGI but in this case that part is working fine. I cannot, however, find anything in my 15 O'Reily books or Google which includes how to do this without using a shell script to record the information. I have tried the following code to test the return values, more to appease myself than to challenge the word of the books... #!/usr/local/bin/perl -w use strict; my $command = 'ls -l /'; my $return = `$command`; my @return= `$command`; my $system_scaler = system( ls, -l, / ); my @system_array = system( ls, -l, / ); Of course, none of these ways of gathering the information actually returns the PID associated to the external call. Has anyone solved this one before? Any help or guidance would be most appreciated! - Jamie Bridges Asst. Sun Hardware Lead (V) 770.447.1951 (F) 678.291.9201 Factory warranty and license transfer policies vary by manufacturer. Purchaser is responsible for all software licensing and registration requirements imposed by the manufacturer. The information contained in this message and any attachments is confidential and intended only for the named recipient(s). If you have received this message in error, you are prohibited from copying, distributing or using the information. Please contact the sender immediately by return email and delete the original message.
perl.beginners.cgi Weekly list FAQ posting
NAME beginners-faq - FAQ for the beginners-cgi mailing list 1 - Administriva 1.1 - I'm not subscribed - how do I subscribe? Send mail to [EMAIL PROTECTED] You can also specify your subscription email address by sending email to (assuming [EMAIL PROTECTED] is your email address): [EMAIL PROTECTED]. 1.2 - How do I unsubscribe? Now, why would you want to do that? Send mail to [EMAIL PROTECTED], and wait for a response. Once you reply to the response, you'll be unsubscribed. If that doesn't work, find the email address which you are subscribed from and send an email like the following (let's assume your email is [EMAIL PROTECTED]): [EMAIL PROTECTED] 1.3 - There is too much traffic on this list. Is there a digest? Yes. To subscribe to the digest version of this list send an email to: [EMAIL PROTECTED] To unsubscribe from the digest, send an email to: [EMAIL PROTECTED] 1.4 - Is there an archive on the web? Yes, there is. It is located at: http://archive.develooper.com/beginners-cgi%40perl.org/ 1.5 - How can I get this FAQ? This document will be emailed to the list once a month, and will be available online in the archives, and at http://beginners.perl.org/ 1.6 - I don't see something in the FAQ, how can I make a suggestion? Send an email to [EMAIL PROTECTED] with your suggestion. 1.7 - Is there a supporting website for this list? Yes, there is. It is located at: http://beginners.perl.org/ 1.8 - Who do I complain to? Complaints can be sent to [EMAIL PROTECTED] 1.9 - Who currently maintains the FAQ? Kevin Meltzer, who can be reached at the email address (for FAQ suggestions only) in question 1.6 1.10 - Who will maintain peace and flow on the list? Casey West, Kevin Meltzer and Ask Bjoern Hansen currently carry large, yet padded, clue-sticks to maintain peace and order on the list. If you are privately emailed by one of these folks for flaming, being off-topic, etc... please listen to what they say. If you see a message sent to the list by one of these people saying that a thread is closed, do not continue to post to the list on that thread! If you do, you will not only meet face to face with a XQJ-37 nuclear powered pansexual roto-plooker, but you may also be taken off of the list. These people simply want to make sure the list stays topical, and above-all, useful to Perl/CGI beginners. 1.11 - When was this FAQ last updated? Feb 04, 2004 2 - Questions about the 'beginners-cgi' list. 2.1 - What is the list for? A list for beginning Perl programmers to ask questions in a friendly atmosphere. The topic of the list is, of course, CGI with Perl. 2.2 - What is this list _not_ for? * SPAM * Homework * Solicitation * Things that aren't Perl related * Non Perl/CGI questions or issues * Lemurs 2.3 - Are there any rules? Yes. As with most communities, there are rules. Not many, and ones that shouldn't need to be mentioned, but they are. * Be nice * No flaming * Have fun 2.4 - What topics are allowed on this list? Basically, if it has to do with Perl/CGI , then it is allowed. If your question has nothing at all to do with Perl/CGI, it will likely be ignored. 2.5 - I want to help, what should I do? Subscribe to the list! If you see a question which you can give an idiomatic and Good answer to, answer away! If you do not know the answer, wait for someone to answer, and learn a little. 2.6 - Is there anything I should keep in mind while answering? We don't want to see 'RTFM'. That isn't very helpful. Instead, guide the beginner to the place in the FM they should R :) 2.7 - I don't want to post a question if it is in an FAQ. Where should I look first? Look in the FAQ! Get acquainted with the 'perldoc' utility, and use it. It can save everyone time if you look in the Perl FAQs first, instead of having a list of people refer you to the Perl FAQs :) You can learn about 'perldoc' by typing: perldoc perldoc At your command prompt. You can also view documentation online at: http://www.perldoc.com and http://www.perl.com 3 - Other Resources 3.1 - What other websites may be useful to a beginner ? * Perl.org - http://www.perl.org * Perl Home Page - http://www.perl.com * PerlMonks - http://www.perlmonks.org * Perldoc - http://www.perldoc.com * Perl Archives - http://www.perlarchives.com * NMS Archive - http://nms-cgi.sourceforge.net/ * Unofficial Perl Beginners' Site - http://perl-begin.berlios.de 3.2 - What resources may be harmful to a beginner? Beware of Perl4-like code-- You might find some script archives and unauthorized mirrors with old Perl4 versions of Selena Sol and Matt Wright scripts. Don't use those scripts. They are outdated and may even in some cases
RE: Capturing PID of Shell Calls
Jamie Bridges wrote: I am attempting to collect the PIDs of system/backtick calls ( up to 40 of them ) and revisit them to ensure that they completed. Both system() and backticks call wait() internally, so they don't return until the child process terminates. If you want to start a process and let it run without waiting for it, you need to use fork() and exec(). fork() returns the PID of the created process. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Capturing PID of Shell Calls
--- Jamie Bridges [EMAIL PROTECTED] wrote: I am attempting to collect the PIDs of system/backtick calls ( up to 40 of them ) and revisit them to ensure that they completed. The frontend interface is CGI but in this case that part is working fine. I cannot, however, find anything in my 15 O'Reily books or Google which includes how to do this without using a shell script to record the information. :) You should study CPAN more - http://search.cpan.org/search?query=PIDmode=all This issue HAS come up before and there are solutions (also as per Bob's posting regarding fork, et al.) Perl and Unix have been hand-in-hand for a long time -- take advantage of this. -Sx- = -Sx- seeking employment: http://youve-reached-the.endoftheinternet.org/ __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
CGI::Session
Could anyone provide a working example of a simple script that uses use CGI::Session; I've tried playing with the examples at: http://search.cpan.org/~sherzodr/CGI-Session-3.95/Session/Tutorial.pm And either they are way out of date or I'm just a complete dufus... I got errors starting with this line in my test script: use CGI::Session; So I tried installing it with cpan using this line: cpan install CGI:Session And got this error: Warning: Cannot install CGI:Session, don't know what it is. So I tried using this in my script instead: use CGI-Session; The error went away but I can't seem to make any headway. I'd send my test script but none of it is working and I don't think it'd help much because it's based on the docs that are not up-to-date (or I'm just a complete dufus...) Thanks, Bill Stephenson -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: :Session
It looks like in your install command, you have only a single colon between CGI and Session. Try 'install CGI::Session'. At least one of the examples worked for me in the recent past. Sean -Original Message- From: Bill Stephenson To: [EMAIL PROTECTED] Sent: 10/11/2004 1:03 PM Subject: CGI::Session Could anyone provide a working example of a simple script that uses use CGI::Session; I've tried playing with the examples at: http://search.cpan.org/~sherzodr/CGI-Session-3.95/Session/Tutorial.pm And either they are way out of date or I'm just a complete dufus... I got errors starting with this line in my test script: use CGI::Session; So I tried installing it with cpan using this line: cpan install CGI:Session And got this error: Warning: Cannot install CGI:Session, don't know what it is. So I tried using this in my script instead: use CGI-Session; The error went away but I can't seem to make any headway. I'd send my test script but none of it is working and I don't think it'd help much because it's based on the docs that are not up-to-date (or I'm just a complete dufus...) Thanks, Bill Stephenson -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: CGI::Session
On Mon, 11 Oct 2004 12:03:27 -0500 Bill Stephenson [EMAIL PROTECTED] wrote: So I tried installing it with cpan using this line: cpan install CGI:Session maybe try install CGI::Session -- -- Owen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: I'm confused: where are the commas for map and sort
On Sun, 10 Oct 2004 14:30:32 -0600, Siegfried Heintze [EMAIL PROTECTED] wrote: The map and the sort statements are strange. Why don't they require a comma between the first and second arguments? They are not special, they are just using a special semantic built into perl. Consider the following: sub iterate(@) { my $code = shift; $code for @_; } @data = ( jack, jill, jenny ); iterate { print Hello $_\n } @data The iterate function takes a CODE reference and an ARRAY of stuff (same as MAP and GREP and SORT). It will then blindly iterate over the array of stuff and invoke the code for each element. The basic rule is, a BLOCK OF CODE does not require a comma after it, because it is self-enclosing (ie, it has braces). Consider then, that since 'map {xx} @data' is actually parsing {xx} as a code reference, the same way 'my $prog = { some code}' does, you can also do sub sortfilter($$){ stuff } sort \sortfilter, @data or even sub special_sort(@) { my $sort_func = shift; sort $sort_func, @_ } You should probably read more on anonymous subroutines and code blocks. (and even closures). Cheers. David Thanks, Siegfried -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Course material for perl training
Sorry for being OT here Is there any good course material for a perl crash course. I am supposed to take training in perl and prepare a syllabus , with exercises Thanks Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
why can't getstore function overwrite the existing file?
Hello: I have encounter a very strange problem. I have the following script: use LWP::Simple; use URI; $base_url=http://finance.yahoo.com;; $filename=finance.htm; while(1) { my $status=getstore($based_url,$filename); if(is_success($status)){ print good\n; } else { print bad\n; } sleep 300; } So this scipt is supposed to fetch the newest finance.yahoo.com webpage every five minutes and store it. But everytime I started it,waited for several hours and stopped it later, the stored finance.htm is always the the first time captured file. What is wrong with my scipt?(I run it at freebas platform) Thank you very much in advance! Franklin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Line replace
Hello I should comment out lines in a text file. I have a lot of troubles to realize this. The lines Alpha(a, b, c) should be changed to # Alpha(a, b, c) What I would like to write is a small perl script to make this convetion. Thanks Urs -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: why can't getstore function overwrite the existing file?
you have using $based_url variable in my $status=getstore($based_url,$filename); but you have declare $base_url it's always better using 'use strict' and warnings pragma... -Original Message- From: Franklin [mailto:[EMAIL PROTECTED] Sent: Monday, October 11, 2004 3:18 PM To: [EMAIL PROTECTED] Subject: why can't getstore function overwrite the existing file? Hello: I have encounter a very strange problem. I have the following script: use LWP::Simple; use URI; $base_url=http://finance.yahoo.com;; $filename=finance.htm; while(1) { my $status=getstore($based_url,$filename); if(is_success($status)){ print good\n; } else { print bad\n; } sleep 300; } So this scipt is supposed to fetch the newest finance.yahoo.com webpage every five minutes and store it. But everytime I started it,waited for several hours and stopped it later, the stored finance.htm is always the the first time captured file. What is wrong with my scipt?(I run it at freebas platform) Thank you very much in advance! Franklin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Line replace
On Mon, 2004-10-11 at 16:23, Urs Wagner wrote: Hello I should comment out lines in a text file. I have a lot of troubles to realize this. The lines Alpha(a, b, c) should be changed to # Alpha(a, b, c) perl -pli.BAK -e 's/(?=.*Alpha\(a, b ,c\))/#/' FILENAME HTH Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Line replace
Good one liner I appreciate it .. Arjun -Original Message- From: Ramprasad A Padmanabhan [mailto:[EMAIL PROTECTED] Sent: Monday, October 11, 2004 4:41 PM To: Urs Wagner Cc: perl beginners Subject: Re: Line replace On Mon, 2004-10-11 at 16:23, Urs Wagner wrote: Hello I should comment out lines in a text file. I have a lot of troubles to realize this. The lines Alpha(a, b, c) should be changed to # Alpha(a, b, c) perl -pli.BAK -e 's/(?=.*Alpha\(a, b ,c\))/#/' FILENAME HTH Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Line replace
Hai ! Open the file with any file handler and use regular expression.. This way it will work. Open (File handler name ,file name); While ( $string=filehandler) { if ( $string = ~ /^Alpha\(a,b,c\)/ ) { $string = # . $string ; print file handler $string ; } } Arjun -Original Message- From: Urs Wagner [mailto:[EMAIL PROTECTED] Sent: Monday, October 11, 2004 4:24 PM To: [EMAIL PROTECTED] Subject: Line replace Hello I should comment out lines in a text file. I have a lot of troubles to realize this. The lines Alpha(a, b, c) should be changed to # Alpha(a, b, c) What I would like to write is a small perl script to make this convetion. Thanks Urs -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Can do in 1 while loop?
On Mon, 2004-10-11 at 06:26, loan tran wrote: Hello Perl Gurus, I wrote a script to search for log suspends and bloking processes in a text file and send me email if it find either of them. My codes below work but it's not efficent. As you can see I open the file and go to while loop twice. Can someone suggest a better way? Thanks. (attached is the text file i open to search.) Below is my codes: #!/bin/perl -w require /home/sybase/tranl/pl/global.pl; ## Search for blocking process open (FILE,$whodo_out) or die (Cannot open file: $!); while (my $line =FILE){ chomp($line); $line =~ s/^\s+//; next if ($line =~ /^\D/); my $blk = substr($line,40,3); print $blk \n; if ($blk != 0){ print 'Alert! Blocking processes'; system(/usr/bin/mailx -s 'Alert Blocking Process' $receipients $whodo_out); } print \n $suspend \n; #exit ; }#end while close (FILE); # Search for LOG SUSPEND process open (FILE,$whodo_out) or die (Cannot open file: $!); while (my $line =FILE){ chomp($line); $line =~ s/^\s+//; next if ($line =~ /^\D/); my $log_suspend = substr($line,70,11); print $log_suspend \n; if ($log_suspend eq 'LOG SUSPEND'){ print 'Alert! LOG SUSPEND processes'; system(/usr/bin/mailx -s 'Alert LOG SUSPEND Process' $receipients $whodo_out); } }#end while close FILE; ## I am not able to get it ? Why cant you put This inside your first while loop my $log_suspend = substr($line,70,11); print $log_suspend \n; if ($log_suspend eq 'LOG SUSPEND'){ print 'Alert! LOG SUSPEND processes'; system(/usr/bin/mailx -s 'Alert LOG SUSPEND Process' $receipients $whodo_out); } Probably after print \n $suspend \n; Bye Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Line replace
On Mon, 11 Oct 2004, Ramprasad A Padmanabhan wrote: On Mon, 2004-10-11 at 16:23, Urs Wagner wrote: I should comment out lines in a text file. I have a lot of troubles to realize this. The lines Alpha(a, b, c) should be changed to # Alpha(a, b, c) perl -pli.BAK -e 's/(?=.*Alpha\(a, b ,c\))/#/' FILENAME Knowing how to do this in Perl is, of course, a very useful thing. In this case though, it would also be useful to know how to do this in your text editor. In vi/Vim, for example, you can do a -- :%s/\(Alpha(a, b, c)\)/# \1/gc -- and this will find every instance of the string [1], show you each instance as it is found, and ask for you to confirm the change. If it looks right when the command finishes, save the file as normal. I know Emacs can do this about as efficiently, but I'm not an Emacs user so I'm not sure how to go about it. Editors like BBEdit, UltraEdit, and even Microsoft Write / WordPad have ways to get similar results, though it may be by way of simple replace rather than a full regular expression match substitution. In this case, that's okay -- you can work with literal strings here -- but using an editor that can do full regex search replace is very useful. It's worth using such an editor and getting comfortable with how it works. [1] Every instance includes multiple instances on the same line, which may or may not be what you want; take out the 'g' at the end of the command if you only want to match the first one. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: why can't getstore function overwrite the existing file?
Franklin wrote: Hello: Hello, I have encounter a very strange problem. I have the following script: always always always use strict; use warnings; use LWP::Simple; use URI; $base_url=http://finance.yahoo.com;; $filename=finance.htm; my $base_url ... my $filename ... since theirs no interpolation (IE no vars) use single quotes, its faster. while(1) { my $status=getstore($based_url,$filename); if(is_success($status)){ print good\n; } else { print bad\n; } sleep 300; } Also better indentation makes it tons more readable. So this scipt is supposed to fetch the newest finance.yahoo.com webpage every five minutes and store it. But everytime I started it,waited for several hours and stopped it later, the stored finance.htm is always the the first time captured file. What is wrong with my scipt?(I run it at freebas platform) Thank you very much in advance! Franklin #!/usr/bin/perl use strict; use warnings; use LWP::Simple; use URI; my $base_url ='http://finance.yahoo.com'; my $filename ='finance.htm'; while(1) { unlink $filename or die $!; # maybe copy the file and if it fails copy it back and if its ok remove the copy instead my $status = getstore($based_url,$filename); print is_success($status) ? good\n : bad\n; sleep(300); # or cron it every 5 minutes instead } since $status is only usedonce you could do: print is_success( getstore($based_url,$filename) ) ? good\n : bad\n; HTH :) Lee.M - JupiterHost.Net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
trying to create a daemon
Hi all, I am a relative newbie and I need to write a small web server load tester. I know there are many tools out there, but I would like to write a simple script that can login to a webserver, connect to port (whatever port number i give it) and do a 'wget https://blah.blah.com :9091. While the first part is quite easy, ie writing a perl script to do a wget from the server, creating this as a daemon, running many processes simultaneously ie. I would like to run 200 to 300 processes, as each process would act like a session, stressing the webserver. The hard part is having the original perl script fork out processes. I've been reading up on fork and signals. does anybody have some suggestions on how i can do this? Thx, Radhika -- It's all a matter of perspective. You can choose your view by choosing where to stand. Larry Wall --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: trying to create a daemon
On Mon, 11 Oct 2004, Radhika Sambamurti wrote: I know there are many tools out there, but I would like to write a simple script that can login to a webserver, connect to port (whatever port number i give it) and do a 'wget https://blah.blah.com :9091. That is to say, you're going to use LWP's modules to do HTTP gets all within Perl, rather than running an external program like wget. Right? :-) http://www.oreilly.com/openbook/webclient/ch05.html As for the other stuff, unfortunately, I'm not as up on that as I wish I were. I'm sure someone more knowledgeable will chime in though... -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Parser
Hi! Has anyone tips to create a xml parser!? i do not know how to start -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: trying to create a daemon
Hi all, I am a relative newbie and I need to write a small web server load tester. I know there are many tools out there, but I would like to write a simple script that can login to a webserver, connect to port (whatever port number i give it) and do a 'wget https://blah.blah.com :9091. While the first part is quite easy, ie writing a perl script to do a wget from the server, creating this as a daemon, running many processes simultaneously ie. I would like to run 200 to 300 processes, as each process would act like a session, stressing the webserver. The hard part is having the original perl script fork out processes. I've been reading up on fork and signals. does anybody have some suggestions on how i can do this? Thx, Radhika I knew something similar had already been written, checking Google turned up a very good candidate. http://stein.cshl.org/~lstein/torture/ Of course if I were to reinvent this wheel, I would probably do it using POE, http://poe.perl.org HTH, http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Parser
Hi! Has anyone tips to create a xml parser!? i do not know how to start Well you can always start at CPAN. Do you really want to write a parser, or just need XML parsed? I would suggest not reinventing this wheel. If you just need a parser then check out: http://search.cpan.org/modlist/String_Language_Text_Processing/XML And specifically the XML::Simple module. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: trying to create a daemon
- Original Message - From: Radhika Sambamurti [EMAIL PROTECTED] Date: Monday, October 11, 2004 9:52 am Subject: trying to create a daemon Hi all, I am a relative newbie and I need to write a small web server load tester. I know there are many tools out there, but I would like to write a simplescript that can login to a webserver, connect to port (whatever port number i give it) and do a 'wget https://blah.blah.com :9091. While the first part is quite easy, ie writing a perl script to do a wget from the server, creating this as a daemon, running many processes simultaneously ie. I would like to run 200 to 300 processes, as each process would act like a session, stressing the webserver. The hard part is having the original perl script fork out processes. I've been reading up on fork and signals. does anybody have some suggestions on how i can do this? A good module would be Parallel-ForkManager. It can manage alot off basic IPC for you. Thx, Radhika -- It's all a matter of perspective. You can choose your view by choosing where to stand. Larry Wall --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Problem using Mailer
Hello, The below piece of code doesn't work for me. $sfile = $req_file; open(RF,$req_file); chop(@rflines=RF); close(RF); use lib /remote/xx/yy/SCRIPTS/libnet-1.12/; use lib /remote/xx/yy/SCRIPTS/; use Mail::Mailer; $mailer = Mail::Mailer-new(sendmail); $mailer-open({From = '[EMAIL PROTECTED]', To = '[EMAIL PROTECTED]', }) or die Can't open: $!\n; print $mailer @rflines\n; $mailer-close(); - I have Mail libnet-1.12 directories under /remote/xx/yy/SCRIPTS/libnet-1.12/. My libnet-1.12 directory has : ChangeLog Configure MANIFEST Net demos t Config.eg Hostname.pm.eg Makefile.PL README install-nomake My Mail directory has : ddress.pm Field Filter.pm Internet.pm Mailer.pm Util.pm Cap.pm Field.pm Header.pm Mailer Send.pm Thanks, Ravi -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Problem using Mailer
T.S. RaviShankar wrote: Hello, The below piece of code doesn't work for me. 1) add use strict and use warnings to the code 2) then make the code strict and warnings safe 3) then tell us specifically what you mean by doesn't work for me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Problem using Mailer
Thanks for the reply. I did check with use warnings . I indeed got few warnings but none of them pertained to the piece of code I showed. The problem is that the code doesn't send any email as it is supposed to. What could have gone wrong if you don't see any problem with the code here ? Thanks again, Ravi JupiterHost.Net wrote: T.S. RaviShankar wrote: Hello, The below piece of code doesn't work for me. 1) add use strict and use warnings to the code 2) then make the code strict and warnings safe 3) then tell us specifically what you mean by doesn't work for me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Variable scope in wanted function
From: Gunnar Hjalmarsson [EMAIL PROTECTED] Ron Goral wrote: I am having some difficulty with a module that is using File::Find. The method is below. The idea is to enter this method feeding it a file name and beginning directory and then looking for all occasions of $file_name and push those addresses into @a_files. This works fine until I need to use FindPath again during the same session. What I'm finding is that while @a_files looses scope within FindPath itself, it does not in ProcessFile. In other words, when I exit FindPath and come back into it later, @a_files is an uninitiated array. However when ProcessFile is called, @a_files has retained the values it had from the last call to FindPath. Am I making sense? Yes. But you are apparently running the code without warnings enabled, or else Perl would have indicated the reason for this problem. sub FindPath { #- Var Declaration And Initialization my ($hr_self, $file_name, $file_path) = @_; # Array to fill with file paths my @a_files = (); # Search file_path for the file find(\ProcessFile, $file_path); #- The Subroutine To Process Files And Directories sub ProcessFile {if ($_ eq $file_name){push (@a_files, $File::Find::name);}} # Return the paths found return @a_files; } # end FindPath One possible solution is to move the ProcessFile() function out from FindPath(), so the former is no longer a nested sub: sub ProcessFile { my ($a_files, $file_name) = @_; push @$a_files, $File::Find::name if $_ eq $file_name; } and call ProcessFile() from FindPath() with arguments: find( \ProcessFile( [EMAIL PROTECTED], $file_name ), $file_path ); You can't do that. You'd have to write it like this: find( sub {ProcessFile( [EMAIL PROTECTED], $file_name )}, $file_path ); Another option would be to use an unnamed subroutine like this: sub FindPath { #- Var Declaration And Initialization my ($hr_self, $file_name, $file_path) = @_; # Array to fill with file paths my @a_files = (); # Search file_path for the file find(sub { if ($_ eq $file_name){push (@a_files, $File::Find::name);} }, $file_path); # Return the paths found return @a_files; } # end FindPath Or (which might very well be fastest) you'd declare the $file_name and @a_files outside the FindPath and ProcessFile: { my ($file_name, @a_files); sub FindPath { #- Var Declaration And Initialization my ($hr_self, $file_path); ($hr_self, $file_name, $file_path) = @_; # Array to fill with file paths @a_files = (); # Search file_path for the file find(\ProcessFile, $file_path); # Return the paths found return @a_files; } # end FindPath #- The Subroutine To Process Files And Directories sub ProcessFile { if ($_ eq $file_name){push (@a_files, $File::Find::name);} } } HTH, 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] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Receve and forward email
From: [EMAIL PROTECTED] One part of my job is to read one e-mail from Pop3 and do a forward of that e-mail with SMTP to +- 1000 users, just changing the from and the to. There is something that can eseally do this? How to do this? Probably there is some modules that can do this work ease, but where to start? To receive: Mail::POP3Client or Net::POP3 To send: Net::SMTP, Mail::Sender, MIME::Lite, ... Since you just need to forward the email, Net::SMTP should be enough. You'll just need to replace the From and To headers (and maybe do something more with the message headers) and then transfer the data. 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] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Variable scope in wanted function
-Original Message- From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED] Sent: Sunday, October 10, 2004 6:32 PM To: [EMAIL PROTECTED] Subject: Re: Variable scope in wanted function Ron Goral wrote: I am having some difficulty with a module that is using File::Find. The method is below. The idea is to enter this method feeding it a file name and beginning directory and then looking for all occasions of $file_name and push those addresses into @a_files. This works fine until I need to use FindPath again during the same session. What I'm finding is that while @a_files looses scope within FindPath itself, it does not in ProcessFile. In other words, when I exit FindPath and come back into it later, @a_files is an uninitiated array. However when ProcessFile is called, @a_files has retained the values it had from the last call to FindPath. Am I making sense? Yes. But you are apparently running the code without warnings enabled, or else Perl would have indicated the reason for this problem. sub FindPath { #- Var Declaration And Initialization my ($hr_self, $file_name, $file_path) = @_; # Array to fill with file paths my @a_files = (); # Search file_path for the file find(\ProcessFile, $file_path); #- The Subroutine To Process Files And Directories sub ProcessFile {if ($_ eq $file_name){push (@a_files, $File::Find::name);}} # Return the paths found return @a_files; } # end FindPath One possible solution is to move the ProcessFile() function out from FindPath(), so the former is no longer a nested sub: sub ProcessFile { my ($a_files, $file_name) = @_; push @$a_files, $File::Find::name if $_ eq $file_name; } and call ProcessFile() from FindPath() with arguments: find( \ProcessFile( [EMAIL PROTECTED], $file_name ), $file_path ); And last but not least: use warnings; ;-) -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl Actually, I am using warnings. However, in the 'real' code, I have placed the the call to 'find' within an eval block so that I can manage the errors. Is this why I did not receive any warnings? The difficulties with moving ProcessFile out of FindPath is that any return values ProcessFile might have are ignored and it can take no arguments (this is from http://search.cpan.org/~nwclark/perl-5.8.5/lib/File/Find.pm#The_wanted_funct ion). I've setting up a global variable like $hr_self-{a_files}, where $hr_self is an object ref to the module. This requires calling ProcessFile like so: find(\$hr_self-ProcessFile, $file_path); or find(\ProcessFile($hr_self), $file_path); File::Find dies here with the complaint invalid top directory at /usr/lib/perl5/5.6.1/File/Find.pm line 295, line 36. I'm fairly certain this is because of the '$hr_self-'. I'm also completely out of ideas for this. At least when ProcessFile is defined within FindPath, the only variable trouble I had was with @a_files. There is a light, however. If ProcessFile is actually an anonymous sub and called this way: my $processfile = sub {if ($_ eq $file_name){push (@a_files, $File::Find::name);}}; find(\$processfile, $file_path); There are no errors and @a_files is populated (and depopulated) as it should be. Thanks for taking the time to check this out and to write an answer. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Problem using Mailer
Ravi, What is the error msg being produced if any ?? - Original Message - From: T.S. RaviShankar [EMAIL PROTECTED] Date: Monday, October 11, 2004 10:53 am Subject: Problem using Mailer Hello, The below piece of code doesn't work for me. $sfile = $req_file; open(RF,$req_file); chop(@rflines=RF); close(RF); use lib /remote/xx/yy/SCRIPTS/libnet-1.12/; use lib /remote/xx/yy/SCRIPTS/; use Mail::Mailer; $mailer = Mail::Mailer-new(sendmail); $mailer-open({From = '[EMAIL PROTECTED]', To = '[EMAIL PROTECTED]', }) or die Can't open: $!\n; print $mailer @rflines\n; $mailer-close(); - I have Mail libnet-1.12 directories under /remote/xx/yy/SCRIPTS/libnet-1.12/. My libnet-1.12 directory has : ChangeLog Configure MANIFEST Net demos t Config.eg Hostname.pm.eg Makefile.PL README install-nomake My Mail directory has : ddress.pm Field Filter.pm Internet.pm Mailer.pm Util.pm Cap.pm Field.pm Header.pm Mailer Send.pm Thanks, Ravi -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
perl.beginners Weekly list FAQ posting
NAME beginners-faq - FAQ for the beginners mailing list 1 - Administriva 1.1 - I'm not subscribed - how do I subscribe? Send mail to [EMAIL PROTECTED] You can also specify your subscription email address by sending email to (assuming [EMAIL PROTECTED] is your email address): [EMAIL PROTECTED]. 1.2 - How do I unsubscribe? Now, why would you want to do that? Send mail to [EMAIL PROTECTED], and wait for a response. Once you reply to the response, you'll be unsubscribed. If that doesn't work, find the email address which you are subscribed from and send an email like the following (let's assume your email is [EMAIL PROTECTED]): [EMAIL PROTECTED] 1.3 - There is too much traffic on this list. Is there a digest? Yes. To subscribe to the digest version of this list send an email to: [EMAIL PROTECTED] To unsubscribe from the digest, send an email to: [EMAIL PROTECTED] This is a high traffic list (100+ messages per day), so please subscribe in the way which is best for you. 1.4 - Is there an archive on the web? Yes, there is. It is located at: http://archive.develooper.com/beginners%40perl.org/ 1.5 - How can I get this FAQ? This document will be emailed to the list once a week, and will be available online in the archives, and at http://learn.perl.org/ 1.6 - I don't see something in the FAQ, how can I make a suggestion? Send an email to [EMAIL PROTECTED] with your suggestion. 1.7 - Is there a supporting website for this list? Yes, there is. It is located at: http://beginners.perl.org/ 1.8 - Who do I complain to? You can send complaints to [EMAIL PROTECTED] 1.9 - Who currently maintains the FAQ? Kevin Meltzer, who can be reached at the email address (for FAQ suggestions only) in question 1.6 1.10 - Who will maintain peace and flow on the list? Casey West, Kevin Meltzer and Ask Bjoern Hansen currently carry large, yet padded, clue-sticks to maintain peace and order on the list. If you are privately emailed by one of these folks for flaming, being off-topic, etc... please listen to what they say. If you see a message sent to the list by one of these people saying that a thread is closed, do not continue to post to the list on that thread! If you do, you will not only meet face to face with a XQJ-37 nuclear powered pansexual roto-plooker, but you may also be taken off of the list. These people simply want to make sure the list stays topical, and above-all, useful to Perl beginners. 1.11 - When was this FAQ last updated? Feb 04, 2004 2 - Questions about the 'beginners' list. 2.1 - What is the list for? A list for beginning Perl programmers to ask questions in a friendly atmosphere. 2.2 - What is this list _not_ for? * SPAM * Homework * Solicitation * Things that aren't Perl related * Monkeys * Monkeys solicitating homework on non-Perl related SPAM. 2.3 - Are there any rules? Yes. As with most communities, there are rules. Not many, and ones that shouldn't need to be mentioned, but they are. * Be nice * No flaming * Have fun 2.4 - What topics are allowed on this list? Basically, if it has to do with Perl, then it is allowed. You can ask CGI, networking, syntax, style, etc... types of questions. If your question has nothing at all to do with Perl, it will likely be ignored. If it has anything to do with Perl, it will likely be answered. 2.5 - I want to help, what should I do? Subscribe to the list! If you see a question which you can give an idiomatic and Good answer to, answer away! If you do not know the answer, wait for someone to answer, and learn a little. 2.6 - Is there anything I should keep in mind while answering? We don't want to see 'RTFM'. That isn't very helpful. Instead, guide the beginner to the place in the FM they should R :) Please do not quote the documentation unless you have something to add to it. It is better to direct someone to the documentation so they hopefully will read documentation above and beyond that which answers their question. It also helps teach them how to use the documentation. 2.7 - I don't want to post a question if it is in an FAQ. Where should I look first? Look in the FAQ! Get acquainted with the 'perldoc' utility, and use it. It can save everyone time if you look in the Perl FAQs first, instead of having a list of people refer you to the Perl FAQs :) You can learn about 'perldoc' by typing: perldoc perldoc At your command prompt. You can also view documentation online at: http://www.perldoc.com and http://www.perl.com 2.8 Is this a high traffic list? YES! You have been warned! If you don't want to get ~100 emails per day from this list, consider subscribing to the digest. 2.9 Other tips before posting to the list
Re: Receve and forward email
From: [EMAIL PROTECTED] One part of my job is to read one e-mail from Pop3 and do a forward of that e-mail with SMTP to +- 1000 users, just changing the from and the to. There is something that can eseally do this? How to do this? Probably there is some modules that can do this work ease, but where to start? To receive: Mail::POP3Client or Net::POP3 To send: Net::SMTP, Mail::Sender, MIME::Lite, ... Since you just need to forward the email, Net::SMTP should be enough. You'll just need to replace the From and To headers (and maybe do something more with the message headers) and then transfer the data. Jenda Though it may be overkill, Mail::Box can achieve all steps of the process with one module suite. Not to discredit the fine list above, just another option... http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
How to process blank line delimeted blocks of text?
I keep trying to do this for different things. I have not found a method I like yet. So here is specifically what I am trying to do *this time*. My current customer has been having problems with members dropping out of various MS Active Directory Security Groups. So I figured I would toss a bit of code together in my spare time (yah, like that exists). I have the bit that dumps an LDIF file starting at a particular point in the AD Tree. Where I am hitting a wall is processing that LDIF file... Here is an example of my data (note the blank line separating dn:'s. ,- | dn: CN=p106730,OU=Scr-Prt,OU=AB,DC=Stuff | 8 snip | member: CN=trn,OU=Scripts,OU=AB,DC=Stuff | member: CN=uci,OU=Scripts,OU=AB,DC=Stuff | 8 snip | groupType: -2147483644 | 8 snip | whenChanged: 20040927234946.0Z | whenCreated: 20030401203303.0Z |Blank Line Here | dn: CN=p101714_mb8,OU=Scr-Prt,OU=AB,DC=Stuff | 8 snip | groupType: -2147483644 | 8 snip | whenChanged: 20040927234926.0Z | whenCreated: 20020531152229.0Z `- This is what I want to keep for each (blank line separated) dn:. ,- [ ] | dn: CN=p106730,OU=Scr-Prt,OU=AB,DC=Stuff | member: CN=trn,OU=Scripts,OU=AB,DC=Stuff | member: CN=uci,OU=Scripts,OU=AB,DC=Stuff | groupType: -2147483644 | | dn: CN=p101714_mb8,OU=Scr-Prt,OU=AB,DC=Stuff | groupType: -2147483644 `- I know I can change the record separator to \n\n to get one dn: section at a time, but how do I then process the individual lines? I don't seem to ever have any luck setting the record separator back to \n... Or am I going about this all wrong? End result, I would like a report of the members of the security groups daily and a diff of yesterdays report from todays. Thanks for any suggestions you may have. btw, I am running this on MS, but if you have *nix examples, I can work with that too. Thanks again! -- Tim Musson Flying with The Bat! eMail v2.12.00 The days of the digital watch are numbered. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX; also need some advice about XML parsing modules on CPAN
Ken Wolcott wrote: I suppose it is in bad taste to reply to one's own posting, but I have an update. After reading some in the O'Reilly Perl XML book, reading the email archives of this mailing list, several FAQS that some people mentioned from the mailing list archives and another reading of the CPAN man page for XML::Simple, I decided to try the OO interface, adding ForceArray = 1, KeepRoot = 1, KeyAttr = 1 to my call to the parser. It seems now that the formatting is nice and the closing tag is specified properly. So, getting patient, calm, cool and collected rather than anxious solved part of the problem. Now the problem that remains is the error/warning message in the subject line: could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX when using XML::Simple. What do I need to do to fix that? Again, replying to my own post as nobody has reponded :-( I saw the could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX warning/error on a Fedora Core 2 system, but did not see the error on three Red Hat 9 systems. So I punted by not using the Fedora system. Ken -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Perl and Threads
Hello Im writing perl scripts that use threads. Mi goal is that each thread could process an element of an array that has 10 elements, so thread0 process array[0], thread1 process array[1] and so on until thread9 process array[9] Those 10 lines come from a file that Perl reads in chunks of ten lines until EOF, something like this while (FILE) { push @buffer, $_; $i++; if ($i == 10) { $i = 0; processthreads (@buffer); @buffer = (); } } My problem is the next After processing like 200 chunks of the file (2000 lines) I get the following error Out of memory! Segmentation Fault I supposed that is because each thread that Perl have created from the beginning still is living. I supposed that each thread is destroyed when it finish, it seems that my script is not correct and that each threads lives, how can I kill a thread?? Below is my code. Please help, thanks in advanced open(INPUT, $file) or die No puedo leer del log: $! $file; while (INPUT) { push @buffer, $_; $i++; if ($i == 10) { $i = 0; processthreads (@buffer); @buffer = (); } } close (INPUT); } sub processthreads() { my @arreglo = (); @arreglo = shift; $thr0 = new threads \proceso, $arreglo[0]; $thr1 = new threads \proceso, $arreglo[1]; $thr2 = new threads \proceso, $arreglo[2]; $thr3 = new threads \proceso, $arreglo[3]; $thr4 = new threads \proceso, $arreglo[4]; $thr5 = new threads \proceso, $arreglo[5]; $thr6 = new threads \proceso, $arreglo[6]; $thr7 = new threads \proceso, $arreglo[7]; $thr8 = new threads \proceso, $arreglo[8]; $thr9 = new threads \proceso, $arreglo[9]; $thr0-detach; $thr1-detach; $thr2-detach; $thr3-detach; $thr4-detach; $thr5-detach; $thr6-detach; $thr7-detach; $thr8-detach; $thr9-detach; } sub proceso () { my ($linea):shared = ; my (@normal):shared = (); my ($time):shared = ; my ($count):shared = 0; my (@buffer)= (); $linea = shift; @normal = $linea =~ / (.*?)\s (.*?)\s (.*?)\s (.*?)\s (.*?)\s (.*?)\s (.*?)\s (.*?)\s (.*?)\s (.*) /x; if ($normal[0] eq '-') { $normal[0] = none; } if (! defined $normal[0]) { $normal[0] = none; } if ($normal[1] eq '-') { $normal[1] = 0; } if (! defined $normal[1]) { $normal[1] = 0; } if ($normal[2] eq '-') {$normal[2] = none; } if (! defined $normal[2]) { $normal[2] = none; } if ($normal[3] eq '-') { $normal[3] = none;} if (! defined $normal[3]) { $normal[3] = none; } if ($normal[4] eq '-') { $normal[4] = 0; } if (! defined $normal[4]) { $normal[4] = 0; } if ($normal[5] eq '-') { $normal[5] = none; } if (! defined $normal[5]) { $normal[5] = none; } if ($normal[6] eq '-') { $normal[6] = none; } if (! defined $normal[6]) { $normal[6] = none; } if ($normal[7] eq '-') {$normal[7] = none; } if (! defined $normal[7]) { $normal[7] = none; } if ($normal[8] eq '-') { $normal[8] = none; } if (! defined $normal[8]) { $normal[8] = none; } if ($normal[9] eq '-') { $normal[9] = none; } if (! defined $normal[9]) { $normal[9] = none; } $time = scalar localtime($normal[0]); } -- If I have seen further it is by standing on the shoulders of the giants Isaac Newton -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX; also need some advice about XML parsing modules on CPAN
ANother observation is that i'm not finding any problem with this warning/err message. There are no side-effects. The XML:: parser is working correctly. regards -Ajey Quoting Ken Wolcott [EMAIL PROTECTED]: Ken Wolcott wrote: I suppose it is in bad taste to reply to one's own posting, but I have an update. After reading some in the O'Reilly Perl XML book, reading the email archives of this mailing list, several FAQS that some people mentioned from the mailing list archives and another reading of the CPAN man page for XML::Simple, I decided to try the OO interface, adding ForceArray = 1, KeepRoot = 1, KeyAttr = 1 to my call to the parser. It seems now that the formatting is nice and the closing tag is specified properly. So, getting patient, calm, cool and collected rather than anxious solved part of the problem. Now the problem that remains is the error/warning message in the subject line: could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX when using XML::Simple. What do I need to do to fix that? Again, replying to my own post as nobody has reponded :-( I saw the could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX warning/error on a Fedora Core 2 system, but did not see the error on three Red Hat 9 systems. So I punted by not using the Fedora system. Ken -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: trying to create a daemon
:) Right. I actually did'nt think of it, but now that you mention it, yes. thx. On Mon, 11 Oct 2004, Radhika Sambamurti wrote: I know there are many tools out there, but I would like to write a simple script that can login to a webserver, connect to port (whatever port number i give it) and do a 'wget https://blah.blah.com :9091. That is to say, you're going to use LWP's modules to do HTTP gets all within Perl, rather than running an external program like wget. Right? :-) http://www.oreilly.com/openbook/webclient/ch05.html As for the other stuff, unfortunately, I'm not as up on that as I wish I were. I'm sure someone more knowledgeable will chime in though... -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- It's all a matter of perspective. You can choose your view by choosing where to stand. Larry Wall --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
in a regex- re-arrange $1..$n
the following is an as yet incomplete regex that i'm working on: $data = $_ =~ s/(name)(.*?)(desc)(.*?)(copy)(.*?)(license)(.*?)(entry)//xg every other capture ($1 $3 $5 $7 $9) is going to be used one way, the other captures will be used differently... i'm wondering if there's a way to force the captures into particular numbered variable, so that $1 =$1 $2 = $3 $3 = $5 $4 = $7 $5 = $9 etc... or is it even worth it for easier coding later on? willy http://www.hackswell.com/corenth -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX; also need some advice about XML parsing modules on CPAN
Ken Wolcott wrote: I suppose it is in bad taste to reply to one's own posting, but I have an update. After reading some in the O'Reilly Perl XML book, reading the email archives of this mailing list, several FAQS that some people mentioned from the mailing list archives and another reading of the CPAN man page for XML::Simple, I decided to try the OO interface, adding ForceArray = 1, KeepRoot = 1, KeyAttr = 1 to my call to the parser. It seems now that the formatting is nice and the closing tag is specified properly. So, getting patient, calm, cool and collected rather than anxious solved part of the problem. Now the problem that remains is the error/warning message in the subject line: could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX when using XML::Simple. What do I need to do to fix that? Again, replying to my own post as nobody has reponded :-( I saw the could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX warning/error on a Fedora Core 2 system, but did not see the error on three Red Hat 9 systems. So I punted by not using the Fedora system. Ken See if I can actually get somewhere with this. XML::Simple is just a wrapper around one of the lower level XML parsers. Essentially any parser can be used. XML::DOM and XML::SAX are two examples, within these examples they can/do wrap lower level C libs, such as expat[1] or libxml[2]. Alternatively they may also provide a pure Perl implementation which is likely slower, but still correct. Unless you specifically request a specific parser XML::Simple will look for one that is available and use it. In this case it appears that either you specified or it came upon XML::SAX and attempts to use. Part of the XML::SAX API allows for alternate parsers to be installed, including the two mentioned above (expat and libxml), and also provides a PurePerl version. The module also checks for a ParserDetails.ini to see if you have written your own parser that you might prefer to load before the others, or before the default pure Perl version is loaded. It appears that the file should be installed at installation time or bootstrapped by the Makefile.PL but this is kinda unclear to me. You can check the top of the source for XML::SAX to see some pod like comments about that file as well as the format it should take. So if I had to guess, the RH9 systems probably came installed with either of the parsers (or both) and the FC system did not. It would be pretty simple to have this problem if you didn't install all of the dev libraries, or selected specific packages, etc. Alternatively a previous version of XML::SAX may have installed the file and newer ones don't. It appears at some point that a makefile touched the file in place, and that may have been removed. I also suspect that it is working since the PurePerl parser is installed with XML::SAX and it is falling back to it. And the message you are seeing is just a warning. So you might check for the various libraries, check their versions, check the versions of XML::Simple/XML::SAX, and make sure that the Perl modules were installed against the most recent versions of those libs. To quiet the warning if you so desire it appears you can touch the ParserDetails.ini file in the directory that XML::SAX is installed. Take all of this with as large of a grain of salt as you wish, I am no XML expert http://danconia.org [1] http://expat.sourceforge.net/ [2] http://www.xmlsoft.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX; also need some advice about XML parsing modules on CPAN
Ken Wolcott wrote: I suppose it is in bad taste to reply to one's own posting, but I have an update. After reading some in the O'Reilly Perl XML book, reading the email archives of this mailing list, several FAQS that some people mentioned from the mailing list archives and another reading of the CPAN man page for XML::Simple, I decided to try the OO interface, adding ForceArray = 1, KeepRoot = 1, KeyAttr = 1 to my call to the parser. It seems now that the formatting is nice and the closing tag is specified properly. So, getting patient, calm, cool and collected rather than anxious solved part of the problem. Now the problem that remains is the error/warning message in the subject line: could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX when using XML::Simple. What do I need to do to fix that? Again, replying to my own post as nobody has reponded :-( I saw the could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX warning/error on a Fedora Core 2 system, but did not see the error on three Red Hat 9 systems. So I punted by not using the Fedora system. Ken See if I can actually get somewhere with this. XML::Simple is just a wrapper around one of the lower level XML parsers. Essentially any parser can be used. XML::DOM and XML::SAX are two examples, within these examples they can/do wrap lower level C libs, such as expat[1] or libxml[2]. Alternatively they may also provide a pure Perl implementation which is likely slower, but still correct. Unless you specifically request a specific parser XML::Simple will look for one that is available and use it. In this case it appears that either you specified or it came upon XML::SAX and attempts to use. Part of the XML::SAX API allows for alternate parsers to be installed, including the two mentioned above (expat and libxml), and also provides a PurePerl version. The module also checks for a ParserDetails.ini to see if you have written your own parser that you might prefer to load before the others, or before the default pure Perl version is loaded. It appears that the file should be installed at installation time or bootstrapped by the Makefile.PL but this is kinda unclear to me. You can check the top of the source for XML::SAX to see some pod like comments about that file as well as the format it should take. So if I had to guess, the RH9 systems probably came installed with either of the parsers (or both) and the FC system did not. It would be pretty simple to have this problem if you didn't install all of the dev libraries, or selected specific packages, etc. Alternatively a previous version of XML::SAX may have installed the file and newer ones don't. It appears at some point that a makefile touched the file in place, and that may have been removed. I also suspect that it is working since the PurePerl parser is installed with XML::SAX and it is falling back to it. And the message you are seeing is just a warning. So you might check for the various libraries, check their versions, check the versions of XML::Simple/XML::SAX, and make sure that the Perl modules were installed against the most recent versions of those libs. To quiet the warning if you so desire it appears you can touch the ParserDetails.ini file in the directory that XML::SAX is installed. Take all of this with as large of a grain of salt as you wish, I am no XML expert http://danconia.org [1] http://expat.sourceforge.net/ [2] http://www.xmlsoft.org/ Ah hah... addendum: http://perl-xml.sourceforge.net/faq/#parserdetails.ini http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Variable scope in wanted function
Ron Goral wrote: Gunnar Hjalmarsson wrote: One possible solution is to move the ProcessFile() function out from FindPath(), so the former is no longer a nested sub: sub ProcessFile { my ($a_files, $file_name) = @_; push @$a_files, $File::Find::name if $_ eq $file_name; } and call ProcessFile() from FindPath() with arguments: find( \ProcessFile( [EMAIL PROTECTED], $file_name ), $file_path ); And last but not least: use warnings; ;-) Actually, I am using warnings. However, in the 'real' code, I have placed the the call to 'find' within an eval block so that I can manage the errors. Is this why I did not receive any warnings? I get the same warnings also with such an eval block. The difficulties with moving ProcessFile out of FindPath is that any return values ProcessFile might have are ignored and it can take no arguments (this is from http://search.cpan.org/~nwclark/perl-5.8.5/lib/File/Find.pm#The_wanted_function). No return values does not matter, since my suggestion didn't make use of return values from ProcessFile, but the rest does. Jenda showed us a way to modify that approach to working code. Sorry for posting non-tested code. :( snip There is a light, however. If ProcessFile is actually an anonymous sub and called this way: my $processfile = sub {if ($_ eq $file_name){push (@a_files, $File::Find::name);}}; find(\$processfile, $file_path); There are no errors and @a_files is populated (and depopulated) as it should be. Yes, that seems to be a nice solution. You can even pass it to find() by just saying: find( $ProcessFile, $file_path ); If you haven't already, to get an understanding of what the original problem actually was about, you can read the Variable '%s' will not stay shared section in perldoc perldiag. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: in a regex- re-arrange $1..$n
the following is an as yet incomplete regex that i'm working on: $data = $_ =~ s/(name)(.*?)(desc)(.*?)(copy)(.*?)(license)(.*?)(entry)//xg every other capture ($1 $3 $5 $7 $9) is going to be used one way, the other captures will be used differently... i'm wondering if there's a way to force the captures into particular numbered variable, so that $1 =$1 $2 = $3 $3 = $5 $4 = $7 $5 = $9 How about just not capturing them to begin with? If you add C?: to the beginning of your capture it will ignore the capture. Having said that, why are you capturing to begin with if you are just going to throw them away? The parens in your example don't matter for the match to work. etc... or is it even worth it for easier coding later on? At the very least I would switch to named variables to make it more readable and prevent the chance that they get clobbered by a later regex. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Can do in 1 while loop?
--- Ramprasad A Padmanabhan [EMAIL PROTECTED] wrote: On Mon, 2004-10-11 at 06:26, loan tran wrote: Hello Perl Gurus, I wrote a script to search for log suspends and bloking processes in a text file and send me email if it find either of them. My codes below work but it's not efficent. As you can see I open the file and go to while loop twice. Can someone suggest a better way? Thanks. (attached is the text file i open to search.) Below is my codes: #!/bin/perl -w require /home/sybase/tranl/pl/global.pl; ## Search for blocking process open (FILE,$whodo_out) or die (Cannot open file: $!); while (my $line =FILE){ chomp($line); $line =~ s/^\s+//; next if ($line =~ /^\D/); my $blk = substr($line,40,3); print $blk \n; if ($blk != 0){ print 'Alert! Blocking processes'; system(/usr/bin/mailx -s 'Alert Blocking Process' $receipients $whodo_out); } print \n $suspend \n; #exit ; }#end while close (FILE); # Search for LOG SUSPEND process open (FILE,$whodo_out) or die (Cannot open file: $!); while (my $line =FILE){ chomp($line); $line =~ s/^\s+//; next if ($line =~ /^\D/); my $log_suspend = substr($line,70,11); print $log_suspend \n; if ($log_suspend eq 'LOG SUSPEND'){ print 'Alert! LOG SUSPEND processes'; system(/usr/bin/mailx -s 'Alert LOG SUSPEND Process' $receipients $whodo_out); } }#end while close FILE; ## I am not able to get it ? Why cant you put This inside your first while loop my $log_suspend = substr($line,70,11); print $log_suspend \n; if ($log_suspend eq 'LOG SUSPEND'){ print 'Alert! LOG SUSPEND processes'; system(/usr/bin/mailx -s 'Alert LOG SUSPEND Process' $receipients $whodo_out); } Probably after print \n $suspend \n; Bye Ram I have tried your suggestion. Howerver, result i got is only the first if run ( reciveice only blocking email). In my first post I forget a last statement in each if. (b/c I dont want to receive multible emails if there are multily blocking or suspending procecess.) So here is the code again: open (FILE,$whodo_out) or die (Cannot open file: $!); while (my $line =FILE){ chomp($line); $line =~ s/^\s+//; next if ($line =~ /^\D/); my $blk = substr($line,40,3); if ($blk != 0){ print Alert Blocking processes\n; system(/usr/bin/mailx -s 'Alert BLOCKING Process' $receipients $whodo_out); last; } }#end while close (FILE); # Search for LOG SUSPEND process open (FILE,$whodo_out) or die (Cannot open file: $!); while (my $line =FILE){ chomp($line); $line =~ s/^\s+//; next if ($line =~ /^\D/); my $log_suspend = substr($line,70,11); if ($log_suspend eq 'LOG SUSPEND'){ print Alert! LOG SUSPEND processes\n; system(/usr/bin/mailx -s 'Alert LOG SUSPEND Process' $receipients $whodo_out); last; } }#end while close FILE; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response __ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. http://promotions.yahoo.com/new_mail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Course material for perl training
Ramprasad == Ramprasad A Padmanabhan [EMAIL PROTECTED] writes: Ramprasad Sorry for being OT here Ramprasad Is there any good course material for a perl crash course. I am supposed Ramprasad to take training in perl and prepare a syllabus , with exercises More people have learned from Learning Perl than any other single course. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How to process blank line delimeted blocks of text?
Tim Musson wrote: I know I can change the record separator to \n\n to get one dn: section at a time, but how do I then process the individual lines? I don't seem to ever have any luck setting the record separator back to \n... Or am I going about this all wrong? How could we know, when you don't show us any code? Post a short but complete program that illustrates what you are currently doing. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: in a regex- re-arrange $1..$n
-Original Message- From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] Sent: Monday, October 11, 2004 3:14 PM To: West, William M; [EMAIL PROTECTED] Subject: Re: in a regex- re-arrange $1..$n the following is an as yet incomplete regex that i'm working on: $data = $_ =~ s/(name)(.*?)(desc)(.*?)(copy)(.*?)(license)(.*?)(entry)//xg every other capture ($1 $3 $5 $7 $9) is going to be used one way, the other captures will be used differently... i'm wondering if there's a way to force the captures into particular numbered variable, so that $1 =$1 $2 = $3 $3 = $5 $4 = $7 $5 = $9 How about just not capturing them to begin with? If you add C?: to the beginning of your capture it will ignore the capture. Having said that, why are you capturing to begin with if you are just going to throw them away? The parens in your example don't matter for the match to work. you misread- i intend to USE all of the captures- but i wanted to categorize them more easily by type, so ?: would be useless. etc... or is it even worth it for easier coding later on? At the very least I would switch to named variables to make it more readable and prevent the chance that they get clobbered by a later regex. what i am likely going to do is finish the processing in the one s///, so leaving them as is might not be a problem. i've worked on this since my last post:: $_ =~ s/(.+?)(.*?)(.+?)(.*?)(.+?)(.*?)(.+?)(.*?)entry/ $css{$1}{open} $2 $css{$1}{close} $css{$3}{open} $4 $css{$3}{close} $css{$5}{open} $6 $css{$5}{close} $css{$7}{open} $8 $css{$7}{close}/xg %css is an HoH- using half the captures as keys etc... looks like this will work well enough for me after all :) but i'm still wondering about the original question... with so much time spent by me with regexen, i'd love to keep them as readable and malleable as i can. willy http://www.hackswell.com/corenth -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: in a regex- re-arrange $1..$n
On Mon, 11 Oct 2004 13:13:37 -0600, Wiggins d Anconia [EMAIL PROTECTED] wrote: the following is an as yet incomplete regex that i'm working on: $data = $_ =~ s/(name)(.*?)(desc)(.*?)(copy)(.*?)(license)(.*?)(entry)//xg Are you thinking of : ( $a1,$b1,$a2,$b2,$a3,$b3,$a4,$b4,$a5,$b5 ) = $_ =~ /regexp/ ? The result of a regexp ($1..$9) are returned in array context, so you can either assign them to an array @data = $_ =~ /regexp/ or return them to named variables as above. I use the above, because I can't stand using '$1' '$2' '$3' etc for more than two lines of code below the regexp capture, because context is lost to the reader. every other capture ($1 $3 $5 $7 $9) is going to be used one way, the other captures will be used differently... i'm wondering if there's a way to force the captures into particular numbered variable, so that $1 =$1 $2 = $3 $3 = $5 $4 = $7 $5 = $9 How about just not capturing them to begin with? If you add C?: to the beginning of your capture it will ignore the capture. Having said that, why are you capturing to begin with if you are just going to throw them away? The parens in your example don't matter for the match to work. etc... or is it even worth it for easier coding later on? At the very least I would switch to named variables to make it more readable and prevent the chance that they get clobbered by a later regex. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Can do in 1 while loop?
- Original Message - From: loan tran [EMAIL PROTECTED] To: perl beginners [EMAIL PROTECTED] Sent: Monday, October 11, 2004 3:36 PM Subject: Re: Can do in 1 while loop? --- Ramprasad A Padmanabhan [EMAIL PROTECTED] wrote: On Mon, 2004-10-11 at 06:26, loan tran wrote: Hello Perl Gurus, I wrote a script to search for log suspends and bloking processes in a text file and send me email if it find either of them. My codes below work but it's not efficent. As you can see I open the file and go to while loop twice. Can someone suggest a better way? Thanks. (attached is the text file i open to search.) Below is my codes: #!/bin/perl -w require /home/sybase/tranl/pl/global.pl; ## Search for blocking process open (FILE,$whodo_out) or die (Cannot open file: $!); while (my $line =FILE){ chomp($line); $line =~ s/^\s+//; next if ($line =~ /^\D/); my $blk = substr($line,40,3); print $blk \n; if ($blk != 0){ print 'Alert! Blocking processes'; system(/usr/bin/mailx -s 'Alert Blocking Process' $receipients $whodo_out); } print \n $suspend \n; #exit ; }#end while close (FILE); # Search for LOG SUSPEND process open (FILE,$whodo_out) or die (Cannot open file: $!); while (my $line =FILE){ chomp($line); $line =~ s/^\s+//; next if ($line =~ /^\D/); my $log_suspend = substr($line,70,11); print $log_suspend \n; if ($log_suspend eq 'LOG SUSPEND'){ print 'Alert! LOG SUSPEND processes'; system(/usr/bin/mailx -s 'Alert LOG SUSPEND Process' $receipients $whodo_out); } }#end while close FILE; ## I am not able to get it ? Why cant you put This inside your first while loop my $log_suspend = substr($line,70,11); print $log_suspend \n; if ($log_suspend eq 'LOG SUSPEND'){ print 'Alert! LOG SUSPEND processes'; system(/usr/bin/mailx -s 'Alert LOG SUSPEND Process' $receipients $whodo_out); } Probably after print \n $suspend \n; Bye Ram I have tried your suggestion. Howerver, result i got is only the first if run ( reciveice only blocking email). In my first post I forget a last statement in each if. (b/c I dont want to receive multible emails if there are multily blocking or suspending procecess.) So here is the code again: You should post your beggin code as well, so you can clearify what modules you are using. open (FILE,$whodo_out) or die (Cannot open file: $!); while (my $line =FILE){ chomp($line); $line =~ s/^\s+//; next if ($line =~ /^\D/); You should change the above logic, match will occure with spaces and line terminators my $blk = substr($line,40,3); You can do both of your string manipulation statments here, unless you are only showing partial code. if ($blk != 0){ print Alert Blocking processes\n; system(/usr/bin/mailx -s 'Alert BLOCKING Process' $receipients $whodo_out); last; } }#end while close (FILE); # Search for LOG SUSPEND process open (FILE,$whodo_out) or die (Cannot open file: $!); while (my $line =FILE){ chomp($line); $line =~ s/^\s+//; next if ($line =~ /^\D/); my $log_suspend = substr($line,70,11); if ($log_suspend eq 'LOG SUSPEND'){ print Alert! LOG SUSPEND processes\n; system(/usr/bin/mailx -s 'Alert LOG SUSPEND Process' $receipients $whodo_out); last; } }#end while close FILE; Here is one way you can try it.#Untested #!PERL use warnings; use strict; my $whodo_out = $ARGV[0] || die NO FILE TO PARSE\a\n; my $receipients = $ARGV[1] || die NO RECEIPIENTS ADDRESS\a\n; open FILE,$whodo_out || die Cannot open file: $!\n; while (my $line =FILE){ next if ($line =~ /^[\s\D]+); chomp $line; # not sure if you need this chomp at all $line =~ s/^\s+//; my $blk = substr($line,40,3); my $log_suspend = substr($line,70,11); if ($blk != 0){ print Alert Blocking processes\n; system /usr/bin/mailx -s 'Alert BLOCKING Process' $receipients $whodo_out; last; } if ($log_suspend eq 'LOG SUSPEND'){ print Alert! LOG SUSPEND processes\n; system /usr/bin/mailx -s 'Alert LOG SUSPEND Process' $receipients $whodo_out; last; } }#end while close FILE; HTH, Mark G. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response __ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. http://promotions.yahoo.com/new_mail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
how/where to install xyz.pm from CPAN (no perl Makefile.PL; make; make test; make install)??
Hi; I see several very interesting CPAN modules regarding Rational/IBM ClearCase. These are just *.pm files. How/where do I install these? I have root privs. I want the modules to be available in the standard place(s). I guess I should just look at the %INC hash and place it in a good location? A more general question along the lines of giving me a fishing pole instead of giving me a fish...I can go to (http://groups.google.com/groups?hl=enlr=ie=UTF-8group=perl.beginners) to search for archived postings, but what meaningful search string would I provide in order to obtain answers pertinent to my question above? I have the 3rd edition of the camel book and refer to it frequently. I have several other perl books (mostly O'Reilly) as well. I don't remember seeing this topic addressed. Thanks, Ken -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: how/where to install xyz.pm from CPAN (no perl Makefile.PL; make; make test; make install)??
On 10/11/2004 11:01 PM, Ken Wolcott wrote: Hi; I see several very interesting CPAN modules regarding Rational/IBM ClearCase. These are just *.pm files. How/where do I install these? I have root privs. I want the modules to be available in the standard place(s). I guess I should just look at the %INC hash and place it in a good location? A more general question along the lines of giving me a fishing pole instead of giving me a fish...I can go to (http://groups.google.com/groups?hl=enlr=ie=UTF-8group=perl.beginners) to search for archived postings, but what meaningful search string would I provide in order to obtain answers pertinent to my question above? I have the 3rd edition of the camel book and refer to it frequently. I have several other perl books (mostly O'Reilly) as well. I don't remember seeing this topic addressed. In general, you should never manually drop in modules. Is there no Makefile.PL or Build.PL file with the module? If not and it is on CPAN, the author should have his or her @$$ kicked. =) What module(s) are you looking at? Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: how/where to install xyz.pm from CPAN (no perl Makefile.PL; make; make test; make install)??
Randy W. Sims wrote: On 10/11/2004 11:01 PM, Ken Wolcott wrote: Hi; I see several very interesting CPAN modules regarding Rational/IBM ClearCase. These are just *.pm files. How/where do I install these? I have root privs. I want the modules to be available in the standard place(s). I guess I should just look at the %INC hash and place it in a good location? A more general question along the lines of giving me a fishing pole instead of giving me a fish...I can go to (http://groups.google.com/groups?hl=enlr=ie=UTF-8group=perl.beginners) to search for archived postings, but what meaningful search string would I provide in order to obtain answers pertinent to my question above? I have the 3rd edition of the camel book and refer to it frequently. I have several other perl books (mostly O'Reilly) as well. I don't remember seeing this topic addressed. In general, you should never manually drop in modules. Is there no Makefile.PL or Build.PL file with the module? If not and it is on CPAN, the author should have his or her @$$ kicked. =) What module(s) are you looking at? Randy. Hi Randy; That was a real bozo question of mine :-( I'm in a desperate rush to completely rewrite one of my build scripts as I have scripted myself into a corner :-( I can't seem to use a Perl CPAN XML module in conjunction with ClearCase, as I did not see the ClearCase Perl modules on CPAN until today, and the ClearCase commands I was calling where in a setview exec mode (trying to call bash for simplicity as I did not want to autogenerate perl to be run later). If I then try to call the Perl XML:Simple module in bash (that won't work!), I then am writing a perl script, which autogenerates bash, which then calls a perl program to do XML, which by then I have lost the ClearCase setview exec context :-( Now I need to have this done by noon on Wednesday as I have to make a ClearCase label build using an Perl XML module in order to view/modify version strings in an XML file that is in ClearCase... One example (did this with four modules): http://search.cpan.org/ enter ClearCase into the search box and press the search button choose the first entry in the response which is http://search.cpan.org/~dsb/ClearCase-Argv-1.18/Argv.pm now select the Source button near the top I thought that this would provide the source of the module, not the source of the *.pm file that the POD was showing :-) What I should have done: http://search.cpan.org/ enter ClearCase into the search box and press the search button choose the first entry in the response which is http://search.cpan.org/~dsb/ClearCase-Argv-1.18/Argv.pm click on the module name, which is: http://search.cpan.org/~dsb/ClearCase-Argv-1.18/ Now I can select the compressed tarball :-) I have now installed all four of the most likely suspects in the proper manner (perl Makefile.PL, make, make test, make install)... :-) Ken -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
help on comparing lines in a text file
so i have a text file that looks like this 10/04/2004 UPL TZOO CME CRDN WIBC PETD SMF 10/11/2004 UPL TZOO CME WIBC PETD VNBC AMED anyway each line has 1 date field and 100 stock symbols and they are in order. I am trying to compare the different lines to see what has changed. so I open the file and put the FH into an array @array=FH; but $array[0]; = line 1 and $array[1]; = line 2. i keep thinking that i need to break down the array into each line and match a symbol to an array so that $array[0] = 10/04/2004 and $array[1] = UPL then compare it to the 2nd line somehow but don't think I am thinking this problem out correctly. can someone help with my logic? tnx in advance, alden -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response