1

I have this perl script.

perl -i -0pe 's/^Insert\s*(.*)\.png\s*\n([^\n]*)$/!\[\2](..\/figures\/\1-tn.png)/mg' */*.markdown

This works fine with MacOS X, but when I execute this command on Windows 10, I have the following error message:

C:\Users\hello\Desktop\progit\en>perl -i -0pe "s/^Insert\s*(.*)\.png\s*\n([^\n]*)$/!\[\2](..\/figures\/\1-tn.png)/mg"
*/*.markdown

Can't open */*.markdown: Invalid argument.

What might cause this issue on Windows 10? I use Strawberry Perl on Windows.

prosseek
  • 182,215
  • 215
  • 566
  • 871
  • windows does not use '/', but '\' as a delimiter. I remember it used to tolerate it at times, but that may be the issue. I don't have one to test this atm, though. You might also want to check your regex for that same problem! – bytepusher May 31 '17 at 23:23

2 Answers2

0

This is not a Strawberry issue. It's a shell issue. Bash will gladly expand multiple wildcards into long lists of command line parameters. Microsoft's shells not so much.

tjd
  • 4,064
  • 1
  • 24
  • 34
-1

When I tried the Perl from MinGW, there is no error. The Cygwin based perl doesn't seem to have the problem (or bypass this problem).

Also refer to: Multi-line regular expression issue in Perl on Windows 10.

prosseek
  • 182,215
  • 215
  • 566
  • 871