Created
July 13, 2012 00:51
-
-
Save swuecho/3102084 to your computer and use it in GitHub Desktop.
simulate the interact function in Haskell
This file contains hidden or 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
| #!/usr/bin/perl | |
| use 5.010; | |
| use strict; | |
| use warnings; | |
| use autodie; | |
| use Path::Class; | |
| #use Simple::IO; | |
| my $dir = dir("C:\\Users\\echo\\Dropbox\\bioinfo"); # /tmp | |
| my $file = $dir->file("scope.pl"); | |
| my $content_proc= sub { | |
| my $contents=shift; | |
| length($contents); | |
| }; | |
| # file_in and methods | |
| sub interact_content { | |
| my $file=shift; | |
| my $fun=shift; | |
| my $content = $file->slurp(); | |
| say $fun->($content); | |
| } | |
| my @lines = $file->slurp(chomp => 1); | |
| interact_content($file,$content_proc); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment