Hi,
Can anyone advise please on whether it’s possible to run Perl scripts within Sublime Text and if so, how do I do that? Thanks for any advice.
Best wishes,
John
Hi,
Can anyone advise please on whether it’s possible to run Perl scripts within Sublime Text and if so, how do I do that? Thanks for any advice.
Best wishes,
John
Basically you have 2 options
Option 1: Sublime Build System
You can create a Packages/User/Perl.sublime-build file with the following content.
{
"shell_cmd": "perl \"${file}\"",
"selector": "source.perl",
"variants":
[
{
"name": "Syntax Check",
"shell_cmd": "perl -c \"${file}\"",
"file_regex": "^.*? at (.*?) line ([0-9]+)",
}
]
}
This enables you to run unattended scripts via F7 or Ctr+B.
Option 2: Terminus
You can install Terminus Package.
Hi,
Thanks for your reply. To be honest, this is all a bit over my head and I can foresee trouble ahead if I try to do this. I had hoped there would be a simple (ish) fix, but I have no idea how to do any of the above. Thanks anyway for your advice.
Regards,
John
This is a re-telling of DeathAxe’s suggestion:
Perl.sublime-build
.If you’re on Mac, the menu in Step 1 is under “Sublime Text,” and in Step 5, use Cmd+B
You can also select Tools > Build System > New Build System...
from the menu. That creates a stub file for you that has the appropriate syntax set automatically and sets up the buffer to save as the right file type directly into your User
package when you save.
Hi Michael,
Thank you for your advice - I’ll give that a try (probably tomorrow or Monday) and see if I can get it to work. Will post an update of how it goes.
One quick query - DeathAxe mentioned that this solution would allow ‘unattended’ scripts to run. I’m not clear about the terminology, but I suspect it means that I would not be able to interact with the script, as in typing in a response to a query. Is that right? If so, is there any way that the code could be modified so as to allow for this?
Thanks again for your advice.
Regards,
John
Hi Odat,
Thanks for your post. That’s given me another avenue to explore in order to get this to work. Much appreciated.
Regards,
John
You suspect correctly, and no, there is not a way that I am aware of. Instead, install the Terminus package (DeathAxe’s “Option 2”), and make a build system for it. This is my untested, seat-of-the-pants guess at what that build system looks like, combining DeathAxe’s post with the Terminus suggestion for a project-specific build system:
{
"shell_cmd": "perl \"${file}\"",
"selector": "source.perl",
"target": "terminus_open",
"working_dir": "$folder",
"auto_close": false
}
Hi Michael,
I tried your first suggestion (creating new text file 'Perl.sublime-build) and I’m happy to say that has worked perfectly. I’m really pleased - thank you for that.
As we suspected though, it doesn’t allow me to run interactive scripts. Although this shouldn’t be a huge problem, I’d quite like to have a go at DeathAxe’s ‘Option 2’. I’ve installed the Terminus package as required, but am unclear about how to go about making a build system for it. Can you advise on this at all? Where would I paste the text you mentioned in your last post?
If you could even just point me to some relevant reading material, that would be great.
Thanks again for your help.
Regards,
John
Replace the Perl.sublime-build
you just made with the snippet from my post. I’m sorry, but I can’t guarantee that it works. (I don’t actually use Terminus.)
If you have trouble, you could try digging through the samples and documentation on the Terminus package’s GitHub. If you still can’t work it out, you could ping the author in this thread by including “@
randy3k” in a reply. Please try to get it working on your own before sending Randy a ping.
Good luck!
Hopefully you’ve gotten yourself sorted by now. But if not, here’s OdatNurd demonstrating a Terminus build system:
Hi Michael,
Thanks for sending me that information (and sorry for not replying earlier - been away for a while). I never did get the interactive terminal working, but it’s something I can live with. However, I’ll have a look at the SublimeREPL package and maybe have another try.
Thanks again and best wishes,
John