Created
April 8, 2011 10:16
-
-
Save smpb/909600 to your computer and use it in GitHub Desktop.
generic Perl stuff
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
# print files in current dir, by date | |
my @files = sort { -M $a <=> -M $b } grep { ! -d } glob "./*"; | |
print "files by modified date:\n"; | |
print "\t$_\n" for @files; |
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
# match valid number | |
($ARGV[0] =~ /^(\d+\.?\d*|\.\d+)$/) ? print "number\n" : print "not number\n"; |
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
# short way to slurp the contents of a file | |
open my $fh, '<', $ARGV[0]; | |
my $slurp = do { local $/; <$fh> }; | |
close $fh; | |
print $slurp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment