Skip to content

Instantly share code, notes, and snippets.

@Freezerburn
Created July 25, 2016 17:36
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 Freezerburn/e383f4c1b797b720653c472044c59620 to your computer and use it in GitHub Desktop.
Save Freezerburn/e383f4c1b797b720653c472044c59620 to your computer and use it in GitHub Desktop.
my $filename = 'test.ftl';
my $grep-filename = $filename.split('.')[0 ..^ *-1] # Get the filename part: foo.bar.ftl -> (foo bar)
.join('') # Make it a string: (foo bar) -> 'foobar'
.split('') # Make it a list: 'foo' -> ( f o o )
.map({ '.*' ~ $^a })[1 .. *] # Add regex wildcards and remove extraneous string: ( f o o ) -> (.*f .*o .*o .*)
.join('') # Turn it back into a string: (.*f .*o .*o .*) -> '.*f.*o.*o.*'
~ $filename.split('.')[*-1]; # Add the file ending back in: '.*f.*o.*o.*.ftl'
@Freezerburn
Copy link
Author

Error is at line 5 '.map ...'. Commenting that line out will run fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment