http://www.perlmonks.org?node_id=1125764


in reply to Re^3: Reading a huge input line in parts
in thread Reading a huge input line in parts

That's actually a very good idea, haven't thought about this approach.
  • Comment on Re^4: Reading a huge input line in parts

Replies are listed 'Best First'.
Re^5: Reading a huge input line in parts
by Anonymous Monk on May 05, 2015 at 21:48 UTC

    You can also use flex to make a scanner with very little fuss. For example:

    %{ void process(char *tok); %} %option noyywrap %% [0-9]+ process(yytext); [ \t\n]+ /* ignore */ . /* printf("Bad input character: %s\n", yytext); */ %% void process(char *tok) { printf("%d\n", atoi(tok)); } int main(int argc, char **argv) { yyin = stdin; if (argc > 1) yyin = fopen(argv[1], "r"); return yylex(); }

    Just run it through flex and compile the generated lex.yy.c.