Re: Using strict and configuration files
Hi, This is how I do it. #!/usr/bin/perl -wT use strict; my $conf; unless ($conf = do ('/path/to/config.pl')) { die (Could not open file); } print $conf-{'var1'}, \n; - Then in a file called config.pl { var1 = one, var2 = two } - The unless part is just to check that the file was opened successfully. The do actually opens the file and assigns the hash structure to $conf. Hope this helps! Carl Hi all, I want to use: use strict; And I want to use a configuration file in a Perl script. The configuration file uses: %page1=( ); %page2=( ); This way I get errors if I run the script because the variables are not defined with my. I've tried putting in the configuration file: my %page1=( ); But this method doesn't work. I use a configuration file and I would like to put the settings only in this file without modifying the script. Is it possible? Thanks. Teddy, [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Counter and scoping(?) issue
Hi, God bless you. On Tue, May 28, 2002 at 12:45:53PM -0500, Camilo Gonzalez wrote: I've been having this problem in various permutations throughout my Perl life. For this particular function, I set $confirm_counter to 1. Then I use $xheader = X-HTTP-Client: [$1]\n . X-Generated-By: NMS FormMail.pl v$VERSION\n; } if ( $confirm_counter = 1){ ^ May be this your problem? if ( $send_confirmation_mail ) { open_sendmail_pipe(\*CMAIL, $mailprog); In the indicated if condition below you are allways assigning 1 to $confirm_counter instead of comparing it to 1. Should be: if($confirm_counter==1) { ... } Well that may be a typo, but if you pasted this part of the script then it may be the error. tip_if_newbie If this is the error, it should be good for you to use the '-w' flag in the perl command line to check for simple errors like this. Also using: 'use strict;' could be useful. :) Just put: #!/usr/bin/perl -w use strict; At the beginning of your scripts. /tip_if_newbie See you Roberto Ruiz -- A train stops at a train station; a bus stops at a bus station; on my desk I have a workstation... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Counter and scoping(?) issue
Camilo Gonzalez wrote at Tue, 28 May 2002 19:45:53 +0200: Gurus, I've been having this problem in various permutations throughout my Perl life. For this particular function, I set $confirm_counter to 1. Then I use a foreach loop to send email to multiple recipients. Within the foreach loop, I increment $confirm_counter by using $confirm_counter++. I then use the value of $confirm_counter as a test for an if conditional. If the counter is one, then a confirmation email will be sent to the person who submitted the form. If not, the confirmation email will be skipped. This is to prevent any user from receiving more than one confirmation email. However, it seems that $confirm_counter is not being incremented and the user will receive as many as 7 email confirmations. Any ideas? I'm enclosing the code in question below. if ( $confirm_counter = 1){ ^^^ That's the problem. You wanted a comparison, but you did an assignment. Just use ==. if ( $send_confirmation_mail ) { open_sendmail_pipe(\*CMAIL, $mailprog); print CMAIL $xheader, To: $email$realname\n$confirmation_text$confirm_counter; close CMAIL; } } ++$confirm_counter; ... When the problem occurs often, there's a trick to avoid: if ( 1 == $confirm_counter ) { ... } When you write a '=' instead of '==' the interpreter is complaining before the script starts :-) Greetings, Janek PS: I'd bet, it's the most done beginner's mistake. Is there anybody who has already written a program to dedect it ? (Like lint) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Counter and scoping(?) issue
On Wed, May 29, 2002 at 03:05:36AM -0500, Roberto Ruiz ([EMAIL PROTECTED]) said something similar to: Hi, God bless you. On Tue, May 28, 2002 at 12:45:53PM -0500, Camilo Gonzalez wrote: if ( $confirm_counter = 1){ ^ May be this your problem? In the indicated if condition below you are allways assigning 1 to $confirm_counter instead of comparing it to 1. Should be: if($confirm_counter==1) { ... } You don't need the quotes if you are doing a numeric check. if($confirm_counter == 1) { ... } Cheers, Kevin -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Down that path lies madness. On the other hand, the road to hell is paved with melting snowballs. --Larry Wall in [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Counter and scoping(?) issue
Gack, you Perl Lords once again save my butt. Thanks Roberto, it worked like a charm. -Original Message- From: Kevin Meltzer [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 7:30 AM To: Roberto Ruiz Cc: Camilo Gonzalez; [EMAIL PROTECTED] Subject: Re: Counter and scoping(?) issue On Wed, May 29, 2002 at 03:05:36AM -0500, Roberto Ruiz ([EMAIL PROTECTED]) said something similar to: Hi, God bless you. On Tue, May 28, 2002 at 12:45:53PM -0500, Camilo Gonzalez wrote: if ( $confirm_counter = 1){ ^ May be this your problem? In the indicated if condition below you are allways assigning 1 to $confirm_counter instead of comparing it to 1. Should be: if($confirm_counter==1) { ... } You don't need the quotes if you are doing a numeric check. if($confirm_counter == 1) { ... } Cheers, Kevin -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Down that path lies madness. On the other hand, the road to hell is paved with melting snowballs. --Larry Wall in [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: Verifying the CONTENT_LENGTH
--- Octavian Rasnita [EMAIL PROTECTED] wrote: Note: I've tried using the functions for uploading from CGI module, but with no good results in Windows 2000, and that's why I want to write my code. Teddy, Can you be more specific about the no good results? If there is a problem with CGI.pm and Windows 2000, I am sure that *many* people would want to know. Cheers, Curtis Ovid Poe = Ovid on http://www.perlmonks.org/ Someone asked me how to count to 10 in Perl: push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//; shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
why do I get the following warning for taint
When I run perl -c myscript.cgi to test the syntax or perl -w ..., it produces this: Too late for -T option at maintenance.cgi line 1 (my line 1 is just the shebang line with the -T option). Does this mean that something is wrong? -Rob Carl Franks [EMAIL PROTECTED] wrote: Hi, This is how I do it. #!/usr/bin/perl -wT use strict; my $conf; unless ($conf = do ('/path/to/config.pl')) { die (Could not open file); } print $conf-{'var1'}, \n; - Then in a file called config.pl { var1 = one, var2 = two } - The unless part is just to check that the file was opened successfully. The do actually opens the file and assigns the hash structure to $conf. Hope this helps! Carl Hi all, I want to use: use strict; And I want to use a configuration file in a Perl script. The configuration file uses: %page1=( ); %page2=( ); This way I get errors if I run the script because the variables are not defined with my. I've tried putting in the configuration file: my %page1=( ); But this method doesn't work. I use a configuration file and I would like to put the settings only in this file without modifying the script. Is it possible? Thanks. Teddy, [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup
Re: why do I get the following warning for taint
You need to have -T on the command line as well: perl -cT script To find out why, 'perldoc perlsec' Cheers, Kevin On Wed, May 29, 2002 at 10:51:45AM -0700, Rob Roudebush ([EMAIL PROTECTED]) said something similar to: When I run perl -c myscript.cgi to test the syntax or perl -w ..., it produces this: Too late for -T option at maintenance.cgi line 1 (my line 1 is just the shebang line with the -T option). Does this mean that something is wrong? -Rob Carl Franks [EMAIL PROTECTED] wrote: Hi, This is how I do it. #!/usr/bin/perl -wT use strict; my $conf; -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Politics is the entertainment branch of industry. -- Frank Zappa -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cisco log parsing
Hello people i been working on this script provided by drieux but i still have some doubts about it. http://www.wetware.com/drieux/pbl/Sys/Admin/CiscoParser1.txt the scripts works fine with a small log but when i try to run it in the long log file it displays all the log file just as if it is being opened with cat. I am trying to get just the number,setup time and disconnect time from the log,,just this values in a single line like this 53353454545 18:10 18:20 When i ran the script it joins the values in a couple of lines,the problem is that i don't entirely understand the regexp,and therefore i cant break it down to get only the number,setup time and disconnect time values From the script my $dtgT = '\d|:|\.'; #numbers or colons or dots my $upT = 'SetupTime'; my $downT = 'DisconnectTime'; my $prefT = '38\#'; my $find = qr/(.*)\s+ (\d+\.\d+\.\d+\.\d+)\s* $prefT (\d+), \s* $upT\s* ([$dtgT]+)\s*$downT\s* ([$dtgT]+)/xo; so the question is how should i form the regexp to just get the number from the entire log file? how should i form the regexp get only the disconnect time? Log File: May 10 14:25:00 13310: %VOIPAAA-5-VOIP_CALL_HISTORY: CallLegType 1, ConnectionId 0 0 0 0, SetupTim e 17:30:58.645 UTC Fri May 10 2002, PeerAddress 38#533147631, PeerSubAddress , DisconnectCause 2F , Disconnect Text no resource., ConnectTime 17:30:58.655 UTC Fri May 10 2002, DisconnectTime 17:30:58.655 UTC Fri May 10 200 2, CallOrigin 1, ChargedUnits 0, InfoType 2, TransmitPackets 0, TransmitBytes 0, ReceivePackets 0, ReceiveBytes 0 May 10 15:03:05 13311: %VOIPAAA-5-VOIP_CALL_HISTORY: CallLegType 1, ConnectionId 0 0 0 0, SetupTim e 18:09:04.262 UTC Fri May 10 2002, PeerAddress 38#5347631, PeerSubAddress , DisconnectCause 2F , DisconnectTe xt no resource., ConnectTime 18:09:04.262 UTC Fri May 10 2002, DisconnectTime 18:09:04.262 UTC Fri May 10 2002, CallOrigin 1, ChargedUnits 0, InfoType 2, TransmitPackets 0, TransmitBytes 0, ReceivePackets 0, ReceiveBytes 0 May 10 15:03:38 %VOIPAAA-5-VOIP_CALL_HISTORY: CallLegType 2, ConnectionId DF125DE2 637711D6 BD90A185 393856AE, SetupTime 18:09:15.110 UTC Fri May 10 2002, PeerAddress , PeerSubAddress , DisconnectCause 10 , DisconnectText normal call clearing., ConnectTime 18:09:37.970 UTC Fri May 10 2002, DisconnectTime 18:09: 37.970 UTC Fri May 10 2002, CallOrigin 2, ChargedUnits 0, InfoType 2, TransmitPackets 451, TransmitBytes 18040, ReceivePackets 0, ReceiveBytes 0 Thanks in advance Hernan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
install crypt::passgen
Greetings, I am having a problem with ActiveState ActivePerl 5.6.1. I am tryin to install the abovementioned lib I get the following error from PPM version 3 beta 3 ppm search crypt::passgen Searching in repository 2 (ActiveState Package Repository) 1. Crypt-PassGen [0.02] ppm install crypt::passgen Error: no suitable installation target found for package Crypt-PassGen. ppm PLease help Ciao -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Crypt::PassGen;
Greetings, Any ideas if there exists a more secure alternative to this library? From the documentation it says that the library only generates passwords in with no panctuation special chars all the passwords are not in mixed case. Is there a library out there that addresses the abovementioned concerns? Langa Kentane | Tel: +27 12 672 7209 Security Engineer | Cell: +27 82 456 2219 Nanoteq (PTY) LTD | PGP Key ID: 0x771B0480 NOTICE: This message and any attachments are confidential and intended solely for the addressee. If you have received this message in error, please notify the sender at Nanoteq (Pty) Ltd immediately, telephone number +27 (0) 12 672 7000. Any unauthorised use, alteration or dissemination is prohibited. Nanoteq (Pty) Ltd accepts no liability whatsoever for any loss whether it be direct, indirect or consequential, arising from information made available and actions resulting there from. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Crypt::PassGen;
on Wed, 29 May 2002 05:32:42 GMT, [EMAIL PROTECTED] (Langa Kentane) wrote: Any ideas if there exists a more secure alternative to this library? From the documentation it says that the library only generates passwords in with no panctuation special chars all the passwords are not in mixed case. Is there a library out there that addresses the abovementioned concerns? Why don't you generate true random passwords, with e.g. the following code: #! perl -w use strict; use constant LENGTH = 8; my @allowed_chars = ('A'..'Z', 'a'..'z', 0..9); srand; # for perl 5.004 my $password = ''; $password .= $allowed_chars[rand @allowed_chars] for (1..LENGTH); You can then alter LENGHT and '@allowed_chars' to suit your needs. -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Shredding a file
Thanks John, Very informative. -Original Message- From: Jonathan E. Paton [mailto:[EMAIL PROTECTED]] Sent: 28 May 2002 05:48 PM To: [EMAIL PROTECTED] Subject: RE: Shredding a file --- Langa Kentane [EMAIL PROTECTED] wrote: Well, reasonable security is fine, but the idea of writing zeroes to the file does not appeal to me, If I can't get any other way I guess I will have to use that. Allow me to assume you are using Unix... you have a hopeless cause if you are using Windows. Here is the situation on most Unixes: * /proc - A virtual filesystem. The memory used by processes can be read/writen, and hence 'root' is critical to security [as always]. * 'root' can alter your script before it is executed! * Only 'root' user can hack raw bytes on your filesystem I assume you need to shred because: * If the box is stolen, then you don't want to have critcal information lying around. And not because: * You don't trust your system admin Then shredding the file is the right thing to do. You shouldn't just zero the files, as harddisks are not digital devices... and it may be possible to recover data that has been zero'd. Commerical shredding programs [why spend good money on a 5 minute Perl program?] err on the side of caution, and write random data several times over. Of course, they probably fail if the file has shrunk in size before being shredded! [partly un-erased] Whatever you do, pay attention to race conditions. Read pages 569-576 of Programming Perl before you move any further! Race conditions are attacked frequently. Never, never, ever declare a program as completely secure! - unless it is very trival. Make sure you create a tempory safely, as per the Camel, or you will be flung out into the hot desert. Jonathan Paton = $_=q|.,@$$. ,.@$@$. .$$@. ,,$ !$_=$p.'$@.',y'$@' .,';for(/\S+/g){ !|.q| .$ .,@, ,$, .,.. @, ,$ ,,@ .,,.!++$.22?${'y'.$_}=chr$.+64:[$$=${'y' !|.q| ,@$@.,. $$$, ..@$,,, $., ..!.$_},$y.=($.=~/22\|26\|3(3\|7)/x?' ' !|.q|. @ ., ,.,,, , .$... .,$ .,,!.$$:\l$$)]};$y=~/ (.*)/;warn$1\n !|.q|. $ .,. .,$$$, @.,.@$@ .|,map{-$|--?$r:$p.=$_}split'!';eval$r __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] NOTICE: This message and any attachments are confidential and intended solely for the addressee. If you have received this message in error, please notify the sender at Nanoteq (Pty) Ltd immediately, telephone number +27 (0) 12 672 7000. Any unauthorised use, alteration or dissemination is prohibited. Nanoteq (Pty) Ltd accepts no liability whatsoever for any loss whether it be direct, indirect or consequential, arising from information made available and actions resulting there from. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Please Remeber to Use the Docs (was: the sort routine)
On 28 May 2002 21:36, Michael Fowler [mailto:[EMAIL PROTECTED]] wrote: On Tue, May 28, 2002 at 01:20:48PM -0700, Eric Wang wrote: @result = sort @array it sorts the numbers by digits, but not the whole number for example is bigger than 443322341 because it's first digit is a 6 Your question was answered by a another poster. I'll reiterate: see perldoc -f sort The sort routine sorts alphabetically (well, ASCIIbetically) by default, use a different comparison operator: @result = sort { $a = $b } @array; This is worth repeating in general (sorry, Eric, to pick on you but this is a rather too good example to miss) If you do something, and it does not quite do what you expect, then the first thing to do is RTFM. We all, from time to time, miss remember the exact semantics of a function/method/property usually just by enough to screw up what we have just written and a careful re-read of the documentation can very quickly correct our memory. (Just my 2p.) Richard Cox Senior Software Developer Dell Technology Online All opinions and statements mine and do not in any way (unless expressly stated) imply anything at all on behalf of my employer -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: elements 2 thru end of the results of a split
Bryan R Harris wrote at Wed, 29 May 2002 01:36:23 +0200: Is it possible to return elements 2 (index 1) thru end of the results of a split? @myarray = (split(/\s+/,$fContent[$i]))[1..-1]; seems right, but doesn't work... The problem of your code is that 1 .. -1 is an empty list for perl. So you have to use the splice command directly (the [x...y] form is only a shortcut for) my @array = splice( @{[split( /\s+/, $fContent[$i] )]}, 1 ); There's a second possibility, which one is a little bit shorter and trickier: my @array = grep {$foo++} split ( /\s+, $fContent[$i] ); Of course I only use it one liners, because it hides what you are really doing, what's always a sign of bad programming. However TMTWTDI. Hope, I could help you, Best Wishes, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Referring to a cgi script within a cgi script.
Richard J. Moyer III wrote at Wed, 29 May 2002 02:39:45 +0200: Hello all, I have a form that activates a cgi script that scans a flat-file *.csv file, matches on a unique identifier, identifies the line that contains the identifier, and pushes the separated values of that line into an array. I want to pass those values into another (second) cgi script, but I don't know how. I made the original script display the values of the line in text input boxes in a web page the original cgi script created after finding the correct line. This essentially creates a new form that *theoretically* you should be able to parse with a new script. However, when I push submit, the form runs the ORIGINAL script and passes all the data from the new form into the URL (i.e. ref.cgi?n0=052802151217n1=2...). Who do I fix this. Sorry, I can't give you the answer you hoped. The script is still to complex for me. But I hope I can give you some advices to write the script more Perlish. 01 #!/usr/bin/perl use strict; With a cgi script, you should also check for tainted data and to give warnings: #!/usr/bin/perl -wT 02 03 print Content-type:text/html\n\n; You should have a look for the CGI module. Definitly. 04 05 read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); 06 @pairs = split(//, $buffer); 07 foreach $pair (@pairs) { 08 ($name, $value) = split(/=/, $pair); 09 $value =~ tr/+/ /; 10 $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg; 11 $FORM{$name} = $value; 12 } 13 14 $reference = $FORM{'ref'}; 15 16 #--- 17 # COMPARE REFERENCE NUMBER TO DATA 18#--- 19 open (DATA, ../data/data.csv) or die error; 20 while ($line = DATA) { 21 if ($line =~ /($reference)/){ 22 push @newdata, $line; 23 } 24 } my @newdata = grep {/$reference/} (DATA); 25 close (numbers); 26 27 #--- 18 #--- OK -- OK -- OK -- OK -- OK -- OK -- 29 #--- 30 $begin=0; 31 for($i=0; $i length $newdata[$#newdata]; $i++) { 32 if ((substr $newdata[$#newdata], $i, 1) eq , or (substr $newdata[$#newdata], $i, 1) eq \n) { 33 push @tokens, (substr $newdata[$#newdata], $begin, $i-$begin); 34 $begin = $i+1; 35 } 36 } Well, the substring seems to be a little bit crazy :-) $i depends on the length of the array. $begin depends on the numbers of entries starting with a ',' or '\n' You use only $newdata[$#newdata], that means you only use the last element of the array. It's unrare the both has something in common with the length of the strings that are saved in the array. However the condition is simplier written as if ($newdata[$#newdata] =~ /^[\,\n]/) { ... } 37 if ($tokens[1] = 1){ 38 $episode = $tokens[1]; 39 $nextepisode = $episode + 1; 40 41 print EndOfHTML; You should have a look to the template modules: http://search.cpan.org/search?mode=modulequery=template 42 html 43 head 44 titleCHUG Output/title 45 /head 46 body bgcolor=#cc6600 47 table width=100% cellspacing=7 cellpadding=0 border=1 bgcolor=#ff 48 tr 49 td align=left valign=top colspan=2p class=textWhat would you like to do now?/td 50 /tr 51 tr 52 td align=left valign=top width=50% 53 table width=100% cellspacing=7 cellpadding=0 border=1 bgcolor=#ff 54 tr 55 td 56 form name=reprint action=reprint.cgi method=post 57 input type=text name=n0 value=$tokens[0] REFERENCE NUMBERbr 58 input type=text You read in an array of reference numbers, if i understand correctly. Which of them is the REFERENCE NUMBER you want. name=n5 value=$tokens[3] Sex/br 59 input type=text name=n6 value=$tokens[5] Weight/br 60 input type=text name=n7 value=$tokens[58] Wow, the tokens have the index numbers 0, 3, 5, 58, 70. These are really magic numbers. But them into constant variables expressing what the say like. Take a look to the constant pragma and the enum - module from the cpan percent less/br 61 input type=text name=n11 value=$tokens[70] Negcon/br 62 input type=submit name=submit 63 /form 64 /td 65 /td 66/tr 67 /table 68 /form 69/td 70 /tr 71/table 72 /body 73 /html 74 EndOfHTML 75 exit; 76 } Best Wishes, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Formatting Output
Melissa Cama wrote at Wed, 29 May 2002 03:13:46 +0200: ... I need to print out each value in the array (for each key) as a new line in an excel/CSV file. Also with each new line, a time stamp needs to be printed. ... foreach $str_feature (%hash_FeatureUsers){ ^^^ foreach $str_feature (keys %hash_FeatureUsers) { foreach my $val (@{$hash_FeatureUsers{$str_feature}}) { Or if you're really only interested in your values: foreach my $val_ref (values %hash_FeatureUsers) { my $val = @$val_ref ... print (userfile $STR_CVSSTRINGBRACKET.GetTimeStamp().$STR_CVSSTRINGBRACKET); print (userfile $STR_CVSCOMMA.$val\n); } } } } Greetings, Janek PS: This message and any attachment is confidential and may be privileged or otherwise protected from disclosure. If you have received it by mistake please let us know by reply and then delete it from your system; you should not copy the message or disclose its contents to anyone. I have to inform you, that this message arrived many not confidential people. I have to inform you, that the message was copied by many servers and can be read with google or so in some hours. I didn't delete, will I be arrested or is there a chance for me ?! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is there a good Perl way for a validation subroutine?
Tagore Smith wrote at Wed, 29 May 2002 06:13:25 +0200: ... in pseudocode: my @failed; if (field fails validation){ push @failed, $fieldname; } } etc. Or in another pseudocode: my @failed = grep {field fails validation} @fields; Cheerio, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: e-mailing with DBI
-Original Message- From: Peter Scott [mailto:[EMAIL PROTECTED]] Although I don't know why you're worried about straining the mysql server; I do not think that the mysql server would be in to much difficulty (depending on the amount of columns) rather the processing in the perl script would be a nightmare to get right. The bandwidth or SMTP server may limit you as well. Are you worried about locking the table up for the duration of the run. I am not 100% sure but does mysql use table locking, if so this could cause a problem. if you do everything in one process that sends mail synchronously you've expended just as much (well a bit less) total resources, you've just remained connected to the database longer. Unless there's some issue with that, why not do it the simple way, then you don't have to worry about making sure you have a big enough mail spool. You could run it in batches as Peter suggested although you could do it by row number grouped on your primary key. You could select 2000 records every 10 minutes for processing. To avoid loading your server you could put some sleep time in the process. I imagine there are ways of throttling your script better than sleep. Batch processing is a common enough task that you may be able to find some ready made scripts on google for a similar purpose. Harry * COLT Telecommunications Registered in England No. 2452736 Registered Office: Bishopsgate Court, 4 Norton Folgate, London E1 6DQ Tel. +44 20 7390 3900 This message is subject to and does not create or vary any contractual relationship between COLT Telecommunications, its subsidiaries or affiliates (COLT) and you. Internet communications are not secure and therefore COLT does not accept legal responsibility for the contents of this message. Any view or opinions expressed are those of the author. The message is intended for the addressee only and its contents and any attached files are strictly confidential. If you have received it in error, please telephone the number above. Thank you. * -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: calculate dates / regex
Encountered another problem: I'm trying to use a calculated date value in a regex. It only works with values which are NOT calculated. my ($dc, $mc, $yc) = (localtime(time))[3,4,5]; my $date_now = sprintf(%02d-%02d-%02d, $dc, $mc+1, $yc-100); my ($da, $ma, $ya) = (localtime (time + (ONE_DAY)))[3,4,5]; my $next_date = sprintf(%02d-%02d-%02d, $da, $ma+1, $ya-100); using $date_now in this regex works: while (APODATA) { ( $date_today, $aponame, $apoaddress, $apotel) = split(/:/,$_); my @data = split(/:/); foreach ($data[0]) { if (/$date_now/) { print $date_now\n; print $next_date\n; } } if I replace $date_now with $next_date I get an error message (premature end of script headers). Does anybody know how? Thanks for your tips in advance. Sven On Tuesday, May 28, 2002, at 07:53 PM, drieux wrote: On Tuesday, May 28, 2002, at 09:25 , Sven Bentlage wrote: Hi ! I'm trying to get all the date values for the week (7days) ahead of a specified date. To get the current date I use : my ($d, $m, $y) = (localtime)[3,4,5]; my $date = sprintf(%02d-%02d-%02d, $d, $m+1, $y-100); To get the date of the date 7 days ahead I use: my ($da, $ma, $ya) = (localtime (time+ (7*24*60*60)))[3,4,5]; my $next_date = sprintf(%02d-%02d-%02d, $da, $ma+1, $ya-100); your friend the loop would help here. use constant SECONDS_PER_DAY(24*60*60); my $day_ahead = 1; my $max_day_ahead = 7; for (; $day_ahead = $max_day_ahead ; $day_ahead++ ) { my $tmp_t =( $day_ahead * SECONDS_PER_DAY); my ($da, $ma, $ya) = (localtime(time + $tmp_t))[3,4,5]; my $next_date = sprintf(%02d-%02d-%02d, $da, $ma+1, $ya-100); } you may want to do the perldoc on constant - since this will help you with more on how to think about writing self documenting code ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Formatting String output
Hi Guys. I want to format my String output with the 'printf' command, but I cant find the solution. For you experienced people this is not problem I think, so could you give me the right hint, please What I want to do: I have several arrays which contains a certain number of strings with different length. And I want to generate an output like this: asdfg a as asdf as asdf asdfgh a asdf asdfg a asdfgh I think this is something like that: for ($i=0; $i$arrayCount; $i++) { printf(%s, myArray[$i]:10); } But this does not work. Where is the fault. Thnx. Heiko -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
converting a hash to an array
I've found a couple of examples of moving an array into a hash, but not of moving a hash into an array. I thought this would work: @sorted = sort { $myhash{$b} = $myhash{a} } keys %myhash ; while ( @sorted ) { printf ( first field = %s second field = %s\n, $sorted{1}, $sorted{2} ) ; } I am trying to sort the hash values (by value, not key) and move the sorted results into an array, so that I can add additional fields later. I get an Use of uninitialized value at ./newlogscan.pl line 46. error. Line 46 is the @sorted = line. Any ideas? Craig Hammer Internal Infrastructure Team Lead Parago, Inc. 972-538-3936 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: converting a hash to an array
-Original Message- From: Craig Hammer [mailto:[EMAIL PROTECTED]] @sorted = sort { $myhash{$b} = $myhash{a} } keys %myhash ; ^ * COLT Telecommunications Registered in England No. 2452736 Registered Office: Bishopsgate Court, 4 Norton Folgate, London E1 6DQ Tel. +44 20 7390 3900 This message is subject to and does not create or vary any contractual relationship between COLT Telecommunications, its subsidiaries or affiliates (COLT) and you. Internet communications are not secure and therefore COLT does not accept legal responsibility for the contents of this message. Any view or opinions expressed are those of the author. The message is intended for the addressee only and its contents and any attached files are strictly confidential. If you have received it in error, please telephone the number above. Thank you. * -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Formatting String output
-Original Message- From: Heiko Heggen [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 5:48 AM To: [EMAIL PROTECTED] Subject: Formatting String output Hi Guys. I want to format my String output with the 'printf' command, but I cant find the solution. For you experienced people this is not problem I think, so could you give me the right hint, please What I want to do: I have several arrays which contains a certain number of strings with different length. And I want to generate an output like this: asdfg a as asdf as asdf asdfgh a asdf asdfg a asdfgh I think this is something like that: for ($i=0; $i$arrayCount; $i++) { printf(%s, myArray[$i]:10); } But this does not work. Where is the fault. All the details are in: perldoc -f sprintf To output in a field of 10 cols: printf('%10s', 'Hello'); # prints ' Hello' Default is right-justified. To left-justify: printf('%-10s', 'Hello'); # prints 'Hello ' Default is to expand the field if input is longer. To truncate to exactly 10 chars (and left-justify): printf('%-10.10s', 'ARatherLongString'); # prints 'ARatherLon' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: converting a hash to an array
ackk, I missed the $ in all of my re-arranging. The script still fails at the same place. The real error is: glob failed (child exited with status 1) at ./newlogscan.pl line 48. Craig Hammer Internal Infrastructure Team Lead Parago, Inc. 972-538-3936 -Original Message- From: Jackson, Harry [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 8:05 AM To: '[EMAIL PROTECTED]' Subject: RE: converting a hash to an array -Original Message- From: Craig Hammer [mailto:[EMAIL PROTECTED]] @sorted = sort { $myhash{$b} = $myhash{a} } keys %myhash ; ^ * COLT Telecommunications Registered in England No. 2452736 Registered Office: Bishopsgate Court, 4 Norton Folgate, London E1 6DQ Tel. +44 20 7390 3900 This message is subject to and does not create or vary any contractual relationship between COLT Telecommunications, its subsidiaries or affiliates (COLT) and you. Internet communications are not secure and therefore COLT does not accept legal responsibility for the contents of this message. Any view or opinions expressed are those of the author. The message is intended for the addressee only and its contents and any attached files are strictly confidential. If you have received it in error, please telephone the number above. Thank you. * -- 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: converting a hash to an array
-Original Message- From: Craig Hammer [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 5:59 AM To: Perl (E-mail) Subject: converting a hash to an array I've found a couple of examples of moving an array into a hash, but not of moving a hash into an array. I thought this would work: @sorted = sort { $myhash{$b} = $myhash{a} } keys %myhash ; ^ s/b $a, I assume So now @sorted is a list of the keys from %myhash, sorted by the hash values (numeric sort). while ( @sorted ) { printf ( first field = %s second field = %s\n, $sorted{1}, $sorted{2} ) ; } I have no idea what this is trying to do. I am trying to sort the hash values (by value, not key) and move the sorted results into an array, so that I can add additional fields later. What do you mean by results? The list of values? The list of key/value pairs? I get an Use of uninitialized value at ./newlogscan.pl line 46. error. Line 46 is the @sorted = line. That's because you have $sorted{a} instead of $sorted{$a}. 'use strict' will catch that. Any ideas? If you want a sorted list of values: my @list = sort { $a = $b } values %myhash; If you want a list of key/value pairs, in order by the values: my @list = map {($_, $myhash{$_})} sort {$myhash{$a} = $myhash{$b}} keys %myhash -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: converting a hash to an array
on Wed, 29 May 2002 12:58:33 GMT, [EMAIL PROTECTED] (Craig Hammer) wrote: I thought this would work: Your code is very buggy: @sorted = sort { $myhash{$b} = $myhash{a} } keys %myhash ; This should read: @sorted = sort { $myhash{$b} = $myhash{$a} } keys %myhash ; ^ Now '@sorted' contains the keys of your '%myhash', sorted numerically, largest first. while ( @sorted ) { Since '@sorted' is not a filehandle, this will be interpreted as a glob(something), where something is the catenation of all your hashkeys, thus looping over all files in the current working directory that fit the something fileglob (probably none). You want for(@sorted) { # whatever } printf ( first field = %s second field = %s\n, $sorted{1}, $sorted{2} ) ; '@sorted' is an array, not a hash, $sorted{something} will not work. -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[Thanks] Re: Is there a good Perl way for a validation subroutine?
Thanks for the suggestions guys. - Original Message - From: Leila Lappin [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, May 28, 2002 11:55 PM Subject: Is there a good Perl way for a validation subroutine? Hello all, I need to write a subroutine that validates several fields and returns one summary field containing names of what failed. I was thinking of concatenating names of all fields that failed and return that string from the subroutine. Then check the string (return value) and if it's not null update the data base with it. Is that considered a good style for Perl? Frankly I'm not sure if this is a valid question, sorry if it's not and just ignore it, I just would like to do this the best way possible. thanks Leila -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Getting data from console
Hi. Just another question. How can I get a user input from the console in perl? I'm just playing with the DBI Module and want to ask for a select statement, which I can enter in the console. Executing the statment works already fine *gg*. Thnx for your help. this is a great mailing list :o) Heiko -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: converting a hash to an array
Thank you Felix and Bob. I see I was approaching this compeltely wrong. Craig Hammer -Original Message- From: Felix Geerinckx [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 8:23 AM To: [EMAIL PROTECTED] Subject: Re: converting a hash to an array on Wed, 29 May 2002 12:58:33 GMT, [EMAIL PROTECTED] (Craig Hammer) wrote: I thought this would work: Your code is very buggy: @sorted = sort { $myhash{$b} = $myhash{a} } keys %myhash ; This should read: @sorted = sort { $myhash{$b} = $myhash{$a} } keys %myhash ; ^ Now '@sorted' contains the keys of your '%myhash', sorted numerically, largest first. while ( @sorted ) { Since '@sorted' is not a filehandle, this will be interpreted as a glob(something), where something is the catenation of all your hashkeys, thus looping over all files in the current working directory that fit the something fileglob (probably none). You want for(@sorted) { # whatever } printf ( first field = %s second field = %s\n, $sorted{1}, $sorted{2} ) ; '@sorted' is an array, not a hash, $sorted{something} will not work. -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Getting data from console
Hi. Just another question. How can I get a user input from the console in perl? I'm just playing with the DBI Module and want to ask for a select statement, which I can enter in the console. Executing the statment works already fine *gg*. Thnx for your help. this is a great mailing list :o) Heiko my $input = STDIN; Best regards, mki [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Getting data from console
From: Heiko Heggen [EMAIL PROTECTED] Date: Wed, 29 May 2002 15:28:17 +0200 To: Beginners@Perl. Org [EMAIL PROTECTED] Subject: Getting data from console Hi. Just another question. How can I get a user input from the console in perl? I'm just playing with the DBI Module and want to ask for a select statement, which I can enter in the console. Executing the statment works already fine *gg*. Do you mean like: print Select what database to open:\n; chomp(my $db = STDIN); Or % perlscript.pl database user Where you can access them trough $ARGV[0] and $ARGV[1] Tor -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[Thanks] AW: Getting data from console
wow, so easy, great. thanks guys. heiko -Ursprüngliche Nachricht- Von: Tor Hildrum [mailto:[EMAIL PROTECTED]] Gesendet: Mittwoch, 29. Mai 2002 17:32 An: Heiko Heggen; Perl Betreff: Re: Getting data from console From: Heiko Heggen [EMAIL PROTECTED] Date: Wed, 29 May 2002 15:28:17 +0200 To: Beginners@Perl. Org [EMAIL PROTECTED] Subject: Getting data from console Hi. Just another question. How can I get a user input from the console in perl? I'm just playing with the DBI Module and want to ask for a select statement, which I can enter in the console. Executing the statment works already fine *gg*. Do you mean like: print Select what database to open:\n; chomp(my $db = STDIN); Or % perlscript.pl database user Where you can access them trough $ARGV[0] and $ARGV[1] Tor -- 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: calculate dates / regex
on Wed, 29 May 2002 12:05:45 GMT, [EMAIL PROTECTED] (Sven Bentlage) wrote: Encountered another problem: [...] Why are you posting the exact same question as yesterday? Why didn't you take John's advice into account? Did you miss his reply? -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
iterating over the contents of a directory
Hi, How can I simply iterate over the contents of a directory? I want to perform a certain action when I locate a particular text file. Thanks. -Jose -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: iterating over the contents of a directory
check out opendir readdir and closedir. -Original Message- From: Torres, Jose [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 10:23 AM To: '[EMAIL PROTECTED]' Subject: iterating over the contents of a directory Hi, How can I simply iterate over the contents of a directory? I want to perform a certain action when I locate a particular text file. Thanks. -Jose -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: iterating over the contents of a directory
You might also check out perldoc DirHandle !! -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 10:27 AM To: 'Torres, Jose'; '[EMAIL PROTECTED]' Subject: RE: iterating over the contents of a directory check out opendir readdir and closedir. -Original Message- From: Torres, Jose [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 10:23 AM To: '[EMAIL PROTECTED]' Subject: iterating over the contents of a directory Hi, How can I simply iterate over the contents of a directory? I want to perform a certain action when I locate a particular text file. Thanks. -Jose -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: iterating over the contents of a directory
Oh and I forgot glob() -Original Message- From: Shishir K. Singh [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 10:27 AM To: Nikola Janceski; Torres, Jose; [EMAIL PROTECTED] Subject: RE: iterating over the contents of a directory You might also check out perldoc DirHandle !! -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 10:27 AM To: 'Torres, Jose'; '[EMAIL PROTECTED]' Subject: RE: iterating over the contents of a directory check out opendir readdir and closedir. -Original Message- From: Torres, Jose [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 10:23 AM To: '[EMAIL PROTECTED]' Subject: iterating over the contents of a directory Hi, How can I simply iterate over the contents of a directory? I want to perform a certain action when I locate a particular text file. Thanks. -Jose -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- -- The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help with linking libraries during install.
Hi All, I am tring to use a module in perl (MQSeries), there are however a few bugs with this module on my platform (hpux). A fix is to link the libraries during a perl installation. I know that I will have to recompile perl and edit the Makefile to do this. But I dont know what I have to edit in the Makefile to do this. Any help would be appreciated. Jas. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: converting a hash to an array
Craig Hammer wrote at Wed, 29 May 2002 14:58:33 +0200: I've found a couple of examples of moving an array into a hash, but not of moving a hash into an array. I thought this would work: @sorted = sort { $myhash{$b} = $myhash{a} } keys %myhash ; I'd like to give another hint, you didn't ask for. You want to sort decreasingly, from the highest to the lowest. But to find it out, one's need good eyes. Especially when you read the code quickly, you read sort the keys in myhash numerically. The important information of the sort order is not simple to see. Make it more readable and write: @sorted = reverse sort { $myhash{$b} = $myhash{b} } keys %myhash; Cheerio, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: iterating over the contents of a directory
Thanks for your help everyone. I had a related question. It looks like readdir just return relative filenames and not absolute ones. Is there a way/method to return absolute filenames? For example, if I'm in /home/docs that has a text file (foo.txt) and I call readdir, I want to return /home/docs/foo.txt instead of just foo.txt. I could theoretically just append foo.txt to a /home/docs/ prefix, but I'm trying to make my code more generic and not hard-code everything if possible. Thank you. -Jose -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 10:27 AM To: Torres, Jose; '[EMAIL PROTECTED]' Subject: RE: iterating over the contents of a directory check out opendir readdir and closedir. -Original Message- From: Torres, Jose [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 10:23 AM To: '[EMAIL PROTECTED]' Subject: iterating over the contents of a directory Hi, How can I simply iterate over the contents of a directory? I want to perform a certain action when I locate a particular text file. Thanks. -Jose -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: iterating over the contents of a directory
Jose, Keep the list in the loop. Sometimes some of us get busy, (or goto lunch), and you won't get a response quickly. The code looks okay, so why not post what the error is so that we can tell you what is wrong. Also why not post how you are calling the subroutine. -Original Message- From: Torres, Jose [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 10:35 AM To: 'Nikola Janceski' Subject: RE: iterating over the contents of a directory I have some code like this: sub CreateChecksum { my($dir) = @_; opendir(DIRHANDLE, $dir) || ERROR: cannot read $dir\n; foreach (readdir(DIRHANDLE)){ print \nfound $_\n; } closedir DIRHANDLE; } where the name of a directory is passed into the subroutine. But every time I run it, it keeps erroring out and I have no idea why. I'm passing a valid directory name into the subroutine. Am I missing something here? Thanks. -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 10:27 AM To: Torres, Jose; '[EMAIL PROTECTED]' Subject: RE: iterating over the contents of a directory check out opendir readdir and closedir. -Original Message- From: Torres, Jose [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 10:23 AM To: '[EMAIL PROTECTED]' Subject: iterating over the contents of a directory Hi, How can I simply iterate over the contents of a directory? I want to perform a certain action when I locate a particular text file. Thanks. -Jose -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- -- The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. 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]
RE: iterating over the contents of a directory
don't think there is a way to get the full path. The only way I can think of is by concatening the results of the readdir with the $path that you used for opening the directory. -Original Message- From: Torres, Jose [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 10:41 AM To: '[EMAIL PROTECTED]' Subject: RE: iterating over the contents of a directory Thanks for your help everyone. I had a related question. It looks like readdir just return relative filenames and not absolute ones. Is there a way/method to return absolute filenames? For example, if I'm in /home/docs that has a text file (foo.txt) and I call readdir, I want to return /home/docs/foo.txt instead of just foo.txt. I could theoretically just append foo.txt to a /home/docs/ prefix, but I'm trying to make my code more generic and not hard-code everything if possible. Thank you. -Jose -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 10:27 AM To: Torres, Jose; '[EMAIL PROTECTED]' Subject: RE: iterating over the contents of a directory check out opendir readdir and closedir. -Original Message- From: Torres, Jose [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 10:23 AM To: '[EMAIL PROTECTED]' Subject: iterating over the contents of a directory Hi, How can I simply iterate over the contents of a directory? I want to perform a certain action when I locate a particular text file. Thanks. -Jose -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: iterating over the contents of a directory
on Wed, 29 May 2002 14:41:23 GMT, [EMAIL PROTECTED] (Jose Torres) wrote: Thanks for your help everyone. I had a related question. It looks like readdir just return relative filenames and not absolute ones. Is there a way/method to return absolute filenames? For example, if I'm in /home/docs that has a text file (foo.txt) and I call readdir, I want to return /home/docs/foo.txt instead of just foo.txt. I could theoretically just append foo.txt to a /home/docs/ prefix, but I'm trying to make my code more generic and not hard-code everything if possible. Thank you. 'readdir' will not return paths, so you will have to stick *something* in front of the filenames. If you want to work from the current directory, have a look at the functions in the 'Cwd' module perldoc Cwd -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
scheduler question
I have written a Perl script that needs to be executed every 10 seconds. How would I go about doing this. I am working with Perl on NT and using scheduler and the lowest I can set it to is 1 minute. Thank you in advance Lance -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: scheduler question
Perhaps write a perl script that is inifinitely looping and sleeps 10 secs then runs your other script. while (1){ sleep 10; system(myotherscript.pl); } -Original Message- From: Lance Prais [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 10:51 AM To: Perl Subject: scheduler question I have written a Perl script that needs to be executed every 10 seconds. How would I go about doing this. I am working with Perl on NT and using scheduler and the lowest I can set it to is 1 minute. Thank you in advance Lance -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: scheduler question
How about using the sleep function in the script?? perldoc -f sleep -Original Message- From: Lance Prais [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 10:51 AM To: Perl Subject: scheduler question I have written a Perl script that needs to be executed every 10 seconds. How would I go about doing this. I am working with Perl on NT and using scheduler and the lowest I can set it to is 1 minute. Thank you in advance Lance -- 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: scheduler question
-Original Message- From: Lance Prais [mailto:[EMAIL PROTECTED]] I have written a Perl script that needs to be executed every 10 seconds. How would I go about doing this. I am working with Perl on NT and using scheduler and the lowest I can set it to is 1 minute. while (1) { sleep 10; execute what ya ma flip; } or alternately look for Perl as an NT service on google H * COLT Telecommunications Registered in England No. 2452736 Registered Office: Bishopsgate Court, 4 Norton Folgate, London E1 6DQ Tel. +44 20 7390 3900 This message is subject to and does not create or vary any contractual relationship between COLT Telecommunications, its subsidiaries or affiliates (COLT) and you. Internet communications are not secure and therefore COLT does not accept legal responsibility for the contents of this message. Any view or opinions expressed are those of the author. The message is intended for the addressee only and its contents and any attached files are strictly confidential. If you have received it in error, please telephone the number above. Thank you. * -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: scheduler question
use WinCron You can find it on http://google.com search for WinCron -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: scheduler question
It's amazing that wincron turned up more results than wincrap http://www.google.com/search?hl=enie=UTF8oe=UTF8q=wincrap -Original Message- From: Mikhail Kyurshin [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 11:58 AM To: Perl Cc: Lance Prais Subject: Re: scheduler question use WinCron You can find it on http://google.com search for WinCron -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: scheduler question - newbie script
Depending on how long the job takes, this little script runs about every 10 seconds. If you want to be more exact I think you'll have to fork. #!/usr/bin/perl -w use strict; use POSIX; # Start the loop for the daemon while(1) { my(@now) = localtime(); my($today) = POSIX::strftime( %m/%d/%Y, @now); my($time) = POSIX::strftime( %H:%M, @now); print Running 10 second job | $today | $time\n; system ( 'perl newftp3.pl gep_card.xml' ); sleep 10; # 10 second intervals } -Original Message- From: Lance Prais [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 7:51 AM To: Perl Subject: scheduler question I have written a Perl script that needs to be executed every 10 seconds. How would I go about doing this. I am working with Perl on NT and using scheduler and the lowest I can set it to is 1 minute. Thank you in advance Lance -- 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: scheduler question
Good one..Wonder how you stumbled across it. Typo error ?? :) -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 11:03 AM To: Perl Subject: RE: scheduler question It's amazing that wincron turned up more results than wincrap http://www.google.com/search?hl=enie=UTF8oe=UTF8q=wincrap -Original Message- From: Mikhail Kyurshin [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 11:58 AM To: Perl Cc: Lance Prais Subject: Re: scheduler question use WinCron You can find it on http://google.com search for WinCron -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: converting a hash to an array
Janek, et al -- ...and then Janek Schleicher said... % % Craig Hammer wrote at Wed, 29 May 2002 14:58:33 +0200: % ... % @sorted = sort { $myhash{$b} = $myhash{a} } keys %myhash ; ... % % You want to sort decreasingly, from the highest to the lowest. ... % Make it more readable and write: % % @sorted = reverse sort { $myhash{$b} = $myhash{b} } keys %myhash; I can only assume that you meant ... { $myhash{$a} = $myhash{$b} } ... since the test you wrote should always be equal ;-) Right? % % % Cheerio, % Janek TIA HAND :-D -- David T-G * It's easier to fight for one's principles (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie (work) [EMAIL PROTECTED] http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg! msg25005/pgp0.pgp Description: PGP signature
RE: iterating over the contents of a directory
Jose Torres wrote at Wed, 29 May 2002 16:41:23 +0200: Thanks for your help everyone. I had a related question. It looks like readdir just return relative filenames and not absolute ones. Is there a way/method to return absolute filenames? For example, if I'm in /home/docs that has a text file (foo.txt) and I call readdir, I want to return /home/docs/foo.txt instead of just foo.txt. I could theoretically just append foo.txt to a /home/docs/ prefix, but I'm trying to make my code more generic and not hard-code everything if possible. Thank you. It's not a big matter. my $path = /.../; opendir DIR, $path or ; my @full_paths = map {$path$_} readdir DIR; closedir DIR; Now @full_paths contains what you need. Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: converting a hash to an array
Janek Schleicher wrote at Wed, 29 May 2002 17:20:02 +0200: Make it more readable and write: @sorted = reverse sort { $myhash{$b} = $myhash{b} } keys %myhash; Oops, there's a typo :-(( Of course, I meant @sorted = reverse sort { $myhash{$a} = $myhash{b} } keys %myhash; Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: converting a hash to an array
on Wed, 29 May 2002 16:10:40 GMT, [EMAIL PROTECTED] (Janek Schleicher) wrote: Oops, there's a typo :-(( Of course, I meant @sorted = reverse sort { $myhash{$a} = $myhash{b} } keys %myhash; There's another typo. And I'd rather add # sort keys in descending numerical order than suffering a substantial speed penalty by using 'reverse'. -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: iterating over the contents of a directory
What about $File::Find::name in File::Find? Bob Rasey On Wed, 2002-05-29 at 10:44, Shishir K. Singh wrote: don't think there is a way to get the full [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DB
How can i create binary db. How can i push 1234 in binary file that perl can read ? - This mail is from: [EMAIL PROTECTED] - -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Shredding a file
On Tue, 28 May 2002 20:15:58 +0100 (BST), [EMAIL PROTECTED] (Jonathan e. paton) wrote: For those that feel comfortable, it is worth pointing out CRT Eavesdropping: Optical Tempest on slashdot. http://slashdot.org/article.pl?sid=02/03/09/199242 Can a knowledgable person design a optical tempest system as a web-project please? I'd love to be able to build I remember when disclosure of the widespread use of audio-bugs was big news on shows like 60 Minutes. The classic being the car salesman leaving potential customers alone to discuss a possible purchase, but actually eavesdropping on them. What revelations await us 20 years from now? The odds are pretty high that computer-bugs are in widespread use, although the public can't purchase them yet, unless you are well-connected. Everything you type in is already being secretly monitored, and fed thru some NSA computer looking for keywords, like they do with the phone conversations. I guess if you wipe your files clean, you could get a good lawyer to argue that the government's surveillance copy was just a forgery. But you should consider everything being typed on your computer as going into the public airwaves and being received by someone. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Shredding a file
Brain Bugs are next. Then the NSA will be selling off the porn movies that I dream up. -Original Message- From: zentara [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 12:36 PM To: [EMAIL PROTECTED] Subject: Re: Shredding a file On Tue, 28 May 2002 20:15:58 +0100 (BST), [EMAIL PROTECTED] (Jonathan e. paton) wrote: For those that feel comfortable, it is worth pointing out CRT Eavesdropping: Optical Tempest on slashdot. http://slashdot.org/article.pl?sid=02/03/09/199242 Can a knowledgable person design a optical tempest system as a web-project please? I'd love to be able to build I remember when disclosure of the widespread use of audio-bugs was big news on shows like 60 Minutes. The classic being the car salesman leaving potential customers alone to discuss a possible purchase, but actually eavesdropping on them. What revelations await us 20 years from now? The odds are pretty high that computer-bugs are in widespread use, although the public can't purchase them yet, unless you are well-connected. Everything you type in is already being secretly monitored, and fed thru some NSA computer looking for keywords, like they do with the phone conversations. I guess if you wipe your files clean, you could get a good lawyer to argue that the government's surveillance copy was just a forgery. But you should consider everything being typed on your computer as going into the public airwaves and being received by someone. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Reading RGB Values of Pixels in Images
Hi, I'm very new to Perl and have a question that I haven't been able to find an answer to. I want to be able to read an image file (BMP, PNG, JPEG, etc...) or a series if image files and read the RGB pixel values from them and write these to a file. I have looked at various image libraries for Perl and around on the Internet but I have not been able to find a method of doing what I want to do. I'd like to make the program as platform and image independent as possible, hence me trying it in Perl. Could any point me in the right direction or provide a few hints? Thanks, Chris. -- Chris Egan [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Shredding a file
More than I wanted to know, thank you.. *LOL* k, let's get this OT off of here then with those lovely words from Nikola.. ;) Best Regards Anders Holm Critical Path Technical Support Engineer -- Tel USA/Canada: 1 800 353 8437 Tel Worldwide: +1 801 736 0806 E-mail: [EMAIL PROTECTED] Internet: http://support.cp.net -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: 29 May 2002 16:54 To: 'zentara'; [EMAIL PROTECTED] Subject: RE: Shredding a file Brain Bugs are next. Then the NSA will be selling off the porn movies that I dream up. -Original Message- From: zentara [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 12:36 PM To: [EMAIL PROTECTED] Subject: Re: Shredding a file On Tue, 28 May 2002 20:15:58 +0100 (BST), [EMAIL PROTECTED] (Jonathan e. paton) wrote: For those that feel comfortable, it is worth pointing out CRT Eavesdropping: Optical Tempest on slashdot. http://slashdot.org/article.pl?sid=02/03/09/199242 Can a knowledgable person design a optical tempest system as a web-project please? I'd love to be able to build I remember when disclosure of the widespread use of audio-bugs was big news on shows like 60 Minutes. The classic being the car salesman leaving potential customers alone to discuss a possible purchase, but actually eavesdropping on them. What revelations await us 20 years from now? The odds are pretty high that computer-bugs are in widespread use, although the public can't purchase them yet, unless you are well-connected. Everything you type in is already being secretly monitored, and fed thru some NSA computer looking for keywords, like they do with the phone conversations. I guess if you wipe your files clean, you could get a good lawyer to argue that the government's surveillance copy was just a forgery. But you should consider everything being typed on your computer as going into the public airwaves and being received by someone. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: hole: a memory leak
-Original Message- From: F.Xavier Noria [mailto:[EMAIL PROTECTED]] What would be the shortest code that leak? Its not really the length as much as the width of the whole that causes a leak. h * COLT Telecommunications Registered in England No. 2452736 Registered Office: Bishopsgate Court, 4 Norton Folgate, London E1 6DQ Tel. +44 20 7390 3900 This message is subject to and does not create or vary any contractual relationship between COLT Telecommunications, its subsidiaries or affiliates (COLT) and you. Internet communications are not secure and therefore COLT does not accept legal responsibility for the contents of this message. Any view or opinions expressed are those of the author. The message is intended for the addressee only and its contents and any attached files are strictly confidential. If you have received it in error, please telephone the number above. Thank you. * -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Getting data from console
On Wednesday, May 29, 2002, at 08:31 , Tor Hildrum wrote: [..] Just another question. How can I get a user input from the console in perl? I'm just playing with the DBI Module and want to ask for a select statement, which I can enter in the console. Executing the statment works already fine *gg*. Do you mean like: print Select what database to open:\n; chomp(my $db = STDIN); For this I normally have a function of the form sub AskTheInfestationUnit { my ($msg ) = @_; my $answer ; print $msg ;# you want to let them format it chomp(my $answer = STDIN); $answer; } # end AskTheInfestationUnit hence everytime I want the hairless apes to answer you will just see lines like: my $the_hairless_ape_said = AskTheInfestationUnit($msg); unless($the_hairless_ape_said =~ /$TheCorrectAnswer/) { hitHairlessApe(); # requires Wired::Seat $the_hairless_ape_said = AskTheInfestationUnit($msg); } # note - if you need multiple lines of input you can wrap # AskTheInfestationUnit($msg) in something that parses for # an EONFHA { end of noise from hairless ape } Or % perlscript.pl database user Where you can access them trough $ARGV[0] and $ARGV[1] Tor as for reading the command lines - yes, we all start there, but the original author really will want to get on to perldoc Getopt::Standard and perldoc Getopt::Long sooner or later... ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Reading RGB Values of Pixels in Images
I am by no means an expert, but you've got a big task on your hands. BMP files will probably be the easiest, since they are stored - red, green, blue, red, green, blue, , but there is header information you have to get past, and you also have to figure out how long the rows are. PNG and JPG are compressed, so you'll have to decompress them before you can get the RGB values, which is not an easy task. I think there are GNU libraries for it, but I'm not sure. HTH. - B __ Hi, I'm very new to Perl and have a question that I haven't been able to find an answer to. I want to be able to read an image file (BMP, PNG, JPEG, etc...) or a series if image files and read the RGB pixel values from them and write these to a file. I have looked at various image libraries for Perl and around on the Internet but I have not been able to find a method of doing what I want to do. I'd like to make the program as platform and image independent as possible, hence me trying it in Perl. Could any point me in the right direction or provide a few hints? Thanks, Chris. -- Chris Egan [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: converting a hash to an array
Please remove me from email list. thanks. --- Felix Geerinckx [EMAIL PROTECTED] wrote: on Wed, 29 May 2002 12:58:33 GMT, [EMAIL PROTECTED] (Craig Hammer) wrote: I thought this would work: Your code is very buggy: @sorted = sort { $myhash{$b} = $myhash{a} } keys %myhash ; This should read: @sorted = sort { $myhash{$b} = $myhash{$a} } keys %myhash ; ^ Now '@sorted' contains the keys of your '%myhash', sorted numerically, largest first. while ( @sorted ) { Since '@sorted' is not a filehandle, this will be interpreted as a glob(something), where something is the catenation of all your hashkeys, thus looping over all files in the current working directory that fit the something fileglob (probably none). You want for(@sorted) { # whatever } printf ( first field = %s second field = %s\n, $sorted{1}, $sorted{2} ) ; '@sorted' is an array, not a hash, $sorted{something} will not work. -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] = Peter Lemus Network Engineer [EMAIL PROTECTED] --A wise man will be master of his mind, a fool will be its slave. Dr.David Schwartz. --Enjoy every moment of the day; Live like as if today was your last day alive, and perhaps, it might be. --Those who know, don't say; those who say don't know. __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DB
On Wed, 2002-05-29 at 11:42, Milen Hristov wrote: How can i create binary db. Depends on what you mean by a DB, take a look at dbmopen (perldoc -f dbmopen). How can i push 1234 in binary file that perl can read ? take a look at pack and unpack (perldoc -f pack, perl -f unpack). - This mail is from: [EMAIL PROTECTED] - -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Today is Prickle-Prickle the 3rd day of Confusion in the YOLD 3168 Wibble. Missile Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Links to randomly-accessed html pages
Hello, I am working on a web project that will be using the srand function both in the creation of html pages (some of the elements get randomly selected from lists) and in the selection of pages to be called when the user clicks certain links. So far, I can get what I need when I'm compiling a page dynamically, so it's not the srand function that's the trouble, but the way I'm trying to get the links to call randomly-accessed pages isn't working very well. I've put the links in a cgi-compiled page in a left frame, to call pages into the right, main frame of a page. The random link works once and then the page needs to be refreshed before it will work again. I can see that this is because I've created a $RandomPage variable from the srand function which, once created, doesn't change until the cgi script is run again from top to bottom, so I've tried various ways with javascript to get the left page to refresh whenever the link is clicked or whenever a new page is opened in the main window. None of my javascript workarounds are working, and I wonder if there's a perl way to get this script to re-run itself every time a user clicks a link? Here's roughly the code: # #!/usr/local/bin/perl5 use CGI qw(:standard); #make array of pages available: @Pages=(../page1.htm, ../page2.htm, ../page3.htm); # pick one of the pages at random for This Link srand; $RandomPage = $Pages[int(rand(@Pages))]; print Content-type:text/html\n\n; print EndOfHTML; html head titleTitle Here/title /head BODY TABLE height = 100%TR TD height = 33% align=center VAlign=centera href=$RandomPage Target=mainThis Link/a/TD /TRTRTD.../TD/TRTRTD.../TD/TR /table EndOfHTML print /body/html; # Many thanks for all and any help in advance! Rohesia = Rohesia Hamilton Metcalfe __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
use Getopt::Std was Re: Getting data from console
On Wednesday, May 29, 2002, at 09:27 , drieux wrote: [..] perldoc Getopt::Standard before the monkeyBoys[tm] start screeching and flapping their wings - that should have been perldoc Getopt::Std I keep forgetting when we spend the $100 and buy the vowel from vanna. So that people do not get confused, while it is true that most of the 'hairless apes' poking at the keyboard providing cmdline arguments, the TLA does not stand for 'sexually transmitted disease' but stands for Shell Traumatized Data since Getopt::Std will work just as well if your programme is called by another programme in the form system($that_prog @arlist); ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
what does a diff return?
Hi, If I'm calling the diff program from within a Perl script with something like: system(diff file1.txt file2.txt); how can I detect if there is a result or not, since if the files are identical, diff doesn't have any output? I need to be able to be able to determine if there was any output from within my script so that I can take one particular action if diff returned something (the files were different) or take another if diff didn't return anything (the files were identical). Thanks for all help with this. -Jose -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Modules
Wanted to know the modules that are already present in the standard stable.tar.gz distribution. I had a Active Perl distribution. Now I need to install the stable.tar.gz and wanted to know the additional modules that I may have to install. Thanks Shishir -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: what does a diff return?
-Original Message- From: Torres, Jose [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 11:30 AM To: [EMAIL PROTECTED] Subject: what does a diff return? Hi, If I'm calling the diff program from within a Perl script with something like: system(diff file1.txt file2.txt); how can I detect if there is a result or not, since if the files are identical, diff doesn't have any output? I need to be able to be able to determine if there was any output from within my script so that I can take one particular action if diff returned something (the files were different) or take another if diff didn't return anything (the files were identical). Thanks for all help with this. Use the exit status from diff, which is available from $? system('diff file1.txt file2.txt'); $exit_value = $? 8; # from perldoc -f system You might also consider cmp(1) (with -s) if you just want to see if the files are identical or not. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: what does a diff return?
Jose, try: $ perl -e ' my $delta; $delta = `diff ae.txt ae.txt`; print $delta.\n; unless ($delta) { printthey are identical\n; }' HTH Jose Torres [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi, If I'm calling the diff program from within a Perl script with something like: system(diff file1.txt file2.txt); how can I detect if there is a result or not, since if the files are identical, diff doesn't have any output? I need to be able to be able to determine if there was any output from within my script so that I can take one particular action if diff returned something (the files were different) or take another if diff didn't return anything (the files were identical). Thanks for all help with this. -Jose -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Links to randomly-accessed html pages
A better approach would be to have a static 'left' frame that links to a CGI that redirects to a random page. Like so: TD height = 33% align=center VAlign=centera href=RandomPage.cgi Target=mainThis Link/a/TD And then RandomPage.cgi just has to pic a random page, and return a redirect header to that page. - Original Message - From: Rohesia Hamilton Metcalfe [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, May 29, 2002 1:55 PM Subject: Links to randomly-accessed html pages Hello, I am working on a web project that will be using the srand function both in the creation of html pages (some of the elements get randomly selected from lists) and in the selection of pages to be called when the user clicks certain links. So far, I can get what I need when I'm compiling a page dynamically, so it's not the srand function that's the trouble, but the way I'm trying to get the links to call randomly-accessed pages isn't working very well. I've put the links in a cgi-compiled page in a left frame, to call pages into the right, main frame of a page. The random link works once and then the page needs to be refreshed before it will work again. I can see that this is because I've created a $RandomPage variable from the srand function which, once created, doesn't change until the cgi script is run again from top to bottom, so I've tried various ways with javascript to get the left page to refresh whenever the link is clicked or whenever a new page is opened in the main window. None of my javascript workarounds are working, and I wonder if there's a perl way to get this script to re-run itself every time a user clicks a link? Here's roughly the code: # #!/usr/local/bin/perl5 use CGI qw(:standard); #make array of pages available: @Pages=(../page1.htm, ../page2.htm, ../page3.htm); # pick one of the pages at random for This Link srand; $RandomPage = $Pages[int(rand(@Pages))]; print Content-type:text/html\n\n; print EndOfHTML; html head titleTitle Here/title /head BODY TABLE height = 100%TR TD height = 33% align=center VAlign=centera href=$RandomPage Target=mainThis Link/a/TD /TRTRTD.../TD/TRTRTD.../TD/TR /table EndOfHTML print /body/html; # Many thanks for all and any help in advance! Rohesia = Rohesia Hamilton Metcalfe __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- 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: Modules
Shishir K. Singh [[EMAIL PROTECTED]] quoth: *Wanted to know the modules that are already present in the standard stable.tar.gz distribution. I had a Active Perl distribution. Now I need to install the stable.tar.gz and wanted to know the additional modules that I may have to install. http://www.cpan.org/misc/cpan-faq.html e. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reading RGB Values of Pixels in Images
You want to read the RGB pixel values from them and write these to a file? As was already pointed out, that is already what is in the file for some graphics formats! What is it you are actually trying to accomplish here? Maybe you just want to use imagemagick on the command line to convert your files to a single format? In any case, image magick (as also previously mentioned) is the way to go. Using the perl library (http://www.imagemagick.org/www/perl.html) you just have to open the image (the library figures out what format it is automagickally), get width and height, then loop through calling pixel and writing the results. - Original Message - From: Chris Egan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, May 29, 2002 11:58 AM Subject: Reading RGB Values of Pixels in Images Hi, I'm very new to Perl and have a question that I haven't been able to find an answer to. I want to be able to read an image file (BMP, PNG, JPEG, etc...) or a series if image files and read the RGB pixel values from them and write these to a file. I have looked at various image libraries for Perl and around on the Internet but I have not been able to find a method of doing what I want to do. I'd like to make the program as platform and image independent as possible, hence me trying it in Perl. Could any point me in the right direction or provide a few hints? Thanks, Chris. -- Chris Egan [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: Modules
Thanks!! -Original Message- From: Elaine -HFB- Ashton [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 2:48 PM To: Shishir K. Singh Cc: [EMAIL PROTECTED] Subject: Re: Modules Shishir K. Singh [[EMAIL PROTECTED]] quoth: *Wanted to know the modules that are already present in the standard stable.tar.gz distribution. I had a Active Perl distribution. Now I need to install the stable.tar.gz and wanted to know the additional modules that I may have to install. http://www.cpan.org/misc/cpan-faq.html e. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help handling text files.
Ok Heres the deal :) I have a script to write to a dat file and the basic output in the dat file is username:plan: so an example would be computer:50: meaning the username computer has 50 hours of paid dialup access. Now Lets say computer calls and wishes to upgrade his account to 100 hours, i need to figure out how to script it so that it replaces the number with the new one..know what i mean? Josh
Thanks/solved - Re: Links to randomly-accessed html pages
Dear Adam, Thanks!!! That worked. (And my stuck brain can work again...) Best, Rohesia --- Adam Morton [EMAIL PROTECTED] wrote: A better approach would be to have a static 'left' frame that links to a CGI that redirects to a random page. Like so: TD height = 33% align=center VAlign=centera href=RandomPage.cgi Target=mainThis Link/a/td And then RandomPage.cgi just has to pic a random page, and return a redirect header to that page. - Original Message - From: Rohesia Hamilton Metcalfe [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, May 29, 2002 1:55 PM Subject: Links to randomly-accessed html pages Hello, I am working on a web project that will be using the srand function both in the creation of html pages (some of the elements get randomly selected from lists) and in the selection of pages to be called when the user clicks certain links. So far, I can get what I need when I'm compiling a page dynamically, so it's not the srand function that's the trouble, but the way I'm trying to get the links to call randomly-accessed pages isn't working very well. I've put the links in a cgi-compiled page in a left frame, to call pages into the right, main frame of a page. The random link works once and then the page needs to be refreshed before it will work again. I can see that this is because I've created a $RandomPage variable from the srand function which, once created, doesn't change until the cgi script is run again from top to bottom, so I've tried various ways with javascript to get the left page to refresh whenever the link is clicked or whenever a new page is opened in the main window. None of my javascript workarounds are working, and I wonder if there's a perl way to get this script to re-run itself every time a user clicks a link? Here's roughly the code: # #!/usr/local/bin/perl5 use CGI qw(:standard); #make array of pages available: @Pages=(../page1.htm, ../page2.htm, ../page3.htm); # pick one of the pages at random for This Link srand; $RandomPage = $Pages[int(rand(@Pages))]; print Content-type:text/html\n\n; print EndOfHTML; html head titleTitle Here/title /head BODY TABLE height = 100%TR TD height = 33% align=center VAlign=centera href=$RandomPage Target=mainThis Link/a/td /trTRTD.../td/trTRTD.../td/tr /table EndOfHTML print /body/html; # Many thanks for all and any help in advance! Rohesia = Rohesia Hamilton Metcalfe __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- 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] = Rohesia Hamilton Metcalfe __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: hole: a memory leak
On Wednesday, May 29, 2002, at 09:06 , Jackson, Harry wrote: -Original Message- From: F.Xavier Noria [mailto:[EMAIL PROTECTED]] What would be the shortest code that leak? Its not really the length as much as the width of the whole that causes a leak. well you could write a self referential function sub sillyMe { my ($arg ) = @_ my $value = $arg + time + 1; sillyMe($value); } sillyMe(1); that wouldn't really 'leak' but it would buy you a stack frame for each call - and some arguments each time through until you ran out of heap ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: hole: a memory leak
-Original Message- From: F.Xavier Noria [mailto:[EMAIL PROTECTED]] What would be the shortest code that leak? Its not really the length as much as the width of the whole that causes a leak. This challange is now being covered on the golf mailing list. I can't find the archives, but here is some ideas: do$0 * self referring (works with near-infinite memory) - AUTHOR: Marko P. O. Nippula $~++while 1 * pure perl (works with near-infinite memory) - AUTHOR: Marko P. O. Nippula/Jonathan Paton $^Tx$^T * pure perl, kills any 5.6.1 perl on a 32 bit platform - (uses more than 2**32 bytes) * $^T is a CTRL T [single byte], replace the first $^T - with 1 to save a byte but only kill on most systems - AUTHOR: Jonathan Paton Jonathan Paton = $_=q|.,@$$. ,.@$@$. .$$@. ,,$ !$_=$p.'$@.',y'$@' .,';for(/\S+/g){ !|.q| .$ .,@, ,$, .,.. @, ,$ ,,@ .,,.!++$.22?${'y'.$_}=chr$.+64:[$$=${'y' !|.q| ,@$@.,. $$$, ..@$,,, $., ..!.$_},$y.=($.=~/22\|26\|3(3\|7)/x?' ' !|.q|. @ ., ,.,,, , .$... .,$ .,,!.$$:\l$$)]};$y=~/ (.*)/;warn$1\n !|.q|. $ .,. .,$$$, @.,.@$@ .|,map{-$|--?$r:$p.=$_}split'!';eval$r __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: hole: a memory leak
On Wed, 2002-05-29 at 15:26, drieux wrote: On Wednesday, May 29, 2002, at 09:06 , Jackson, Harry wrote: -Original Message- From: F.Xavier Noria [mailto:[EMAIL PROTECTED]] What would be the shortest code that leak? Its not really the length as much as the width of the whole that causes a leak. well you could write a self referential function sub sillyMe { my ($arg ) = @_ my $value = $arg + time + 1; sillyMe($value); } sillyMe(1); that wouldn't really 'leak' but it would buy you a stack frame for each call - and some arguments each time through until you ran out of heap ciao drieux One way to create a memory leak (at least while a script is running) is to use circular references: code #!/usr/bin/perl use strict; for (0..100) { my $a = 8; #$a's reference count is set to 1 my $b = 10; #$b's reference count is set to 1 #$a leaves scope so is reference count is decremented by 1 #$b leaves scope so is reference count is decremented by 1 } #$a and $b's reference counts are 0 so the get GC'ed system(ps -o rss,pid,cmd | grep $$ | grep -v grep); for (0..100) { my $a; #$a's reference count is set to 1 my $b; #$b's reference count is set to 1 $a = \$b; #$b's reference count is incremented by 1 $b = \$a; #$b's reference count is incremented by 1 #$a leaves scope so is reference count is decremented by 1 #$b leaves scope so is reference count is decremented by 1 } #$a and $b's reference counts are both still 1 so they don't get GC'ed system(ps -o rss,pid,cmd | grep $$ | grep -v grep); #program ends and the real GC code cleans up the mess /code output 1224 7565 /usr/bin/perl ./hog.pl 33108 7565 /usr/bin/perl ./hog.pl /output -- Today is Prickle-Prickle the 3rd day of Confusion in the YOLD 3168 Kallisti! Missile Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem reading a file and passing a variable
I am m using the following code to read from a .txt file. I am running into a problem that I am not sure why it is happening. The problem is when I run this script the SQL is not reading the variable. I am testing to make sure the .txt file contains data and it does. I get the following error: DBD::Oracle::st execute failed: called with 1 bind variables when 0 are needed at /data/verity/custom-kb/scripts/test.pl line 36, BULK line 1. DBD::Oracle::st execute failed: called with 1 bind variables when 0 are needed at /data/verity/custom-kb/scripts/test.pl line 36, BULK line 1. Issuing rollback() for database handle being DESTROY'd without explicit disconnect(), BULK line 1. LINE 36 where the error is occuring: sr_num = $ln); In the past when reading form an array fbuilt by a SQL statement I do it different. This is my first tiem trying to read form Files Any Ideas what I am doing wrong? Thank you in advance Lance #!/usr/local/bin/perl # # Purpose: To extract Daily Siebel (SecureTrak) cases # # Written by Lance #ENVIRONMENT VARIABLES $CUSTOM = /data/verity/custom-kb; $SERVICE= X.world; $oracle_user= XX; $oracle_password= X; $html_file_path = $CUSTOM/content/daily_securetrak_new; $bif_file_path = $CUSTOM/content/daily_securetrak; $bulk_load_filename = $CUSTOM/bif/daily_securetrak.bif; $template_filename = $CUSTOM/templates/daily_securetrak_main_build_template.html; $template_comm_filename = $CUSTOM/templates/daily_securetrak_comm_build_template.html; $daily_sr_file = $CUSTOM/scripts/unique_sr_list.txt; print Extract started at: . `date`; #open connection to the DB use DBI; $connect_string=DBI:Oracle:$SERVICE; my $dbh = DBI-connect($connect_string,$oracle_user,$oracle_password, { AutoCommit= 0, LongTruncOk= TRUE, PrintError = 1, ChopBlanks= TRUE,LongTruncOk= TRUE,LongReadLen= 5, RaiseError = 1 }) or die connecting: $DBI::errstr; #open file to read from open(BULK, $daily_sr_file) || die(Could not open file!); my $line = 1; while( my $ln = BULK ) { chomp($ln); #use the items of the my $get_case_text = $dbh-prepare(SELECT a.sr_num ,b.name ,b.loc ,a.sr_title,f.mid_name ,a.sr_stat_id ,e.name ,f.fst_name ,f.last_name ,f.email_addr ,g.country,g.Province ,g.zipcode,to_char(a.x_cp_created,'DD-MON-') ,to_char(a.x_cp_closed,'DD-MON-') ,c.login ,a.desc_text FROM s_srv_req a,s_org_ext b,s_employee c,s_postn d,s_org_int e,s_contact f,s_addr_org g WHERE a.cst_ou_id = b.row_id and a.cst_con_id = f.row_id and a.owner_emp_id = c.row_id and c.pr_postn_id = d.row_id and d.ou_id = e.row_id and b.pr_addr_id = g.row_id and sr_num = $ln); $get_case_text-execute($sr_num) || $dbh-errstr; ($sr_num ,$account_name ,$loc ,$sr_title , $uc_id ,$sr_stat_id ,$group_name ,$fst_name ,$last_name ,$email_addr ,$country,$Province ,$zipcode,$x_cp_created ,$x_cp_closed ,$login ,$desc_text) = $get_case_text-fetchrow_array(); $get_case_text-finish; print -- SR(bulk): $sr_num\n; print -- User Id(name): $uc_id\n; $line++; } close(DAT); $dbh-disconnect; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem reading a file and passing a variable
I am m using the following code to read from a .txt file. I am running into a problem that I am not sure why it is happening. The problem is when I run this script the SQL is not reading the variable. I am testing to make sure the .txt file contains data and it does. I get the following error: DBD::Oracle::st execute failed: called with 1 bind variables when 0 are needed at /data/verity/custom-kb/scripts/test.pl line 36, BULK line 1. DBD::Oracle::st execute failed: called with 1 bind variables when 0 are needed at /data/verity/custom-kb/scripts/test.pl line 36, BULK line 1. Issuing rollback() for database handle being DESTROY'd without explicit disconnect(), BULK line 1. LINE 36 where the error is occuring: sr_num = $ln); In the past when reading form an array fbuilt by a SQL statement I do it different. This is my first tiem trying to read form Files Any Ideas what I am doing wrong? Thank you in advance Lance #!/usr/local/bin/perl # # Purpose: To extract Daily Siebel (SecureTrak) cases # # Written by Lance #ENVIRONMENT VARIABLES $CUSTOM = /data/verity/custom-kb; $SERVICE= X.world; $oracle_user= XX; $oracle_password= X; $html_file_path = $CUSTOM/content/daily_securetrak_new; $bif_file_path = $CUSTOM/content/daily_securetrak; $bulk_load_filename = $CUSTOM/bif/daily_securetrak.bif; $template_filename = $CUSTOM/templates/daily_securetrak_main_build_template.html; $template_comm_filename = $CUSTOM/templates/daily_securetrak_comm_build_template.html; $daily_sr_file = $CUSTOM/scripts/unique_sr_list.txt; print Extract started at: . `date`; #open connection to the DB use DBI; $connect_string=DBI:Oracle:$SERVICE; my $dbh = DBI-connect($connect_string,$oracle_user,$oracle_password, { AutoCommit= 0, LongTruncOk= TRUE, PrintError = 1, ChopBlanks= TRUE,LongTruncOk= TRUE,LongReadLen= 5, RaiseError = 1 }) or die connecting: $DBI::errstr; #open file to read from open(BULK, $daily_sr_file) || die(Could not open file!); my $line = 1; while( my $ln = BULK ) { chomp($ln); #use the items of the my $get_case_text = $dbh-prepare(SELECT a.sr_num ,b.name ,b.loc ,a.sr_title,f.mid_name ,a.sr_stat_id ,e.name ,f.fst_name ,f.last_name ,f.email_addr ,g.country,g.Province ,g.zipcode,to_char(a.x_cp_created,'DD-MON-') ,to_char(a.x_cp_closed,'DD-MON-') ,c.login ,a.desc_text FROM s_srv_req a,s_org_ext b,s_employee c,s_postn d,s_org_int e,s_contact f,s_addr_org g WHERE a.cst_ou_id = b.row_id and a.cst_con_id = f.row_id and a.owner_emp_id = c.row_id and c.pr_postn_id = d.row_id and d.ou_id = e.row_id and b.pr_addr_id = g.row_id and sr_num = $ln); $get_case_text-execute($sr_num) || $dbh-errstr; ($sr_num ,$account_name ,$loc ,$sr_title , $uc_id ,$sr_stat_id ,$group_name ,$fst_name ,$last_name ,$email_addr ,$country,$Province ,$zipcode,$x_cp_created ,$x_cp_closed ,$login ,$desc_text) = $get_case_text-fetchrow_array(); $get_case_text-finish; print -- SR(bulk): $sr_num\n; print -- User Id(name): $uc_id\n; $line++; } close(DAT); $dbh-disconnect; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem reading a file and passing a variable
I am m using the following code to read from a .txt file. I am running into a problem that I am not sure why it is happening. The problem is when I run this script the SQL is not reading the variable. I am testing to make sure the .txt file contains data and it does. I get the following error: DBD::Oracle::st execute failed: called with 1 bind variables when 0 are needed at /data/verity/custom-kb/scripts/test.pl line 36, BULK line 1. DBD::Oracle::st execute failed: called with 1 bind variables when 0 are needed at /data/verity/custom-kb/scripts/test.pl line 36, BULK line 1. Issuing rollback() for database handle being DESTROY'd without explicit disconnect(), BULK line 1. LINE 36 where the error is occuring: sr_num = $ln); In the past when reading form an array fbuilt by a SQL statement I do it different. This is my first tiem trying to read form Files Any Ideas what I am doing wrong? Thank you in advance Lance #!/usr/local/bin/perl # # Purpose: To extract Daily Siebel (SecureTrak) cases # # Written by Lance #ENVIRONMENT VARIABLES $CUSTOM = /data/verity/custom-kb; $SERVICE= X.world; $oracle_user= XX; $oracle_password= X; $html_file_path = $CUSTOM/content/daily_securetrak_new; $bif_file_path = $CUSTOM/content/daily_securetrak; $bulk_load_filename = $CUSTOM/bif/daily_securetrak.bif; $template_filename = $CUSTOM/templates/daily_securetrak_main_build_template.html; $template_comm_filename = $CUSTOM/templates/daily_securetrak_comm_build_template.html; $daily_sr_file = $CUSTOM/scripts/unique_sr_list.txt; print Extract started at: . `date`; #open connection to the DB use DBI; $connect_string=DBI:Oracle:$SERVICE; my $dbh = DBI-connect($connect_string,$oracle_user,$oracle_password, { AutoCommit= 0, LongTruncOk= TRUE, PrintError = 1, ChopBlanks= TRUE,LongTruncOk= TRUE,LongReadLen= 5, RaiseError = 1 }) or die connecting: $DBI::errstr; #open file to read from open(BULK, $daily_sr_file) || die(Could not open file!); my $line = 1; while( my $ln = BULK ) { chomp($ln); #use the items of the my $get_case_text = $dbh-prepare(SELECT a.sr_num ,b.name ,b.loc ,a.sr_title,f.mid_name ,a.sr_stat_id ,e.name ,f.fst_name ,f.last_name ,f.email_addr ,g.country,g.Province ,g.zipcode,to_char(a.x_cp_created,'DD-MON-') ,to_char(a.x_cp_closed,'DD-MON-') ,c.login ,a.desc_text FROM s_srv_req a,s_org_ext b,s_employee c,s_postn d,s_org_int e,s_contact f,s_addr_org g WHERE a.cst_ou_id = b.row_id and a.cst_con_id = f.row_id and a.owner_emp_id = c.row_id and c.pr_postn_id = d.row_id and d.ou_id = e.row_id and b.pr_addr_id = g.row_id and sr_num = $ln); $get_case_text-execute($sr_num) || $dbh-errstr; ($sr_num ,$account_name ,$loc ,$sr_title , $uc_id ,$sr_stat_id ,$group_name ,$fst_name ,$last_name ,$email_addr ,$country,$Province ,$zipcode,$x_cp_created ,$x_cp_closed ,$login ,$desc_text) = $get_case_text-fetchrow_array(); $get_case_text-finish; print -- SR(bulk): $sr_num\n; print -- User Id(name): $uc_id\n; $line++; } close(DAT); $dbh-disconnect; -- 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: Problem reading a file and passing a variable
on Wed, 29 May 2002 20:13:13 GMT, Lance Prais wrote: There is no need to post your message three times in less than 10 minutes. while( my $ln = BULK ) { chomp($ln); #use the items of the my $get_case_text = $dbh-prepare(SELECT a.sr_num ,b.name ,b.loc ,a.sr_title,f.mid_name ,a.sr_stat_id ,e.name ,f.fst_name ,f.last_name ,f.email_addr ,g.country,g.Province ,g.zipcode,to_char(a.x_cp_created,'DD-MON-') ,to_char(a.x_cp_closed,'DD-MON-') ,c.login ,a.desc_text FROM s_srv_req a,s_org_ext b,s_employee c,s_postn d,s_org_int e,s_contact f,s_addr_org g WHERE a.cst_ou_id = b.row_id and a.cst_con_id = f.row_id and a.owner_emp_id = c.row_id and c.pr_postn_id = d.row_id and d.ou_id = e.row_id and b.pr_addr_id = g.row_id and sr_num = $ln); $get_case_text-execute($sr_num) || $dbh-errstr; ($sr_num ,$account_name ,$loc ,$sr_title , $uc_id ,$sr_stat_id ,$group_name ,$fst_name ,$last_name ,$email_addr ,$country,$Province ,$zipcode,$x_cp_created ,$x_cp_closed ,$login ,$desc_text) = $get_case_text-fetchrow_array(); $get_case_text-finish; print -- SR(bulk): $sr_num\n; print -- User Id(name): $uc_id\n; $line++; } close(DAT); $dbh-disconnect; 1) move the prepare out and in front of the while-loop 2) replace, in the SQL statement, the 'sr_num = $ln' at the end with sr_num = ? 3) call the execute statement as follows $get_case_text-execute($ln); -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help handling text files.
Josh wrote at Wed, 29 May 2002 23:56:48 +0200: Ok Heres the deal :) I have a script to write to a dat file and the basic output in the dat file is username:plan: so an example would be computer:50: meaning the username computer has 50 hours of paid dialup access. Now Lets say computer calls and wishes to upgrade his account to 100 hours, i need to figure out how to script it so that it replaces the number with the new one..know what i mean? my $user = computer; my $upgrade = 100; open DAT, your_file.dat or die Cant open ...; my @dat = (DAT); close DAT; open DAT, your_file.dat or die Cant open ...; while (@dat) { print DAT /^$user/ ? $user:$upgrade:\n : $_; } close DAT; Is it what you need ?! Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem reading a file and passing a variable
On Wed, 2002-05-29 at 16:13, Lance Prais wrote: I am m using the following code to read from a .txt file. I am running into a problem that I am not sure why it is happening. The problem is when I run this script the SQL is not reading the variable. I am testing to make sure the .txt file contains data and it does. I get the following error: DBD::Oracle::st execute failed: called with 1 bind variables when 0 are needed at /data/verity/custom-kb/scripts/test.pl line 36, BULK line 1. DBD::Oracle::st execute failed: called with 1 bind variables when 0 are needed at /data/verity/custom-kb/scripts/test.pl line 36, BULK line 1. Issuing rollback() for database handle being DESTROY'd without explicit disconnect(), BULK line 1. LINE 36 where the error is occuring: sr_num = $ln); In the past when reading form an array fbuilt by a SQL statement I do it different. This is my first tiem trying to read form Files Any Ideas what I am doing wrong? Thank you in advance Lance Besides failing to use whitespace? You used string interpolation when you built the query instead of using variable binding. Both are valid methods -- when used separately. I prefer binding since there aren't any quote problems that way. I can understand why you couldn't see it; your code was horrifyingly unindented. Below is your script with decent indenting and a few minor idiomatic changes. N.B. if you version perl is old you may have to change the ours to mys. #!/usr/local/bin/perl # # Purpose: To extract Daily Siebel (SecureTrak) cases # # Written by Lance use strict; #ALWAYS USE STRICT use DBI; #ENVIRONMENT VARIABLES our $CUSTOM = /data/verity/custom-kb; our $SERVICE= X.world; our $oracle_user= XX; our $oracle_password= X; our $html_file_path = $CUSTOM/content/daily_securetrak_new; our $bif_file_path = $CUSTOM/content/daily_securetrak; our $bulk_load_filename = $CUSTOM/bif/daily_securetrak.bif; our $template_filename = $CUSTOM/templates/daily_securetrak_main_build_template.html; our $template_comm_filename = $CUSTOM/templates/daily_securetrak_comm_build_template.html; our $daily_sr_file = $CUSTOM/scripts/unique_sr_list.txt; print Extract started at: . `date`; #open connection to the DB #why use FALSE/TRUE sometimes and 0/1 others? #be consistent my $dbh = DBI-connect( DBI:Oracle:$SERVICE, $oracle_user, $oracle_password, { AutoCommit = 0, LongTruncOk = TRUE, PrintError = TRUE, ChopBlanks = TRUE, LongTruncOk = TRUE, LongReadLen = 5, RaiseError = TRUE } ) or die connecting: $DBI::errstr; #open file to read from #use $! here to tell you why #also use of or allows you to ditch the parens open BULK, $daily_sr_file or die Could not open file:$!; my $line = 1; while( my $ln = BULK ) { chomp($ln); #what in the world is this comment? #use the items of the #NOTE: all columns are named my $get_case_text = $dbh-prepare( SELECT a.sr_num sr_num, b.name account_name, b.loc loc, a.sr_title sr_title, f.mid_name uc_id, a.sr_stat_id sr_stst_id, e.name group_name, f.fst_name fst_name, f.last_namelast_name, f.email_addr email_addr, g.country country, g.Province Province, g.zipcode zipcode, to_char( a.x_cp_created,'DD-MON-' ) x_cp_created, to_char( a.x_cp_closed,'DD-MON-' ) x_cp_closed, c.loginlogin, a.desc_textdesc_text FROM s_srv_req a, s_org_ext b, s_employee c, s_postnd, s_org_int e, s_contact f, s_addr_org g WHERE a.cst_ou_id= b.row_id AND a.cst_con_id = f.row_id AND a.owner_emp_id = c.row_id AND c.pr_postn_id = d.row_id AND d.ou_id= e.row_id AND b.pr_addr_id = g.row_id AND sr_num = ? ); #just above is the problem should be a ? instead of
Re: what does a diff return?
Jose Torres wrote at Wed, 29 May 2002 20:30:06 +0200: Hi, If I'm calling the diff program from within a Perl script with something like: system(diff file1.txt file2.txt); how can I detect if there is a result or not, since if the files are identical, diff doesn't have any output? I need to be able to be able to determine if there was any output from within my script so that I can take one particular action if diff returned something (the files were different) or take another if diff didn't return anything (the files were identical). Thanks for all help with this. When using the system command, it's most better to seperate the arguments from the command. Why ? So all shell quoting are done for you. Assume one file comes from the win - world with spaces including or so. Why not ? It doesn't make any effort. So you script should change to: if (system('diff', $file1, $file2)) { # different } else { # same } Cheerio, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Problem reading a file and passing a variable
On Wed, 2002-05-29 at 17:05, Lance Prais wrote: [Chas], Thank you, you made me realize the value of indention like never before. In the past I used the =? to return results form the query but in this case when I used in and run this script it does not error out but instead the query returns no values? Could that be because there are leading or trailing spaces. My understanding is that the Chomp would take care of that. Am I wrong in my assumption? Thanks again Lance The chomp function removes the trailing newline character (actually it removes whatever is in $/ variable, but that is usually \n so it doesn't really matter). In this case $ln looks like a number so you could say $ln += 0; which would force $ln to contain a number instead of a string (thus getting rid of spaces). If spaces are not the problem then try running the query by hand in sql*plus (or toad if you have it) to make sure it is not a problem with the query. -- Today is Prickle-Prickle the 3rd day of Confusion in the YOLD 3168 This statement is false. Missile Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: converting a hash to an array
Felix Geerinckx wrote at Wed, 29 May 2002 17:17:38 +0200: on Wed, 29 May 2002 16:10:40 GMT, [EMAIL PROTECTED] (Janek Schleicher) wrote: Oops, there's a typo :-(( Of course, I meant @sorted = reverse sort { $myhash{$a} = $myhash{b} } keys %myhash; There's another typo. Year, I must have been drunken :-( And I'd rather add # sort keys in descending numerical order than suffering a substantial speed penalty by using 'reverse'. Allthough, I can't get familiar with the exchanging of $a and $b. When I try to read a source code, I see sort { ${} = ${} } ... and I expect that the sort routine goes normal. I checked now for the first time, how much time an extra reverse cost. I had always expected that the compiler does a code optimization for itself, when he sees reverse sort { ... }, there shouldn't be a problem to interprete it. as sort { -(...) }. However perl does not. But the last syntax is as quick as the normal sort routine: use Benchmark; my @list = (); push @list, rand() while ($i++ 500_000); timethis( 100, sub {sort {$a = $b} @list} ); timethis( 100, sub {sort {-($a = $b)} @list} ); prints: timethis 100: 2 wallclock secs ( 2.84 usr + 0.01 sys = 2.85 CPU) @ 35.09/s (n=100) timethis 100: 3 wallclock secs ( 2.85 usr + 0.00 sys = 2.85 CPU) @ 35.09/s (n=100) So I decided for myself, to write reverse sort { ... } when it's not time critical and the lists are small and to write sort { -(...) } when it's time critical. (I like it more than writing a command - the program has to be self explaining) Thanks a lot to Felix for his hint. Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: elements 2 thru end of the results of a split
@myarray = split ' ', $fContent[$i]; Is this special form of split documented somewhere? Does it still split on all whitespace? My problem is that the string I'm splitting may or may not have leading whitespace... TIA. - B __ Bryan R Harris wrote: Is it possible to return elements 2 (index 1) thru end of the results of a split? @myarray = (split(/\s+/,$fContent[$i]))[1..-1]; seems right, but doesn't work... If you are doing this because split/\s+/ returns an empty element in $myarray[0] you should use the special form of split @myarray = split ' ', $fContent[$i]; John -- use Perl; program fulfillment -- 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]
variable initialization
I stumbled across a bug in my own code I figured I'd share... Actually, I'm wondering if there is a way to do this I was using the following code : my ($var1, $var2) = 0; The intent was to initialize the variables to 0. However, as I found out a few minutes ago, this only initializes the first variable in the list to 0 and leaves the others as undefined... Is there an easy way to do this? I know I can do them this way : my ($var1, $var2) = (0,0); or my $var1 = 0; my $var2 = 0; But I was looking for something similar to what I was doing... Oh well, you live, you learn... :-) --- Jason H. Frisvold Senior ATM Engineer Engineering Dept. Penteledata CCNA Certified - CSCO10151622 [EMAIL PROTECTED] --- I love deadlines. I especially like the whooshing sound they make as they go flying by. -- Douglas Adams [1952-2001]
Re: variable initialization
On May 29, Jason Frisvold said: my ($var1, $var2) = 0; The intent was to initialize the variables to 0. However, as I found out a few minutes ago, this only initializes the first variable in the list to 0 and leaves the others as undefined... Is there an easy way to do this? I know I can do them this way : Well, you could always do something like my ($x, $y, $z) = (0) x 3; -- 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]
RE: Problem reading a file and passing a variable
Thank you.I scaled down the SQL and tested it in SQL (records returned) and then in the script(no records returned). This is bizarre to me. Actually it it is a string with the values being for example 1-9 Does perl default to a string? If I put or '' around the? Like so '?' Or ?, I get an error message therefore I know I am not going down the write path. Could it have something to do with permissions? I have them set for execute. Thanks Lance -Original Message- From: Chas Owens [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 4:11 PM To: Lance Prais Cc: Perl Subject: RE: Problem reading a file and passing a variable On Wed, 2002-05-29 at 17:05, Lance Prais wrote: [Chas], Thank you, you made me realize the value of indention like never before. In the past I used the =? to return results form the query but in this case when I used in and run this script it does not error out but instead the query returns no values? Could that be because there are leading or trailing spaces. My understanding is that the Chomp would take care of that. Am I wrong in my assumption? Thanks again Lance The chomp function removes the trailing newline character (actually it removes whatever is in $/ variable, but that is usually \n so it doesn't really matter). In this case $ln looks like a number so you could say $ln += 0; which would force $ln to contain a number instead of a string (thus getting rid of spaces). If spaces are not the problem then try running the query by hand in sql*plus (or toad if you have it) to make sure it is not a problem with the query. -- Today is Prickle-Prickle the 3rd day of Confusion in the YOLD 3168 This statement is false. Missile Address: 33:48:3.521N 84:23:34.786W -- 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: Problem reading a file and passing a variable
On Wed, 2002-05-29 at 18:35, Lance Prais wrote: Thank you.I scaled down the SQL and tested it in SQL (records returned) and then in the script(no records returned). This is bizarre to me. Actually it it is a string with the values being for example 1-9 Do yo mean $ln contains the value 1-9? The following will strip spaces from a string: $ln =~ s/ //g; If it worked before you may want to eschew using the binding feature and just plop $ln directly into the query (just make certain to call execute with no parameters). Does perl default to a string? If I put or '' around the? Like so '?' Or ?, I get an error message therefore I know I am not going down the write path. Could it have something to do with permissions? I have them set for execute. Thanks Lance -Original Message- From: Chas Owens [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 29, 2002 4:11 PM To: Lance Prais Cc: Perl Subject: RE: Problem reading a file and passing a variable On Wed, 2002-05-29 at 17:05, Lance Prais wrote: [Chas], Thank you, you made me realize the value of indention like never before. In the past I used the =? to return results form the query but in this case when I used in and run this script it does not error out but instead the query returns no values? Could that be because there are leading or trailing spaces. My understanding is that the Chomp would take care of that. Am I wrong in my assumption? Thanks again Lance The chomp function removes the trailing newline character (actually it removes whatever is in $/ variable, but that is usually \n so it doesn't really matter). In this case $ln looks like a number so you could say $ln += 0; which would force $ln to contain a number instead of a string (thus getting rid of spaces). If spaces are not the problem then try running the query by hand in sql*plus (or toad if you have it) to make sure it is not a problem with the query. -- Today is Prickle-Prickle the 3rd day of Confusion in the YOLD 3168 This statement is false. Missile Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Today is Prickle-Prickle the 3rd day of Confusion in the YOLD 3168 You are what you see. Missile Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: elements 2 thru end of the results of a split
Bryan R Harris wrote: @myarray = split ' ', $fContent[$i]; Is this special form of split documented somewhere? Does it still split on all whitespace? perldoc -f split [snip] As a special case, specifying a PATTERN of space (`' '') will split on white space just as `split' with no arguments does. Thus, `split(' ')' can be used to emulate awk's default behavior, whereas `split(/ /)' will give you as many null initial fields as there are leading spaces. A `split' on `/\s+/' is like a `split(' ')' except that any leading whitespace produces a null first field. A `split' with no arguments really does a `split(' ', $_)' internally. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: variable initialization
Jason Frisvold wrote: I stumbled across a bug in my own code I figured I'd share... Actually, I'm wondering if there is a way to do this I was using the following code : my ($var1, $var2) = 0; The intent was to initialize the variables to 0. However, as I found out a few minutes ago, this only initializes the first variable in the list to 0 and leaves the others as undefined... Is there an easy way to do this? I know I can do them this way : my ($var1, $var2) = (0,0); or my $var1 = 0; my $var2 = 0; But I was looking for something similar to what I was doing... my $var1 = my $var2 = 0; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: install crypt::passgen
Hi - Are you, by chance, running Windows? If you use the ppm3 command: ppm describe crypt-passgen you will note that this module is available for Solaris and Linux only. Aloha = Beau. -Original Message- From: Postman Pat [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 28, 2002 8:02 PM To: [EMAIL PROTECTED] Subject: install crypt::passgen Greetings, I am having a problem with ActiveState ActivePerl 5.6.1. I am tryin to install the abovementioned lib I get the following error from PPM version 3 beta 3 ppm search crypt::passgen Searching in repository 2 (ActiveState Package Repository) 1. Crypt-PassGen [0.02] ppm install crypt::passgen Error: no suitable installation target found for package Crypt-PassGen. ppm PLease help Ciao -- 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: elements 2 thru end of the results of a split
Thanks, John. __ Bryan R Harris wrote: @myarray = split ' ', $fContent[$i]; Is this special form of split documented somewhere? Does it still split on all whitespace? perldoc -f split [snip] As a special case, specifying a PATTERN of space (`' '') will split on white space just as `split' with no arguments does. Thus, `split(' ')' can be used to emulate awk's default behavior, whereas `split(/ /)' will give you as many null initial fields as there are leading spaces. A `split' on `/\s+/' is like a `split(' ')' except that any leading whitespace produces a null first field. A `split' with no arguments really does a `split(' ', $_)' internally. John -- use Perl; program fulfillment -- 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]