Re: css attributes in CGI - more questions
Jimmy George wrote at Sun, 29 Sep 2002 10:38:16 +0200: LIMITED SUPPORT FOR CASCADING STYLE SHEETS from perldoc CGI where is that? I am a beginner. On a Mac. With a home page serviced by a remote ISP. No Linux contact. It's a subsection in the perl documentation of the CGI module. perldoc is a program showing the perl documentation of Perl itself and every installed module. perldoc is installed (in general - I never used it on a Mac, but it should be the same), when Perl with it's command line call perl is installed. Just go to the commandline and type perldoc CGI or perldoc perldoc to understand how perldoc works. Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Looking for the Sendmail.pm for Appache ver 1.3
Hi all, Could any one send of tell where I could find this Module. thanks in advance. Bruce
Re: How to run a process in background?
On Sun, 29 Sep 2002 at 16:40, Octavian Rasnita opined: OR:Can you give me some hints about how I should use the fork, to run the OR:process in background? have you read perldoc -f fork yet? if so, what part of that do you not understand? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run a process in background?
On Sun, 29 Sep 2002 16:40:07 +0200, [EMAIL PROTECTED] (Octavian Rasnita) wrote: I want to make a script that is activated from a browser but it might take a long time to send all the messages using the Net::SMTP. So I think that it could be a good idea to make a background process to run it. Can you give me some hints about how I should use the fork, to run the process in background? Your biggest problem is to close the pipes to apache from the forked children, else your clients will see their browser's hang. Merlyn has a good column on this at www.stonehenge.com column 20. Here is a simple example to demonstrate the problem. Make up some long process to test this with, like while(1){sleep(1)} Then try running it as a cgi script with and without the line which closes STDOUT, STDIN, and STDERR. With it commented out, your browser will hang. ## #!/usr/bin/perl use warnings; use strict; $| = 1; # need either this or to explicitly flush stdout, etc. # before forking print Content-type: text/plain\n\n; print Going to start the fork now\n; fork exit; #try running with the following line commented out close STDOUT;close STDIN;close STDERR; exec('./fork-long-process-test-process') || warn funniness $!; #if you use system here, instead of exec, the parent process #hangs around for child to exit, even though the cgi exits. # -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
What am I missing or doing wrong?
Hi all, I've taken the following example from a Perl book but it doesn't work well. It should print the content of a web page, but it prints only the first 4 kb, then the page continues opening... and even if I press the stop button after more time, it doesn't print more than 4 kb. After waiting for more time for the page to finish loading, I can see the following error in the log file, even though the page continues loading... [Mon Sep 30 17:03:56 2002] [error] [client 127.0.0.1] Premature end of script headers: test.pl [Mon Sep 30 17:04:13 2002] [error] [client 127.0.0.1] (20507)The timeout specified has expired: ap_content_length_filter: apr_bucket_read() failed Here is the script file I tried: #!/perl/bin/perl -w print Content-type: text/html\n\n; use strict; use IO::Socket; use URI; my $location = 'http://localhost'; my $url = new URI($location); my $host = $url-host; my $port = $url-port || 80; my $path = $url-path || /; my $socket = new IO::Socket::INET (PeerAddr = $host, PeerPort = $port, Proto= 'tcp') or die Cannot connect to the server.\n; $socket-autoflush(1); print $socket GET $path HTTP/1.1\n, Host: $host\n\n; print while ($socket); $socket-close; Teddy's Center: http://teddy.fcc.ro/ Mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: What am I missing or doing wrong?
seems to work fine for me, but i tested it on a simple web page. Try removing the line $socket-autoflush(1); -Original Message- From: Octavian Rasnita [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 11:08 AM To: [EMAIL PROTECTED] Subject: What am I missing or doing wrong? Hi all, I've taken the following example from a Perl book but it doesn't work well. It should print the content of a web page, but it prints only the first 4 kb, then the page continues opening... and even if I press the stop button after more time, it doesn't print more than 4 kb. After waiting for more time for the page to finish loading, I can see the following error in the log file, even though the page continues loading... [Mon Sep 30 17:03:56 2002] [error] [client 127.0.0.1] Premature end of script headers: test.pl [Mon Sep 30 17:04:13 2002] [error] [client 127.0.0.1] (20507)The timeout specified has expired: ap_content_length_filter: apr_bucket_read() failed Here is the script file I tried: #!/perl/bin/perl -w print Content-type: text/html\n\n; use strict; use IO::Socket; use URI; my $location = 'http://localhost'; my $url = new URI($location); my $host = $url-host; my $port = $url-port || 80; my $path = $url-path || /; my $socket = new IO::Socket::INET (PeerAddr = $host, PeerPort = $port, Proto= 'tcp') or die Cannot connect to the server.\n; $socket-autoflush(1); print $socket GET $path HTTP/1.1\n, Host: $host\n\n; print while ($socket); $socket-close; Teddy's Center: http://teddy.fcc.ro/ Mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: What am I missing or doing wrong?
Ok, lets troubleshoot this: Try it without the URI module and see what happens then. This trim it down to: -- use IO::Socket; my $host = 'localhost'; my $socket = new IO::Socket::INET (PeerAddr = $host, PeerPort = 80, Proto= 'tcp') or die Cannot connect to the server.\n; $socket-autoflush(1) print $socket GET /index.htm HTTP/1.0\n\n; while($socket){ print } close $socket; -Original Message- From: Kipp, James Sent: Monday, September 30, 2002 10:27 AM To: 'Octavian Rasnita'; [EMAIL PROTECTED] Subject: RE: What am I missing or doing wrong? seems to work fine for me, but i tested it on a simple web page. Try removing the line $socket-autoflush(1); -Original Message- From: Octavian Rasnita [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 11:08 AM To: [EMAIL PROTECTED] Subject: What am I missing or doing wrong? Hi all, I've taken the following example from a Perl book but it doesn't work well. It should print the content of a web page, but it prints only the first 4 kb, then the page continues opening... and even if I press the stop button after more time, it doesn't print more than 4 kb. After waiting for more time for the page to finish loading, I can see the following error in the log file, even though the page continues loading... [Mon Sep 30 17:03:56 2002] [error] [client 127.0.0.1] Premature end of script headers: test.pl [Mon Sep 30 17:04:13 2002] [error] [client 127.0.0.1] (20507)The timeout specified has expired: ap_content_length_filter: apr_bucket_read() failed Here is the script file I tried: #!/perl/bin/perl -w print Content-type: text/html\n\n; use strict; use IO::Socket; use URI; my $location = 'http://localhost'; my $url = new URI($location); my $host = $url-host; my $port = $url-port || 80; my $path = $url-path || /; my $socket = new IO::Socket::INET (PeerAddr = $host, PeerPort = $port, Proto= 'tcp') or die Cannot connect to the server.\n; $socket-autoflush(1); print $socket GET $path HTTP/1.1\n, Host: $host\n\n; print while ($socket); $socket-close; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: pop-up window with database access
On Fri, 27 Sep 2002 14:43:50 -0400, [EMAIL PROTECTED] (Jim Lundeen) wrote: Hello, I'm creating a web site for our department at my school. We have a sign-up form for a society that people can join. I want to create a MySQL database of university names and allow the user to click on a Lookup button on the sign-up form when they get to the field University Affiliation and the pop-up window would then go out and get a list of universities in the database and allow them to select the university they are with, then the selected value would be put in the correct text box on the main page form. I would guess that JavaScript is involved, but I don't know. Any help (detailed help!) would be very much appreciated by many students and professors from around the world! If you have limited perl knowledge, it will take you some time to develope this yourself, maybe a month? You might be better off buying an existing package which does this.for instance http://www.gossamer-threads.com/scripts/dbman/index.htm P.S. Avoid javascript. It will cause you headaches. :-) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: pop-up window with database access
Avoid Javascript is a pretty far-reaching statement. If you want to launch a popup window, Perl isn't going to do that, Javascript is. It only takes one or two lines of client-side code. There are easy-to-follow Javascript primers at http://javascript.internet.com and http://www.htmlgoodies.com/primers/jsp/jsp_toc.html With regard to the database functionality, Perl and MySQL are powerful tools if you have the time and inclination to learn them. Good reading: 'Learning Perl', 'Perl in a Nutshell', 'CGI Programming with Perl' and 'Programming the Perl DBI' (all O'Reilly books). There is also an O'Reilly MySQL book but I forget the name of it. Actually the documentation that comes with the MySQL distribution is quite good. http://www.mysql.com/doc/en/index.html I also like the SAMS series of SQL books ('Teach Yourself SQL in ...'). This is really a time and learning curve issue. If you don't have much time, maybe an off-the-shelf CGI is the answer. But I think you'll probably get more benefit in the long run if you go through the steps of building it yourself. HTH, Scot R. inSite -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of zentara Sent: Monday, September 30, 2002 10:02 AM To: [EMAIL PROTECTED] Subject: Re: pop-up window with database access On Fri, 27 Sep 2002 14:43:50 -0400, [EMAIL PROTECTED] (Jim Lundeen) wrote: Hello, I'm creating a web site for our department at my school. We have a sign-up form for a society that people can join. I want to create a MySQL database of university names and allow the user to click on a Lookup button on the sign-up form when they get to the field University Affiliation and the pop-up window would then go out and get a list of universities in the database and allow them to select the university they are with, then the selected value would be put in the correct text box on the main page form. I would guess that JavaScript is involved, but I don't know. Any help (detailed help!) would be very much appreciated by many students and professors from around the world! If you have limited perl knowledge, it will take you some time to develope this yourself, maybe a month? You might be better off buying an existing package which does this.for instance http://www.gossamer-threads.com/scripts/dbman/index.htm P.S. Avoid javascript. It will cause you headaches. :-) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Planning Implementing a web project
On 28 Sep 2002 at 18:58, MMKHAJAH wrote: I have a fairly good experince with Perl. I can program under strict, do some OO and connect to databases. Up until this point I didn't do any real big script. So I wonder how to plan and implement big projects ( like web protal, discussion forum ). It sounds like you need to acquaint yourself with the project development lifecycle. Check out the current series of articles at DevShed http://www.devshed.com/Talk/Practices/. Good luck, William -- Lead Developer Knowmad Services Inc. || Internet Applications Database Integration http://www.knowmad.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Has Perl extra memory!?
Hi everybody! One of my program generates a HTML formulary whose number of checkboxes fluctuates (they are named mod_0, mod_1, mod_2, mod_3...etc). Therefore I need a loop in my other program which has to read the formulary : my $count ; for ($count=0; $count = $num; $count++) { my $mod = $cgi-param(mod_.$count) ? $cgi-param(mod_.$count) : ; if ($mod ne ) .etc ($num is the number (-1) of checkboxes and it is stocked in a hidden inputin the Web page) Unfortunately it seems that Perl memorises the values of these $mod_i and doesn't always execute the script with the values that are given to it!! I have tried differents ways of declaring these parameters (our, my, local, outside or inside the loop...etc) and there has always been the same problem. Basically the first formulary you fill is well executed, and after that there is no way to tell when it'll start to bug! Sometimes it executes the formulary you have filled three or four times before! I hope someone could help me with this, this problem is poisoning my programs! Ti Bruno -- Damien Delhomme [EMAIL PROTECTED]
Re: Has Perl extra memory!?
Sounds like a mod_perl problem. If you are using Apache::Registry apache will compile your script once and just keep running it until the child process dies. This means that any global variables you pass to it will stay in scope. How is your script being called? R At 17:45 30/09/2002 +0200, Damien Delhomme wrote: Hi everybody! One of my program generates a HTML formulary whose number of checkboxes fluctuates (they are named mod_0, mod_1, mod_2, mod_3...etc). Therefore I need a loop in my other program which has to read the formulary : my $count ; for ($count=0; $count = $num; $count++) { my $mod = $cgi-param(mod_.$count) ? $cgi-param(mod_.$count) : ; if ($mod ne ) .etc ($num is the number (-1) of checkboxes and it is stocked in a hidden inputin the Web page) Unfortunately it seems that Perl memorises the values of these $mod_i and doesn't always execute the script with the values that are given to it!! I have tried differents ways of declaring these parameters (our, my, local, outside or inside the loop...etc) and there has always been the same problem. Basically the first formulary you fill is well executed, and after that there is no way to tell when it'll start to bug! Sometimes it executes the formulary you have filled three or four times before! I hope someone could help me with this, this problem is poisoning my programs! Ti Bruno -- Damien Delhomme [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: pop-up window with database access
On Mon, 30 Sep 2002 10:28:51 -0500, [EMAIL PROTECTED] (Scot Robnett) wrote: Avoid Javascript is a pretty far-reaching statement. If you want to launch a popup window, Perl isn't going to do that, Javascript is. It only takes one or two lines of client-side code. There are easy-to-follow Javascript Yeah, you are right. But alot of people keep javascript disabled, so if you design your site expecting people to use it, you will be dissapointed. I've turned off pop-up javascript windows in my mozilla preferences because there are so many annoying pop-ads now. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: pop-up window with database access
Define a lot of people. I use Pop-Up Stopper myself, but when there is a popup window that I *want* to see, I can CTRL-click the link. I don't have to turn Javascript off. Most browsers are preconfigured to allow Javascript and the user or the company has to explicitly turn it off. I agree that it's probably going to cover more ground if he keeps the user experience within the main browser window. 95% of the clients I deal with still have Javascript enabled. But 100% of them can see what's going on in their browser, so you have a point. I guess it depends how important the pop-up function is to the project. Perl and MySQL are quite capable of handling the back end, but they're not going to manage this function. Scot R. inSite -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of zentara Sent: Monday, September 30, 2002 11:30 AM To: [EMAIL PROTECTED] Subject: Re: pop-up window with database access On Mon, 30 Sep 2002 10:28:51 -0500, [EMAIL PROTECTED] (Scot Robnett) wrote: Avoid Javascript is a pretty far-reaching statement. If you want to launch a popup window, Perl isn't going to do that, Javascript is. It only takes one or two lines of client-side code. There are easy-to-follow Javascript Yeah, you are right. But alot of people keep javascript disabled, so if you design your site expecting people to use it, you will be dissapointed. I've turned off pop-up javascript windows in my mozilla preferences because there are so many annoying pop-ads now. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Has Perl extra memory!?
The only modules I use are : use CGI; use DBI; use HTML::Template; use Data::Dumper; (I am not the original programmer, I'm trying to make it work!) My script is called by a file .xml with : !--#exec cgi=/perl/interne/annuaire/assoces_modif.pl -- Thank you for your quick answer! - Original Message - From: Robin Cragg [EMAIL PROTECTED] To: Damien Delhomme [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, September 30, 2002 5:52 PM Subject: Re: Has Perl extra memory!? Sounds like a mod_perl problem. If you are using Apache::Registry apache will compile your script once and just keep running it until the child process dies. This means that any global variables you pass to it will stay in scope. How is your script being called? R At 17:45 30/09/2002 +0200, Damien Delhomme wrote: Hi everybody! One of my program generates a HTML formulary whose number of checkboxes fluctuates (they are named mod_0, mod_1, mod_2, mod_3...etc). Therefore I need a loop in my other program which has to read the formulary : my $count ; for ($count=0; $count = $num; $count++) { my $mod = $cgi-param(mod_.$count) ? $cgi-param(mod_.$count) : ; if ($mod ne ) .etc ($num is the number (-1) of checkboxes and it is stocked in a hidden inputin the Web page) Unfortunately it seems that Perl memorises the values of these $mod_i and doesn't always execute the script with the values that are given to it!! I have tried differents ways of declaring these parameters (our, my, local, outside or inside the loop...etc) and there has always been the same problem. Basically the first formulary you fill is well executed, and after that there is no way to tell when it'll start to bug! Sometimes it executes the formulary you have filled three or four times before! I hope someone could help me with this, this problem is poisoning my programs! Ti Bruno -- Damien Delhomme [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: pop-up window with database access
On Mon, 30 Sep 2002 11:47:37 -0500, [EMAIL PROTECTED] (Scot Robnett) wrote: Define a lot of people. I just did a quick google search for javascript statistics, and most of the surveys show somewhere between 10% and 15 % of people have disabled javascript. I guess it depends how important the pop-up function is to the project. Perl and MySQL are quite capable of handling the back end, but they're not going to manage this function. Well you can design your page to not need javascript. Like use frames, with a small frame for you to display your pop-up data in, keep some nice logo in there otherwise. Or you can always just pop open a new browser windowit isn't as cute and a tiny window, but it will always work. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: pop-up window with database access
Jim Lundeen wrote: Hello, I'm creating a web site for our department at my school. We have a sign-up form for a society that people can join. I want to create a MySQL database of university names and allow the user to click on a Lookup button on the sign-up form when they get to the field University Affiliation and the pop-up window would then go out and get a list of universities in the database and allow them to select the university they are with, then the selected value would be put in the correct text box on the main page form. I would guess that JavaScript is involved, but I don't know. Any help (detailed help!) would be very much appreciated by many students and professors from around the world! Jimmy James yeah. javascript seems like a good choice for this kind of client side pop-up window stuff. :-) i don't know how much help we can provide here unless you tell us at least what have you try. what your plan is. any problems(be specific) you encounter. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Has Perl extra memory!?
Damien Delhomme wrote at Mon, 30 Sep 2002 18:48:01 +0200: The only modules I use are : use CGI; use DBI; use HTML::Template; use Data::Dumper; (I am not the original programmer, I'm trying to make it work!) My script is called by a file .xml with : !--#exec cgi=/perl/interne/annuaire/assoces_modif.pl -- I don't know much about this xml feature, but I could imagine that it works like a calling from the command line. In this context, the CGI module will (perhaps) try to read the parameters from STDIN, what should really block your script. Excuse, but as I'm realling lacking in the xml knowledge, I just can't help you how to really solve the problem :-(( Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Has Perl extra memory!?
My script is called by a file .xml with : !--#exec cgi=/perl/interne/annuaire/assoces_modif.pl -- I don't know much about this xml feature, but I could imagine that it works like a calling from the command line. In this context, the CGI module will (perhaps) try to read the parameters from STDIN, what should really block your script. Does STDIN stand for Standard IN ? To be honest I am not familiar with it and I don't know how it could block my script. But I don't really think the fact that this is a XML file and not a HTML file is linked to the problem. In fact a lot a my scripts are called like that, and the prolem occured only with this program. Maybe the use of this loop put forward an error that I may have made in all of my scripts but which only has bad consequences in this case. I'm glad everybody answer that way, I thought I would have to wait a week before someone finally read my e-mail! I would have done it before if I had known! Ti Bruno -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Looking for the Sendmail.pm for Appache ver 1.3
http://search.cpan.org/author/MIVKOVIC/Mail-Sendmail-0.78/Sendmail.pm This has absolutely nothing to do with your Apache version. http://danconia.org Bruce Ambraal wrote: Hi all, Could any one send of tell where I could find this Module. thanks in advance. Bruce -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Realtime output to the browser
Mark Schouten wrote at Fri, 27 Sep 2002 14:44:38 +0200: I'm writing some code to autmatically retrieve a file if the local file is older than a day. I would like to output some data to the browser while this script is running instead of waiting untill the script is done. Here's the code: if (-M $file = 1) { ... } Anyone knows how to do it? $| = 1; Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: problem with overlapping matches and while m//g
On Fri, 27 Sep 2002, nkuipers wrote: Hello, I am trying to get the positions of every instance of a given substring within a given superstring (DNA sequence), and currently have a while ( $super_string =~ m/${sub_string}/gi ) { ... } construct. I was under the impression that the regex transmission would bump along every character and try to match, backtracking even after success to try the character after the first character from the successful match. However, The Camel 3rd says that used in a scalar context, the /g modifier...makes Perl start the next match on the same variable at a position just past where the last one stopped(p151). This is obviously inadequate in cases where one match may commence within another. Suggestions? From the perl cookbook, page: 162 #!/usr/bin/perl -w use strict; my $digits = '123456789'; my @yeslap = $digits =~ /(?=(\d\d\d))/g; print @yeslap\n; '?=' is a zero-width positive look-ahead assertion. In this case it matches three successive \d without the regex engine moving ahead. When it sees the /g it bumps ahead one position. Is this what you need? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Searching Storing
Henry Wong wrote: Henry Wong wrote: I am wondering if you guys can help me out here: I have a log file containing information like this: THU DEC 6 14:55:00 2001111222333444 FRI DEC 7 01:00:00 2001 555666777888 SAT DEC 8 13:00:00 2001xxxxxxxxxxxx SUN DEC 9 04:00:00 2001xxxxxxxxxxxx MON DEC 10 12:00:00 2001xxxxxxxxxxxx TUE DEC 11 09:00:00 2001xxxxxxxxxxxx Having the above log file with the first column containing the usual TIME, following by 4 columns of numerical data, I am thinking of having this program asking the user to input his/her desired starting date ending date, and thus thereby extracting all the relevant 4 column datas corresponding to the above dates. What i'm trying to say is, lets say the user inputs START DATE to be THU DEC 6, and END DATE to be MON DEC 10. So my code will then extract all relevant data corresponding to THU DEC 6 (which is 111, 222, 333, 444) up till MON DEC 10. That means the code would've extracted all 5 rows of data with their corresponding 4 xxx columns (from start date to end date), and then putting it into a file. Ok, i've decided to skip using the Date::Manip coz its giving me lots of problems. Is there a way to compare dates (e.g. Thu Jun 20 12:00:00 2002) and sort them in order? What i've always wanted is to sort them, and subsequently using User's input of Start End date to capture relevant logs as explained below. Assuming that $noforlines is the no of lines the log file has, and that $convertedList[] contains the dates, while $user_start $user_end containing the user's desired start end date, how do i compare dates? The below coding doesn't seem to work right. for ($s=0;$s$noforlines;$s++) { if (($convertedList[$sian]= $user_start)($convertedList[$sian]= $user_end)) { open (USER, ${filename}_REQUEST.TXT); print USER $convertedList[$sian]\t$inputList[$sian]\n; } You can use the Time::Local module to convert the log file dates to epoch time (number of seconds since the epoch date.) use Time::Local; my $wdayre = qr/mon|tue|wed|thu|fri|sat|sun/i; my %months = qw/jan 0 feb 1 mar 2 apr 3 may 4 jun 5 jul 6 aug 7 sep 8 oct 9 nov 10 dec 11/; my $monre = qr/@{[ join '|', keys %months ]}/i; while ( LOG ) { next unless /$wdayre\s+($monre)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)/ $epoch_time = timelocal( $5, $4, $3, $2, $months{$1}, $6 - 1900 ); if ( $epoch_time $start_time and $epoch_time $end_time ) { # do stuff here } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Finding if a module is already 'require'd
How do I find in a function if a particular module is already loaded for eg, sub mysub { my @vars = @_; require Data::Dumper unless ( already_required('Data::Dumper')); print Data::Dumper::Dumper(\@vars); } I want help writing the function already_required() -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: dbmopen can't open /etc/aliases.db file
Hi Bruno, The reason you could not open it properly is that Sendmail changed the hashing algorithm it uses some time back. Have a look at man makemap to see how Sendmail does it. PERL can read the Sendmail hash tables if you save them in the right format R At 16:22 27/09/2002 -0300, Bruno Negrao - Perl List wrote: Yeah it worked! I simply changed the '/usr/lib/news/history' for '/etc/aliases' and the script showed the file contents. But, why? Why dbmopen didn't work? thanks, Bruno. - Original Message - From: david [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, September 27, 2002 3:49 PM Subject: Re: dbmopen can't open /etc/aliases.db file Bruno Negrao - Perl List wrote: Ok david. Could you send me a code example of a database file being opened for reading with tie? thanks, bnegrao. use NDBM_File; tie(%HIST, 'NDBM_File', '/usr/lib/news/history', 1, 0); while (($key,$val) = each %HIST) { print $key, ' = ', unpack('L',$val), \n; } untie(%HIST); this example is directly from perldoc -f tie david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Finding if a module is already 'require'd
Ramprasad A Padmanabhan wrote at Mon, 30 Sep 2002 09:36:50 +0200: How do I find in a function if a particular module is already loaded for eg, sub mysub { my @vars = @_; require Data::Dumper unless ( already_required('Data::Dumper')); print Data::Dumper::Dumper(\@vars); } I want help writing the function already_required() You don't need it. From perldoc -f require: Otherwise, demands that a library file be included if it hasn't already been included. The file is included via the do-FILE mechanism, which is essentially just a variety of eval. Has semantics similar to the following subroutine: So a required module is only loaded when it hadn't been loaded yet. Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
$1, $2, $3, ... as array
Are the $n variables accessible as an array as well? Currently I am using no strict 'refs'; ... ... ${$i} ... but I don't really like that. I know I can do @array = ($string =~ /regexp/); but I need to access the matched strings in the code in s/regexp/code/ge so this is not workable. So did I overpass anything? Thanks, 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: $1, $2, $3, ... as array
while($string=~/regexp/g) { push @arr , $1 } Jenda Krynicky wrote: Are the $n variables accessible as an array as well? Currently I am using no strict 'refs'; ... ... ${$i} ... but I don't really like that. I know I can do @array = ($string =~ /regexp/); but I need to access the matched strings in the code in s/regexp/code/ge so this is not workable. So did I overpass anything? Thanks, 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: Finding if a module is already 'require'd
-Original Message- From: Janek Schleicher [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 10:05 AM To: [EMAIL PROTECTED] Subject: Re: Finding if a module is already 'require'd Ramprasad A Padmanabhan wrote at Mon, 30 Sep 2002 09:36:50 +0200: How do I find in a function if a particular module is already loaded for eg, sub mysub { my @vars = @_; require Data::Dumper unless ( already_required('Data::Dumper')); print Data::Dumper::Dumper(\@vars); } I want help writing the function already_required() You don't need it. From perldoc -f require: Otherwise, demands that a library file be included if it hasn't already been included. The file is included via the do-FILE mechanism, which is essentially just a variety of eval. Has semantics similar to the following subroutine: So a required module is only loaded when it hadn't been loaded yet. As from which version of Perl this functionality has been included. I'm asking this because, I have seen in the DBI code (DBI.pm file) That the author is checking if a DBD::* module has been already installed (loaded) ... Here an extract of DBI.pm file : sub install_driver {# croaks on failure my $class = shift; my($driver, $attr) = @_; my $drh; $driver ||= $ENV{DBI_DRIVER} || ''; # allow driver to be specified as a 'dbi:driver:' string $driver = $1 if $driver =~ s/^DBI:(.*?)://i; Carp::croak(usage: $class-install_driver(\$driver [, \%attr])) unless ($driver and @_=3); # already installed return $drh if $drh = $DBI::installed_drh{$driver}; [snip] José. DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: $1, $2, $3, ... as array
From: Ramprasad A Padmanabhan [EMAIL PROTECTED] while($string=~/regexp/g) { push @arr , $1 } I said that the code that needs access to the $n variables is inside the replacement code of s/regexp/code/ge! The regexp is fairly complex, returns many matched substrings and matches many times during the s///ge. 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]
pop-up window with database access
Hello, I'm creating a web site for our department at my school. We have a sign-up form for a society that people can join. I want to create a MySQL database of university names and allow the user to click on a Lookup button on the sign-up form when they get to the field University Affiliation and the pop-up window would then go out and get a list of universities in the database and allow them to select the university they are with, then the selected value would be put in the correct text box on the main page form. I would guess that JavaScript is involved, but I don't know. Any help (detailed help!) would be very much appreciated by many students and professors from around the world! Jimmy James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Permission Problems
To clarify in my earlier posting, the part where I say, I have played with chown but the fact is nobody can't chown a file that belongs to root. For grins I did: chown nobody:nobody ./fooness.cfg chmod 666 ./fooness.cfg I meant that I issued those commands from the command line. So even with the file owned by nobody and everything is world read/writable I still get a permission denied error. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PPM trouble !
According to the ActiveState docs I have, the environment variables you need to set are: HTTP_proxy HTTP_proxy_user HTTP_proxy_pass For instance: HTTP_proxy=http://proxy.yourdomain.com:portnumber HTTP_proxy_user=youruserid HTTP_proxy_pass=yourpassword HTH. John Nyimi Jose [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I'm trying to install perl modules (DBI actually ...) for windows using PPM. My connection is via proxy and I have set HTTP_proxy , HTTP_user and HTTP_pass variables ... When I type the ppm command : search * I got the following messages: Searching in repository 1 (ActiveState Package Repository) Error: 501 Protocol scheme ' ' is not supported How can I solve this ? Thanks in advance. Jose. DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: State Variables
On Fri, Sep 27, 2002 at 08:29:53PM -0500, Grant Hansen wrote: Can anyone provide an example of how to use a state variable to break out of a loop? Thanks I smell homework. But to be fair: what do you have so far? Why doesn't it do what you want? If you showed us your code where you were trying to use a state variable to break out of a loop, you'd be more likely to get an answer. -- Michael -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Quick ?
It´s represent not; 0 represents FALSE; and not 0 represents TRUE; $quit = 0; while ( ! $quit ){# means while not 0, that means while not false, that means while true any statement; } Try this test: #BEGIN OF CODE $count = 10; $quit = 0; while (! $quit) {# not 0 represents not false or just true, making the while loop to be active print $count, \n; $count--; if ( $count == 0 ) { $quit = 1;# not 1 represents not true or just false, making the while loop to stop } } print 'Press ENTER to quit', \n; $etc = STDIN; #END OF CODE Josimar - Original Message - From: Grant Hansen [EMAIL PROTECTED] To: Perl Beginners [EMAIL PROTECTED] Sent: Saturday, September 28, 2002 12:26 AM Subject: Quick ? What is the ! doing in this statement? $quit = 0; while (! $quit) Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
remove duplicate lines
hi, i want to remove duplicate lines from one file(original file), and save the result to another file. the origianl file like this: [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] --- with each email address a line. I want to remove the duplicate lines(emais adresses) and save the result to a new file. I wrote a program , but it output nothing. can someome help ? Thanks a lot. kevin --- #!/usr/bin/perl -w ### #Remove the duplicate line # #from a orginal file and save # #the result to a file. # ### print Enter the file that has duplicate lines.\n; $Dupli_file=stdin; chomp; print The file you select is '$Dupli_file'\n; open (Dupli_file,$Dupli_file); print Please select the file you want to save the result to:\n; $Resu_file=stdin; chomp; print The result file is $Resu_file\n; open (Resu_file,$Resu_file); while (Dupli_file) { $orin_line=$_; while (Resu_file){ if($_ eq $orin_line) { next; } print Resu_file $orin_line; }; } --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Microsoft Exchange
Can anyone tell me if it's possible to create a mailbox in Exchange 5.5 from perl? Thanks, Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
SQL Table Rows
How is it possible to cycle through an SQL table row by row, without having to increment an ID by 1 in a while loop and go SELECT * FROM table WHERE id=$id ? And how can I find out how many rows are in the table? Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Postgres Select
Dear friend, I don't know if I've figured out what you want, but I've written a script for you. You can test it! Warning!!! I didn't test it, ok! So. It's the following. #!/usr/bin/perl use Pg; # In DBNAME you must change to your database name. $conn = Pg::connectdb(dbname=DBNAME); open (YES, /var/log/this_customer_are.log); open (NO, /var/log/this_customer_arent.log); # In TABLE and COLUMN you must to change to first table and coluna of your database. # In TABLE1 and COLUMN1 you must to change to second table and coluna of your database. $result_first = $conn-exec(select * from TABLE order by COLUMN;); $result_second = $conn-exec(select * from TABLE1 order by COLUMN1;); for($i=0;$i$result_first-ntuples;$i++) { $customer_number_first = $result_first-getvalue($i, COLUMN); for($count=0;$count$result_second-ntuples;$count++) { $customer_number_second = $result_first-getvalue($count, COLUMN); if ($customer_number_first == $customer_number_second) { $costumer_found = 1; } else { $costumer_found = 0; } } if ($costumer_found == 1) { print YES $customer_number_first\n; } elsif ($costumer_found == 0) { print NO $customer_number_first\n; } } close(YES); close(NO); Best regards, Cleiton L. Siqueira Colégio Monjolo [EMAIL PROTECTED] (0xx45) 520-1915 Esta mensagem foi enviada pelo sistema MONJOLO WEBMAIL http://www.colegiomonjolo.com.br -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: State Variables
Here's a simple version... $a = 5; while ($a) { foreach (1..10) { if ($_ == $a) { $exit++; } } last if ($exit); } print \$a is $a\n; R At 20:20 27/09/2002 -0700, Michael Kelly wrote: On Fri, Sep 27, 2002 at 08:29:53PM -0500, Grant Hansen wrote: Can anyone provide an example of how to use a state variable to break out of a loop? Thanks I smell homework. But to be fair: what do you have so far? Why doesn't it do what you want? If you showed us your code where you were trying to use a state variable to break out of a loop, you'd be more likely to get an answer. -- Michael -- 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 know weather perl script is already running?
Hello List, i have a perl script that i have running from a cron Job. It usually opens every 4 hours. But sometimes it takes the script longer to execute its job so after cron opens up the perl script as usual, i have two perl jobs running. Is there any possibility to check weather the script is already running? Maybe i can use a system command in the crontab? any help welcoe greets Johannes -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: remove duplicate lines
On Fri, 27 Sep 2002, waytech wrote: hi, i want to remove duplicate lines from one file(original file), and save the result to another file. the origianl file like this: [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] --- with each email address a line. I want to remove the duplicate lines(emais adresses) and save the result to a new file. I wrote a program , but it output nothing. can someome help ? Thanks a lot. kevin --- #!/usr/bin/perl -w ### #Remove the duplicate line # #from a orginal file and save # #the result to a file. # ### print Enter the file that has duplicate lines.\n; $Dupli_file=stdin; chomp; chomp by default works on $_, to chomp $Dupli_file you will have to say chomp ($Dupli_file); print The file you select is '$Dupli_file'\n; open (Dupli_file,$Dupli_file); When opening a file always check for failure like this open (Dupli_file, $Dupli_file) or die Cannot open $Dupli_file: $!\n; $! will contain the error string. For more info on $! (perldoc perlvar) print Please select the file you want to save the result to:\n; $Resu_file=stdin; chomp; chomp ($Resu_file); print The result file is $Resu_file\n; open (Resu_file,$Resu_file); Check for failure while (Dupli_file) { $orin_line=$_; while (Resu_file){ You are trying to read from a filehandle that has been opened for writing. This will throw a warning message. This logic will not work even if you open the result file for both reading and writing. If the result file is empty to start with, the execution path will never go into the while loop. while (Resu_file) will fail the first time, which means nothing gets written into Resu_file. This makes it fail again the 2'nd time, 3'rd time ... if($_ eq $orin_line) { next; } print Resu_file $orin_line; }; } A hash is more suited for your job #!/usr/bin/perl -w use strict; chomp (my $dupli_file = STDIN); chomp (my $res_file = STDIN); open (DUPLI, $dupli_file) or die Failed to open $dupli_file: $!\n; open (RESULT, $res_file) or die Failed to open $res_file for writing: $!\n; my %res_hash; while (DUPLI) { chomp; unless ($res_hash{$_}++) { print RESULT $_\n; } } close (DUPLI); close (RESULT); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to know weather perl script is already running?
There are two easy ways... If your file creates a lock file when it starts and removes it when it finishes, a chec to see if the file exists will tell you if the script is already running./ On linux / unix systems do a ps and looks for any occurrances of your script name. If there are more than one, then die R At 11:18 30/09/2002 +0200, Theuerkorn Johannes wrote: Hello List, i have a perl script that i have running from a cron Job. It usually opens every 4 hours. But sometimes it takes the script longer to execute its job so after cron opens up the perl script as usual, i have two perl jobs running. Is there any possibility to check weather the script is already running? Maybe i can use a system command in the crontab? any help welcoe greets Johannes -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: SQL Table Rows
Dear Dan, I don't know if I understood what you really want. Therefore I will try to help, ok. I use Postgres as Database. You can find out how many rows have in a table after you run a SQL like this. #!/usr/bin/perl use Pg; $db= Pg::connectdb(dbname=database); # This is a way to do it. $result = $db-exec(SELECT * FROM table;); $number_of_row = $result-ntuples; print $number_of_row; # This is another way to do it. $result = $db-exec(SELECT count(*) FROM table;); $number_of_row = $result-getvalue(0, 0); print $number_of_row; Best regards, Na Sunday, 29 de September de 2002 às 09:44:40 PM, dan escreveu: How is it possible to cycle through an SQL table row by row, without having to increment an ID by 1 in a while loop and go SELECT * FROM table WHERE id=$id ? And how can I find out how many rows are in the table? Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Cleiton L. Siqueira Colégio Monjolo [EMAIL PROTECTED] (0xx45) 520-1915 Esta mensagem foi enviada pelo sistema MONJOLO WEBMAIL http://www.colegiomonjolo.com.br -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Can I append @INC before use module
Hello All, I have a perl script which has (assuming BAR.pm is in /tmp/foo/) BEGIN { push @::INC , /tmp/foo; # use BAR; # Does not work require BAR; # Works fine } Can I get to use 'use' instead of require any how Thanx Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Finding if a module is already 'require'd
From: Ramprasad A Padmanabhan [EMAIL PROTECTED] How do I find in a function if a particular module is already loaded Look at the %INC hash. 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: Microsoft Exchange
Steve wrote: Can anyone tell me if it's possible to create a mailbox in Exchange 5.5 from perl? Thanks, Steve I Dont think that will be the straightforward Why dont u use a mailer and send the mails using SMTP instead of directly creating the mailbox U could use Net::SMTP if you do care Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
re: NET::Netrc
Hello All, I'm trying to use the Netrc module to read from the netrc file. Anyone familiar with it? Below is the code. I'm getting an error stating Can't call method password on an undefined value at ftp.pl line 28. Here is the code. Anyone see the problem. #Get the username and passwd of the remote mach. $mach = Net::Netrc-lookup('Name'); 28:$usr = $mach-login(); #$passwd = $mach-password(); printThe usr is - $usr\n; #printThe passwd is - $passwd\n; William Black _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: SQL Table Rows
right, this is like an outline to what i want to be able to achieve.. -- my table --- row # : id , myid2 , myid3 --- row 1 : 1 , item 1 , item 2 row 2 : 2 , item 3 , item 4 row 3 : 3 , item 5 , item 6 row 4 : 4 , item 7 , item 8 I'm using DBI mysql.. What i want to be able to do, is search through the table using the row number, rather than the column id, myid1, myid2, and myid3. this is how i'm currently going through the database row by row to get all the information: __ START __ $id = 1; $sth = $dbh-prepare(SELECT * FROM table WHERE id=$id); $sth-execute; @ary = $sth-fetchrow_array; while ($ary[0] ne ) { # here i set up the variables which contain the data from the table, which will be used later on, $id++; $sth = $dbh-prepare(SELECT * FROM table WHERE id=$id); $sth-execute; @ary = $sth-fetchrow_array; } __ END __ that's all very well if all id's are there, but if say ID 2 was deleted because the information was no longer needed, the while loop would break straight after ID 1, since there's no data corresponding to ID 2. The table would end up like this: -- my table --- row # : id , myid2 , myid3 --- row 1 : 1 , item 1 , item 2 row 2 : 3 , item 5 , item 6 row 3 : 4 , item 7 , item 8 what i want to be able to do is go through the table row by row and select all the data from each row, rather than have to select by id. any better clues now? and how is it possible to find out how many rows a table has? Dan Cleiton L. Siqueira [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Dear Dan, I don't know if I understood what you really want. Therefore I will try to help, ok. I use Postgres as Database. You can find out how many rows have in a table after you run a SQL like this. #!/usr/bin/perl use Pg; $db= Pg::connectdb(dbname=database); # This is a way to do it. $result = $db-exec(SELECT * FROM table;); $number_of_row = $result-ntuples; print $number_of_row; # This is another way to do it. $result = $db-exec(SELECT count(*) FROM table;); $number_of_row = $result-getvalue(0, 0); print $number_of_row; Best regards, Na Sunday, 29 de September de 2002 às 09:44:40 PM, dan escreveu: How is it possible to cycle through an SQL table row by row, without having to increment an ID by 1 in a while loop and go SELECT * FROM table WHERE id=$id ? And how can I find out how many rows are in the table? Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Cleiton L. Siqueira Colégio Monjolo [EMAIL PROTECTED] (0xx45) 520-1915 Esta mensagem foi enviada pelo sistema MONJOLO WEBMAIL http://www.colegiomonjolo.com.br -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Postgres Select
Dear friend, I don't know if I've figured out what you want, but I've written a script for you. You can test it! Warning!!! I didn't test it, ok! So. It's the following. #!/usr/bin/perl use Pg; # In DBNAME you must change to your database name. $conn = Pg::connectdb(dbname=DBNAME); open (YES, /var/log/this_customer_are.log); open (NO, /var/log/this_customer_arent.log); # In TABLE and COLUMN you must to change to first table and coluna of your database. # In TABLE1 and COLUMN1 you must to change to second table and coluna of your database. $result_first = $conn-exec(select * from TABLE order by COLUMN;); $result_second = $conn-exec(select * from TABLE1 order by COLUMN1;); for($i=0;$i$result_first-ntuples;$i++) { $customer_number_first = $result_first-getvalue($i, COLUMN); for($count=0;$count$result_second-ntuples;$count++) { $customer_number_second = $result_first-getvalue($count, COLUMN); if ($customer_number_first == $customer_number_second) { $costumer_found = 1; } else { $costumer_found = 0; } } if ($costumer_found == 1) { print YES $customer_number_first\n; } elsif ($costumer_found == 0) { print NO $customer_number_first\n; } } close(YES); close(NO); Best regards, Cleiton L. Siqueira Colégio Monjolo [EMAIL PROTECTED] (0xx45) 520-1915 Esta mensagem foi enviada pelo sistema MONJOLO WEBMAIL http://www.colegiomonjolo.com.br -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: NET::Netrc
I havent used this module but look at catching errors it could be something like this $mach = Net::Netrc-lookup('Name') || die Net::Netrc-error() Bye the way you have you created your .netrc file William Black wrote: Hello All, I'm trying to use the Netrc module to read from the netrc file. Anyone familiar with it? Below is the code. I'm getting an error stating Can't call method password on an undefined value at ftp.pl line 28. Here is the code. Anyone see the problem. #Get the username and passwd of the remote mach. $mach = Net::Netrc-lookup('Name'); 28:$usr = $mach-login(); #$passwd = $mach-password(); printThe usr is - $usr\n; #printThe passwd is - $passwd\n; William Black _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Can I append @INC before use module
set PERL5LIB environment varible to /tmp/foo then you will be able to use 'use BAR;' Or give a look at 'perldoc lib' José. -Original Message- From: Ramprasad A Padmanabhan [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 2:53 PM To: [EMAIL PROTECTED] Subject: Can I append @INC before use module Hello All, I have a perl script which has (assuming BAR.pm is in /tmp/foo/) BEGIN { push @::INC , /tmp/foo; # use BAR; # Does not work require BAR; # Works fine } Can I get to use 'use' instead of require any how Thanx Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Can Someone Help Me?
I'm setting up a list for free and pro members. I want the pro members to be able to mail daily. I have this part working. I want the free members to only be able to mail every 4 Days to the list. Using the localtime(time) = (second,minute,hour,day-of-month,month,year,day-of-week,day-of-year) Can someone tell me how to code it to only allow it to mail every 3 days? Thanks Dan
Re: SQL Table Rows
Hi Dan, I'm used to PostgreSQL, but using DBI, that shouldn't matter for what we're doing. On Monday 30 Sep 2002 1:54 pm, dan wrote: right, this is like an outline to what i want to be able to achieve.. -- my table --- row # : id , myid2 , myid3 --- row 1 : 1 , item 1 , item 2 row 2 : 2 , item 3 , item 4 row 3 : 3 , item 5 , item 6 row 4 : 4 , item 7 , item 8 I'm using DBI mysql.. What i want to be able to do, is search through the table using the row number, rather than the column id, myid1, myid2, and myid3. this is how i'm currently going through the database row by row to get all the information: __ START __ $id = 1; $sth = $dbh-prepare(SELECT * FROM table WHERE id=$id); $sth-execute; @ary = $sth-fetchrow_array; while ($ary[0] ne ) { # here i set up the variables which contain the data from the table, which will be used later on, $id++; $sth = $dbh-prepare(SELECT * FROM table WHERE id=$id); $sth-execute; @ary = $sth-fetchrow_array; } __ END __ $sth=$dbh-prepare(SELECT * from table;); $sth-execute || die select failed: $DBI::errstr; while (@ary=$sth-fetchrow_array) { # do your stuff } I've not tested this, but that's all you should need to do. Gary that's all very well if all id's are there, but if say ID 2 was deleted because the information was no longer needed, the while loop would break straight after ID 1, since there's no data corresponding to ID 2. The table would end up like this: -- my table --- row # : id , myid2 , myid3 --- row 1 : 1 , item 1 , item 2 row 2 : 3 , item 5 , item 6 row 3 : 4 , item 7 , item 8 what i want to be able to do is go through the table row by row and select all the data from each row, rather than have to select by id. any better clues now? and how is it possible to find out how many rows a table has? Dan Cleiton L. Siqueira [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Dear Dan, I don't know if I understood what you really want. Therefore I will try to help, ok. I use Postgres as Database. You can find out how many rows have in a table after you run a SQL like this. #!/usr/bin/perl use Pg; $db= Pg::connectdb(dbname=database); # This is a way to do it. $result = $db-exec(SELECT * FROM table;); $number_of_row = $result-ntuples; print $number_of_row; # This is another way to do it. $result = $db-exec(SELECT count(*) FROM table;); $number_of_row = $result-getvalue(0, 0); print $number_of_row; Best regards, Na Sunday, 29 de September de 2002 às 09:44:40 PM, dan escreveu: How is it possible to cycle through an SQL table row by row, without having to increment an ID by 1 in a while loop and go SELECT * FROM table WHERE id=$id ? And how can I find out how many rows are in the table? Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Cleiton L. Siqueira Colégio Monjolo [EMAIL PROTECTED] (0xx45) 520-1915 Esta mensagem foi enviada pelo sistema MONJOLO WEBMAIL http://www.colegiomonjolo.com.br -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: SQL Table Rows
-Original Message- From: dan [mailto:[EMAIL PROTECTED]] Sent: 30 September 2002 13:55 To: [EMAIL PROTECTED] Subject: Re: SQL Table Rows snip __ START __ $id = 1; $sth = $dbh-prepare(SELECT * FROM table WHERE id=$id); $sth-execute; @ary = $sth-fetchrow_array; while ($ary[0] ne ) { # here i set up the variables which contain the data from the table, which will be used later on, $id++; $sth = $dbh-prepare(SELECT * FROM table WHERE id=$id); $sth-execute; @ary = $sth-fetchrow_array; } __ END __ that's all very well if all id's are there, but if say ID 2 was deleted because the information was no longer needed, the while loop would break straight after ID 1, since there's no data corresponding to ID 2. The table maybe you really mean something like this: $sth = $dbh-prepare(SELECT * FROM table); $sth-execute; while ( my ( @ary ) = $sth-fetchrow_array ) { # set up your variables # and do your processing print Got: @ary\n; } There is no WHERE clause on the select - you will get every row back, and there is no need to execute another select, you just iterate through processing each row. This is the simplest solution that I could make, cutting and pasting your own code. Depending on what you are really doing, look at the fetchrow_hash - you can then work with named fields, more robust and easier to maintain. regards Jeff -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Can Someone Help Me?
.--[ Bootscat wrote (2002/09/30 at 09:13:19) ]-- | | I'm setting up a list for free and pro members. | I want the pro members to be able to mail daily. I have this part working. | | I want the free members to only be able to mail every 4 Days to the list. | | Using the localtime(time) = | (second,minute,hour,day-of-month,month,year,day-of-week,day-of-year) | | Can someone tell me how to code it to only allow it to mail every 3 days? | `- Without knowing how your E-mail mailing list software works, this may not even be possible. However to for an easy way to get every third day I would suggest you look at Date::Calc or Date::Manip modules on cpan.org as they have several easy functions for working with dates. - Frank Wiles [EMAIL PROTECTED] http://frank.wiles.org - -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how to know weather perl script is already running?
-Original Message- From: Theuerkorn Johannes [mailto:[EMAIL PROTECTED]] Sent: 30 September 2002 10:18 To: '[EMAIL PROTECTED]' Subject: how to know weather perl script is already running? Hello List, i have a perl script that i have running from a cron Job. It usually opens every 4 hours. But sometimes it takes the script longer to execute its job so after cron opens up the perl script as usual, i have two perl jobs running. Is there any possibility to check weather the script is already running? Maybe i can use a system command in the crontab? any help welcoe greets Johannes -- We use the following subs to do this on Linux: example call: # In your main program: # This will exit 0 if there are no available instances my $instance = getInstance(reporter,3); # maximum of 3 reporters # - # Get an instance name and lock # Used to control the maximum number of instances for a specified process # e.g. reporter.pl sub getInstance { my $name = shift; my $max = shift; my $msg = ''; $max ||= 1; $msg ||= No available instances for '$name' [maximum $max already locked]; my $locked = ''; foreach my $instance ( 1..$max ) { my $token = $name$instance; $locked = $token if lockToken($token); last if $locked; } # Note that we die gracefully print \n$msg\n unless $locked; exit 0 unless $locked; return $locked; } # - sub lockToken { my $token = shift; mkdir /var/lock unless -d /var/lock; mkdir /var/lock/mylocks unless -d /var/lock/mylocks; my $token_file = /var/lock/mylocks/$token; open(FH, $token_file) || LogFatal(Cannot open token locking file '$token_file' for writing: $OS_ERROR); # Return success or failure depending on whether we can exclusively lock the file return flock(FH, LOCK_EX | LOCK_NB); } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: SQL Table Rows
Dan, In MySQL I don't know how you can do, but I believe that in theory is the same thing. #!/usr/bin/perl use Pg; $db= Pg::connectdb(dbname=database); open (FILE, /var/log/file.log); $result = $db-exec(SELECT * FROM table;); for($i=0;$i$result-ntuples;$i++) { $id = $result-getvalue($i,0); $myid2 = $result-getvalue($i,1); $myid3 = $result-getvalue($i,2); print FILE Line nº $i: $id - myid2 - myid3\n; } close(FILE); Na Sunday, 29 de September de 2002 às 09:54:36 PM, dan escreveu: right, this is like an outline to what i want to be able to achieve.. -- my table --- row # : id , myid2 , myid3 --- row 1 : 1 , item 1 , item 2 row 2 : 2 , item 3 , item 4 row 3 : 3 , item 5 , item 6 row 4 : 4 , item 7 , item 8 I'm using DBI mysql.. What i want to be able to do, is search through the table using the row number, rather than the column id, myid1, myid2, and myid3. this is how i'm currently going through the database row by row to get all the information: __ START __ $id = 1; $sth = $dbh-prepare(SELECT * FROM table WHERE id=$id); $sth-execute; @ary = $sth-fetchrow_array; while ($ary[0] ne ) { # here i set up the variables which contain the data from the table, which will be used later on, $id++; $sth = $dbh-prepare(SELECT * FROM table WHERE id=$id); $sth-execute; @ary = $sth-fetchrow_array; } __ END __ that's all very well if all id's are there, but if say ID 2 was deleted because the information was no longer needed, the while loop would break straight after ID 1, since there's no data corresponding to ID 2. The table would end up like this: -- my table --- row # : id , myid2 , myid3 --- row 1 : 1 , item 1 , item 2 row 2 : 3 , item 5 , item 6 row 3 : 4 , item 7 , item 8 what i want to be able to do is go through the table row by row and select all the data from each row, rather than have to select by id. any better clues now? and how is it possible to find out how many rows a table has? Dan Cleiton L. Siqueira [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Dear Dan, I don't know if I understood what you really want. Therefore I will try to help, ok. I use Postgres as Database. You can find out how many rows have in a table after you run a SQL like this. #!/usr/bin/perl use Pg; $db= Pg::connectdb(dbname=database); # This is a way to do it. $result = $db-exec(SELECT * FROM table;); $number_of_row = $result-ntuples; print $number_of_row; # This is another way to do it. $result = $db-exec(SELECT count(*) FROM table;); $number_of_row = $result-getvalue(0, 0); print $number_of_row; Best regards, Na Sunday, 29 de September de 2002 às 09:44:40 PM, dan escreveu: How is it possible to cycle through an SQL table row by row, without having to increment an ID by 1 in a while loop and go SELECT * FROM table WHERE id=$id ? And how can I find out how many rows are in the table? Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Cleiton L. Siqueira Colégio Monjolo [EMAIL PROTECTED] (0xx45) 520-1915 Esta mensagem foi enviada pelo sistema MONJOLO WEBMAIL http://www.colegiomonjolo.com.br -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Cleiton L. Siqueira Colégio Monjolo [EMAIL PROTECTED] (0xx45) 520-1915 Esta mensagem foi enviada pelo sistema MONJOLO WEBMAIL http://www.colegiomonjolo.com.br -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: AW: how to know weather perl script is already running?
Jea, thats it! Thats exactly what i had in mind! Thank you very much! This List and it´s members are excellent! Greets Johannes -Ursprüngliche Nachricht- Von: Robin Cragg [mailto:[EMAIL PROTECTED]] Gesendet: Montag, 30. September 2002 15:10 An: Theuerkorn Johannes Betreff: Re: AW: how to know weather perl script is already running? Hi, firstly, the problem with your script is most likely that your path is wrong (don't forget the `` or system open a shell and then run the command. That means you should try to specify all the patsh in your command line. Secondly, I would not use grep if I were you. ps -wfaux | grep myproc will produce two lines. The first is myprog, the second is \_ grep myprog. :-) Linux is cute like that. It's much simpler to do it all in PERL. I would do the PS too, but I've not seen a module for it yet. This code works. open PS, /bin/ps -wwfaux |; @PS = PS; close PS; my $flag = 0; foreach (@PS) { $flag++ if (/$0/); } die $0: Process already running!\n if ($flag 1); while (1) { sleep 10; } It's also neater to use $0 so you can change your script name. R At 14:35 30/09/2002 +0200, you wrote: Hi Robin, that was the way i wanted to do it, but i got problems with it. I tried to use: #!/bin/sh if ! [`ps ax|grep perl /home/user1/DiREx/generate_database/`] then `scripttorun` fi but it returns the following error: ./call_script: [23038: command not found It seems to use the returned process id as command... So how to write such a script? Greets Johannes -Ursprüngliche Nachricht- Von: Robin Cragg [mailto:[EMAIL PROTECTED]] Gesendet: Montag, 30. September 2002 14:25 An: Theuerkorn Johannes; '[EMAIL PROTECTED]' Betreff: Re: how to know weather perl script is already running? There are two easy ways... If your file creates a lock file when it starts and removes it when it finishes, a chec to see if the file exists will tell you if the script is already running./ On linux / unix systems do a ps and looks for any occurrances of your script name. If there are more than one, then die R At 11:18 30/09/2002 +0200, Theuerkorn Johannes wrote: Hello List, i have a perl script that i have running from a cron Job. It usually opens every 4 hours. But sometimes it takes the script longer to execute its job so after cron opens up the perl script as usual, i have two perl jobs running. Is there any possibility to check weather the script is already running? Maybe i can use a system command in the crontab? any help welcoe greets Johannes -- 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]
Exiting loop to higher level
Hi folks, Quick question I left my books at home. I am sure I'e seen a way to next a loop to a higher level. Let me explain.. while { if ($_ =~ /something I need to find/) { if ($_=~/something that tells me I need to look elsewhere/) { doublenext; # exits to next itteration of while loop :-) Bypassing higher IF. } else { do something cool; } } else { do something less cool; } } I know there is not a function doublenext, but what can I do to get the functionality of the fabled doublenext? Thanks. At work having writers block James Hughes -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Exiting loop to higher level
Drop the double. 'next' is what you're looking for. James Gray On Monday, September 30, 2002, at 09:28 AM, Hughes, James wrote: Hi folks, Quick question I left my books at home. I am sure I'e seen a way to next a loop to a higher level. Let me explain.. while { if ($_ =~ /something I need to find/) { if ($_=~/something that tells me I need to look elsewhere/) { doublenext; # exits to next itteration of while loop :-) Bypassing higher IF. } else { do something cool; } } else { do something less cool; } } I know there is not a function doublenext, but what can I do to get the functionality of the fabled doublenext? Thanks. At work having writers block James Hughes -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: $1, $2, $3, ... as array
On Sep 30, Jenda Krynicky said: Are the $n variables accessible as an array as well? You can use the @- and @+ arrays (which hold offsets) to do your work: for (0 .. $#-) { # do something with substr($X, $-[$_], $+[$_] - $-[$_]) } -- 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 ** stu what does y/// stand for? tenderpuss 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]
AW: Exiting loop to higher level
Thanks, but I need something that will take me past the first if statement... Something that itterates past the if, and tells the while to go on with the next lump of data... next will only break the inner if loop. best regards, James Hughes -Ursprungliche Nachricht- Von: James Edward Gray II [mailto:[EMAIL PROTECTED]] Gesendet: Montag, 30. September 2002 16:34 An: Hughes, James Cc: [EMAIL PROTECTED]; Jones, Jeremy Betreff: Re: Exiting loop to higher level Drop the double. 'next' is what you're looking for. James Gray On Monday, September 30, 2002, at 09:28 AM, Hughes, James wrote: Hi folks, Quick question I left my books at home. I am sure I'e seen a way to next a loop to a higher level. Let me explain.. while { if ($_ =~ /something I need to find/) { if ($_=~/something that tells me I need to look elsewhere/) { doublenext; # exits to next itteration of while loop :-) Bypassing higher IF. } else { do something cool; } } else { do something less cool; } } I know there is not a function doublenext, but what can I do to get the functionality of the fabled doublenext? Thanks. At work having writers block James Hughes -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Microsoft Exchange
There is a new module that was just introduced called Win32::Exchange that can do that very easily. If you are using ActiveState's ActivePerl then you can get it via PPM at Dave Roth's repository. PPM set repository dave http://www.roth.net/perl/packages PPM set save PPM install win32-exchange -Original Message- From: Ramprasad A Padmanabhan [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 6:02 AM To: [EMAIL PROTECTED]; Steve Cc: [EMAIL PROTECTED] Subject: Re: Microsoft Exchange Steve wrote: Can anyone tell me if it's possible to create a mailbox in Exchange 5.5 from perl? Thanks, Steve I Dont think that will be the straightforward Why dont u use a mailer and send the mails using SMTP instead of directly creating the mailbox U could use Net::SMTP if you do care Ram -- 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]
What Type Of Data Structure Is This?
A strange question. I'm using the following data structure to store information from a data base query: $tablename{$table} = { table_name= [$table], index_name= [$index_name], columns = [@column_name], type = [$index_type], tablespace= [$tablespace_name] This works great and I can later extract the info from this structure. I have 2 questions. What type of structure is this and how do I add to it? When I try to add more info from a subsequent query like this: $tablename{$table} = { con_name = [$constraint_name], con_type = [$type], rem_con_name = [$r_constraint_name], created_by= [$generated] }; I lose all the previous information, so that only the above is now stored. What have I done, how do I do what I want, and am I in over my head? -- Ken -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
check process state
Hi guys, I want to do a sub that check if a process is sleeping or not... I wrote the following sub, but I was wondering if it was possible to to it without shell calls... Thanks, jp. sub isSleeping{ # get PID of process to check my $pid = shift || return 0; # get user name my $user; if(`id` =~ /\((\w+)\)/) {$user=$1}; # the 7th field (starting at 0) of top output is the state. # top -b (for batch mode) -U $user (processes of $user). my $state = (split /\s+/, (grep {/$pid/} `top -b -U $user`)[0])[7]; return $state eq sleep; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: What Type Of Data Structure Is This?
$tablename{$table} = { table_name= [$table], index_name= [$index_name], columns = [@column_name], type = [$index_type], tablespace= [$tablespace_name] This works great and I can later extract the info from this structure. I have 2 questions. What type of structure is this and how do I add to it? When I try to add more info from a subsequent query like this: $tablename{$table} = { con_name = [$constraint_name], con_type = [$type], rem_con_name = [$r_constraint_name], created_by= [$generated] }; I lose all the previous information, so that only the above is now stored. What have I done, how do I do what I want, and am I in over my head? For one thing, at least in the case of scalar values, why are you loading the scalars in anonymous arrays? Why not just have con_name = $constraint_name for example? Also, you could only be clobbering previous contents if $table already exists in the overall hash. Otherwise $table is created as a new key and there should be no problem. So you need to use a check, something like if (exists $tablename{$table}) {...next (or whatever)...} else { $tablename{$table} = ... } Check out chapter 9 of the Camel 3rd edition for how to load and access nested data structures. In my opinion it just gets to be to much of a hassle after 3 levels of nesting. So try to re-think your approach if it's too much to deal with, or check out the various Data modules on CPAN. Regards, Nathanael Kuipers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: What Type Of Data Structure Is This?
Hi Ken, the reason you lose your data is simple. You have something of the form: $myscalar = A weird hested hash; you then try to add an entry by doing: $myscalar = Some other data; What you look at it like that, it's clear what is going wrong. What you want is: $tablename{$table}{con_name} = [constraint_name]; Happy to explain hested hashes off list R At 11:24 30/09/2002 -0400, Ken Hammer wrote: A strange question. I'm using the following data structure to store information from a data base query: $tablename{$table} = { table_name= [$table], index_name= [$index_name], columns = [@column_name], type = [$index_type], tablespace= [$tablespace_name] This works great and I can later extract the info from this structure. I have 2 questions. What type of structure is this and how do I add to it? When I try to add more info from a subsequent query like this: $tablename{$table} = { con_name = [$constraint_name], con_type = [$type], rem_con_name = [$r_constraint_name], created_by= [$generated] }; I lose all the previous information, so that only the above is now stored. What have I done, how do I do what I want, and am I in over my head? -- Ken -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: What Type Of Data Structure Is This?
What you have is a hash of hashes, the values of which is a reference to a hash of arrays. The original scalar is a reference to an anonymous hash. The value of each hash key is a reference to an anonymous array. The reason why what you tried doesn't work is that you are assigning a reference to a new anonymous hash instead of adding to the one you have. Try something like this: %{$tablename{$table}}{con_name} = [$constraint_name]; or $tablename{$table}-{con_name} = [$constraint_name]; The first example dereferences the anonymous hash and then accesses the key, and the second one accesses the key indirectly (and is easier to read IMHO). One question, though. Why are you creating anonymous arrays that have only one element? Couldn't table_name = [$table] be more easily written as $table_name = $table? -Original Message- From: Ken Hammer [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 8:24 AM To: [EMAIL PROTECTED] Subject: What Type Of Data Structure Is This? A strange question. I'm using the following data structure to store information from a data base query: $tablename{$table} = { table_name= [$table], index_name= [$index_name], columns = [@column_name], type = [$index_type], tablespace= [$tablespace_name] This works great and I can later extract the info from this structure. I have 2 questions. What type of structure is this and how do I add to it? When I try to add more info from a subsequent query like this: $tablename{$table} = { con_name = [$constraint_name], con_type = [$type], rem_con_name = [$r_constraint_name], created_by= [$generated] }; I lose all the previous information, so that only the above is now stored. What have I done, how do I do what I want, and am I in over my head? -- Ken -- 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]
STDIN
I have an HTML in which I have a text box and 2 combo boxes, what I want to do, is to read the information entered by text and also the informatios selected from the combo boxes (not always used) to compare it with the information on it, I already have the code to get from the database the information I need, but what I really need is help with the information entered and selected. Can somebody help me with this problem? Thanks in advance. Janfek Esquivel. _ Chat with friends online, try MSN Messenger: http://messenger.msn.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: check process state
you could use the Proc::ProcessTable module -Original Message- From: Sylvanie, Jean-Pierre [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 11:39 AM To: '[EMAIL PROTECTED]' Subject: check process state Hi guys, I want to do a sub that check if a process is sleeping or not... I wrote the following sub, but I was wondering if it was possible to to it without shell calls... Thanks, jp. sub isSleeping{ # get PID of process to check my $pid = shift || return 0; # get user name my $user; if(`id` =~ /\((\w+)\)/) {$user=$1}; # the 7th field (starting at 0) of top output is the state. # top -b (for batch mode) -U $user (processes of $user). my $state = (split /\s+/, (grep {/$pid/} `top -b -U $user`)[0])[7]; return $state eq sleep; } -- 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]
Weekly posting statistics - 39/2002
Weekly posting statistics for perl.beginners - week 39 of 2002. From Monday 2002-09-23 to Sunday 2002-09-29 there were 483 articles posted (22798 lines) by 136 authors, giving an average 3.55 articles per author, and an average article length of 47 lpa. The average number of articles per day was 69. There were 109 (23%) original articles, and 374 (77%) replies (articles that started with 'RE:' in their subject line). 60 (44%) authors posted only one article. The authors top-10 by number of articles is as follows: All/Ori Lines lpa Author 47/01896 40 [EMAIL PROTECTED] (David) 21/0 831 39 [EMAIL PROTECTED] (John W. Krahn) 21/0 800 38 [EMAIL PROTECTED] (Michael Fowler) 17/0 661 38 [EMAIL PROTECTED] (Sudarshan Raghavan) 14/0 834 59 [EMAIL PROTECTED] (Timothy Johnson) 14/0 537 38 [EMAIL PROTECTED] (Jenda Krynicky) 14/0 463 33 [EMAIL PROTECTED] (Janek Schleicher) 13/0 403 31 [EMAIL PROTECTED] (Jeff 'Japhy' Pinyan) 12/1 284 23 [EMAIL PROTECTED] (Nkuipers) 9/2 446 49 [EMAIL PROTECTED] (James Edward Gray ... -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
another regx ...
Hi! I am getting no where on this and it is not that hard. I am trying to break down the following: D-2165033-10.TKB61a into D 2165033 10 and 4-2175587-08.TKB63a into 4 2175587 08 using (( $ref, $numt, $id, $ext ) = $PATH[ 7 ] ) =~ /\w-(\d{7})-(\d{2}).[\w+|\d+]/; What am I doing wring? Thanks, Jerry
RE: another regx ...
-Original Question- D-2165033-10.TKB61a = D 2165033 10 and 4-2175587-08.TKB63a = 4 2175587 08 using (( $ref, $numt, $id, $ext ) = $PATH[ 7 ] ) =~ /\w-(\d{7})-(\d{2}).[\w+|\d+]/; What am I doing wring? -My Response- Your parens are in the wrong place. You aren't capturing the word (\w) character at the start. You're capturing four variables, but you only show breaking down into three. The . in your regexp represents any byte, not a literal period, for that you need \. [\w+|\d+] is confusing, since digits are included in \w, just use it. Try: ($ref,$numt,$id,$ext) = ($PATH[7] =~ /(\w)-(\d{7})-(\d{2})\.(\w+)/); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
opening MS ACCESS via the system function
Lo, I'm attempting to write a program that will run daily, and perform the following actions: 1. Open a database in MS Access 2002, 2. Execute a program in SAS v8.02 that will, simply put, do a lot of statistical analyses and compare the current database to the backup from the night before to identify any changes, and 3. Generate a txt report summarizing the analyses and send the report to a handful of users via email. The problem is this: I have user-level security B.S. on the MS Access database. In order for SAS to do its things, the Access database needs to be open, which I was going to do via the perl system function. However, I can't open the database without providing Access with a logon and password. Does anyone have any ideas or suggestions here? Is there a way to send the logon and password when I invoke the Access via system? I know there's a DBD::ODBC module that I can use to get at the data, but I'm pretty sure that it won't open the database. ANY suggestions or ideas would be appreciated. This is my first program in perl. Thanks. Doug out. --- Douglas Cacialli - Data Manager / Data Analyst Sleep and Depression Research Laboratory University of Rochester Medical Center 300 Crittenden Blvd. - Box PSYCH Rochester, New York 14642 Phone: (585)273-3309 Fax: (585)506-0287 NOTE NEW FAX NUMBER --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Searching Storing
Henry Wong wrote: Hi all, I tried using the below codes provided but i got an error saying Can't locate Date/Manip.pm in @INC...etc. I reckon that the Date::Manip do not exist in my library. Any other alternatives for my problem below? Regards, you just have to install Date::Manip. it's very easy to install. it's a stand alone module written entirely in Perl and do not requires any other external module. try install it this way: perl -MCPAN -e 'install Date::Manip' if that doesn't work, do the following: 1. download Date::Manip from CPAN manually 2. untar it like tar -zxf Date::Manip module 3. cd Date::Manip directory 4. perl Makefile.PL 5. make 6. make test 7. make install 8. make clean run the above as 'root' and it should install without error. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: another regx ...
This idea is even simpler though not purely regex: $yourstring =~ s/\..*//; @result = split /-/, $yourstring; = Original Message From Mark Anderson [EMAIL PROTECTED] = -Original Question- D-2165033-10.TKB61a = D 2165033 10 and 4-2175587-08.TKB63a = 4 2175587 08 using (( $ref, $numt, $id, $ext ) = $PATH[ 7 ] ) =~ /\w-(\d{7})-(\d{2}).[\w+|\d+]/; What am I doing wring? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: opening MS ACCESS via the system function
Check out the Win32::SetupSup module. You should be able to open the program via system, find the window, and send the keystrokes to it using this module. -Original Message- From: Cacialli, Doug [mailto:[EMAIL PROTECTED]] Sent: Monday, September 30, 2002 10:16 AM To: '[EMAIL PROTECTED]' Subject: opening MS ACCESS via the system function Lo, I'm attempting to write a program that will run daily, and perform the following actions: 1. Open a database in MS Access 2002, 2. Execute a program in SAS v8.02 that will, simply put, do a lot of statistical analyses and compare the current database to the backup from the night before to identify any changes, and 3. Generate a txt report summarizing the analyses and send the report to a handful of users via email. The problem is this: I have user-level security B.S. on the MS Access database. In order for SAS to do its things, the Access database needs to be open, which I was going to do via the perl system function. However, I can't open the database without providing Access with a logon and password. Does anyone have any ideas or suggestions here? Is there a way to send the logon and password when I invoke the Access via system? I know there's a DBD::ODBC module that I can use to get at the data, but I'm pretty sure that it won't open the database. ANY suggestions or ideas would be appreciated. This is my first program in perl. Thanks. Doug out. --- Douglas Cacialli - Data Manager / Data Analyst Sleep and Depression Research Laboratory University of Rochester Medical Center 300 Crittenden Blvd. - Box PSYCH Rochester, New York 14642 Phone: (585)273-3309 Fax: (585)506-0287 NOTE NEW FAX NUMBER --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Searching Storing
Henry Wong wrote: Ok, i've decided to skip using the Date::Manip coz its giving me lots of problems. Is there a way to compare dates (e.g. Thu Jun 20 12:00:00 2002) and sort them in order? What i've always wanted is to sort them, and subsequently using User's input of Start End date to capture relevant logs as explained below. Assuming that $noforlines is the no of lines the log file has, and that $convertedList[] contains the dates, while $user_start $user_end containing the user's desired start end date, how do i compare dates? The below coding doesn't seem to work right. for ($s=0;$s$noforlines;$s++) { if (($convertedList[$sian]= $user_start)($convertedList[$sian]= $user_end)) { open (USER, ${filename}_REQUEST.TXT); print USER $convertedList[$sian]\t$inputList[$sian]\n; } Pls advise, thanks. Regards, ~ HENRY WONG ~ what problem do you have with Date::Manip? :-) I found it very easy to use. anyway, if you don't want to use Date::Manip, you can still sort/compare date/time. there are a couple ways(at least) of doing this: 1. compare the date/time as string. consider you have the following 2 dates: my $date1 = '2002-12-23 21:34:45'; my $date2 = '2002-12-21 09:08:12'; you can compare them like: if($date1 $date2){ print yes\n; }else{ print no\n; } which we use it as string and compare it like a string. you must remember to make all of your dates the same exact format. if you don't, you will run into problem like: my $date1 = '2002-12-23 21:34:45'; my $date2 = '2002-2-23 02:34:12'; suddenly, $date2 is 'bigger' than $date1 but $date1 is Dec 2002 and $date1 is only Feb 2002. 2. another way is to convert the date string into seconds with Time::Local and localtime. when the user enter a date, convert it to seconds and then compare it with whatever you parsed from the log. i would recommand you using this method david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: system call troubles...
Jenda Krynicky wrote: Windows is one example. There you do not create a new process by forking and then changin the program your process executes, but by a CreateProcess(): (from MSDN) The CreateProcess function creates a new process and its primary thread. The new process runs the specified executable file in the security context of the calling process. BOOL CreateProcess( LPCTSTR lpApplicationName, LPTSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCTSTR lpCurrentDirectory, LPSTARTUPINFO lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation ); fork() is totally alien to Windows. Therefore perl under Windows implements system() with CreateProcess(), fork() is emulated by creating thread and exec() uses CreateProcess() and exits the current thread or process. This means that it's much more efficient to use system() then fork() exec() under Windows. Jenda P.S.: I did not look at the actual implementation of fork(), exec() and system() in Perl sources. This is just from what I know about windows and what I read in the docs and posts. But I believe I am about right. Perl implement fork() internally (after 5.6.X i think) so even OS that do not support fork() can be fork. i am not sure if that is true on Windos or not. prior to 5.6, yes fork() is implemented differently(or not implemented at all for some OS) but after 5.6, Perl handles this by dupping itself, which is very expensive according to the doc but it gives all user on all OS the same interface to the [U|Li]nux fork world. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: check process state
On Mon, 30 Sep 2002 11:38:40 -0400, [EMAIL PROTECTED] (Jean-Pierre Sylvanie) wrote: Hi guys, I want to do a sub that check if a process is sleeping or not... I wrote the following sub, but I was wondering if it was possible to to it without shell calls... My top command dosn't allow for -U or $user. Maybe you meant to use ps ? sub isSleeping{ # get PID of process to check my $pid = shift || return 0; # get user name my $user; if(`id` =~ /\((\w+)\)/) {$user=$1}; # the 7th field (starting at 0) of top output is the state. # top -b (for batch mode) -U $user (processes of $user). my $state = (split /\s+/, (grep {/$pid/} `top -b -U $user`)[0])[7]; return $state eq sleep; } Try this Proc::ProcessTable method: ## #!/usr/bin/perl -w use strict; use Proc::ProcessTable; my $t = new Proc::ProcessTable; foreach my $p ( @{$t-table} ){ print $p-pid,\t,$p-state,\t,$p-cmndline,\n; } ### -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Permission Problems
Josh wrote: To clarify in my earlier posting, the part where I say, I have played with chown but the fact is nobody can't chown a file that belongs to root. For grins I did: chown nobody:nobody ./fooness.cfg chmod 666 ./fooness.cfg I meant that I issued those commands from the command line. So even with the file owned by nobody and everything is world read/writable I still get a permission denied error. that's interesting! even the file is world read/writable, you still have the permission denied error. hum... could it be that another process is locking up the file? david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to snip the end of a huge log file
Mark Richmond wrote: Hi: I have may huge log files where all I care about is the error at the end how can seek backwards to find my pattern and snip off the end. I'm looking for strings like. Rebuilding link which only occur once when reading backwards but may times when reading forward. here is one way of doing it with seek/tell. it reads the foo.txt file line by line from the end: #!/usr/bin/perl -w use strict; my @character; open(FH,foo.txt) || die $!; seek(FH,(-s foo.txt)-2,0); while(1){ read(FH,$b,1); if($b eq \n){ #-- one line. do your stuff here print join('',@character),\n; @character = (); }else{ unshift @character,$b; } #-- the following is for the first 2 lines from the top seek(FH,tell(FH)-2,0); next unless(tell(FH) == 1); read(FH,$b,1); unshift @character,$b; seek(FH,0,0); read(FH,$b,1); unshift @character,$b; print join('',@character),\n; last; } close(FH); __END__ i am sure you can make the above better. :-) david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Breaking out of STDIN Question
Jenda Krynicky wrote: If you want to stop input based on what the user entered on the command line then you have to read ONE line at a time and not use an array for input. BTW your loop will only read numbers and not strings because the test '== 0' will evaluate strings in a numerical context which are always equal to 0. Unless the string starts with a number that is not equal to zero :-) true but if you have warning enable (which i think is a good idea), Perl will warn you about this even the string starts with a number but doesn't contain purely number. so if you want to avoid those warning, you can disable warning (which is not recommanded) or you have to enter a pure number. :-) david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: SQL Table Rows
Dan wrote: How is it possible to cycle through an SQL table row by row, without having to increment an ID by 1 in a while loop and go SELECT * FROM table WHERE id=$id ? And how can I find out how many rows are in the table? Dan have you try: SELECT * FROM table; and then just cycle it through with DBI like: while(@array = $sth-fetchrow_array){ #-- @array holds a single row from table #-- $array[0] is the first field of the row #-- $array[1] is the second field of the row #-- ... etc #-- i think you get the idea right? } to find out how many rows are in the table, try: SELECT COUNT(*) FROM table; david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Finding if a module is already 'require'd
Ramprasad A Padmanabhan wrote: How do I find in a function if a particular module is already loaded for eg, sub mysub { my @vars = @_; require Data::Dumper unless ( already_required('Data::Dumper')); print Data::Dumper::Dumper(\@vars); } I want help writing the function already_required() if you use the compile time 'use Data::Dumper' then you don't have to worry abut this since Perl will complain and won't compile if the module is missing. if you try to do it in run time, here is one way: sub already_required{ my $module = shift; eval{ require $module; }; if($@){ #-- something is wrong. $module could be missing return 0; }else{ #-- looks like $module is successfully loaded! return 1; } } david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to know weather perl script is already running?
Theuerkorn Johannes wrote: Hello List, i have a perl script that i have running from a cron Job. It usually opens every 4 hours. But sometimes it takes the script longer to execute its job so after cron opens up the perl script as usual, i have two perl jobs running. Is there any possibility to check weather the script is already running? Maybe i can use a system command in the crontab? any help welcoe greets Johannes try the Proc::ProcessTable module. example to find a process 'running.pl': #!/usr/bin/perl -w use strict; use Proc::ProcessTable; my $t = new Proc::ProcessTable; foreach my $p (@{$t-table}){ if($p-cmndline =~ /running\.pl/){ print $p-cmndline, already running!\n; last; } } __END__ david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Can I append @INC before use module
Ramprasad A Padmanabhan wrote: Hello All, I have a perl script which has (assuming BAR.pm is in /tmp/foo/) BEGIN { push @::INC , /tmp/foo; # use BAR; # Does not work require BAR; # Works fine } Can I get to use 'use' instead of require any how Thanx Ram what sort of error message do you get? assume i have: /home/david/perl/A.pm, the following works for me: BEGIN{ push @INC, '/home/david/perl'; use A; } david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: pop-up window with database access
Jim Lundeen wrote: Hello, I'm creating a web site for our department at my school. We have a sign-up form for a society that people can join. I want to create a MySQL database of university names and allow the user to click on a Lookup button on the sign-up form when they get to the field University Affiliation and the pop-up window would then go out and get a list of universities in the database and allow them to select the university they are with, then the selected value would be put in the correct text box on the main page form. I would guess that JavaScript is involved, but I don't know. Any help (detailed help!) would be very much appreciated by many students and professors from around the world! Jimmy James yeah. javascript seems like a good choice for this kind of client side pop-up window stuff. :-) i don't know how much help we can provide here unless you tell us at least what have you try. what your plan is. any problems(be specific) you encounter. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: check process state
Jean-Pierre Sylvanie wrote: Hi guys, I want to do a sub that check if a process is sleeping or not... I wrote the following sub, but I was wondering if it was possible to to it without shell calls... Thanks, jp. sub isSleeping{ # get PID of process to check my $pid = shift || return 0; # get user name my $user; if(`id` =~ /\((\w+)\)/) {$user=$1}; # the 7th field (starting at 0) of top output is the state. # top -b (for batch mode) -U $user (processes of $user). my $state = (split /\s+/, (grep {/$pid/} `top -b -U $user`)[0])[7]; return $state eq sleep; } i don't understand why people keep using 'ps' or 'top' and then do a bunch of regular expression to look for a program/process that they want. this is so inefficient(more coding especially the reg. portion), unsafe(if $user happens to be: 'whatever;rm -fr /*' and you are root, your system is gone, forever!), not portable(not every system use the exact same display for top or ps. what happen if all the ps or top change the display format? are you all going to re-do all of your reg. expression to match the new format? another change, another re-do?). sorry about the complian! it's my only 2cent of the day. i promise. :-) please check out the Proc::ProcessTable in CPAN. it does everything you ask for and much more such as 'give me all process that's using more than 50% of the system memory' or 'give me a list of process that have sleep for more than 5 minutes'... etc. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: STDIN
Janfek Esquivel wrote: I have an HTML in which I have a text box and 2 combo boxes, what I want to do, is to read the information entered by text and also the informatios selected from the combo boxes (not always used) to compare it with the information on it, I already have the code to get from the database the information I need, but what I really need is help with the information entered and selected. Can somebody help me with this problem? Thanks in advance. Janfek Esquivel. _ Chat with friends online, try MSN Messenger: http://messenger.msn.com is your application a CGI application? if so, whatever the text the user enter into the text box is passed in as param. maybe you can check out the CGI module? david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: check process state
Zentara wrote: My top command dosn't allow for -U or $user. Maybe you meant to use ps ? the -U argument only exist for a certain version of top Top version 3.4 has it in my UNIX machine in my Linux box: [david@panda]$ top -V top (procps version 2.0.7) doesn't have it. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: $1, $2, $3, ... as array
From: david [EMAIL PROTECTED] Jenda Krynicky wrote: Are the $n variables accessible as an array as well? Currently I am using no strict 'refs'; ... ... ${$i} ... but I don't really like that. I know I can do @array = ($string =~ /regexp/); but I need to access the matched strings in the code in s/regexp/code/ge so this is not workable. So did I overpass anything? maybe i miss you point and your question. s/regexp/code/ge, the code portion is not matched/search for Perl, it's purely a replacement string(or expression with as many / as you want). OK. I thought the difference between I need to access the matched strings in the code in s/regexp/code/ge vs. I need to access the strings matched in the code in s/regexp/code/ge is big enough :-) This is a little like what I have: $text =~ s{$regexp}{ my $tagname = $1; my %params = ('' = '%'); my $i = 2; no strict 'refs'; while (defined ${$i}) { $params{${$i}} = ${$i+1}; ... $i+=2; } ... }ge The ${$i} and ${$i+1} is the thing I do not like. 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: Can I append @INC before use module
On Mon, Sep 30, 2002 at 11:25:32AM -0700, david wrote: what sort of error message do you get? assume i have: /home/david/perl/A.pm, the following works for me: BEGIN{ push @INC, '/home/david/perl'; use A; } Are you sure? Remember that . is in @INC by default. In this case you want the use statement after the BEGIN block. But really you want use lib. It goes back to before anything that anyone should reasonably be using now. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
CGI Script and getting the PID
Hi all, I've run into a bit of a problem. I need to see if a program is currently running. If it is, I want to display this on a web page that tells the status of the program (either on or off). The script I created which is probably longer than it needs to be, basically issues a system(ps -A) call and writes it out to a file which in turns gets parsed through. This works fine from the command line. However, when I try to execute this same script by accessing the web page, it won't write the file to the directory which causes it to in turn display incorrect results. I am not sure what permissions a cgi-script (or the directory it resides in) should have so I didn't want to just try to change permissions to allow it to write. I may be approaching this the wrong way entirely so any help would be greatly appreciated! Jessee -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Or Syntax
When I read about this Module it really was not clear about using it with strings. I tried it with the following code and it is causing so many problems. If anyone has any Ideas it would be appreciated, I have been pounding my head with this for a while now. if ($partition eq Public){ open(PUBLIC_ALERTSFILE,$public_alerts_index_txt_filename); print PUBLIC_ALERTSFILE$oid. :: .$title. :: ..$partition. :: .$date\n; close(PUBLIC_ALERTSFILE)|| die can't close $file: $!; } if ($partition eq any(qw/Public OPSEC SDK)){ open(OPSEC_ALERTSFILE,$opsec_alerts_index_txt_filename); print OPSEC_ALERTSFILE$oid. :: .$title. :: ..$partition. :: .$date\n; close(OPSEC_ALERTSFILE)|| die can't close $file: $!; } if ($partition eq any(qw/Public OPSEC SDK Gold/Platinum)){ open(ADVANCED_ALERTSFILE,$advanced_alerts_index_txt_filename); print ADVANCED_ALERTSFILE$oid. :: .$title. :: ..$partition. :: .$date\n; close(ADVANCED_ALERTSFILE)|| die can't close $file: $!; } if ($partition eq any(qw/Public OPSEC SDK Gold/Platinum CSP)){ open(CSP_ALERTSFILE,$csp_alerts_index_txt_filename); print CSP_ALERTSFILE$oid. :: .$title. :: ..$partition. :: .$date\n; close(CSP_ALERTSFILE)|| die can't close $file: $!; } Thank you in advance Lance -Original Message- From: Janek Schleicher [mailto:[EMAIL PROTECTED]] Sent: Friday, September 27, 2002 3:16 AM To: [EMAIL PROTECTED] Subject: Re: Or Syntax Lance Prais wrote at Fri, 27 Sep 2002 01:55:31 +0200: If a=b or a=c or a=d do this How would I do that? I thought I could do it like this but it did not work. 1. If ($a=b) || ($a=c) || ($a=d) { DO this } 2. If ($a=b) || if ($a=c) || if ($a=d) { DO this } If there are some things to compare with for equality, it's sometime also a good idea to use a hash for a direct lookup: my %valid_value = map {$_ = 1} (qw/b c d)); if ($valid_value{$a}) { ... } If time doesn't play any role, but nice code does, there's also the use Quantum::Superpositions; if ($a == any(qw/b c d)) { ... } way. Greetings, Janek -- 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]
Reading mail headers from mqueue
Hi; Looking to read in mail headers from /var/spool/mqueue/ and load them into an array or hash to filter based on some rules. I know there must be a good module out there to do this. I just want To,From,CC and Subject. given you have a file with the headers in $_ anybody out there using Mail:: like this ? Thanks Scot -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: What Type Of Data Structure Is This (Summary)
The structure is a hash of hashes. Thanks to: nkuipers [EMAIL PROTECTED] Robin Cragg [EMAIL PROTECTED] Timothy Johnson [EMAIL PROTECTED] who correctly pointed this also to me. They also provided some information on how to add items to the array, and an easier way to populate the hash. I was using an anonymous hash method. Thanks Again Original Post: A strange question. I'm using the following data structure to store information from a data base query: $tablename{$table} = { table_name= [$table], index_name= [$index_name], columns = [@column_name], type = [$index_type], tablespace= [$tablespace_name] This works great and I can later extract the info from this structure. I have 2 questions. What type of structure is this and how do I add to it? When I try to add more info from a subsequent query like this: $tablename{$table} = { con_name = [$constraint_name], con_type = [$type], rem_con_name = [$r_constraint_name], created_by= [$generated] }; I lose all the previous information, so that only the above is now stored. What have I done, how do I do what I want, and am I in over my head? -- Ken Hammer University Of Michigan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Or Syntax
David, Thank you for your help but I think I am not explaining myself correctly. I am writing to four separate .txt files file where the array [2] is assigned to the variable $partition If $partition eq Public only write to a file called $public_text If $partition eq Public or $partition eq OPSEC SDK then write to a file called $opsec_text If $partition eq GOLD or $partition eq Public or $partition eq OPSEC SDK then write to a file called advanced If $partition eq CSP or If $partition eq GOLD or $partition eq Public or $partition eq OPSEC SDK then write to a file called CSP Does that make sense? Thank you in advance Lance -Original Message- From: david [mailto:[EMAIL PROTECTED]] Sent: Friday, September 27, 2002 12:33 PM To: [EMAIL PROTECTED] Subject: Re: Or Syntax Lance Prais wrote: If I wanted to say: If a=b or a=c r a=d do this How would I do that? don't use '=' for comparison, sue '==' for numeric comparison and 'eq' for string I thought I could do it like this but it did not work. 1. If ($a=b) || ($a=c) || ($a=d) { DO this } the above is syntax error. should have been: if($a eq 'b' || $a eq 'c' || $a eq 'd'){ } 2. If ($a=b) || if ($a=c) || if ($a=d) { DO this } the above is also syntax error i notice that in your code, you sometimes have: if($a eq 'Public'){ $b = 1; } if($a eq 'Public' || $a eq 'Whatever'){ $b = 2; } if($a eq 'Public' || $a eq 'Whatever' || $a eq 'Something'){ $b = 3; } now if $a is 'Public', all three of the if statement is true and the last if statement sets $b equal to 3 which overwrites whatever is set in the first 2 if statement. i am not sure if that's really what you want or do you mean: if($a eq 'Public'){ }elsif($a eq 'Whatever'){ }elsif($a eq 'Something'){ }else{ } david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Printing A Hash of Hashes
From a previous post I needed to identify a particular data structure. It is a hash of hashes. Now, I need to print the hash out. I'm using the code from the Programing Perl 3rd edition from O'Reilly on how to print out the hash and of course I'm having a problem. This is from Chapter 9, page 281 slighly changed to reflect my values: for $table ( keys %tablename) { print Table Name: $table \n; for $items ( keys %{ $tablename{$table} } ) { print \t$items=$tablename{$table}{$items}\n ; } print \n; Here are the results: Table Name: TURBINE_PERMISSION con_name=ARRAY(0x216de8) index_name=TURBINE_PERMISSION_PK con_type=ARRAY(0x216c8c) columns=PERMISSION_ID created_by=ARRAY(0x211a50) type=NORMAL rem_con_name=ARRAY(0x211b04) tablespace=CTNG This is the code that created the hash of hashes. It was done in 2 parts: First part (initilizing): $tablename{$table} = { index_name= $index_name, columns = @column_name, type = $index_type, tablespace= $tablespace_name }; Adding to the hash: $tablename{$table} - {con_name} = [$constraint_name]; $tablename{$table} - {con_type} = [$type]; $tablename{$table} - {rem_con_name} = [$r_constraint_name]; $tablename{$table} - {created_by} = [$generated]; The above is from the help (thank you) from a previous post. Why am I getting the value in the first part, and the memory location for the second part? In other words, the key/values print out as expected from the initializing loop, but not from the adding part? -- Ken Hammer University Of Michigan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]