$foo = $bar + $blee ; #example
OK, so you have Alice. Alice is a good subgenius and wants to log onto the Bob.com web page (using the convention, but the real Bob.com seems like a real Saint of Sales!). She puts her userid and her password, which pass to the server.
So, Mallory could sniff the network and grab the password that way, because the general machine on the network serves HTTP, not HTTPS, which sucks to the depth and the breadth and the height my soul can reach. And only marginally better, you can't really hash it in javascript and send it that way. Perl's Digest::MD5 module is compiled in C because speed-wise, it'd suck otherwise, and I can just imagine how badly a Javascript implementation of MD5 would suck.
OK, clearly, you store the password in hashed form only, and clearly you start thinking about switching to something less theoreticallyy pwned than SHA1 or MD5. So, the best solution I've seen is to store the userid and a long random cookie, and always forcing a password on significant uses, like posting or whatever. This makes sense to me. The threat from Mallory is lessened but still there, because the password is still being passed in the clear. And so, the depth and the breadth and the height....
And yes, this is more web standards questioning than Perl questioning, but I do intend to code this thing in Perl. --DaveJacoby
# revised regex-count.pl 2006-09-14 18:21 Mark Senn http://www.ecn.purdue.edu/~mark # created regex-count.pl 2006-09-13 12:00 Mark Senn http://www.ecn.purdue.edu/~mark # # Perl 5: Count occurrences of regular expression in a string. # # Question: How to count the number of occurrences of something in a string? # Answer: The program below uses the same basic idea to show how to solve the problem # four different ways in Perl 5. # $string = 'x a x xax'; # (1) # Count the number of x's. # Put them in () and evaluate the array in scalar context. # Evaluating the array in scalar context returns the length of the array. $_ = $string; $count = () = /(x)/g; print qq/(1) $count "$_"\n/; # (2) # Same as (1) but don't use a $count temporary variables. print qq/(2) /, scalar(() = /(x)/g), qq/ "$_"\n/; # (3) # Same as (1) but do it on $a instead of $_. # "=~" binds tighter than "=". $a = $string; $count = () = $a =~ /(x)/g; print qq/(3) $count "$a"\n/; # (4) # Same as (2) but do it on $a instead of $_. # "=~" binds tighter than "=". print qq/(4) /, scalar(() = $a =~ /(x)/g), qq/ "$a"\n/; # The method at # http://www.perl.com/doc/FAQs/FAQ/oldfaq-html/Q4.24.html # may be faster. I don't like it as well because of # the "while" loop though. Don't forget to set the $count # variable to zero before starting the loop each time.
prints
(1) 4 "x a x xax" (2) 4 "x a x xax" (3) 4 "x a x xax" (4) 4 "x a x xax"
my $text = 'abracadabra' ;
print length join "" , $text =~ m{a|b}gmx ;My first instinct is to go for an s{a}{b} kind of thing:
$text =~ s{a|b}{$i++}ge ;
print $i ;-- DaveJacoby
I'm working on my spy code, and one of the things I'm doing is calling an outside program to do certain things, like send email and harvest links off mp3 blogs, and I decided that having the program fork that stuff would be good, so that long-running processes can run while the later spies spy. But because I haven't really done forking for years and then in a client-server context, My fork code, from lines 146-153 of my Spy example code:
if ( $action ) {
my $kid = fork ;
if ( !defined $kid ){ print_log qq(fork fail: $!\n) ; }
if ( $kid ) {
print_log qq(THIS IS THE FORK) ;
print_log join " " , qx(pwd) , $action , $target , $url ;
print_log qx( .spy_tools/$action -t "$target" -u "$url" ) ;
print_log qq(THIS IS THE FORK) ;
kill(TERM => $kid ) ;
}
}I don't want to be a necromancer. Any pointers toward better fork coding? -- DaveJacoby
local $SIG{CHLD}; # = sub { wait };
if (defined($pid = fork)) {
if ($pid) { #parent
# wait;
waitpid $pid, 0;
} else { #child
# note, this exec isn't necessary if
# inactivity_timeout is 0. On the Mac I'd
# suggest, we set it always to 0.
exec $system;
}The errors I see include putting the activity I wanted forked in the parent part, not the child part, I wouldn't doubt there's more. -- DaveJacoby
[http://slashdot.org/ SlashDot]
Adding a pair of single quotes around something makes it italic, like this:
''italics''
So putting them around the square brackets of a link looks like this:
''[http://slashdot.org/ SlashDot]''
And works like this:
SELECT rant_id FROM rants ;
and play around with the big array you feed it into to get the specific rant_ids you want, or should you do this:
SELECT rant_id FROM rants LIMIT 20,10 ;
or the like to specify and get a smaller array? --DaveJacoby