Skip to content

Instantly share code, notes, and snippets.

@thundergnat
Created January 29, 2023 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thundergnat/ff2f5e228fdb05c6a3bb680b28e9e68c to your computer and use it in GitHub Desktop.
Save thundergnat/ff2f5e228fdb05c6a3bb680b28e9e68c to your computer and use it in GitHub Desktop.
sub ValidateLineType($ln) returns Int {
my $lt = $ln.split( /<ws>/, :skip-empty )[0];
($lt ~~ 0..5) ?? $lt.Int !! -1
}
my @fp = # open "data.ldr", :r;
#Meh, just load some data into the array
"0 0\n1 0\n2 0\n3 0\n4 0\n5 0\n6 0\n12 5\n3 3\n4\t\t3\n".lines;
say .&ValidateLineType for @fp;
my $currentline = 0;
say my $linetype = ValidateLineType(@fp[$currentline]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment