This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
my $str = '.,a..A,,C..+4ACGTG.,-2TG,,...,a.'; | |
print replace($str); | |
sub replace { | |
my $str = shift; | |
if ($str =~ m/([+-])(\d+)/) { | |
$str =~ s/\Q$1\E$2.{$2}//; | |
return replace($str); | |
} | |
return $str; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
my $delim = $/; | |
undef $/; | |
my $file = <DATA>; | |
$/ = $delim; | |
$file =~ s/(<%--)?\s*<script(.*?)>/($1 ? '' : "\n<%-- ") . "<script$2>"/ige; | |
$file =~ s=</script>\s*(-->)?='</script>' . ($1 ? '' : " -->\n")=ige; | |
print $file; | |
__DATA__ | |
<script type="java/js"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! perl | |
print <DATA>; | |
__DATA__ | |
<some> <markup> | |
$this = 'that' | |
This is me | |
testing how gist | |
marks up data token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! perl | |
# encode a string/file in Base64 in pure Perl | |
# edit: cleaner (but non-buffered) version @ http://cpansearch.perl.org/src/GAAS/MIME-Base64-Perl-1.00/lib/MIME/Base64/Perl.pm | |
use strict; | |
use Getopt::Std; | |
use File::Temp qw/tempfile/; | |
# get and process command line options | |
my %opts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# current solution using map and autosplit - 80 | |
#!perl -pa | |
map{$c[$i++]+=$_;$r[$j]+=$_}@F;$i=0;$j++}{$_=(sort{$a<=>$b}@r,@c)[-1] | |
######################################### | |
=pod | |
old solutions and scratch | |
# run switch solution - 102 | |
#!perl -an |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# current solution - regex - 85 | |
#!perl -p | |
1while(s/((\d+)-)?(\d+)\.? (\d+)/$3==$4-1?"@{[$2||$3]}-$4.":"$1$3, $4."/e) | |
###################################################################################### | |
=pod | |
# scratch and previous solutions | |
while(s/(\d+)?-?(\d+),? (\d+) \?/$2==$3-1?"@{[$1||$2]}-$3, ":"$2, $3, "/e){} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
# import data from master to changedb | |
# changedb implements columns for filenumber, filedate and updateflag | |
use strict; | |
use Getopt::Long; | |
use DBI; | |
my $dbh; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- delete an entire row_id | |
delete from rows_of_cols | |
where row_id in ( | |
select row_id from rows_of_cols | |
where [filter condition]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# current solution using local minima/maxima algorithm - 222 | |
@z=split' ',<>;while(!$t){$t==$_-1?$t=$_:($t=0,last)for@z=(f(shift@z),@z)}sub f{$i++;my($p,$c)=(pop,shift@z);if(($p<$c&&$c>$z[0])||($p>$c&&$c<$z[0])||$#z==-1){if($i+1!=$l){$l=$i+1;print"$l ";$i=0;return($c,$p)}}(f($c),$p)} | |
=pod | |
@z=qw(30 13 19 23 18 11 21 8 10 4 29 14 31 27 1 9 22 32 7 2 25 12 17 33 5 26 16 6 35 3 24 28 34 15 20); | |
while (!$t) { | |
$t==$_-1?$t=$_:($t=0,last) for @z=( func(shift@z), @z); | |
#map {$t==$_-1?$t++:0} @z=( func(shift@z), @z); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# current solution using regex - 90 | |
#!perl -p0 | |
for$i(0,7..9){for$j(1..7){$c+=()=/(?=(?:_.{$i}){$j}Q|Q(?:.{$i}_){$j})/sg}}$_=$c | |
=pod | |
$/=0;$z=<>; | |
while($i++<7){ | |
$c+=()=$z=~/(?=$_)/sg for( | |
('_'.'.'x7)x$i.'Q', | |
('_'.'.'x9)x$i.'Q', |