Re: How do you build your HTML?
Kevin Old wrote: Hi Chris, Well, I already use HTML::Mason as a templating engine and everything is fine. What I need is a way to generate HTML 4.01 compliant HTML. Basically taking the concept of CGI.pm, but keeping the resulting HTML up to date with the HTML specifications. For example, if you use CGI.pm or write a table by hand without the width parameter of the table the HTML validator at w3.org will not validate your HTML. That doesn't really seem to be software problem. Better authoring software would probably just not let you complete the table insertion without this critical specification. It might offer the convenience of a best-guess default, but that is really all it should do, since table width is intrinsically a design decision. I found this out the hard way. For years I wondered why my tables always came out funky in Netscape. Then I relaized that it just wanted that overall parameter before it could crunch the internal dimensions of a table. The tables where I had specified width came out nicely. Better to just give the spec. HTML is very flexible, accepting width as absolute pixels or relative percentages of screen width. I know this is just one example, but if that is indicative of the demands made by 4.1, I'd suggest just going with the flow and learning from the error messages. HTML is still a very approachable language. Just as, with Perl, you keep chipping away at your errors until it compoiles cleanly, working with your HTML till it passes muster will simply add more skills to your toolkit. It may also inform your programming/markup. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
how to print modification date
Hello list, I tried to dig my way through my newly acquired Perl ina nutshell and Learning Perl, but I couldn't find a satisfying solution to my problem: How can I print the last modification date of a file? It should work on different systems (*nix and OS X, Win32 is nice to have but not a mus). Any pointers to a solution are very welcome! Feliz navidad, Stephan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
How to Create a hash using SQL 2000
I am using activestate version 5.8 on XP with DBI 1.38. I am trying to return values into an associative array so that I don't keep needing to connect to the database. I am new to perl and DBI is looking like rocket science. The code below has been gleaned from the Internet so I am not completely sure what is going on. Basically I need to read the values into the array so that they can be called anywhere within the script. When I use print drop folder $queue {'cch'}\n; as a test for a known value i get a nil value. Any help would be much appreciated. Cheers Neill sqlstatement=SELECT KeyName,[Value] FROM ConfigTable where SectionName = 'OPIQ'; #Select rows from table $sth = $dbh-prepare($sqlstatement); $sth-execute || die Could not execute SQL statement ... maybe invalid?; while (my $opi = $sth-fetchrow_hashref){ my %queue = $opi }; IMPORTANT NOTICE This email (including any attachments) is meant only for the intended recipient. It may also contain confidential and privileged information. If you are not the intended recipient, any reliance on, use, disclosure, distribution or copying of this email or attachments is strictly prohibited. Please notify the sender immediately by email if you have received this message by mistake and delete the email and all attachments. Any views or opinions in this email are solely those of the author and do not necessarily represent those of Trinity Mirror PLC or its associated group companies (hereinafter referred to as TM Group). TM Group accept no liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. Although every reasonable effort is made to keep its network free from viruses, TM Group accept no liability for any virus transmitted by this email or any attachments and the recipient should use up-to-date virus checking software. Email to or from this address may be subject to interception or monitoring for operational reasons or for lawful business practices. Trinity Mirror PLC is the parent company of the Trinity Mirror group of companies and is registered in England No 82548, with its address at One Canada Square, Canary Wharf, London E14 5AP. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: how to print modification date
Stephan Hochhaus wrote: Hello list, I tried to dig my way through my newly acquired Perl ina nutshell and Learning Perl, but I couldn't find a satisfying solution to my problem: How can I print the last modification date of a file? It should work on different systems (*nix and OS X, Win32 is nice to have but not a mus). Any pointers to a solution are very welcome! The stat() function returns a list of information about a file, including the modification timestamp. This value is in epoch seconds. You can convert it to a printable date using localtime() or gmtime(): $mtime = (stat /etc/passwd)[9]; print scalar localtime $mtime; This will work on all the platforms you listed. If you want more control over the formatting, consider using POSIX strftime() function. perldoc -f stat perldoc -f localtime perldoc -f gmtime perldoc POSIX HTH -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How to Create a hash using SQL 2000
* [EMAIL PROTECTED] [2003-12-16T07:21:19] I am using activestate version 5.8 on XP with DBI 1.38. I am trying to return values into an associative array so that I don't keep needing to connect to the database. I am new to perl and DBI is looking like rocket science. The code below has been gleaned from the Internet so I am not completely sure what is going on. [...] while (my $opi = $sth-fetchrow_hashref){ my %queue = $opi }; I believe this is your problem, not the other bits. $sth-fetchrow_hashref will return a reference to a hash. So, now $opi is { col1 = val1, col2 = val2 } and so on. You're assigning that to %queue, which is a hash that should have pairs put into it. Do you have strict and warnings on? (use strict and use warnings at the top of your script.) If so, you should see a message about assinging an odd number of elements to a hash. Even if you said: %queue = ( 1 = $opi ) you'd be overwriting the element in your hash every time. I suggest you do one of two things: (a) use $dbh-selectall_hashref, which will return a hashref (keyed off the column you indicate) of all the rows returned by the select. So, you could say $queue = $dbh-selectall_hashref($sth); print $queue-{$key}{$column}; (b) make %queue an array; if it's really a queue (and you're going to be shifting work off the bottom) an array is more natural. Then the loop would read: while ($sth-fetchrow_hashref) { push @queue, $_; } (I believe this look should work now. I think there's a caveat in the DBI docs that someday fetchrow_hashref may return the same hashref with new values every time.) IMPORTANT NOTICE This email (including any attachments) is meant only for the intended recipient. It would be nice if you could not send this disclaimer. I realize that might not be an options. -- rjbs pgp0.pgp Description: PGP signature
Re: Split question
John wrote: Here is a little quiz for you beginners out there. split() treats its first argument as a regular expression. There are TWO exceptions where the first argument does not behave the same as a normal regular expression. What are they? I know! Please sir! Actually this 'backwards' sort of question is good for clearing the synapses. There used to be a question in the British driving test which asked 'name six road situations where it would be illegal to park'. Answering this is useless to the task of driving but it does help to float those facts to the forefront of consciousness! Similarly, being able to recite the alphabet backwards is remarkably useful for some character programming. Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
mysql cgi admin and client
Hi, I thought there was something like myphpadmin (for mysql) in perl but I'm not finding it. I'm looking for a perl or mod_perl cgi, to create (as admin) mysql database and tables, data entry interface and access client. Ideally template / css based. Lots of companies sell this sort og thing for under $40, but I suspect there is a GNU one out there? // George -- GEORGE GEORGALIS, System Admin/Architectcell: 646-331-2027IXOYE Security Services, Web, Mail,mailto:[EMAIL PROTECTED] Multimedia, DB, DNS and Metrics. http://www.galis.org/george -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Please help me! Thanks.
On Tue, 16 Dec 2003, pagoda wrote: for (my $value = -1; $value = 1; $value += 0.1) { print $value\n; } Hi, I don't know if it might be helpful, but the following code works better: for ($value = -1; $value = 1; $value += 0.1) { printf (%.1f\n,$value); } This produces: -1.0 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 -0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 Senthil -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: mysql cgi admin and client
After I wrote that, I made some good progress... notably: http://www.thedumbterminal.co.uk/software/webmysql.shtml This might be good too, haven't tried http://sourceforge.net/projects/mysqltool/ // George On 12/15/03, George Georgalis wrote: Hi, I thought there was something like myphpadmin (for mysql) in perl but I'm not finding it. I'm looking for a perl or mod_perl cgi, to create (as admin) mysql database and tables, data entry interface and access client. Ideally template / css based. Lots of companies sell this sort og thing for under $40, but I suspect there is a GNU one out there? // George -- GEORGE GEORGALIS, System Admin/Architectcell: 646-331-2027IXOYE Security Services, Web, Mail,mailto:[EMAIL PROTECTED] Multimedia, DB, DNS and Metrics. http://www.galis.org/george -- GEORGE GEORGALIS, System Admin/Architectcell: 646-331-2027IXOYE Security Services, Web, Mail,mailto:[EMAIL PROTECTED] Multimedia, DB, DNS and Metrics. http://www.galis.org/george -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: mysql cgi admin and client
Try http://www.gossamer-threads.com/scripts/mysqlman/index.htm José. -Original Message- From: George Georgalis [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 16, 2003 6:14 AM To: [EMAIL PROTECTED] Subject: Re: mysql cgi admin and client After I wrote that, I made some good progress... notably: http://www.thedumbterminal.co.uk/software/webmysql.shtml This might be good too, haven't tried http://sourceforge.net/projects/mysqltool/ // George On 12/15/03, George Georgalis wrote: Hi, I thought there was something like myphpadmin (for mysql) in perl but I'm not finding it. I'm looking for a perl or mod_perl cgi, to create (as admin) mysql database and tables, data entry interface and access client. Ideally template / css based. Lots of companies sell this sort og thing for under $40, but I suspect there is a GNU one out there? // George -- GEORGE GEORGALIS, System Admin/Architectcell: 646-331-2027IXOYE Security Services, Web, Mail,mailto:[EMAIL PROTECTED] Multimedia, DB, DNS and Metrics. http://www.galis.org/george -- GEORGE GEORGALIS, System Admin/Architectcell: 646-331-2027IXOYE Security Services, Web, Mail,mailto:[EMAIL PROTECTED] Multimedia, DB, DNS and Metrics. http://www.galis.org/george -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response 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] http://learn.perl.org/ http://learn.perl.org/first-response
Re: pass vars to sub via TK/Button
Oliver Schaedlich wrote: my $win = MainWindow-new(height = 150, -width = 250); Hmm, are you sure this works? [blushin' deep red] Uh, no, actually, I'm pretty sure it doesn't. The MainWindow seems to grow only to the size dictated by its geometry manager to hold all the controls to be packed. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: pass vars to sub via TK/Button
Oliver Schaedlich wrote: Greetings, 15.12.2003, zentara wrote: $main - Button ( -text = 'Add', -command = sub{\add_item($var1,$var2)} ) - pack; [...] sub add_item { [...] my $entry1 = $_[0]-get(); my $entry2 = $_[1]-get(); [...] } thanks for your reply. I tried this out and it works, though I have no idea what it actually does and why I have to alter/decode/whatever the fetched data in the first place. I guess I have to read into get() a bit. Thanks a bunch, same goes to Laurent. Best regards, oliver. There is no decoding happening. Entry is a Tk widget. It is not a string. The string contents are a property held in the widget's hash. The get method is an accessor function that returns this value. AFAIK, Tk does not use the sort of default properties that you might find in VB, where you can assign a Text widget to a string, and the string gets the value of that widgets text. Since Perl stores its references at least partly as strings, you get the reference string when you assign or use a widget referencxe in string context. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Please help me! Thanks.
Paul Johnson wrote: On Tue, Dec 16, 2003 at 02:25:42PM +0800, pagoda wrote: now, a stupid solution is: for (my $value = -1000; $value = 1000; $value += 100) { print $value/1000, \n; } hehe, Not so stupid, really. If you can keep most of your maths confined to integers you will have fewer floating point problems. There's no need to increment in steps of 100 though. $ perl -le 'print $_ / 10 for -10 .. 10' -- Paul Johnson - [EMAIL PROTECTED] Good point. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
What would be the best data structure to keep these values
Hi people, I want trap the results of 'ps -ef' command. I first trap the results by splitting the results in scalar values such as $uid $pid $ppid $stime, etc... I would like, for each line returned, to hold these values in an array, so that, for each uid, I could return its corresponding pid, ppid, stime, cmd, etc. What would be the best data structure to use? An hash table in an array? ... Thanks in advance, Best regards, Steve Hemond Programmeur Analyste / Analyst Programmer Smurfit-Stone, Ressources Forestires La Tuque, P.Q. Tel.: (819) 676-8100 X2833 [EMAIL PROTECTED]
Re: Please help me! Thanks.
Hacksaw wrote: now, a stupid solution is: for (my $value = -1000; $value = 1000; $value += 100) { print $value/1000, \n; } hehe, Sadly, it's not as stupid as you think. Unless I misunderstand things, what you are seeing here is a problem called IEEE 754 floating point. I'm sure there is some explanation that someone could offer as to why it's the best thing, but IEEE754 doesn't represent simple decimals very well. It converts them into binary using an odd method allowing it to represent the number in one chunk, avoiding the mantissa and exponent form. However, this encoding can't represent any decimal not ending in 5 finitely, much the same way it's not possible to represent 1/3 in decimal finitely. The upshot of this is that unless you *really* need floating point math, and are willing to do what is necessary to compensate for the error that will creep in, you should stay away from it. Smart folks will often represent monetary values in hundreths or thousanths of cents, just to avoid floating point math. It's also worth pointing out here that rational values are almost always what is wanted in this sort of situation. The (very nice indeed) Math::Fraction module lets you do just this. The only changes to the code are to initialise $value as a Math::Fraction object with my $value = frac -1 and to convert the value back to decimal for printing (otherwise the values would appear as .. 1/10 1/5 3/10 .. etc.). HTH, Rob use strict; use warnings; use Math::Fraction; for (my $value = frac -1; $value = 1; $value += 0.1) { print $value-decimal, \n; } **OUTPUT -1 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: pass vars to sub via TK/Button
Greetings, 16.12.2003, R. Joseph Newton wrote: There is no decoding happening. Entry is a Tk widget. It is not a string. The string contents are a property held in the widget's hash. The get method is an accessor function that returns this value. AFAIK, Tk does not use the sort of default properties that you might find in VB, where you can assign a Text widget to a string, and the string gets the value of that widgets text. Since Perl stores its references at least partly as strings, you get the reference string when you assign or use a widget referencxe in string context. Ah, I can see the light (Faintly. At the other side of the tunnel. Wait, don't run!). Maybe I should use modules more often. Thanks a bunch! :) Best regards, oliver. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Comparing Hashes with different keys. How ?
Hi, I have two different hashes built from separate data and need to find the common then differing items. $HoA1{$custnum} = [ $uid, $firstname, $lastname ]; $HoA2{$uid} = [ $custnum, $firstname, $lastname ]; I have looked at examples for Finding Common or Different Keys in Two Hashes but the keys must be the same. To make the keys the same I would like to effect a reverse function but only reversing the key and the first value leaving the remaining array items in place. Examples or suggestion would be most appreciated. Thanks John. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How to Create a hash using SQL 2000
[EMAIL PROTECTED] wrote: I am using activestate version 5.8 on XP with DBI 1.38. I am trying to return values into an associative array so that I don't keep needing to connect to the database. I am new to perl and DBI is looking like rocket science. The code below has been gleaned from the Internet so I am not completely sure what is going on. That probably is not the best way to learn Perl. Perl supports many idioms, and this has the result that much of the code you find will be highly idiomatic. The code may work in its own context, but be very fragile when adapted in an imitative manner, without a ground-up understanding of the language. Better to learn Perl, starting from: #!perl use strict; use warnings; print Hello, World\n; Then build up. Basically I need to read the values into the array so that they can be called anywhere within the script. When I use print drop folder $queue {'cch'}\n; as a test for a known value i get a nil value. Any help would be much appreciated. Cheers Neill sqlstatement=SELECT KeyName,[Value] FROM ConfigTable where SectionName = 'OPIQ'; #Select rows from table Huh? This doesn't really look like a SQL statement to me. What is the [Value] doing there? $sth = $dbh-prepare($sqlstatement); $sth-execute || die Could not execute SQL statement ... maybe invalid?; while (my $opi = $sth-fetchrow_hashref){ my %queue = $opi That is not a valid assignment. Did you use strict; use warnings; ? These are a must if you want to understand what is happening with your code. What you are doing here is assigning a simple scalar to a hash. Scalars can only be assigned to hashes in pairs. Instead, you could assign the whole hash: my %queue = %$opi which assigns the hash pointed to by $opi to %queue. That is probably wasteful, though, since the whole hash then has to be loaded into a new hash. Better simply to use $opi, and access your fields through the reference, using the arrow notation: my $address = $opi-{'address'}; }; Can you describe your desired select clearly, preferably in plain language rather than code. If you can explain what you are trying to do with the brackets, we can probably show a better, more portable, way to get there. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: What would be the best data structure to keep these values
* Hemond, Steve [EMAIL PROTECTED] [2003-12-16T10:13:31] I want trap the results of 'ps -ef' command. I first trap the results by splitting the results in scalar values such as $uid $pid $ppid $stime, etc... I would like, for each line returned, to hold these values in an array, so that, for each uid, I could return its corresponding pid, ppid, stime, cmd, etc. What would be the best data structure to use? An hash table in an array? ... The answer really really depends on what you want to do with the data. If you just want to print it back out, an array of arrayrefs is simplest. If you want to query specific fields line-by-line, an array of hashrefs might be best. If you want to look things up by pid, a hash of hashrefs might be best. In order, those would be something like: # LOL - list of lists foreach $line (@ps_results) { push @lines, [ split /\s+/, $line ] } # LOH - list of hashes foreach $line (@ps_results) { @results{uid pid stime} = split /\s+/, $line; # this line is pseudo push @lines, \%results; } # HOH - hash of hashes foreach $line (@ps_results) { @results{uid pid stime} = split /\s+/, $line; # this line is pseudo %lines{$results-{pid}} = \%results; } I'd probably use a HOH, because accessing the data would be easy to write and because *I'd* probably only be /reading/ the data if I thought I'd later need to access it by pid and field name. -- rjbs pgp0.pgp Description: PGP signature
Re: Comparing Hashes with different keys. How ?
On Dec 16, 2003, at 9:36 AM, John Hennessy wrote: Hi, I have two different hashes built from separate data and need to find the common then differing items. $HoA1{$custnum} = [ $uid, $firstname, $lastname ]; $HoA2{$uid} = [ $custnum, $firstname, $lastname ]; I have looked at examples for Finding Common or Different Keys in Two Hashes but the keys must be the same. To make the keys the same I would like to effect a reverse function but only reversing the key and the first value leaving the remaining array items in place. What defines likeness or difference? Do we just need to check one field, two fields together or what? James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Server Errors
I've got the below script saved on my server - but every time I use it I get an Internel Server Error! I've set the permission to 755 but still no luck. Any ideas folks? www.klconsulting.co.uk/cgi-bin/cssc.pl If you run it in abrowser: 1) is it execuatbale? 2) is apache(or whatever webserever) configured to execute .pl files ac cgi 3) therer is no Content-type header 4) what do the logs say? 5) What happens when you execute it via cli? 6) icmp is , as far as I know, only doable as root. I remember using tcp, maybe udp also but I don't do this very often. HTH DMuey #!/usr/bin/perl use Net::Ping; @host_array = (192.153.1.10,192.153.0.18,212.241.168.197,212.241.168. 138,212. 241.167.11,194.153.21.68,194.153.20.100,194.153.20.51, 194.153.20 .52,194.153.20.53,515.35.226.5,212.241.160.12,194.153. 1.19,194 .153.1.18,212.35.224.125,212.35.224.126); $p = Net::Ping-new(icmp); $p-bind($my_addr); foreach $host (@host_array) { print $host is ; print NOT unless $p-ping($host, 2); print reachable.\n; sleep(1); } $p-close(); W. A. Khushil Dep Technical Support Agent PIPEX Communications Plc Phone : 0845 077 83 24 Fax: 08702 434440 WWW: www.pipex.net/support The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Although PIPEX Internet Limited operates anti-virus programs, it does not accept responsibility for any damage whatsoever that is caused by viruses being passed. If you suspect that the message may have been intercepted or amended, please call the sender. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of zentara Sent: 15 December 2003 15:16 To: [EMAIL PROTECTED] Subject: Re: pass vars to sub via TK/Button On Mon, 15 Dec 2003 12:27:34 +0100, [EMAIL PROTECTED] (Oliver Schaedlich) wrote: Greetings, I'd like to know how to pass variables fetched by TK/entry to a subroutine by using a Button. The Button/-command line in the following script is obviously wrong, but should suffice to illustrate what I want it to do. I'd be happy if someone could tell me how to do this properly. #!/usr/bin/perl use strict; use Tk; my $main = MainWindow-new; my $var1 = $main - Entry( -width = 30 ); $var1 - pack; my $var2 = $main - Entry( -width = 30 ); $var2 - pack; $main - Button ( -text = 'Add', -command = sub{\add_item($var1,$var2)} ) - pack; MainLoop; sub add_item { my (@widgets) = @_; print @widgets\n; my $entry1 = $_[0]-get(); my $entry2 = $_[1]-get(); print Added-$entry1 + $entry2 = ,$entry1+$entry2,\n; return; } __END__ -- When life conspires against you, and no longer floats your boat, Don't waste your time with crying, just get on your back and float. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Comparing Hashes with different keys. How ?
John Hennessy wrote: Hi, I have two different hashes built from separate data and need to find the common then differing items. $HoA1{$custnum} = [ $uid, $firstname, $lastname ]; $HoA2{$uid} = [ $custnum, $firstname, $lastname ]; I have looked at examples for Finding Common or Different Keys in Two Hashes but the keys must be the same. To make the keys the same I would like to effect a reverse function but only reversing the key and the first value leaving the remaining array items in place. Hi John. I would start by pulling out the lists of Customer Numbers and User IDs from the two hashes like this: my @custnum1 = keys %HoA1; my @uid1 = map { $Hoa1{$_}[0] } @custnum1; my @uid2 = keys %HoA1; my @custnum2 = map { $Hoa1{$_}[0] } @uid2; Then you only have the job of finding differences and commonalities between @custnum1/@custnum2 and @uid1/@uid2. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: What would be the best data structure to keep these values
Steve Hemond wrote: I want trap the results of 'ps -ef' command. I first trap the results by splitting the results in scalar values such as $uid $pid $ppid $stime, etc... I would like, for each line returned, to hold these values in an array, so that, for each uid, I could return its corresponding pid, ppid, stime, cmd, etc. What would be the best data structure to use? An hash table in an array? ... Hey Steve. Depending on what you want to do with the data, I would just keep a hash relating UID to the entire 'ps' output record: my %ps = map { /(\S+)/; ($1, $_) } `ps -ef`; and then split the record after later extracting it from the hash. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Server Errors
I've got the below script saved on my server - but every time I use it I get an Internel Server Error! I've set the permission to 755 but still no luck. Any ideas folks? www.klconsulting.co.uk/cgi-bin/cssc.pl If you run it in abrowser: 1) is it execuatbale? 2) is apache(or whatever webserever) configured to execute .pl files ac cgi 3) therer is no Content-type header 4) what do the logs say? 5) What happens when you execute it via cli? 6) icmp is , as far as I know, only doable as root. I remember using tcp, maybe udp also but I don't do this very often. HTH Dmuey Also use strict; and warnings that will help imensely. It would have told you $my_addr is uninitialized, which may be the problem. Global symbol $my_addr requires explicit package name at ping.pl line 14. Execution of ping.pl aborted due to compilation errors. Also $p-bind() seems off: Can't locate object method bind via package Net::Ping at ping.pl line 14. What is bind(0 supposed to be form/do? Try this version: (it will ping either the hostname of the server or whatever you specify as arguments) ./ping.pl Or ./ping.pl google.com joemama.com etc.com Once oyu get this oing then add your array and you'll be all set! #!/usr/bin/perl -w use strict; use Net::Ping; my $hstnm = `hostname`; # there are more modular ways of doing this but hey I have the flu! chomp($hstnm); my @hosts = @ARGV; if([EMAIL PROTECTED]) { push @hosts, $hstnm; } my $p = Net::Ping-new('tcp'); for(@hosts) { print $_ :; print ' NOT' unless $p-ping($_); print pingable.\n; sleep(1); } $p-close(); HTH DMuey #!/usr/bin/perl use Net::Ping; @host_array = (192.153.1.10,192.153.0.18,212.241.168.197,212.241.168. 138,212. 241.167.11,194.153.21.68,194.153.20.100,194.153.20.51, 194.153.20 .52,194.153.20.53,515.35.226.5,212.241.160.12,194.153. 1.19,194 .153.1.18,212.35.224.125,212.35.224.126); $p = Net::Ping-new(icmp); $p-bind($my_addr); foreach $host (@host_array) { print $host is ; print NOT unless $p-ping($host, 2); print reachable.\n; sleep(1); } $p-close(); W. A. Khushil Dep Technical Support Agent PIPEX Communications Plc Phone : 0845 077 83 24 Fax: 08702 434440 WWW: www.pipex.net/support The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Although PIPEX Internet Limited operates anti-virus programs, it does not accept responsibility for any damage whatsoever that is caused by viruses being passed. If you suspect that the message may have been intercepted or amended, please call the sender. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of zentara Sent: 15 December 2003 15:16 To: [EMAIL PROTECTED] Subject: Re: pass vars to sub via TK/Button On Mon, 15 Dec 2003 12:27:34 +0100, [EMAIL PROTECTED] (Oliver Schaedlich) wrote: Greetings, I'd like to know how to pass variables fetched by TK/entry to a subroutine by using a Button. The Button/-command line in the following script is obviously wrong, but should suffice to illustrate what I want it to do. I'd be happy if someone could tell me how to do this properly. #!/usr/bin/perl use strict; use Tk; my $main = MainWindow-new; my $var1 = $main - Entry( -width = 30 ); $var1 - pack; my $var2 = $main - Entry( -width = 30 ); $var2 - pack; $main - Button ( -text = 'Add', -command = sub{\add_item($var1,$var2)} ) - pack; MainLoop; sub add_item { my (@widgets) = @_; print @widgets\n; my $entry1 = $_[0]-get(); my $entry2 = $_[1]-get(); print Added-$entry1 + $entry2 = ,$entry1+$entry2,\n; return; } __END__ -- When life conspires against you, and no longer floats your boat, Don't waste your time with crying, just get on your back and float. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For
Re: What would be the best data structure to keep these values
Hi people, I want trap the results of 'ps -ef' command. I first trap the results by splitting the results in scalar values such as $uid $pid $ppid $stime, etc... I would like, for each line returned, to hold these values in an array, so that, for each uid, I could return its corresponding pid, ppid, stime, cmd, etc. What would be the best data structure to use? An hash table in an array? ... Per my usual, no fun for anyone response, I would dispense with shelling out to ps, and use Proc::ProcessTable as your command is not cross platform compatible, error prone, slow, etc. then use its standard interface for retrieving the values you need when you need them... http://danconia.org -- Boycott the Sugar Bowl! You couldn't pay me to watch that game. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How to Create a hash using SQL 2000
Ricardo SIGNES wrote: [Good points, all] (b) make %queue an array; if it's really a queue (and you're going to be shifting work off the bottom) an array is more natural. Then the loop would read: while ($sth-fetchrow_hashref) { push @queue, $_; } (I believe this look should work now. I think there's a caveat in the DBI docs that someday fetchrow_hashref may return the same hashref with new values every time.) Why recommend an approach that is being deprecated? I'd suggest that you [and the OP] use the references returned only in transit, and get that information into locally declared and allocated data structures as soon as possible. There are good reasons for a DB access module to keep the memory footprint of its transfer structures small. Client-side storage for the data should be in memory owned by the client, not in memory borrowed from an interface. Thanks for passing on this warning. I probably would have thought nothing of pushing the refs into a local data structure had you not pointed this out. Once you did, it became instantly clear why the DBI authors would wish to move in this direction. IMPORTANT NOTICE This email (including any attachments) is meant only for the intended recipient. It would be nice if you could not send this disclaimer. I realize that might not be an options. Ditto. Oh well, it probably can't be helped. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Please help me! Thanks.
On Dec 16, 2003, at 7:16 AM, Rob Dixon wrote: [..] Rob use strict; use warnings; use Math::Fraction; for (my $value = frac -1; $value = 1; $value += 0.1) { print $value-decimal, \n; } [..] neat solution, minor problem is that Math::Fraction is not a 'default' module yet. http://search.cpan.org/~kevina/Fraction-v.53b/Fraction.pm An interum work around for the IEEE754 float problem of -0.0 would of course be to test and remove it: for (my $value = -1; $value = 1; $value += 0.1) { my $number = sprintf %.1f, $value; $number = 0 if ( $number == 0 ); print $number\n; } ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Please help me! Thanks.
Rob Dixon wrote: Hacksaw wrote: now, a stupid solution is: for (my $value = -1000; $value = 1000; $value += 100) { print $value/1000, \n; } hehe, Sadly, it's not as stupid as you think. Unless I misunderstand things, what you are seeing here is a problem called IEEE 754 floating point. I'm sure there is some explanation that someone could offer as to why it's the best thing, but IEEE754 doesn't represent simple decimals very well. It converts them into binary using an odd method allowing it to represent the number in one chunk, avoiding the mantissa and exponent form. However, this encoding can't represent any decimal not ending in 5 finitely, much the same way it's not possible to represent 1/3 in decimal finitely. The upshot of this is that unless you *really* need floating point math, and are willing to do what is necessary to compensate for the error that will creep in, you should stay away from it. Smart folks will often represent monetary values in hundreths or thousanths of cents, just to avoid floating point math. It's also worth pointing out here that rational values are almost always what is wanted in this sort of situation. The (very nice indeed) Math::Fraction module lets you do just this. The only changes to the code are to initialise $value as a Math::Fraction object with my $value = frac -1 and to convert the value back to decimal for printing (otherwise the values would appear as .. 1/10 1/5 3/10 .. etc.). HTH, Rob Sounds good. I've always tried to do any multiplication steps [at least within the range expressed as true integers, which in Perl is pretty large] before dividing. Mostly I just ahve a hunch that rounding errors will be minimized if numbers are kept in integfer frm as long as possible. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Comparing Hashes with different keys. How ?
Date sent: Tue, 16 Dec 2003 23:36:16 +0800 From: John Hennessy [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject:Comparing Hashes with different keys. How ? Hi, I have two different hashes built from separate data and need to find the common then differing items. $HoA1{$custnum} = [ $uid, $firstname, $lastname ]; $HoA2{$uid} = [ $custnum, $firstname, $lastname ]; I have looked at examples for Finding Common or Different Keys in Two Hashes but the keys must be the same. To make the keys the same I would like to effect a reverse function but only reversing the key and the first value leaving the remaining array items in place. my %HoA2r; while (my ($key, $value) = each %HoA2) { $HoA2r{$value-[0]} = [ $key, $value-[1], $value-[2]]; } You should probably check whether exists $HoA2r{$value-[0]} and handle the duplicate '$custnum's in the %HoA2 as well. Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: What would be the best data structure to keep these values
On Dec 16, 2003, at 7:13 AM, Hemond, Steve wrote: [..] I first trap the results by splitting the results in scalar values such as $uid $pid $ppid $stime, etc... I would like, for each line returned, to hold these values in an array, so that, for each uid, I could return its corresponding pid, ppid, stime, cmd, etc. [..] One strategy would be to go with http://search.cpan.org/~durist/Proc-ProcessTable-0.39/ProcessTable.pm from the CPAN. An alternative strategy would be something like my pet favorite Process Table Grovellor http://www.wetware.com/drieux/CS/Proj/PID/ In my case I was not trying to use 'ps' as the all singing all dancing process grabber - and hence went with the simpler set of arguments to 'ps' that got me userNamePID PPIDCOMMAND This started out from a question much like yours that got me to a simple piece of code like: http://www.wetware.com/drieux/pbl/Sys/psTree.txt in which you can see that I use a hash of hashes { $pid = { $user = string, $cmd = string, } } HTH. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: mysql cgi admin and client
George Georgalis wrote: After I wrote that, I made some good progress... notably: http://www.thedumbterminal.co.uk/software/webmysql.shtml This might be good too, haven't tried http://sourceforge.net/projects/mysqltool/ // George That sounds good. You didn't say what myphpadmin does, though, so I'm not really sure what functionality you are looking for. The standard tool in Perl for basic DB access is the DBI [database independent] interface, coulple withDBD::target_db as the driver for specific engine target_db. You will want to get familiar with these, though it sounds like yur immediate issue has more to do with database administration. I'm not sure what DBI's capabilities are for design tasks. It does have methods for querying metadata. My guess is that it will also pass DDL statements as well as SQL. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: What would be the best data structure to keep these values
Hemond, Steve wrote: Hi people, I want trap the results of 'ps -ef' command. I first trap the results by splitting the results in scalar values such as $uid $pid $ppid $stime, etc... I would like, for each line returned, to hold these values in an array, so that, for each uid, I could return its corresponding pid, ppid, stime, cmd, etc. What would be the best data structure to use? An hash table in an array? ... Sound like maybe a hash of hash references. If you think you might take it on the road, you might make it an anonymous hash, so you can just mainpulate it by reference: my $processes = {}; foreach (split /\n/, `ps -ef`) { my ($uid $pid $ppid $stime, $etc) = split /\s+/, $_, 5; $processes-{$ppid} = { 'uid' = $uid, 'pid' = $pid, ... } } I am assuming here that the ppid is a sub-process id. Basically, use any field that constitutes a GUID as the key for each child hash. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Comparing Hashes with different keys. How ?
John Hennessy wrote: Hi, I have two different hashes built from separate data and need to find the common then differing items. $HoA1{$custnum} = [ $uid, $firstname, $lastname ]; $HoA2{$uid} = [ $custnum, $firstname, $lastname ]; I have looked at examples for Finding Common or Different Keys in Two Hashes but the keys must be the same. To make the keys the same I would like to effect a reverse function but only reversing the key and the first value leaving the remaining array items in place. Examples or suggestion would be most appreciated. Thanks John. my $uids_by_name = {} foreach $fields_ref (keys %HoA1) { my $uid = $fields_ref-[0]; my $name_slice = [$fields_ref-[1,2] ]; $uids_by_name-{$name_slice} = [] unless $uids_by_name-{$name_slice}; push @{$uids_by_name-{$name_slice}}, $uid; } Oooh, yuck! I just realized that you have a potentially insoluble problem here. Since you don't seem to have a cross-reference between custid and uid, and since names are *never* determinate as references, I can't see any way to programatically associate the two structures. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Error when running pmake to compile a module
This is my first attempt to compile a module downloaded from the web. The instructions in the 'readme' file are: Extract the archive. Then run the following commands. perl Makefile.PL make make install I didn't have make, so I installed a perl module called make, that runs pmake. Below are the results from my attempt. ## C:\Temp\ARSperl-1.81perl makefile.pl Building against perl 5.008001 Generating support.h file.. Processing AR_STRUCT_ITEM codes.. Processing AR_SERVER_STAT codes.. Processing AR_SCHEMA codes.. Processing AR_COM_PARM codes.. Processing AR_COM_METHOD codes.. Processing AR_ACTIVE_LINK_ACTION codes.. Processing AR_CHAR_MENU codes.. Processing AR_FILTER_ACTION codes.. Processing AR_MENU_REFRESH codes.. Processing AR_PERMISSIONS (Schema) codes.. Processing AR_PERMISSIONS (Field) codes.. Processing AR_DATA_TYPE codes.. Processing AR_BYTE_LIST codes.. Processing AR_NO_MATCH codes.. Processing AR_MULTI_MATCH codes.. Processing AR_RETURN codes.. Processing AR_FUNCTION codes.. Processing AR_KEYWORD codes.. Processing AR_SERVER_INFO codes.. Generating serverTypeInfoHints.h .. Converting C header files to perl modules .. Configuring with options: ARSVERSION = 4.52 ARSAPI = /remedy/api_folder/api AUTODEFINES = -D_WIN32 -DARS32 -DARS452 -DPERL_PATCHLEVEL_IS=8 -DPERL_SUBVERSION_IS=1 -DPERL_BASEREV_IS=50 Note (probably harmless): No library found for -lar Note (probably harmless): No library found for -lnsl Note (probably harmless): No library found for oldnames.lib Note (probably harmless): No library found for kernel32.lib Note (probably harmless): No library found for user32.lib Note (probably harmless): No library found for gdi32.lib Note (probably harmless): No library found for winspool.lib Note (probably harmless): No library found for comdlg32.lib Note (probably harmless): No library found for advapi32.lib Note (probably harmless): No library found for shell32.lib Note (probably harmless): No library found for ole32.lib Note (probably harmless): No library found for oleaut32.lib Note (probably harmless): No library found for netapi32.lib Note (probably harmless): No library found for uuid.lib Note (probably harmless): No library found for wsock32.lib Note (probably harmless): No library found for mpr.lib Note (probably harmless): No library found for winmm.lib Note (probably harmless): No library found for version.lib Note (probably harmless): No library found for odbc32.lib Note (probably harmless): No library found for odbccp32.lib Note (probably harmless): No library found for msvcrt.lib Writing Makefile for ARS === ARSperl 'make test' configuration. === Please enter the following information. This information will be recorded in ./t/config.cache If you want to skip the 'make test' step, just hit ENTER three times. You can configure it later by either re-running 'perl Makefile.PL' or by editting ./t/config.cache Fair warning: you probably don't want to run 'make test' against a production ARSystem server. Server Name []: mysever Admin Username []: Test Admin Password []: test Type 'make' (windows: 'nmake') to build ARSperl. Type 'make test' to test ARSperl before installing. Type 'make install' to install ARSperl. - C:\Temp\ARSperl-1.81pmake Reading C:/Perl/site/lib/Make.pm Reading C:\Temp\ARSperl-1.81\makefile Cannot recurse Make - no target C:\Perl\lib^ in C:/Temp/ARSperl-1.81 at C:/Perl/site/lib/Make.pm line 454. C:\Temp\ARSperl-1.81 # Any ideas what the Cannot recurse Make error is for ? Am I doing this correctly ? Dale -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Please help me! Thanks.
R. Joseph Newton wrote: Rob Dixon wrote: It's also worth pointing out here that rational values are almost always what is wanted in this sort of situation. The (very nice indeed) Math::Fraction module lets you do just this. The only changes to the code are to initialise $value as a Math::Fraction object with my $value = frac -1 and to convert the value back to decimal for printing (otherwise the values would appear as .. 1/10 1/5 3/10 .. etc.). HTH, Rob Sounds good. I've always tried to do any multiplication steps [at least within the range expressed as true integers, which in Perl is pretty large] before dividing. Mostly I just ahve a hunch that rounding errors will be minimized if numbers are kept in integfer frm as long as possible. That's effectively what this module does. It just keeps the divisor along with the dividend (0.1 is represented as the pair (1, 10)) so that you don't have to keep track of the scaling. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: What would be the best data structure to keep these values
On Dec 16, 2003, at 9:32 AM, R. Joseph Newton wrote: [..] I am assuming here that the ppid is a sub-process id. Basically, use any field that constitutes a GUID as the key for each child hash. [..] other way around, ppid - parent process id. Given a Pid the system needs to know whom the Parent is, so that when the child exits it knows which process gets the SIG_CHLD. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Error when running pmake to compile a module
[EMAIL PROTECTED] wrote: This is my first attempt to compile a module downloaded from the web. The instructions in the 'readme' file are: Extract the archive. Then run the following commands. perl Makefile.PL make make install I didn't have make, so I installed a perl module called make, that runs pmake. Below are the results from my attempt. ## C:\Temp\ARSperl-1.81perl makefile.pl Building against perl 5.008001 Generating support.h file.. Processing AR_STRUCT_ITEM codes.. Processing AR_SERVER_STAT codes.. Processing AR_SCHEMA codes.. Processing AR_COM_PARM codes.. Processing AR_COM_METHOD codes.. Processing AR_ACTIVE_LINK_ACTION codes.. Processing AR_CHAR_MENU codes.. Processing AR_FILTER_ACTION codes.. Processing AR_MENU_REFRESH codes.. Processing AR_PERMISSIONS (Schema) codes.. Processing AR_PERMISSIONS (Field) codes.. Processing AR_DATA_TYPE codes.. Processing AR_BYTE_LIST codes.. Processing AR_NO_MATCH codes.. Processing AR_MULTI_MATCH codes.. Processing AR_RETURN codes.. Processing AR_FUNCTION codes.. Processing AR_KEYWORD codes.. Processing AR_SERVER_INFO codes.. Generating serverTypeInfoHints.h .. Converting C header files to perl modules .. Configuring with options: ARSVERSION = 4.52 ARSAPI = /remedy/api_folder/api AUTODEFINES = -D_WIN32 -DARS32 -DARS452 -DPERL_PATCHLEVEL_IS=8 -DPERL_SUBVERSION_IS=1 -DPERL_BASEREV_IS=50 Note (probably harmless): No library found for -lar Note (probably harmless): No library found for -lnsl Note (probably harmless): No library found for oldnames.lib Note (probably harmless): No library found for kernel32.lib Note (probably harmless): No library found for user32.lib Note (probably harmless): No library found for gdi32.lib Note (probably harmless): No library found for winspool.lib Note (probably harmless): No library found for comdlg32.lib Note (probably harmless): No library found for advapi32.lib Note (probably harmless): No library found for shell32.lib Note (probably harmless): No library found for ole32.lib Note (probably harmless): No library found for oleaut32.lib Note (probably harmless): No library found for netapi32.lib Note (probably harmless): No library found for uuid.lib Note (probably harmless): No library found for wsock32.lib Note (probably harmless): No library found for mpr.lib Note (probably harmless): No library found for winmm.lib Note (probably harmless): No library found for version.lib Note (probably harmless): No library found for odbc32.lib Note (probably harmless): No library found for odbccp32.lib Note (probably harmless): No library found for msvcrt.lib Writing Makefile for ARS === ARSperl 'make test' configuration. === Please enter the following information. This information will be recorded in ./t/config.cache If you want to skip the 'make test' step, just hit ENTER three times. You can configure it later by either re-running 'perl Makefile.PL' or by editting ./t/config.cache Fair warning: you probably don't want to run 'make test' against a production ARSystem server. Server Name []: mysever Admin Username []: Test Admin Password []: test Type 'make' (windows: 'nmake') to build ARSperl. Type 'make test' to test ARSperl before installing. Type 'make install' to install ARSperl. -- --- C:\Temp\ARSperl-1.81pmake Reading C:/Perl/site/lib/Make.pm Reading C:\Temp\ARSperl-1.81\makefile Cannot recurse Make - no target C:\Perl\lib^ in C:/Temp/ARSperl-1.81 at C:/Perl/site/lib/Make.pm line 454. C:\Temp\ARSperl-1.81 # Any ideas what the Cannot recurse Make error is for ? Am I doing this correctly ? You need 'nmake' to build modules under Windows. Get nmake 1.5 from here: http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/nmake15.exe Unless you already have it as part of Visual Studio. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Internal -e escape char
Howdy, I just finished a script that does Benchmarking from a web based form. It's pretty handy since all I have to do it tell it how many different pieces of code I want to run, type them in and see the results. I did this because it is quick and easy and I can use it when all I have is web access.(must be autheticated to use) (IE no ssh or ftp)And I don't have to create a new script everytim I want to see which is fsatest. Ok, now with that same idea in mind I'd like top have a form I couls enter som perl and have it execute it via perl -e. (I know I know, security etc..., what is they put in `rm -f /` etc... just hear me out ;p) If I con't have shell access I'd like to login to my area, Select from a menu which code to run (All they get is value's of number s that correspond to a hash internally so they can't give it evil input.) and a few other options (which must be clean via some regexes,) Al of it is run with -w and use strict; and I may make it do -T also. So with all of that in mind here's my question: Doing this: ... my $pthprl = '/usr/bin/perl -Mstrict -we'; ... print `$pthprl '$codeX' '$inpuX'`; Assume $codeX and $inpuX are being properly safeified ( they are also being run via webserver so there's even less privilegs that if I was ssh in). This works very well, unless $codeX has single quotes. ($inpuX I urlencode and must therefore use CGI 'param' to get it into my -e test code) I could replace all single quotes with double quotes and escape everythgin inbetween them but that seems like a lot. Any ideas how to deal with the single quotes? (Since shell escape characters may or may not work since apache is executing it) TIA DaN -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Out of memory error problem
I wrote a small script that uses message ID's as unique values and extracts recipient address info. The goal is to count 1019 events per message ID. It also gets the sum of recipients per message ID. The script works fine but when it runs against a very large file (2GB+) I receive an out of memory error. Is there a more efficient way of handling the hash portion that is less memory intense and preferably faster? --Paul # Tracking log parser use strict; my $recips; my %event_id; my $counter; my $total_recips; my $count; # Get log file die You must enter a tracking log. \n if $#ARGV 0; my $logfile = shift; open (LOGFILE, $logfile) || die Unable to open $logfile because\n $!\n; foreach (LOGFILE) { next if /^#/; #skip any comment lines that contain the pound sign. my @fields = split (/\t/, $_); #split the line by tabs $recips = $fields[13]; # Number or recipients column my $message_id = $fields[9]; # message ID if ($fields[8] == 1019) { $event_id{$message_id}++ unless exists $event_id{$message_id}; $counter++; $total_recips = ($total_recips + $recips); } close LOGFILE; } print \n\nTotal instances of 1019 events in \$logfile\ is $counter.\n\n; print \nTotal single instances of 1019 event per message ID is ; #print keys %event_id; foreach my $key (keys (%event_id)) { $count ++; } print $count; print \n\nTotal # of recipients per message ID is ; print $total_recips;
Re: pass vars to sub via TK/Button
zentara wrote: The first is that you cannot count on a sub call always passing the caller. In some languages, like gtk2, when you call a sub, $_[0] is always the widget that called it. But in Tk, sometimes it is, and sometimes it isn't. If in doubt, just print @_ in your subs and see what is coming in. Tk dosn't pass it's widget reference in callbacks. Only the bind() method will implicity pass a widget reference, and even this default (and generally preferred) action can be defeated. I think the canvas widget is good about this. Look at this program to see how it works. ## #!/usr/bin/perl use strict; use Tk; #use Data::Dumper; my $mw = MainWindow-new; for(0..4){ my $b = $mw-Button(-text = Hello World$_, -command=[\change])-pack; } MainLoop; sub change { #Tk dosn't pass it's widget reference in callbacks #Only the bind() method will implicity pass a widget reference, and even #this default (and generally preferred) action can be defeated. print sub_input-@_\n; #prints nothing my $caller=$Tk::widget; print $caller\n; $caller-configure(-text=Hello Stranger); #print Dumper([$caller]); } The second thing to watch out for is the -command= syntax. The -command expects a sub or codefref which can be performed LATER. -command=[\change]) works but occaisionally you will run into situations where you need the sub{ } syntax. For instance try the above command as: -command=[Tk::exit])-pack; and the command will execute as soon as the button is created, so the program will prematurely terminate. And it's a hard bug to find. But it will work as -command=sub{[Tk::exit]})-pack; which will exit on the first button click. Tk can be very tricky with its callbacks. Some widgets already have machineries set up for handling thier command parameter. For instance, the Tree widget [my personal favorite] has a browsecmd option that passes the path of the node by default. Sometimes you just have to feel around within any context. Unfortunately, the docs don't always shed much light. They show many ways to handle events, but still you have to pin down what is applicable per context. One general approach that has usually worked well with me is, as in my sample, to offer an anonymous array. Most Tk event handlers will recognize it correctly, take the first element as the code reference, and further elements as the argument list. I think there may be cases where it will shift a default argument in front of those offered, but don't take me word on this--test! -command = [\my_function, $my_arg1, $my_arg2] Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Out of memory error problem
On Dec 16, 2003, at 1:15 PM, Perl wrote: I wrote a small script that uses message ID's as unique values and extracts recipient address info. The goal is to count 1019 events per message ID. It also gets the sum of recipients per message ID. The script works fine but when it runs against a very large file (2GB+) I receive an out of memory error. Is there a more efficient way of handling the hash portion that is less memory intense and preferably faster? Sure is. # Tracking log parser use strict; my $recips; my %event_id; my $counter; my $total_recips; my $count; # Get log file die You must enter a tracking log. \n if $#ARGV 0; Or: die ... unless @ARGV; my $logfile = shift; open (LOGFILE, $logfile) || die Unable to open $logfile because\n $!\n; You won't need either of the above lines after the following change. Drop 'em. foreach (LOGFILE) { Here's your problem. Change to: while () { Your old loop is reading in the entire file, then handing you one line at a time. The while version reads one line at a time and when we leave out the file handle, it operates on @ARGV entries by default. It sets $_, just like your foreach() loop was doing so the rest of this stuff should just work. next if /^#/; #skip any comment lines that contain the pound sign. my @fields = split (/\t/, $_); #split the line by tabs $recips = $fields[13]; # Number or recipients column This $recips variable looks like it should be declared here, not above. my $message_id = $fields[9]; # message ID if ($fields[8] == 1019){ $event_id{$message_id}++ unless exists $event_id{$message_id}; $counter++; $total_recips = ($total_recips + $recips); Or: $total += $recips; } close LOGFILE; You need to drop this also. } print \n\nTotal instances of 1019 events in \$logfile\ is $counter.\n\n; print \nTotal single instances of 1019 event per message ID is ; #print keys %event_id; foreach my $key (keys (%event_id)) { $count ++; } print $count; print \n\nTotal # of recipients per message ID is ; print $total_recips; Well, hope that helps put you back on track. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Align text
Hi again, Thanks for you help with my data structure problem, a hash of hashes problem did the job :-) I would like to know how to align text with the print command. I have four scalar variables to print but I want them to follow their header's size. So, if the header is 8 chars long, I would like the output of $user (which is paul (4 chars) to print 4 more spaces) How could I do that? Thanks a lot! Best regards, Steve Hemond Programmeur Analyste / Analyst Programmer Smurfit-Stone, Ressources Forestieres La Tuque, P.Q. Tel.: (819) 676-8100 X2833 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Align text
\On Dec 16, 2003, at 1:39 PM, Hemond, Steve wrote: Hi again, Thanks for you help with my data structure problem, a hash of hashes problem did the job :-) I would like to know how to align text with the print command. I have four scalar variables to print but I want them to follow their header's size. So, if the header is 8 chars long, I would like the output of $user (which is paul (4 chars) to print 4 more spaces) How could I do that? You're looking for printf(). See if this documentation fixes you up: perldoc -f printf perldoc -f sprintf James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Internal -e escape char
Dan Muey wrote: [snip] I could replace all single quotes with double quotes and escape everythgin inbetween them but that seems like a lot. Any ideas how to deal with the single quotes? (Since shell escape characters may or may not work since apache is executing it) after trying (a few years ago) to do something similar to what you propose which lead to a total mess and difficult to maintain codes, i have basically gave up this escape-shell-character approach. it's almost impossible to know when to escape and when not to escape. i now use a different approach. instead of involving Perl from the command line with -e, i simply print the code to a file and then run the code within the file. here is a strip down version of what i used to do: #!/usr/bin/perl -w use strict; use CGI; use File::Temp qw/tempfile tempdir/; my $cgi = CGI-new; if($cgi-param('code')){ my($fh,$fn) = tempfile(DIR = tempdir(CLEANUP = 1)); print $fh #!/usr/bin/perl -w\n; print $fh use strict;\n\n; print $fh $cgi-param('code'); close($fh); if(chmod(0755,$fn)){ html($cgi,$cgi-param('code'),`$fn`); }else{ html($cgi,Unable to run: \n\n . $cgi-param('code')); } }else{ html($cgi,undef); } #-- DONE-- # sub html{ my $cgi = shift; my $code = shift; my $value = $code || ''; if(@_){ $value .= \n\n__END__\n\n; $value .= $_ for(@_); } print $cgi-header,HTML; htmlbody form method=post action=your_script.pl textarea name=code cols=60 rows=10$value/textareabr input type=submit value=Submit /form /body/html HTML } __END__ a textarea is printed along a submit button, code is entered through the textarea, when the submit button is clicked, a tmp file is create which holds the code from the textarea. the file is then run from the command line and output is returned back to the textarea. finally, the tmp file is deleted when the script finish. david -- sub'_{print@_ ;* \ = * __ ,\ \} sub'__{print@_ ;* \ = * ___ ,\ \} sub'___{print@_ ;* \ = * ,\ \} sub'{print@_,\n}{_+Just}(another)-(Perl)-(Hacker) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Can I set '$!' ?
I want to be able to return a true or false value from a function in a module and populate the $! variable with the specific errors. Is this possible? Is there documentation on how to do this? I can find docs on how to use $! but not how to set it. Thanks for any help -Ken The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Converting using a hash
Hi, sorry for the lengthy post. I recently wrote a Perl script to convert 8-bit characters to LaTeX commands. The first version (which works just fine) looks like this (the ... indicates more lines to follow): #!/usr/bin/perl -pw s//{\\glqq}/g; s//{\\grqq}/g; s//\\'{a}/g; s//\\`{a}/g; s//\\^{a}/g; s//\\{a}/g; Now I tried to use a hash instead of consecutive replacement commands. The second version looked like this: #!/usr/bin/perl -w %enctabelle = (={\\glqq}, ={\\grqq}, =\\'{a}, =\\`{a}, =\\^{a}, while () { $zeile = $_; foreach $char (keys %enctabelle) { $zeile =~ s/$char/$enctabelle{$char}/g; } print $zeile; } This worked, too, but it was extremely slow, obviously since the variables where compiled over and over again. I gave it a third try like this (code taken from someone else's script): %enctabelle = (={\\glqq}, ={\\grqq}, =\\'{a}, =\\`{a}, =\\^{a}, while () { s/(.)/exists $enctabelle{$1} ? $enctabelle{$1} : $1/geo; print; } This did not change the text at all. When I removed the ternary operator s/(.)/exists $enctabelle{$1}/g; I got an error message like this: Line 208: Use of uninitialized value in substitution iterator line 1. Obviously, Perl cannot interpolate variable names like $enctabelle{}. Both the script and the file to convert are UTF-8 encoded. What's the problem here? On another list, I got a rather complicated snippet I did not fully understand: #!perl %enctabelle = (...); my $re = '(' . join('|', map quotemeta($_), keys %enctabelle) . ')'; $re = qr/$re/; while () { s/$re/$enctabelle{$1}/g; print; } Maybe the quotemeta part is what helps identifying the corresponding value? Any hints are greatly appreciated, Jan -- Hanlon's Razor: Never attribute to malice that which can be adequately explained by stupidity. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Converting using a hash
From: Jan Eden [EMAIL PROTECTED] I recently wrote a Perl script to convert 8-bit characters to LaTeX commands. The first version (which works just fine) looks like this (the ... indicates more lines to follow): #!/usr/bin/perl -pw s/?/{\\glqq}/g; s/?/{\\grqq}/g; s//\\'{a}/g; s//\\`{a}/g; s//\\^{a}/g; s//\\{a}/g; Now I tried to use a hash instead of consecutive replacement commands. The second version looked like this: #!/usr/bin/perl -w %enctabelle = (?={\\glqq}, ?={\\grqq}, =\\'{a}, =\\`{a}, =\\^{a}, while () { $zeile = $_; foreach $char (keys %enctabelle) { $zeile =~ s/$char/$enctabelle{$char}/g; } print $zeile; } You want something like this: my $re = join '|', keys %enctabelle; while () { s/$re/$enctabelle{$1}/go; print $_; } or my $re = join '|', keys %enctabelle; $re = qr/($re)/; while () { s/$re/$enctabelle{$1}/g; print $_; } Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Can I set '$!' ?
Ken Lehman wrote: I want to be able to return a true or false value from a function in a module and populate the $! variable with the specific errors. Is this possible? Is there documentation on how to do this? I can find docs on how to use $! but not how to set it. Thanks for any help $! is a special variable that is a number in numeric context and a string in string context. You can assign a number to $! and it will display the corresponding system error message but you cannot assign a string to it. $! is set by perl whenever a system call sets errno. $! is described in the perlvar.pod document. perldoc perlvar So, you CAN set it if you want to return one of the pre-defined error messages but it can also be changed by perl on any system call so it might not retain the value that you set. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
script for passwd file
Hi, I'm stuck and that I would ask if anyone has a script to check for empty passwords /etc/passwd/ /etc/shadow and then lock them Thanks Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Converting using a hash
Jan Eden wrote: Hi, Hello, sorry for the lengthy post. I recently wrote a Perl script to convert 8-bit characters to LaTeX commands. The first version (which works just fine) looks like this (the ... indicates more lines to follow): Your regular expressions look like they are longer then 8 bits. #!/usr/bin/perl -pw s/â??/{\\glqq}/g; s/â??/{\\grqq}/g; s/á/\\'{a}/g; s/à /\\`{a}/g; s/â/\\^{a}/g; s/ä/\\{a}/g; Now I tried to use a hash instead of consecutive replacement commands. The second version looked like this: #!/usr/bin/perl -w %enctabelle = (â??={\\glqq}, â??={\\grqq}, á=\\'{a}, à =\\`{a}, â=\\^{a}, while () { $zeile = $_; foreach $char (keys %enctabelle) { $zeile =~ s/$char/$enctabelle{$char}/g; } print $zeile; } This worked, too, but it was extremely slow, obviously since the variables where compiled over and over again. I gave it a third try like this (code taken from someone else's script): %enctabelle = (â??={\\glqq}, â??={\\grqq}, á=\\'{a}, à =\\`{a}, â=\\^{a}, while () { s/(.)/exists $enctabelle{$1} ? $enctabelle{$1} : $1/geo; print; } This did not change the text at all. When I removed the ternary operator s/(.)/exists $enctabelle{$1}/g; I got an error message like this: Line 208: Use of uninitialized value in substitution iterator line 1. Obviously, Perl cannot interpolate variable names like $enctabelle{ä}. Both the script and the file to convert are UTF-8 encoded. What's the problem here? The problem is probably that you are searching for a single byte (.) not a UTF character. perldoc perlunicode perldoc utf8 perldoc bytes On another list, I got a rather complicated snippet I did not fully understand: #!perl %enctabelle = (...); my $re = '(' . join('|', map quotemeta($_), keys %enctabelle) . ')'; $re = qr/$re/; while () { s/$re/$enctabelle{$1}/g; print; } Maybe the quotemeta part is what helps identifying the corresponding value? Any hints are greatly appreciated, Do you want the fastest code? The shortest code? The most maintainable code? What are you trying to accomplish? John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Converting using a hash
On Dec 16, Jan Eden said: #!perl %enctabelle = (...); my $re = '(' . join('|', map quotemeta($_), keys %enctabelle) . ')'; $re = qr/$re/; while () { s/$re/$enctabelle{$1}/g; print; } Let me explain this for you, and fix it, too. # this produces 'key1|key2|key3|...' my $re = join '|', map quotemeta($_), # this escapes non-alphanumberic # characters; sort { length($b) = length($a) } # sorts by length, biggest first keys %enctabelle; # the strings to encode What this does is put the keys in a string, separated by a | (which means or in a regex), quotemeta()d (which ensures any regex characters in them are properly escaped), and ordered by length (longest to shortest). That last part is important: if you have keys 'a' and 'ab', you want to try matching 'ab' BEFORE you try matching 'a', or else 'ab' will NEVER be matched. Then, we take $re, and turn it into a compiled regex: $re = qr/($re)/; The qr// operator (in perlop) gives you a compiled regex; it's good for efficiency in certain situations (although this isn't really one of them). $text =~ s/$re/$enctabelle{$1}/g; That replaces all keys with their values. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ 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] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Out of memory error problem
On Dec 16, 2003, at 11:15 AM, Perl wrote: [..] The script works fine but when it runs against a very large file (2GB+) I receive an out of memory error. was the perl that you are using built to work with large datafiles? There is a USE_LARGE_FILE that is normally set, and you would see it with perl -V so the 'memory' problem could be at that end as well. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Managing PS data was -Re: What would be the best data structure to keep these values
On Dec 16, 2003, at 7:13 AM, Hemond, Steve wrote: [..] I first trap the results by splitting the results in scalar values such as $uid $pid $ppid $stime, etc... I would like, for each line returned, to hold these values in an array, so that, for each uid, I could return its corresponding pid, ppid, stime, cmd, etc. [..] There are times when the stench of my hacked code bothers me, so I have cleaned up a module that I used in a Project, cleared it with the Owner that I can take my 'works for hire' public and remove the corporate copyright notice. http://www.wetware.com/drieux/CS/Proj/Wetware_ps/ Your comments and opinions always appreciated. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: script for passwd file
we'll be curious to see what you come up with for a solution, rob. *and help if you get stuck* -Tom Kinzer -Original Message- From: rmck [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 16, 2003 5:01 PM To: [EMAIL PROTECTED] Subject: script for passwd file Hi, I'm stuck and that I would ask if anyone has a script to check for empty passwords /etc/passwd/ /etc/shadow and then lock them Thanks Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response