Form mail with preview?
Hi there, I was wondering whether anyone could point me in the direction of a formmail script that has an option to preview before posting the form data. The preview would be a web page showing the data without the form fields so it can be printed out. Much thanx in advance Phil S -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Form-mail blues
You should really separate the header printing process from the HTML printing process. The first thing you want to do is tell the browser that HTML is coming, -then- write the HTML. A couple different ways of accomplishing this: use CGI; $q = new CGI; print $q-header; or print Content-type: text/html\n\n; The first option is the preferred method, as you can easily add more arguments to the header block. Do a 'perldoc CGI' for the documentation. If you decide to use the second method because it seems easier to you for one reason or another, make sure that you get the case, punctuation, and spacing correct. - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] -Original Message- From: Ramon Hildreth [mailto:ramon;ramonred.net] Sent: Saturday, November 02, 2002 2:49 PM To: [EMAIL PROTECTED] Subject: Form-mail blues Hi, I don't have access to the error logs on my hosting account, and I am trying to troubleshoot formail script. It runs okay from the commandline. It also sends the info collected in the form correctly to the email address I have specified. It also gives internal server error. I am guessing that this part of the script is making the trouble, but I don't know what it could be. - Use CGI qw(:standard); -- #show thank you screen print header EOF; HTML HEAD TITLEThank You/TITLE /HEAD BODY H1Thank You for your submission/H1 preturn to a href=http://www.subudusa.org/concept.html;Subud Enterprises Services/a./p /BODY /HTML EOF --- TIA. Ramon Hildreth --- [ www.subudusa.org ] [www.subudseattle.org [ www.ramonred.net ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Translators
Are we talking programming languages like C to Perl? Or spoken languages like Spanish to Italian? if you're talking about localization I know there are lots of modules and tools to help you out... you might look here: http://cpan.org/modules/by-category/13_Internationalization_Locale/Locale/ maketext sounds like a good starting point. gnu gettext is another popular way to internationalize perl scripts (or any software, I suppose) http://www.gnu.org/manual/gettext/index.html Of course, with both of these, I think you'll still have to do most of the translation yourself. Does anybody have experience with either of these? Are there other freeware products that handle translation memories and things like that? I know the TMX project sounds pretty cool in that it allows you to reuse translations, etc. http://www.lisa.org/tmx/ of course, I don't actually know how it works... Anyway, I hope this helps! -Peter -Original Message- From: Octavian Rasnita [mailto:[EMAIL PROTECTED]] Sent: Saturday, November 02, 2002 11:17 AM To: [EMAIL PROTECTED] Subject: Translators Hi all, Does anyone know if there are perl modules that can translate from a language into another? Or free perl programs? I don't need a proffessional one but just an example. Thanks. Teddy Teddy's Center: teddy.fcc.ro Email: [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: How to check server for perl setup?
I tend to agree with zentara...Are you able to run simple perl scripts from the command line? If so then your perl install is okay... Can you run simple CGI scripts? When i first start using a new server I always run a quick: #!/usr/bin/perl print Content-type: text/html\n\n; print Howdy y'all!; (yes, you could do this on one line but this seems easier for me to read...) If it runs at all then that usually means my Apache config is okay and ready to go (which usually isn't the case ;-) If it gives me a premature end of script headers message, then it usually means that perl is not where I thought it was...in which case I'll telnet (or SSH) into the box and run a which perl as zentara recommends. (I assume you've got telnet or ssh access since it sounds like this is your own box) If my shebang line (#!) is okay, then I check to make sure that I've changed the permissons on the script to be executable by others (chmod o+x scriptname.pl) If that doesn't work, I go out for coffee. Lastly, do your trusty old perl scripts use any non-standard modules? Have you installed those on your new box? Are they in your perl lib directory where perl expects to find them? One good way to test this is to try running the script from the command line. If it's having package problems it should let you know and tell you where it's looking for stuff... Good luck! -Peter -Original Message- From: zentara [mailto:zentara;highstream.net] Sent: Saturday, November 02, 2002 5:57 AM To: [EMAIL PROTECTED] Subject: Re: How to check server for perl setup? On Sat, 2 Nov 2002 06:21:43 -0500, [EMAIL PROTECTED] (Dan Sabo) wrote: Hi, Is there a way I can check my server to see if my perl setup and configuration is running OK and ready to run cgi scripts? I've run pre written perl cgi scripts for a few years on a shared server but recently set up my own server and for some reason I can't seem to get my long used cgi script running. I think my path settings are correct in my config files for the script - /usr/bin/perl, but how can I check to see if perl is actually ready to go on my server and being accessed by the cgi scripts OK? I use Linux 7.3, apache 1.3.23 and perl 5.6.1 If you are switching scripts from another server, a likely culprit is your directories have changed. Like they used to be in /var/www/httpd/cgi-bin and now they are in /usr/local/httpd/cgi-bin. ( Or something similar). Your best bet is to put in a simple cgi test script on the server and see if it runs. If it dos'nt, you probably need to work on your httpd.conf file to enable cgi execution in your cgi-bin. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: hard coded
looks to me like you are trying to read the voblist from clearcase? or is it the labels that is in that VOB? why have you placed them in a text file? why not read em out from the system directly? if you want to read the label names you can just run it like this my $vob = vobname @labels = `cleartool lstype -s -kind lbtype -invob $vob` or die cant run lstype; foreach $label (@labels){ print $label\n; } regards David / ClearCase Admin -Original Message- From: Javeed SAR [mailto:SAR.Javeed;sisl.co.in] Sent: den 4 november 2002 06:12 To: [EMAIL PROTECTED] Subject: hard coded Hi all, i am reading certain label names from textfile stored in a particular machine. I am working on WIN2k. For eg here i have kept it in machine blrk35ed. This becomes hard coded, is there any other way to read label names, because i dont' want to hard coded in my script. open(FILE,BLRK35ED\\LABEL\\comepr_voblist.txt); @str = FILE; close(FILE); foreach (@str){ $out=`cleartool mount $_`; Regards j@veed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
PDF to PS
Hi, all Do someone knows about a perl module to convert PDF files to postscript ? I'm working on several UNIX (AIX) boxes and want to 'automagically' print PDF files. Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: hard coded
No I have kept the vob names? I don't need all the vobs. i.e the reason i am reading from file. Regards j@veed -Original Message- From: David Samuelsson (PAC) [mailto:David.Samuelsson;pac.ericsson.se] Sent: Monday, November 04, 2002 1:29 PM To: Javeed SAR; [EMAIL PROTECTED] Subject: RE: hard coded looks to me like you are trying to read the voblist from clearcase? or is it the labels that is in that VOB? why have you placed them in a text file? why not read em out from the system directly? if you want to read the label names you can just run it like this my $vob = vobname @labels = `cleartool lstype -s -kind lbtype -invob $vob` or die cant run lstype; foreach $label (@labels){ print $label\n; } regards David / ClearCase Admin -Original Message- From: Javeed SAR [mailto:SAR.Javeed;sisl.co.in] Sent: den 4 november 2002 06:12 To: [EMAIL PROTECTED] Subject: hard coded Hi all, i am reading certain label names from textfile stored in a particular machine. I am working on WIN2k. For eg here i have kept it in machine blrk35ed. This becomes hard coded, is there any other way to read label names, because i dont' want to hard coded in my script. open(FILE,BLRK35ED\\LABEL\\comepr_voblist.txt); @str = FILE; close(FILE); foreach (@str){ $out=`cleartool mount $_`; Regards j@veed
The basics of SWITCH
Hi, I have a problem with SWITCH. I wrote this, I think it's clear to anzone what it should do: print Type in a number 1-5: ; $s = STDIN; SWITCH; { if ($s == 1) { print one\n; last SWITCH; } if ($s == 2) { print two\n; last SWITCH; } if ($s == 3) { print three\n; last SWITCH; } if ($s == 4) { print four\n; last SWITCH; } if ($s == 5) { print five\n; last SWITCH; } } And I get an error message saying Label not found for last SWITCH at line 11. STDIN chunk 1. (with line 11 being the first line of the chunk) So what's wrong? Also, how can I do something like in bash, where I have options 1), 2)... and also *). That is, how can I do that *) thing? :) Thanks, Csaba -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: The basics of SWITCH
if i am going to do something like this i would have done: use strict; my ($answer); #create menu print \n\n\t\t\tinstall menu\n\n; print \t\t\tChoose one of the following options..\n; print \t\t\t1. Install/reinstall xxx.\n; print \t\t\t2. Install/reinstall xxx.\n; print \t\t\t3. Uninstal xxx.\n; print \t\t\tpress 1 to 3 to select. Finish with enter\n; while (defined($answer = STDIN)) { chomp $answer; if ($answer eq 1) { do blah } if ($answer eq 2) { etc.. else { print ERROR: Must submit choice between 1 to 3.\n; die; } //Dave -Original Message- From: Gajo Csaba [mailto:[EMAIL PROTECTED]] Sent: den 4 november 2002 15:18 To: perl-beginners Subject: The basics of SWITCH Hi, I have a problem with SWITCH. I wrote this, I think it's clear to anzone what it should do: print Type in a number 1-5: ; $s = STDIN; SWITCH; { if ($s == 1) { print one\n; last SWITCH; } if ($s == 2) { print two\n; last SWITCH; } if ($s == 3) { print three\n; last SWITCH; } if ($s == 4) { print four\n; last SWITCH; } if ($s == 5) { print five\n; last SWITCH; } } And I get an error message saying Label not found for last SWITCH at line 11. STDIN chunk 1. (with line 11 being the first line of the chunk) So what's wrong? Also, how can I do something like in bash, where I have options 1), 2)... and also *). That is, how can I do that *) thing? :) Thanks, Csaba -- 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: The basics of SWITCH
-Original Message- From: Gajo Csaba [mailto:[EMAIL PROTECTED]] Sent: Monday, November 04, 2002 9:18 AM To: perl-beginners Subject: The basics of SWITCH Hi, I have a problem with SWITCH. I wrote this, I think it's clear to anzone what it should do: print Type in a number 1-5: ; $s = STDIN; SWITCH; Your label needs a colon, not a semicolon SWITCH: { if ($s == 1) { print one\n; last SWITCH; } if ($s == 2) { print two\n; last SWITCH; } if ($s == 3) { print three\n; last SWITCH; } if ($s == 4) { print four\n; last SWITCH; } if ($s == 5) { print five\n; last SWITCH; } } And I get an error message saying Label not found for last SWITCH at line 11. STDIN chunk 1. (with line 11 being the first line of the chunk) So what's wrong? Also, how can I do something like in bash, where I have options 1), 2)... and also *). That is, how can I do that *) thing? :) Just put your default case before the closing brace: ... if ($s == 5) { print five\n; last SWITCH; } print Default case; # if no previous match } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: The basics of SWITCH
Hi, when you get $s from STDIN, it comes along with a newline, so try something like: chomp($s = STDIN); A+ Gajo Csaba a écrit : Hi, I have a problem with SWITCH. I wrote this, I think it's clear to anzone what it should do: print Type in a number 1-5: ; $s = STDIN; SWITCH; { if ($s == 1) { print one\n; last SWITCH; } if ($s == 2) { print two\n; last SWITCH; } if ($s == 3) { print three\n; last SWITCH; } if ($s == 4) { print four\n; last SWITCH; } if ($s == 5) { print five\n; last SWITCH; } } And I get an error message saying Label not found for last SWITCH at line 11. STDIN chunk 1. (with line 11 being the first line of the chunk) So what's wrong? Also, how can I do something like in bash, where I have options 1), 2)... and also *). That is, how can I do that *) thing? :) Thanks, Csaba -- 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: hi,everyone,help me
-Original Message- From: alex chen [mailto:cg;gddc.com.cn] Sent: Sunday, November 03, 2002 6:05 AM To: [EMAIL PROTECTED] Subject: hi,everyone,help me hi,all! today,i have write such a program #!usr/local/bin/perl5.6.1 #middle machine version 1.0 use IO::Socket; $SIG{CHLD} = sub {wait()}; $main_sock = new IO::Socket::INET(LocalHost ='192.168.1.2', LocalPort = 34561, Listen= 5, Proto = 'tcp', Reuse = 1, ); die main Socket could not be created.Reason: $!\n unless ($main_sock); while ($new_sock = $main_sock-accept()){ $pid = fork(); die Cannot fork : $! unless defined ($pid); if ($pid ==0){ while (defined ($buf = $new_sock)){ print $buf; send_message();} exit(0); } } close ($main_sock); sub send_message{ $send_sock = new IO::Socket::INET(PeerAddr ='192.168.1.3', PeerPort =34562, Proto='tcp' ); die Socket Could not be created.Reason:$!\n unless $send_sock; print $send_sock $buf; $send_sock -flush(); close ($send_sock); } the problem is the socket $send_sock could not establish with the host 192.168.1.3 while i run this program the hos 192.168.1.3 just a simple program to recieve the message from this program. how to resolve this problem,please help me ,thanks!!! :-) You bind the server socket $to 192.168.1.2, but your client attempts to connect to 192.168.1.3 Does the server have two interfaces or is 192.168.1.2 the client's IP? If the former, then change your client to connect to 1.2. If the latter, change your server to bind to 1.3 (or leave off LocalHost altogether, to bind to all interfaces). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: The basics of SWITCH
-Original Message- From: Jean Padilla [mailto:jean.padilla;ac-montpellier.fr] Sent: Monday, November 04, 2002 9:41 AM To: Gajo Csaba Cc: perl-beginners Subject: Re: The basics of SWITCH Hi, when you get $s from STDIN, it comes along with a newline, so try something like: chomp($s = STDIN); A+ True, but the newline doesn't affect the numeric comparison's he is using. So, 3\n == 3 is true. Gajo Csaba a écrit : Hi, I have a problem with SWITCH. I wrote this, I think it's clear to anzone what it should do: print Type in a number 1-5: ; $s = STDIN; SWITCH; { if ($s == 1) { print one\n; last SWITCH; } if ($s == 2) { print two\n; last SWITCH; } if ($s == 3) { print three\n; last SWITCH; } if ($s == 4) { print four\n; last SWITCH; } if ($s == 5) { print five\n; last SWITCH; } } And I get an error message saying Label not found for last SWITCH at line 11. STDIN chunk 1. (with line 11 being the first line of the chunk) So what's wrong? Also, how can I do something like in bash, where I have options 1), 2)... and also *). That is, how can I do that *) thing? :) Thanks, Csaba -- 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 names
Hi all Is it possible to use the string value of a variable to create a new hash i.e. My $name = fred; Can I use $name to create a hash called fred? Thanks Brian BBCi at http://www.bbc.co.uk/ This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated. If you have received it in error, please delete it from your system, do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately. Please note that the BBC monitors e-mails sent or received. Further communication will signify your consent to this.
Re: The basics of SWITCH
Try this: SWITCH: { $s == 1 do {print one\n; last SWITCH;}; $s == 2 do {print two\n; last SWITCH;}; $s == 3 do {print three\n; last SWITCH;}; $s == 4 do {print four\n; last SWITCH;}; $s == 5 do {print five\n; last SWITCH;}; print No match found.\n; } You need a colon, not a semicolon, after SWITCH. The logical and serves very well in place of a string of if statements. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: The basics of SWITCH
Hello Gajo, A different approach to your problem is to use a data structure, e.g. an array or hash. Your script rewritten using an array, #!/usr/bin/perl -w my @option = (one,two,three,four,five,six,maybe seven?); print Type in a number 1-, $#option+1, : ; $s = STDIN; chomp $s ; if ( $s =~ /\d+/ and defined $option[$s-1] ) { print $option[$s-1]\n; } else { print not between 1-5\n; } Notice that it is quite easy to add, remove, or change items by modifying @options. You don't have to write any new code. HTH, - Robert - At 03:18 PM 11/4/2002 +0100, Gajo Csaba wrote: print Type in a number 1-5: ; $s = STDIN; SWITCH; { if ($s == 1) { print one\n; last SWITCH; } if ($s == 2) { print two\n; last SWITCH; } if ($s == 3) { print three\n; last SWITCH; } if ($s == 4) { print four\n; last SWITCH; } if ($s == 5) { print five\n; last SWITCH; } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Variable names
From: Brian Ling [EMAIL PROTECTED] Is it possible to use the string value of a variable to create a new hash i.e. My $name = fred; Can I use $name to create a hash called fred? This is really a FAQ :-( Yes you can, but you don't want to. Please read Why it's stupid to `use a variable as a variable name' http://www.plover.com/~mjd/perl/varvarname.html Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Variable names
-Original Message- From: Brian Ling [mailto:brian.ling;bbc.co.uk] Sent: Monday, November 04, 2002 4:17 PM To: [EMAIL PROTECTED] Subject: Variable names Hi all Is it possible to use the string value of a variable to create a new hash i.e. My $name = fred; Can I use $name to create a hash called fred? Give a look to this advice from Jenda: = ARCHIVE From: Dario Greco [EMAIL PROTECTED] i must create an array and an hash and store them for each cycle of a while. i want name these variables @array1, @array2... and %hash1, %hash2... in which 1,2 etc are the number of cycle of the while. No you don't. Please read Why it's stupid to `use a variable as a variable name' http://www.plover.com/~mjd/perl/varvarname.html Jenda = ARCHIVE DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: The basics of SWITCH
Gajo Csaba writes: Hi, I have a problem with SWITCH. I wrote this, I think it's clear to anzone what it should do: Just out of curiousity I typed in 'perldoc SWITCH' and 'perldoc -f SWITCH' and found nothing. What is it? (the short answer is fine) Thanks, Kevin -- Kevin Pfeiffer International University Bremen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Split a file
Hello all, I am trying to take a file of variable length on a daily basis and divide it up into 4 equal parts for processing on each file. Does someone have an easy way to do this? The original file is just a series of numbers like.. 3233404936 3233404934 3233669122 3233557761 3233818369 3234343425 3233431553 3233455617 3233404932 3233435393 3233562369 3233554689 I've tried everything I know. Granted, that isn't very much. :-) Here is what I'm doing so far.. Thanks, Johnny Hall #!/bin/perl -w # Script for cloning Unix hosts weekly. # This is ran from cron on Saturdays at 9am # This will get Full savesets for all servers in the /root/backups/ux_serverlist file $SSID_LIST = /tmp/ux_clonelist; @CLONE_LIST = `cat /root/backups/ux_serverlist`; system rm $SSID_LIST; foreach $CLONE_HOST (@CLONE_LIST) { chomp $CLONE_HOST; system /usr/sbin/mminfo -q level=full,client=$CLONE_HOST -r 'ssid' -t 'one week ago' $SSID_LIST; } # Attempt to break the /tmp/ux_clonelist file into equal parts for multiple cloning streams $NUM_SSID = `cat '$SSID_LIST' | wc -l`; chomp $NUM_SSID; $NUM_CON_JOBS = 4; $SSID_PER_FILE = int(($NUM_SSID / $NUM_CON_JOBS) + 1); chomp $SSID_PER_FILE; $FILE_COUNT = 1; $CLONE_FILE_LIST = $SSID_LIST.$FILE_COUNT; @SSID_LIST_ARRAY = `cat $SSID_LIST`; system rm $CLONE_FILE_LIST; $SSID_COUNT = 0; $FILE_COUNT = 0; chomp $SSID_COUNT; open(FILE, $CLONE_FILE_LIST); while ($SSID_COUNT = $SSID_PER_FILE) { foreach $SSID (@SSID_LIST_ARRAY) { while ($SSID_COUNT = $SSID_PER_FILE) { open(FILE, $CLONE_FILE_LIST); chomp $SSID; print FILE $SSID \n; $SSID_COUNT = ($SSID_COUNT + 1); close FILE; } } $FILE_COUNT = ($FILE_COUNT + 1); $CLONE_FILE_LIST = $SSID_LIST.$FILE_COUNT; } # Now start cloning from the 4 files #system nsrclone -v -s catlmsxi02 -b 'UX Clone' -S -f $CLONELIST; #system rm $CLONELIST; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Data storage problem
Hi All I have a foreach (array) loop that is reading data in from config files and saving the parts I want into a hash, the value of the hash is overwritten by each pass through the loop, for some of the passes round the loop I need to save the contents of the hash ideally into an array of hashes. I don't know in advance how many time the loop will execute. How can I save the hashes? If I, push save_array, \%hash_data I obviously get a array referencing the same mem address for each loop, the value of which gets overwritten next time round. How do I do this in a way that works. I'm shore there is an easy way to do this, but I seem to have a problem working it out a present. Thanks Brian BBCi at http://www.bbc.co.uk/ This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated. If you have received it in error, please delete it from your system, do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately. Please note that the BBC monitors e-mails sent or received. Further communication will signify your consent to this.
RE: Perl x RedHat 8.0 x Apache 2.0.40
-Original Message- From: Josimar Nunes de Oliveira [mailto:jn_oliveira;estadao.com.br] Sent: Monday, November 04, 2002 11:31 AM To: [EMAIL PROTECTED] Subject: Perl x RedHat 8.0 x Apache 2.0.40 Hello everybody, Please, does someone know how to fix this problem? The server is RedHat 8.0 with Apache 2.0.40. The same test was made on IIS 5.0 and no problem happened. Thanks in advance, Josimar /browserscreen Server error! The server encountered an internal error and was unable to complete your request. Error message: Premature end of script headers: teste.pl If you think this is a server error, please contact the webmaster Error 500 192.168.1.8 Mon 04 Nov 2002 05:02:05 AM GMT-3 Apache/2.0.40 (Red Hat Linux) Error 500 is a catch-all for a malformed response. Always go look at the web server's error log for more detailed error messages. /browsescreen code #!/usr/bin/perl print EOHTML; HTTP/1.0 200 OK\n Don't send the response code. The server takes care of that. Removing this line should clear up the problem. Content-type: text/html\n\n html headtitleTest/title/headbody test /body/html EOHTML /code -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Split a file
One way would be to print each line to a different file and loop through the input file: open(INFILE,my.log) || die Couldn't open my.log!\n; open(FILE1,file1) || die Couldn't open file1!\n; open(FILE2,file2) || die Couldn't open file2!\n; open(FILE3,file3) || die Couldn't open file3!\n; open(FILE4,file4) || die Couldn't open file4!\n; my $count = 1; while(INFILE){ print FILE1 $_; $_ = INFILE || last; print FILE2 $_; $_ = INFILE || last; print FILE3 $_; $_ = INFILE || last; print FILE4 $_; } Another alternative would be to use sysread to break up the file into equal parts, but it would be difficult to break it up by lines. I'm not the expert at sysread, or I'd give you an example. -Original Message- From: Johnny Hall To: PERL Beginners Sent: 11/4/02 9:31 AM Subject: Split a file Hello all, I am trying to take a file of variable length on a daily basis and divide it up into 4 equal parts for processing on each file. Does someone have an easy way to do this? The original file is just a series of numbers like.. 3233404936 3233404934 3233669122 3233557761 3233818369 3234343425 3233431553 3233455617 3233404932 3233435393 3233562369 3233554689 . I've tried everything I know. Granted, that isn't very much. :-) Here is what I'm doing so far.. Thanks, Johnny Hall clone_ux.pl.dev ATT52016.txt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
V Unpretty code
There's always another way to do it, right? I have a piece of code that does repeated searches through an input string and modifies it according to certain criteria. What I have works great, but I'd like to know how to write it better/more efficiently. Given that I'm going over the same record until I get a hit (or not), how would I re-write the following so that it's not a series of if if...if...if? if (/^\s[eE|aA]\d\d\d\d\d\D/){s/A/W95/;$w95++;print DFILE;next;}; # (E or A + n) = Windows95 if (/^\s[a-zA-Z]{5}dfs\d\d\d+/){s/A/W2K-S/;$w2ks++;print DFILE;next;}; # W2K Server if (/^\s[a-zA-Z]{3}salnm+/){s/A/W2K-S/;$w2ks++;print DFILE;next;}; # W2K Server if (/^\s[a-zA-Z]{3}scadc+/){s/A/W2K-DC/;$dc++;print DFILE;next;}; # w2k Domain Controller if (/^\s\w\w\wnfris\d\d\d/){s/A/Snap/;$snaps++;print DFILE;next;}; # Quantum Snap server if (/^\susu/){s/A/Non-MS/;$switch++;print DFILE;next;}; # Switch if (/^\sus/){s/A/Non-MS/;$legacy++;print DFILE;next;}; # Legacy device (Print Server, etc) if (/^\ssap/){s/A/Non-MS/;$legacy++;print DFILE;next;}; # SAP Host if (/^\srib/){s/A/Non-MS/;$legacy++;print DFILE;next;}; # SNMP Host if (/^\s\wdcs+/){s/A/DCD/;$legacy++;print DFILE;next;};# Data Center Device if (/^\s[a-zA-Z]{3}de\d\d\d\d\d/){s/A/W2K/;$w2k++;$good++;print DFILE;next;};# w2k desktop - obeying convention if (/^\s[a-zA-Z]{3}le\d\d\d\d\d/){s/A/W2K/;$w2k++;$good++;print DFILE;next;};# w2k laptop - obeying convention if (/^\s[a-zA-Z]{3}d\d{1,6}/){s/A/W2K/;$w2k++;print DFILE;next;}; # w2k desktop - Pre-Nextwave if (/^\s[a-zA-Z]{3}l\d{1,6}/){s/A/W2K/;$w2k++;print DFILE;next;}; # w2k laptop - Pre-Nextwave if (/^\s[a-zA-Z]{3}l+/){s/A/W2K?/;$w2k++;print DFILE;next;}; # w2k laptop - probable. if (/^\s[a-zA-Z]{3}d+/){s/A/W2K?/;$w2k++;print DFILE;next;}; # w2k desktop - probable. {s/A/?/;} # Anything left over is interesting. Flag it for follow-up with a ?. Thanks. Pat. Wisdom for husbands: You can be right. You can be happy. Pick One.
Re: V Unpretty code
In article 00e201c28426$051681e0$[EMAIL PROTECTED], [EMAIL PROTECTED] (Patrick Salmon) writes: I have a piece of code that does repeated searches through an input = string and modifies it according to certain criteria. What I have works = great, but I'd like to know how to write it better/more efficiently.=20 Given that I'm going over the same record until I get a hit (or not), = how would I re-write the following so that it's not a series of if = if...if...if? if (/^\s[eE|aA]\d\d\d\d\d\D/){s/A/W95/;$w95++;print DFILE;next;}; # = (E or A + n) =3D Windows95 if (/^\s[a-zA-Z]{5}dfs\d\d\d+/){s/A/W2K-S/;$w2ks++;print = DFILE;next;}; # W2K Server if (/^\s[a-zA-Z]{3}salnm+/){s/A/W2K-S/;$w2ks++;print DFILE;next;}; # = W2K Server if (/^\s[a-zA-Z]{3}scadc+/){s/A/W2K-DC/;$dc++;print DFILE;next;}; # = w2k Domain Controller =20 if (/^\s\w\w\wnfris\d\d\d/){s/A/Snap/;$snaps++;print DFILE;next;}; # = Quantum Snap server if (/^\susu/){s/A/Non-MS/;$switch++;print DFILE;next;}; # Switch if (/^\sus/){s/A/Non-MS/;$legacy++;print DFILE;next;}; # Legacy = device (Print Server, etc) if (/^\ssap/){s/A/Non-MS/;$legacy++;print DFILE;next;}; # SAP = Host =20 if (/^\srib/){s/A/Non-MS/;$legacy++;print DFILE;next;}; # SNMP = Host =20 if (/^\s\wdcs+/){s/A/DCD/;$legacy++;print DFILE;next;};# Data = Center Device if (/^\s[a-zA-Z]{3}de\d\d\d\d\d/){s/A/W2K/;$w2k++;$good++;print = DFILE;next;};# w2k desktop - obeying convention if (/^\s[a-zA-Z]{3}le\d\d\d\d\d/){s/A/W2K/;$w2k++;$good++;print = DFILE;next;};# w2k laptop - obeying convention if (/^\s[a-zA-Z]{3}d\d{1,6}/){s/A/W2K/;$w2k++;print DFILE;next;}; # = w2k desktop - Pre-Nextwave=20 if (/^\s[a-zA-Z]{3}l\d{1,6}/){s/A/W2K/;$w2k++;print DFILE;next;}; # = w2k laptop - Pre-Nextwave if (/^\s[a-zA-Z]{3}l+/){s/A/W2K?/;$w2k++;print DFILE;next;}; # w2k = laptop - probable. if (/^\s[a-zA-Z]{3}d+/){s/A/W2K?/;$w2k++;print DFILE;next;}; # w2k = desktop - probable. {s/A/?/;} # Anything left over is interesting. Flag it for follow-up = with a ?. Sure there's no print DFILE in that last case? Why the substitution then? I'd do something like my @rules = ( qr/^\s[eE|aA]\d\d\d\d\d\D/ = sub { s/A/W95/; $w95++ }, qr/^\s[a-zA-Z]{5}dfs\d\d\d+/ = sub { s/A/W2K-S/; $w2ks++;}, ... ); OUTER: while (SOMEINPUTSTREAM) { for (my $i = 0; $i = $#rules; $i += 2) { /$rules[$i]/ and do { $rules[$i+1]-(); print DFILE; next OUTER }; } s/A/?/; } If it weren't for the fact that sometimes you increment two variables I'd have used a hash for the increments instead. Might still be better to have a hash instead of all those little variables. -- Peter Scott http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: The basics of SWITCH
On Nov 4, K Pfeiffer said: Gajo Csaba writes: Hi, I have a problem with SWITCH. I wrote this, I think it's clear to anzone what it should do: Just out of curiousity I typed in 'perldoc SWITCH' and 'perldoc -f SWITCH' and found nothing. What is it? (the short answer is fine) It is nothing. A switch statement in Perl can be written as the OP showed. SWITCH here is just a label. FOO: { if ($x == 1) { ...; last FOO; } if ($x == 2) { ...; last FOO; } ... } -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Data storage problem
On Nov 4, Brian Ling said: If I, push @save_array, \%hash_data I obviously get a array referencing the same mem address for each loop, the value of which gets overwritten next time round. Then you need to scope your hash. When you declare the hash, use my: for (...) { my %hash = something(); push @saved, \%hash; } or, use the anonymous hash constructor to COPY the contents of the hash: for (...) { %hash = something(); push @saved, { %hash }; } But I prefer the first method. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: V Unpretty code
Yes, there's a DFILE for the last entry. Mis-edit on my partkinda left it hanging, didn't I? All the output goes to the same file. Thanks for the suggestion. I'll play some and see how it goes. Thanks again. Pat - Original Message - From: Peter Scott [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 04, 2002 12:50 PM Subject: Re: V Unpretty code In article 00e201c28426$051681e0$[EMAIL PROTECTED], [EMAIL PROTECTED] (Patrick Salmon) writes: I have a piece of code that does repeated searches through an input = string and modifies it according to certain criteria. What I have works = great, but I'd like to know how to write it better/more efficiently.=20 Given that I'm going over the same record until I get a hit (or not), = how would I re-write the following so that it's not a series of if = if...if...if? if (/^\s[eE|aA]\d\d\d\d\d\D/){s/A/W95/;$w95++;print DFILE;next;}; # = (E or A + n) =3D Windows95 if (/^\s[a-zA-Z]{5}dfs\d\d\d+/){s/A/W2K-S/;$w2ks++;print = DFILE;next;}; # W2K Server if (/^\s[a-zA-Z]{3}salnm+/){s/A/W2K-S/;$w2ks++;print DFILE;next;}; # = W2K Server if (/^\s[a-zA-Z]{3}scadc+/){s/A/W2K-DC/;$dc++;print DFILE;next;}; # = w2k Domain Controller =20 if (/^\s\w\w\wnfris\d\d\d/){s/A/Snap/;$snaps++;print DFILE;next;}; # = Quantum Snap server if (/^\susu/){s/A/Non-MS/;$switch++;print DFILE;next;}; # Switch if (/^\sus/){s/A/Non-MS/;$legacy++;print DFILE;next;}; # Legacy = device (Print Server, etc) if (/^\ssap/){s/A/Non-MS/;$legacy++;print DFILE;next;}; # SAP = Host =20 if (/^\srib/){s/A/Non-MS/;$legacy++;print DFILE;next;}; # SNMP = Host =20 if (/^\s\wdcs+/){s/A/DCD/;$legacy++;print DFILE;next;};# Data = Center Device if (/^\s[a-zA-Z]{3}de\d\d\d\d\d/){s/A/W2K/;$w2k++;$good++;print = DFILE;next;};# w2k desktop - obeying convention if (/^\s[a-zA-Z]{3}le\d\d\d\d\d/){s/A/W2K/;$w2k++;$good++;print = DFILE;next;};# w2k laptop - obeying convention if (/^\s[a-zA-Z]{3}d\d{1,6}/){s/A/W2K/;$w2k++;print DFILE;next;}; # = w2k desktop - Pre-Nextwave=20 if (/^\s[a-zA-Z]{3}l\d{1,6}/){s/A/W2K/;$w2k++;print DFILE;next;}; # = w2k laptop - Pre-Nextwave if (/^\s[a-zA-Z]{3}l+/){s/A/W2K?/;$w2k++;print DFILE;next;}; # w2k = laptop - probable. if (/^\s[a-zA-Z]{3}d+/){s/A/W2K?/;$w2k++;print DFILE;next;}; # w2k = desktop - probable. {s/A/?/;} # Anything left over is interesting. Flag it for follow-up = with a ?. Sure there's no print DFILE in that last case? Why the substitution then? I'd do something like my @rules = ( qr/^\s[eE|aA]\d\d\d\d\d\D/ = sub { s/A/W95/; $w95++ }, qr/^\s[a-zA-Z]{5}dfs\d\d\d+/ = sub { s/A/W2K-S/; $w2ks++;}, ... ); OUTER: while (SOMEINPUTSTREAM) { for (my $i = 0; $i = $#rules; $i += 2) { /$rules[$i]/ and do { $rules[$i+1]-(); print DFILE; next OUTER }; } s/A/?/; } If it weren't for the fact that sometimes you increment two variables I'd have used a hash for the increments instead. Might still be better to have a hash instead of all those little variables. -- Peter Scott http://www.perldebugged.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: Calculate PI
--- Sven Bentlage [EMAIL PROTECTED] wrote: Hi everyone! I am trying to write a program calculating pi. The formula I would like to use is pi = 4x( (1/1) - (1/3) + (1/5) - (1/7) + (1/9) - (1/11) ) or $pi = 4x ( (1/$y) - ) Hi Sven, The Leibniz series is very slow, but here's one implementation: #!/usr/bin/perl -w #Compute pi. Based on Leibniz's algorithm # pi = 4 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11... use strict; my $pi = 4; my $next_digits = get_leibniz(); for ( 1 .. 10 ) { my ( $subtract, $add ) = $next_digits-(); $pi = $pi - $subtract + $add; } print $pi; sub get_leibniz { my $index = 1; my $sub = sub { $index += 2; my $first = 4/$index; $index += 2; my $second = 4/$index; return ($first, $second); }; return $sub; } If you want to see some fun implmentations, check out this thread on Perlmonks: http://www.perlmonks.org/index.pl?node_id=159377. One of my favorites: sub _{$---4/$_}print- _$-=1e5 Cheers, Ovid = 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!? HotJobs - Search new jobs daily now http://hotjobs.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Connecting to a drive
Hello, I am trying to write a Perl script that will replicate a directory on one computer to another. All of the computers are running XP. I do have administrative privileges. The problem is when I run the line below I never get connected to the computer from within the scripted. system net use m: \\$node\\c\$ file:///\\$node\c\$ user:/username password; The error I get from the line is a syntax error. If I map the drive manually my script works.(That's no good when you have to do it 40 times ) Any suggestions would be appreciated Thanks for your help! Larry Sandwick Sarreid, Ltd. Network Administrator (252) 291-1414 x223
RE: Connecting to a drive
remember what \ does in these try: system net use m: $nodec\\$ file:///$node\\c\\$ user:/username password; remember for one \ you need \\ for 2 \ you need -Original Message- From: Larry Sandwick [mailto:lgs;sarreid.com] Sent: Monday, November 04, 2002 3:31 PM To: [EMAIL PROTECTED] Subject: Connecting to a drive Hello, I am trying to write a Perl script that will replicate a directory on one computer to another. All of the computers are running XP. I do have administrative privileges. The problem is when I run the line below I never get connected to the computer from within the scripted. system net use m: \\$node\\c\$ file:///\\$node\c\$ user:/username password; The error I get from the line is a syntax error. If I map the drive manually my script works.(That's no good when you have to do it 40 times ) Any suggestions would be appreciated Thanks for your help! Larry Sandwick Sarreid, Ltd. Network Administrator (252) 291-1414 x223 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: Connecting to a drive
From: Larry Sandwick [EMAIL PROTECTED] I am trying to write a Perl script that will replicate a directory on one computer to another. All of the computers are running XP. I do have administrative privileges. The problem is when I run the line below I never get connected to the computer from within the scripted. system net use m: \\$node\\c\$ file:///\\$node\c\$ user:/username password; Try to print the command instead of executing it. You'll see the problem. You may also want to try use Win32::FileOp; # http://Jenda.Krynicky.cz/#Win32::FileOp Map 'M:' = $node\\c\$, {user = $username, passwd = $password, overwrite = 1}; Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Connecting to a drive
Thanks for the quick response, using the print command I saw the error of my way !!! I had a space in $node. Thanks again for the help !!! ---Larry -Original Message- From: Jenda Krynicky [mailto:Jenda;Krynicky.cz] Sent: Monday, November 04, 2002 3:41 PM To: [EMAIL PROTECTED] Subject: Re: Connecting to a drive From: Larry Sandwick [EMAIL PROTECTED] I am trying to write a Perl script that will replicate a directory on one computer to another. All of the computers are running XP. I do have administrative privileges. The problem is when I run the line below I never get connected to the computer from within the scripted. system net use m: \\$node\\c\$ file:///\\$node\c\$ user:/username password; Try to print the command instead of executing it. You'll see the problem. You may also want to try use Win32::FileOp; # http://Jenda.Krynicky.cz/#Win32::FileOp Map 'M:' = $node\\c\$, {user = $username, passwd = $password, overwrite = 1}; Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: V Unpretty code
Patrick Salmon wrote: There's always another way to do it, right? I have a piece of code that does repeated searches through an input string and modifies it according to certain criteria. What I have works great, but I'd like to know how to write it better/more efficiently. Given that I'm going over the same record until I get a hit (or not), how would I re-write the following so that it's not a series of if if...if...if? if (/^\s[eE|aA]\d\d\d\d\d\D/){s/A/W95/;$w95++;print DFILE;next;}; # (E or A + n) = Windows95 [eE|aA] is NOT E or A, it is 'e' or 'E' or '|' or 'a' or 'A'. if (/^\s[a-zA-Z]{5}dfs\d\d\d+/){s/A/W2K-S/;$w2ks++;print DFILE;next;}; # W2K Server if (/^\s[a-zA-Z]{3}salnm+/){s/A/W2K-S/;$w2ks++;print DFILE;next;}; # W2K Server if (/^\s[a-zA-Z]{3}scadc+/){s/A/W2K-DC/;$dc++;print DFILE;next;}; # w2k Domain Controller if (/^\s\w\w\wnfris\d\d\d/){s/A/Snap/;$snaps++;print DFILE;next;}; # Quantum Snap server if (/^\susu/){s/A/Non-MS/;$switch++;print DFILE;next;}; # Switch if (/^\sus/){s/A/Non-MS/;$legacy++;print DFILE;next;}; # Legacy device (Print Server, etc) if (/^\ssap/){s/A/Non-MS/;$legacy++;print DFILE;next;}; # SAP Host if (/^\srib/){s/A/Non-MS/;$legacy++;print DFILE;next;}; # SNMP Host if (/^\s\wdcs+/){s/A/DCD/;$legacy++;print DFILE;next;};# Data Center Device if (/^\s[a-zA-Z]{3}de\d\d\d\d\d/){s/A/W2K/;$w2k++;$good++;print DFILE;next;};# w2k desktop - obeying convention if (/^\s[a-zA-Z]{3}le\d\d\d\d\d/){s/A/W2K/;$w2k++;$good++;print DFILE;next;};# w2k laptop - obeying convention if (/^\s[a-zA-Z]{3}d\d{1,6}/){s/A/W2K/;$w2k++;print DFILE;next;}; # w2k desktop - Pre-Nextwave if (/^\s[a-zA-Z]{3}l\d{1,6}/){s/A/W2K/;$w2k++;print DFILE;next;}; # w2k laptop - Pre-Nextwave if (/^\s[a-zA-Z]{3}l+/){s/A/W2K?/;$w2k++;print DFILE;next;}; # w2k laptop - probable. if (/^\s[a-zA-Z]{3}d+/){s/A/W2K?/;$w2k++;print DFILE;next;}; # w2k desktop - probable. {s/A/?/;} # Anything left over is interesting. Flag it for follow-up with a ?. You can factor out the common statements to make it shorter. if( /^\s[eEaA]\d{4}\D/ ) { s/A/W95/;$w95++ } elsif ( /^\s[a-zA-Z]{5}dfs\d{3,}/ ) { s/A/W2K-S/; $w2ks++ } elsif ( /^\s[a-zA-Z]{3}salnm+/ ) { s/A/W2K-S/; $w2ks++ } elsif ( /^\s[a-zA-Z]{3}scadc+/ ) { s/A/W2K-DC/; $dc++ } elsif ( /^\s\w\w\wnfris\d\d\d/ ) { s/A/Snap/; $snaps++ } elsif ( /^\susu/ ){ s/A/Non-MS/; $switch++ } elsif ( /^\s(?:us|sap|rib)/ ) { s/A/Non-MS/; $legacy++ } elsif ( /^\s\wdcs+/ ) { s/A/DCD/;$legacy++ } elsif ( /^\s[a-zA-Z]{3}[dl]e\d{5}/ ) { s/A/W2K/;$w2k++; $good++ } elsif ( /^\s[a-zA-Z]{3}[dl]\d{1,6}/ ) { s/A/W2K/;$w2k++ } elsif ( /^\s[a-zA-Z]{3}[dl]+/ ) { s/A/W2K?/; $w2k++ } else { s/A/?/ } print DFILE; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: changing case
try this.. __ START __ my $path = qq~$HOME/documents~; # set this to your path opendir(DIR,$path) or diesub(can't readdir $path: $!); # open the entire directory for getting the contents of while (my $file = readdir DIR) { # $file gets assigned the next value of DIR, and exits when there's no more files my ($fname,$ext) = split(/\./,$file); # removes extension next if $file eq '.' or $file eq '..' or $ext ne 'html'; # goes to next look if $file is . (current dir) or .. (parent dir) rename $file, lc($file); # rename } closedir DIR; # close directory __ END __ dan P.S: This is untested.. test/alter/correct/test as need be. Desmond Coughlan [EMAIL PROTECTED] wrote in message news:20021103180226.GE15981;lievre.voute.net... Hi, I'm trying to figure out how I can change the filenames in a directory, from having an initial capital letter, to all lowercase. The files came from a Windows system, which doesn't really care about case. My BSD box, however, does ! I've tried fiddling around with tr and lc, but I don't know perl enough to get it to work. FYI, the directory is called $HOME/documents, and the files are called 'Indexpage.html', or 'Reportback.html' and so on ... Thanks in advance. D. -- Desmond Coughlan [EMAIL PROTECTED] http://www.zeouane.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Reading from mulitple files
Hello all, I know this has been asked a few times over the years, but I can't find an answer that is what I need in the archives. I have 2 files. I have a for loop. I need to read from both files with 1 file handle, or whatever will allow my code to read from both files alternating between them. Basically I need the equivalent of this: #open file1 #open file2 while (file1 || file2) { #process line from file1 #process line from file2 } I've tried the Perl Cookbook recipe for reading from multiple filehandles and I need more than just to have a list of file handles returned. I need to be able to read (and process) a line from each file handle so that they finish at about the same time. Not a solution that reads one file then the other. Any help is appreciated. Kevin -- Kevin Old [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reading from mulitple files
--- Kevin Old [EMAIL PROTECTED] wrote: Hello all, I know this has been asked a few times over the years, but I can't find an answer that is what I need in the archives. I have 2 files. I have a for loop. I need to read from both files with 1 file handle, or whatever will allow my code to read from both files alternating between them. Kevin, I'm sure there is a module for this somewhere, but I don't know it offhand (and a quick search didn't reveal it). You did mention that you wanted the files handles to be finished at roughly the same time, but I'm not sure exactly what you meant by that. I wrote a small test program that takes a list of files, opens them, and reads each file sequentially allowing you to process all lines. If one file has fifteen lines and another file has three lines then you will be processing the extra 12 lines from the first file *after* the three lines from the second file. It should be noted that this program doesn't tell you which file is which as you didn't necessarily specify that in your email. It should be fairly easy to add, though. Cheers, Ovid #!/usr/bin/perl -w use strict; use IO::File; use vars qw( @file_handle $open_files ); my @files = qw( file1 file2 bad_file ); while( my @lines = read_data( \@files ) ) { foreach my $lines ( @lines ) { print $lines; } } sub read_data { my $files = shift; unless ( defined $open_files ) { initialize_file_handles( $files ); } my (@lines,@finished_files); return unless $open_files; foreach my $index ( 0 .. $#file_handle ) { my ($name,$fh) = @{ $file_handle[$index] }; if ( my $line = $fh ) { push @lines = $line; } else { push @finished_files = $index; } } foreach my $index ( @finished_files ) { close $file_handle[ $index ][1]; splice @file_handle, $index, 1; $open_files--; } return @lines; } sub initialize_file_handles { my $files = shift; $open_files = 0; foreach my $file ( @$files ) { my $fh = IO::File-new( $file ); if ( defined $fh ) { $file_handle[ $open_files ] = [ $file, $fh ]; $open_files++; } else { warn Could not open $file for reading: $!; } } } = 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!? HotJobs - Search new jobs daily now http://hotjobs.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Calling a win32 script from within perl fetching the output
Hi all I will be glad if you can help me.. all I need is to execute a win32 script on a workstation on a LAN and fetch the output using perl my current set of resources includes : a win32 exe : a main.pl I em able to this very same thing on a local machine . ie I can get the output after calling it from within perl.. but when it comes to having it called from a remote node... I em a bit lost How do I go about doing that ... should i give the UNC and If I should then how do I give it... Please help regards voodoo man _ Broadband? Dial-up? Get reliable MSN Internet Access. http://resourcecenter.msn.com/access/plans/default.asp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
checking input syntax
I would like to be able to verify the presence and syntax of an argument coming into my script prior to actually doing anything with it. My script is execpting to see something like this ../myscript server10.boston or ../myscript server30.california I am able to check for the presense of an argument like this: ( $#ARGV == 0 ) or die usage: $0 server[number].[location] \n; But I am having trouble testing for proper syntax that would prevent the user trying to something like: ../myscript server10 or ../myscript 30.california I would like to be able to force them use the server[number].[location] syntax and generate a warning if they don't. Would it be possible to add a second argument test after the first? Something like: ( $#ARGV eq server*.* ) or die usage: $0 server[number].[location]\n; I seem to be having trouble with the wildcard* part of it. Any help would be greatly appreciated. Thanks in advance. -Jose
Re: Reading from mulitple files
Kevin Old wrote: Hello all, I know this has been asked a few times over the years, but I can't find an answer that is what I need in the archives. I have 2 files. I have a for loop. I need to read from both files with 1 file handle, or whatever will allow my code to read from both files alternating between them. Basically I need the equivalent of this: #open file1 #open file2 while (file1 || file2) { #process line from file1 #process line from file2 } I've tried the Perl Cookbook recipe for reading from multiple filehandles and I need more than just to have a list of file handles returned. I need to be able to read (and process) a line from each file handle so that they finish at about the same time. Not a solution that reads one file then the other. Any help is appreciated. Something like this should work. open F1, 'file1' or die Cannot open 'file1': $!; open F2, 'file2' or die Cannot open 'file2': $!; while ( my $line1 = F1 and my $line2 = F2 ) { #process line from file1 #process line from file2 } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help with Hash values and variable interpolation
Hello all, I've got a file which contains ports and hostnames. I'd like to count the number of instances that each item occurs in my file. I'm having a difficult time with this. This is my script: Basically I'm splitting the first line a few times to get the data I need. What am I doing wrong? At the bottom you'll find a snippet of the file I'm parsing. Thank you for all your help! ### #/usr/bin/perl -w open (FILE,'c:\temp\outbound.traffic'); %allports=(); file=FILE; foreach (file) { chomp(); ($source,$other,$dest) = split(/\s/,$_); ($a,$b,$c,$d,$src_port)= split(/\./,$source); ($e,$f,$g,$h,$dst_port) = split(/\./,$dest); $sourceip = $a.$b.$c.$d; $destip = $e.$f.$g.$h; $dst_port =~ s/:/ /; push(dstports,$dst_port); }; foreach $element (dstports) { chomp($element); print $element\n; $allports{$element}++; } print Port 53: $allports{53}\t Port 80: $allports{80}\n; close (FILE); ###3 FILE THAT IS BEING PARSED 112.58.26.32.32770 192.35.51.30.53: 64596[|domain] (DF) 112.58.26.32.32770 192.100.59.110.53: 24685 [1au][|domain] (DF) 112.58.26.4.2506 216.148.227.69.80: . ack 3280436924 win 2920 (DF) 112.58.26.4.2506 216.148.227.69.80: . ack 1759 win 1162 (DF) 112.58.26.4.2498 66.207.130.76.80: . ack 2195940947 win 7906 (DF) 112.58.26.4.2498 66.207.130.76.80: R 2576805184:2576805184(0) win 0 (DF) == NOTICE - This communication may contain confidential and privileged information that is for the sole use of the intended recipient. Any viewing, copying or distribution of, or reliance on this message by unintended recipients is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer. ==
RE: Help with Hash values and variable interpolation
I figured it out already! I ran a replace on the dst_port and replaced it with a whitespace which threw off the count. I've modified it to delete the whitespace and all works perfect. Joshua Scott Security Systems Analyst, CISSP 626-568-7024 -Original Message- From: Scott, Joshua [mailto:Joshua.Scott;Jacobs.com] Sent: Monday, November 04, 2002 5:42 PM To: '[EMAIL PROTECTED]' Subject: Help with Hash values and variable interpolation Hello all, I've got a file which contains ports and hostnames. I'd like to count the number of instances that each item occurs in my file. I'm having a difficult time with this. This is my script: Basically I'm splitting the first line a few times to get the data I need. What am I doing wrong? At the bottom you'll find a snippet of the file I'm parsing. Thank you for all your help! ### #/usr/bin/perl -w open (FILE,'c:\temp\outbound.traffic'); %allports=(); @file=FILE; foreach (@file) { chomp(); ($source,$other,$dest) = split(/\s/,$_); ($a,$b,$c,$d,$src_port)= split(/\./,$source); ($e,$f,$g,$h,$dst_port) = split(/\./,$dest); $sourceip = $a.$b.$c.$d; $destip = $e.$f.$g.$h; $dst_port =~ s/:/ /; push(@dstports,$dst_port); }; foreach $element (@dstports) { chomp($element); print $element\n; $allports{$element}++; } print Port 53: $allports{53}\t Port 80: $allports{80}\n; close (FILE); ###3 FILE THAT IS BEING PARSED 112.58.26.32.32770 192.35.51.30.53: 64596[|domain] (DF) 112.58.26.32.32770 192.100.59.110.53: 24685 [1au][|domain] (DF) 112.58.26.4.2506 216.148.227.69.80: . ack 3280436924 win 2920 (DF) 112.58.26.4.2506 216.148.227.69.80: . ack 1759 win 1162 (DF) 112.58.26.4.2498 66.207.130.76.80: . ack 2195940947 win 7906 (DF) 112.58.26.4.2498 66.207.130.76.80: R 2576805184:2576805184(0) win 0 (DF) == NOTICE - This communication may contain confidential and privileged information that is for the sole use of the intended recipient. Any viewing, copying or distribution of, or reliance on this message by unintended recipients is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer. == == NOTICE - This communication may contain confidential and privileged information that is for the sole use of the intended recipient. Any viewing, copying or distribution of, or reliance on this message by unintended recipients is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer. == == NOTICE - This communication may contain confidential and privileged information that is for the sole use of the intended recipient. Any viewing, copying or distribution of, or reliance on this message by unintended recipients is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer. == -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help with Hash values and variable interpolation
Joshua Scott wrote: Hello all, Hello, I've got a file which contains ports and hostnames. I'd like to count the number of instances that each item occurs in my file. I'm having a difficult time with this. This is my script: Basically I'm splitting the first line a few times to get the data I need. What am I doing wrong? At the bottom you'll find a snippet of the file I'm parsing. Thank you for all your help! ### #/usr/bin/perl -w open (FILE,'c:\temp\outbound.traffic'); You should _always_ verify that the file opened successfully. Also, you can use slashes instead of backslashes in file names. open FILE, 'c:/temp/outbound.traffic' or die Cannot open 'c:/temp/outbound.traffic': $!; %allports=(); @file=FILE; foreach (@file) { You shouldn't read the whole file into an array unless you _really_ need to. while ( FILE ) { chomp(); You don't really need to chomp as you are not using the data at the end of the line. ($source,$other,$dest) = split(/\s/,$_); ($a,$b,$c,$d,$src_port)= split(/\./,$source); ($e,$f,$g,$h,$dst_port) = split(/\./,$dest); $sourceip = $a.$b.$c.$d; $destip = $e.$f.$g.$h; next unless my ( $source, $src_port, $dest, $dst_port ) = /^([\d.]+)\.(\d+)[ ]+([\d.]+)\.(\d+)/; $dst_port =~ s/:/ /; push(@dstports,$dst_port); print $dst_port\n; $allports{$dst_port}++; }; foreach $element (@dstports) { chomp($element); print $element\n; $allports{$element}++; } print Port 53: $allports{53}\t Port 80: $allports{80}\n; close (FILE); ###3 FILE THAT IS BEING PARSED 112.58.26.32.32770 192.35.51.30.53: 64596[|domain] (DF) 112.58.26.32.32770 192.100.59.110.53: 24685 [1au][|domain] (DF) 112.58.26.4.2506 216.148.227.69.80: . ack 3280436924 win 2920 (DF) 112.58.26.4.2506 216.148.227.69.80: . ack 1759 win 1162 (DF) 112.58.26.4.2498 66.207.130.76.80: . ack 2195940947 win 7906 (DF) 112.58.26.4.2498 66.207.130.76.80: R 2576805184:2576805184(0) win 0 (DF) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]