Skip to content

Commit

Permalink
no need to write to disk just use IO::Scalar
Browse files Browse the repository at this point in the history
  • Loading branch information
schelcj committed Oct 1, 2012
1 parent a2636ef commit f22efc5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
18 changes: 7 additions & 11 deletions create.pl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use WWW::Mechanize;
use Net::Netrc;
use Readonly;
use File::Slurp;
use File::Slurp qw(read_file);
use File::Temp;
use IO::Scalar;
use Data::Dumper;
Expand All @@ -18,13 +18,12 @@
Readonly::Scalar my $DIRECTIONS => q{Hello World};
Readonly::Scalar my $SUMMARY => q{Goodbye World};

my $latex = $ARGV[0]; # TODO - use getopts
my $lesson_name = q{2013}; # TODO - get from command line arg
my $title = q{SPH Algebra Assesment for 2013}; # TODO - get from command line arg
my $agent = get_login_agent();
my $latex = $ARGV[0]; # TODO - use getopts
my $lesson_name = q{2013}; # TODO - get from command line arg
my $title = q{SPH Algebra Assesment for 2013}; # TODO - get from command line arg
my $agent = get_login_agent();
my $question_ref = parse_latex($latex);


print Dumper $question_ref;
exit;

Expand All @@ -41,13 +40,10 @@ sub parse_latex {

$contents =~ s/^(?:(.*)?\\begin{document})|(?:\\end{document})$//gs;

write_file($temp_fh->filename, $contents);

{
local $/ = q{%QUESTION };
foreach my $line (read_file($temp_fh)) {
push @questions, $line;
}
my $content_fh = IO::Scalar->new(\$contents);
@questions = map {$_} $content_fh->getlines;
}

foreach my $question (@questions) {
Expand Down
9 changes: 3 additions & 6 deletions parse.pl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env perl

use Modern::Perl;
use File::Slurp;
use File::Slurp qw(read_file);
use File::Temp;
use IO::Scalar;
use Data::Dumper;
Expand All @@ -14,13 +14,10 @@

$contents =~ s/^(?:(.*)?\\begin{document})|(?:\\end{document})$//gs;

write_file($temp_fh->filename, $contents);

{
local $/ = q{%QUESTION };
foreach my $line (read_file($temp_fh)) {
push @questions, $line;
}
my $content_fh = IO::Scalar->new(\$contents);
@questions = map {$_} $content_fh->getlines;
}

foreach my $question (@questions) {
Expand Down

0 comments on commit f22efc5

Please sign in to comment.