|
Browse by Tags
All Tags » Perl (RSS)
-
[quote user="Ren"]From man regex: "To include a literal '-', make it the first or last character, or the second endpoint of a range." [/quote] What do POSIX regex functions have to do with .NET ones? [quote user="Ren"] ~$ perl -e '$_ = "-"; print "x...
-
[quote user="morbiuswilters"]I really hate zero-based indexing. Can't we move on beyond this?[/quote] $[++;
-
[quote]have a website designed in Perl based on LAMP architecture[/quote] and I always thought the P in LAMP stands for PHP. learned something new today
-
too_many_usernames: flop: #!/usr/bin/perl # one word per line, at least 4 characters in a word. $dupl=$count=0; %ana=(); while (<>) { @chars=sort m#(\l[a-z])#gi; next unless @chars>=4; $dupl++ if (++$ana{join("",@chars)}) >1; $count++; } printf "Of %d words %d duplicate anagrams (%5.2f%%...
-
tster: On a related note, 4 is the magic number. Do you know why? because 4 is 4 is 4 is 4! No other number possesses this property! for instance: 10 is 3 is 5 is 4. 11 is 6 is 3 is 5 is 4. in fact, 193 is 21 is 9 is 4. Go figure! write a program to figure out why 4 is the magic number. Sure. #!/usr...
-
makomk: $r->finfo; I suspect the author expected this to set the "last stat buffer" used by the -e _ and -r _ expressions, but from the documentation (I didn't bother testing it, so I could be wrong) it looks as though the finfo method uses some special Apache thingy, not Perl's normal stat builtin...
-
Hmm... -e is an operator, not a function. The guy could have created the function so that he could use it in later HOFs, but probably not. :) I agree that the -e thing is weird. I personally think that Larry should have made an effort to eliminate every conceivable feature of Perl 5 that would leave...
-
Some lovely perl code I inherited. This might seem like a minor offense, but I've got 50K lines of code written by this guy and it is all this ugly. sub fexists { my $fil = shift; if(-e $fil) { return 1; } return 0; }
-
...and the boring but reasonably efficient version, just for the record: sub is_balanced($) { my @stack; foreach my $c (split(//, shift)) { if (@stack && $stack[$#stack] eq $c) { pop(@stack); } else { push(@stack, {'('=>')','['=>']','{'=>'}'}->{$c} || ""); } } @stack == 0; } print...
-
Number 3: sub is_balanced($) { my $s = shift; while ($s =~ s,\(\)|\[\]|\{\},,g) {} length $s == 0; } print is_balanced "()", "\n"; print is_balanced "()[]", "\n"; print is_balanced "({{[]}})", "\n"; print is_balanced "(]", "\n"; print is_balanced "([)]", "\n"; print is_balanced "{{{{", "\n";
|
|
|