Re: why is this showing up in my error_log?
on Wed, 22 May 2002 00:22:30 GMT, [EMAIL PROTECTED] (Jake) wrote: open(outfile, .$pathToXML ) or die (couldnt open xml file); [...] Unquoted string outfile may clash with future reserved word at /var/www/cgi-bin/adminWorkReport2.cgi line 66. [...] open(assignFile, .$pathToAssignNum) or die (couldnt open [...] doesnt! wtf??? 'outfile' is all lowercase, while 'assignFile' is miXeD cASe. It's not an error though, it's a warning, which will go away when you turn off warnings. (No, I'm not promoting to turn of warnings ;-) If you stick to the convention of naming your file descriptors in UPPERCASE, you won't get into trouble. -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
convert date value into text value..
Hi ! How can I convert a date value (I get via /bin/date) into a text value? Thanks for your help. Sven -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Sysread and syswrite
Hi all, I am having some problem with sysread and syswrite. Example:- I want to print out a variable to my client over the internet, but would like to use syswrite and sysread would help to reduce mistakes in EOF characters. #!/usr/bin/perl my $buffer; my $test = hello, how do u do; #reading into buffer sysread($test, $buffer, 1024); syswrite(STDOUT, $buffer); The above doesn't return anything, is it something wrong with my program? Kindly advice, thanks! _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
use variables in regex
Hi I'l looking for a way to use a scalar in a regex. The snibblet below shows in about what it is supposed to do. if someone has a better idea how to compare the date value with the $date_today value I extract from the text file, I'd be really happy about any hints.. The snibblet doesn't work, because it looks for the string $date and not for the value of $date... Thanks for your help. Regards, Sven sub regex { #textfile has the following format: # DD-MM-YY:name:address:telephone #$date has the value of the current date DD-MM-YY open APODATA2, $apodataFile || die Can't open $apodataFile for regex :$!\n; while ($date_today = APODATA2 ) { if ($date_today =~ /$date/) { print date_today: $date_today\n; } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: use variables in regex||solved
ok, found out myself why it didn't work. I am not sure if it's an elegant chunk of code, but it works. Since the data is in the $_ variable, fooling around with $date_today in the regex coulnd't work out. (Omitted =~ since I use $_.) Sven my $date = `/bin/date +%d.%m.%y`; $date =~ tr/./-/; chomp $date; my $apodataFile = /Users/johnd0e/Desktop/apodata.txt; open APODATA2, $apodataFile || die Can't open $apodataFile for regex :$!\n; my ( $date_today, $aponame, $apoaddress, $apotel ); while ( APODATA2 ) { ( $date_today, $aponame, $apoaddress, $apotel ) = split(/:/,$_); if (/$date/) { print date_today: $date_today __ $date\n ; } } On Wednesday, May 22, 2002, at 11:57 AM, Sven Bentlage wrote: Hi I'l looking for a way to use a scalar in a regex. The snibblet below shows in about what it is supposed to do. if someone has a better idea how to compare the date value with the $date_today value I extract from the text file, I'd be really happy about any hints.. The snibblet doesn't work, because it looks for the string $date and not for the value of $date... Thanks for your help. Regards, Sven sub regex { #textfile has the following format: # DD-MM-YY:name:address:telephone #$date has the value of the current date DD-MM-YY open APODATA2, $apodataFile || die Can't open $apodataFile for regex :$!\n; while ($date_today = APODATA2 ) { if ($date_today =~ /$date/) { print date_today: $date_today\n; } } -- 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]
Sockets tutorial
Hi everyone, I'm intressted in learning socket programming in perl. does someone know of a good tutorial or mailing list that isn't beginer or CGI oriented? TIA Tim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: use variables in regex||solved
Hi Felix thanks for the tips. On Wednesday, May 22, 2002, at 01:20 PM, Felix Geerinckx wrote: You have a precedence problem here, since '||' has higher precedence than ','. You should either use open(FH, foo) || die; open FH, foo or die; didn't know that yet. fixed it. (Why are you putting a second '||' within quotes?) sorry, but I'm not really understanding what you mean by second || within the quotes. here is the code again: my ($d, $m, $y) = (localtime)[3,4,5]; my $date = sprintf(%02d-%02d-%02d, $d, $m+1, $y-100); $date =~ tr/./-/; chomp $date; my $apodataFile = /Users/johnd0e/Desktop/apodata.txt; open (APODATA2, $apodataFile) || die Can't open $apodataFile for regex :$!\n; my ( $date_today, $aponame, $apoaddress, $apotel ); while ( APODATA2 ) { ( $date_today, $aponame, $apoaddress, $apotel ) = split(/:/,$_); if (/$date/) { print date_today: $date_today __ $date\n ; } } Regards, Sven -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Sockets tutorial
on Wed, 22 May 2002 11:14:34 GMT, [EMAIL PROTECTED] (Tim Fletcher) wrote: Hi everyone, I'm intressted in learning socket programming in perl. does someone know of a good tutorial or mailing list that isn't beginer or CGI oriented? Invest in Lincoln Stein's Network Programming with Perl http://www.aw.com/catalog/academic/product/1,4096,0201615711,00.html -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Translating newlines to HTML paragraphs
I've gone through and read all the other posts in reply to this, and they all seem to ignore a very simple solution. First: strip off the \r\n: s/\r\n/\n/sg Then look for the pattern \n\n (which would indicate the existence of an empty line. For example: Some paragraph text\n\nA new paragraph) and replace it with \np\n (which gives you Some paragraph text\np\nA new paragraph): s/\n\n/\np\n/sg In both regular expressions, you treat the text as a single string (s) and replace all instances (g). The problem with using patterns such as s/$/p/m is that while it will match the end-of-line condition, it will not _replace_ it (see Programming Perl, chapter 2, on Regular Expressions and the s/// operator). --Matthew On Mon, 20 May 2002 13:51:57 -0400, John Brooking wrote: Hello, all, I'm trying to translate the value entered in a TEXTAREA tag to one or more HTML paragraphs. That means any newlines entered into the text box need to be turned into P tags by the script. But I'm having trouble coming up with a regex to do this. I know I need multiline mode, so I've been trying combinations involving s/$/p/mg or s/^/p/mg, but nothing has worked so far. Everything I've tried has (1) added the P tag but not removed the newline, and/or (2) also added one at the end of the string (using $, or at the beginning using ^) even though there's not a newline there. The latter seems to be by Perl design, but I don't want it in this case. Here's the test program I'm using to experiment (warning to HTML email clients, there is an HTML tag in this code): my $lf = chr(10); my $Text = Para.${lf}Para.${lf}Para.; $Text =~ s/$/p/mg; print $Text; And a follow-up question: When newlines are entered into a TEXTAREA, is TEXTAREA standardized to use CR/LF pairs, or just CR, just LF, or does it depend on the client and/or the server platform? Do we need to worry about this? Or will the ^ and $ characters work correctly with any of these combinations so we don't need to worry about it? Thanks in advance for any help. - John = When you're following an angel, does it mean you have to throw your body off a building? - They Might Be Giants, http://www.tmbg.com Word of the week: Serendipity, see http://www.bartleby.com/61/93/S0279300.html __ Do You Yahoo!? LAUNCH - Your Yahoo! Music Experience http://launch.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: use variables in regex||solved
On Wednesday, May 22, 2002, at 03:26 , Sven Bentlage wrote: ok, found out myself why it didn't work. I am not sure if it's an elegant chunk of code, but it works. Since the data is in the $_ variable, fooling around with $date_today in the regex coulnd't work out. (Omitted =~ since I use $_.) may I recommend what may be simpler? # never argue with what works. PERIOD. my @t=localtime;$t[4]++;$t[5]+=1900; # for the DD-MM- we would use my $dtg = sprintf(%02d-%02d-%4d,@t[3,4,5]); my @notFound; while(FH) { if (/$dtg/ ) { print $_; #or what ever you } else { push(@notFound, $_); } } close(FH); print #--\n# ok, so what did we put in the \@notFound\n\n; print $_ for @notFound; ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Sysread and syswrite
Well, firstly, it ain't CGI, it's network programming. Well, it's slightly one sublayer below HTML, it's HTTP request/response headers. Thus, print, , read, write are not advisable, thus resorting to these. However, I would like to thank both felix and drieux for addressing this problem. Seems like i have to tackle the problem from another perspective then. Thanks! Advice still welcome! - Original Message - From: drieux [EMAIL PROTECTED] To: cgi cgi-list [EMAIL PROTECTED] Sent: Wednesday, May 22, 2002 10:06 PM Subject: Re: Sysread and syswrite On Wednesday, May 22, 2002, at 01:07 , ChaoZ InferNo wrote: [..] I want to print out a variable to my client over the internet, but would like to use syswrite and sysread would help to reduce mistakes in EOF characters. [..] I back felix's main line - since sysread/syswrite are for accessing files - not variables already in your code. So why are you concerned about 'EOF' characters What is leading your analysis there??? may I recommend http://www.wetware.com/drieux/pbl/cgi/basicPagePopper.txt as a simple basic 'how to get the Page Out the Door' with use CGI; since it shows the simple start_html(...) # do some stuff end_html; remember as many author's of new things have learned after reading the book on it - 'wow, even I didn't know that...' so everyone is new to stuff, till they have experienced it all. ciao drieux --- -- 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: Sysread and syswrite
ChaoZ Inferno wrote: Well, firstly, it ain't CGI, it's network programming. if it ain't, why are you posting to a cgi list? http://learn.perl.org/ - choose another list. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to match next line?
I am concatenating several e-mail lists into one, and some of the addresses are on multiple lists. I need to be able to print out a full, alphabetically sorted list of all the names without printing duplicates. How would I alter the following to make that happen? This gets close; it *will* remove a duplicate address if there are only two of the same address. But it won't work if there are three or four of the same address, for example. I'm also sure this could be shortened or cleaned up; suggestions welcome #!/usr/bin/perl -w use strict; my $infile = '/path/to/.biglist.list'; my @slurped = (); open(IN,$infile); while(IN) { @slurped = IN; # Pull addresses into an array } close(IN); my @sorted = sort(@slurped); # Create a sorted list my $i; my $j; foreach ($i = 0; $i = @sorted; $i++) { chomp($i); $j = $i++; # Only finds 1 address beyond $i if ($sorted[$i] =~ /$j/) # Compare this line w/next line { next; # If it matches, skip it } else { print Address = $sorted[$i] \n; } } Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] [EMAIL PROTECTED] --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to get REMOTE_GROUP
Hi There, I have a question about Perl in combination with Apache. You can set restricted areas within Apache to force autentication. Afterwards you can read the userid using : my $user = ($ENV{'REMOTE_USER'}); But as you can see below, there also is a group called htuser in this case. Does anyone know if there is a way to find out in what group they are, using ENV ? So that $group in: my $group = ($ENV{'REMOTE_GROUP'}); would work. In this case it won't harm, but I intend to use multiple groups for access. Directory /path/to/cgi-bin/IPlib AuthName RESTRICTED ACCESS AuthType Basic require group htuser AuthUserFile /path/to/users AuthGroupFile /path/to/groups /Directory Thanks for you help in advance !!! Regs David -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to match next line?
Scot Robnett wrote: I am concatenating several e-mail lists into one, and some of the addresses are on multiple lists. I need to be able to print out a full, alphabetically sorted list of all the names without printing duplicates. How would I alter the following to make that happen? This gets close; it *will* remove a duplicate address if there are only two of the same address. But it won't work if there are three or four of the same address, for example. I'm also sure this could be shortened or cleaned up; suggestions welcome perldoc -q duplicate will get you to the faq entry for this. Some of the solutions are a little obscure, relying on grep, slicing, etc.. A simple way of doing it is just to put the values in a hash, as hash keys must be unique: my %resulthash=(); foreach my $address(@slurped){ $resulthash{$address}++; } my @result=sort(keys %resulthash); This could be made more compact (and in fact is essentially what some of the faq answers are doing, just more verbose), but it's pretty clear this way. It also stores the number of times each address occurred as the values of the hash. It does wind up using a lot of extra space if your list is large. You could get around this by just reading the addresses straight into a hash. If you want to do it in a way sumilar to what you're doing below you could try: my $lastseen=''; foreach my $address(@sorted){ print $address\n unless ($address eq $lastseen); #or push onto a new array, or write to a file $lastseen=$address; } A couple of things about your code: Usually in Perl you don't need to use the c style for loop unless you actually need to know what index you're looking at. Also you don't need to use a regular expression to compare addresses, eq is probably what you want. In fact, using a regular expression without anchors will consider two email addresses like [EMAIL PROTECTED] and [EMAIL PROTECTED] to be duplicates. (or [EMAIL PROTECTED] and [EMAIL PROTECTED], depending on whether you're looking ahead or back in the sorted list). Also, you should probably check to make sure that your call to open succeeded. Anyway, the answers in the faq are more Perlish (and probably better :) ), the solutions I wrote are more verbose, but maybe more immediately comprehensible if you're not used to grep or slicing. #!/usr/bin/perl -w use strict; my $infile = '/path/to/.biglist.list'; my @slurped = (); open(IN,$infile); while(IN) { @slurped = IN; # Pull addresses into an array } close(IN); my @sorted = sort(@slurped); # Create a sorted list my $i; my $j; foreach ($i = 0; $i = @sorted; $i++) { chomp($i); $j = $i++; # Only finds 1 address beyond $i if ($sorted[$i] =~ /$j/) # Compare this line w/next line { next; # If it matches, skip it } else { print Address = $sorted[$i] \n; } } Tagore Smith -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to match next line?
BTW, one thing you might consider is that there may be duplicate email addresses that differ only in case. You might want to check for that. Tagore Smith -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to match next line?
Tagore, Good points, and well taken. I was definitely planning to modify case using tr/[A-Z]/[a-z]/ but just hadn't gotten that far yet. I hadn't considered the hash idea but it makes a hell of a lot more sense than what I was doing. Thanks. Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] [EMAIL PROTECTED] -Original Message- From: Tagore Smith [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 22, 2002 1:16 PM To: cgi Subject: Re: How to match next line? BTW, one thing you might consider is that there may be duplicate email addresses that differ only in case. You might want to check for that. Tagore Smith -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Translating newlines to HTML paragraphs
--- Matthew Weier O'Phinney [EMAIL PROTECTED] wrote: I've gone through and read all the other posts in reply to this, and they all seem to ignore a very simple solution. First: strip off the \r\n: s/\r\n/\n/sg Then look for the pattern \n\n (which would indicate the existence of an empty line. For example: Some paragraph text\n\nA I've got my solution, it's something like yours, and it works fine. The main difference was I explicitely used \x0d and \x0a because I wasn't sure if \n and \r were defined to the same ASCII codes on all platforms. Any double newlines I assume the user meant a paragraph, any single ones just a line break. Here's the code I finally used (embedded tags, sorry if code wraps in ugly places due to this silly Yahoo editor): sub NL2HTML { $_ = shift; s/\x0d\x0a/\x0d/g;# Strip LF out of CR/LF combinations (Convert DOS - *nix) s/\x0d{2}|\x0a{2}/\/pp/g; # Replace double CR or LF with paragraph break s/\x0d|\x0a/br/g; # Replace single CR or LF with line break return p$_/p; # Wrap whole thing in outside p/p } = When you're following an angel, does it mean you have to throw your body off a building? - They Might Be Giants, http://www.tmbg.com Word of the week: Serendipity, see http://www.bartleby.com/61/93/S0279300.html __ Do You Yahoo!? LAUNCH - Your Yahoo! Music Experience http://launch.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Opening Filehandles under taint check
Dudes, Someone has to have some inkling how to open filehandles for writing whilst running in taint mode (-T). C'mon there are some of the best Perl minds in the world here. Is it impossible? I've tried untainting the data I'm using to write with this snippet: #untaint $count if ($count =~ /^([-\@\w.]+)$/){ $count = $1; } but kept getting this error, Insecure dependency in open while running with -T switch at /u/web/lega63/cgi-local/SecureMail.pl line 455. HELP! I don't want to run this program without taint checks. The full filehandle portion is: if ($mailPrefix[0]) { open (COUNTER,$mailPrefix[0]Counter.txt) or die Couldn't read counter, $! \n; $count=COUNTER; ++$count; close (COUNTER); #untaint $count if ($count =~ /^([-\@\w.]+)$/){ $count = $1; } else { die Bad data in $count; } #The next line is line 455 open (COUNTER,$mailPrefix[0]Counter.txt) or die Couldn't write counter, $! \n; print COUNTER $count; close (COUNTER); unless ($skip eq yes){ open (COUNTER,$mailPrefix[0]Report.txt) or die Couldn't write Report, $! \n; print (COUNTER ${count}. $Config{'email'} on $date\n); close (COUNTER); } } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Opening Filehandles under taint check
--- Camilo Gonzalez [EMAIL PROTECTED] wrote: Dudes, Someone has to have some inkling how to open filehandles for writing whilst running in taint mode (-T). C'mon there are some of the best Perl minds in the world here. Is it impossible? [snip] but kept getting this error, Insecure dependency in open while running with -T switch at /u/web/lega63/cgi-local/SecureMail.pl line 455. HELP! I don't want to run this program without taint checks. #The next line is line 455 open (COUNTER,$mailPrefix[0]Counter.txt)... Hi Camilo, Earlier in the program, you were allowed to open the filehandle for reading because Perl doesn't think that *reading* is a security hole. However, *writing* is a different matter. In the above snippet, Perl says that $mailPrefix[0] is tainted and the open is unsafe, so it kills your script. Untaint $mailPrefix[0] and your problem should be solved. 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!? LAUNCH - Your Yahoo! Music Experience http://launch.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Cron alternatives?
Try Anacron http://freshmeat.net/projects/anacron/?topic_id=136 -Original Message- From: Troy May [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 22, 2002 12:02 AM To: Beginners CGI List Subject: Cron alternatives? Hello, A friend of mine has a task he wants to do daily, so I told him to check into cron but he said he doesn't have it. His server is running RedHat 6.1 Cartman. I've never used cron before but I'm assuming that it is not available to him from what he said. Is there an alternative to cron for servers that do not have it? He needs to have a data file erased the first time it is wrote to every day. But the rest of the day it will just append to it as normal. I thought of cron right away, but now I'm stuck since he can't go that route. Any ideas? Thanks in advance! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]