Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open dialogue with a bare bones version of Perl

I have a bare bones installation of Perl and I would like to create an dialogue box asking for a file and/or folder location to run the script on/in.

This is my work computer and I needed permission to install Perl - IT ignored my request (they didn't deny it). I happened to find a stripped down version of Perl installed with another program and have been using that to script with. It had exactly 3 modules and I added strict and warnings.

I understand that there are modules out there to do this (TK being the most popular), but they are dependent upon other modules (AutoLoader, DynaLoader, ...) which are probably dependent upon others. Sneaking two modules in was one thing...sneaking a dozen+ is another.

Edit (from below): Another complication. My immediate team members use my scripts and they all have the bare-bones install of Perl, because they all have the parent program. The first time someone uses one of my Perl scripts I set the file association and add strict and warnings (so I don't have to remember to comment them out). Thus - I would like to keep as simple of a setup as possible.


All my scripts currently run on the folder they are located in. This is getting unwieldy due to changes in the scripts over time. My current plan is to utilize a prompt on the command line - having the user copy the file path from windows explorer and then analyzing it with regex. I foresee a couple issues with this:

  • Pasting into a command prompt is annoying
  • Need to be careful about crossing network drives (C > G > N)
  • spaces/weird characters/slashes going the right way
  • Making sure the script operates in the "new" input location

This seems doable, yet I wanted to see if there would be a friendlier way to do this (esp to get around the command prompt paste annoyance).

Hopefully the question isn't too broad for this forum - if not I'll come back later with some attempted code.


OS: Windows 7 Professional (64 bit)

Perl: ActiveState Version 5.6.0 (downloaded Feb 21, 2001)

Modules currently available: Exporter, RE, utf8, strict & warnings. Generally this works well enough since I'm typically just doing file manipulations.

like image 465
LadyCygnus Avatar asked Apr 29 '14 18:04

LadyCygnus


1 Answers

You're not going to get much out of a 13 year old version of Perl that may not even include all of the 5.6 modules. Is this perchance a Rational package that installed this version of Perl? If it's ClearCase, there's a program called clearprompt. You can try that.

I know this isn't what you want to here, but forget about Perl, and try it in PowerShell.

PowerShell is an under utilized programming language created by Microsoft specifically for Windows. It is a full fledge programming language that integrates tightly with Windows. It is highly object oriented. It can display dialog boxes And, most importantly, it comes on all Windows Machines since Windows XP. This means that if you write a PowerShell application, all of your colleagues can use it.

My entire Powershell experience consists of three programs. I usually work in Unix/Linux environments and mainly on the server side. However, we had a client that needed a special script to monitor some processes and to email support if these processes weren't updated in certain time frames.

It would be a cinch to do in Perl, but they didn't have Perl or Python and I was told that nothing could be installed on these systems. I had to use whatever tools were already there, so my only choice was PowerShell.

In the end, Powershell worked pretty well and it wasn't that difficult to pick up. My main problem is that all I could find was PowerShell 2 documentation, but the servers where the script had to run were using PowerShell 1. Even worse, my system has PowerShell 2, so I would run a script on my system, then found it didn't work on the customer's system. However, I did get the hang of PowerShell and still delivered the program to the customer on time.

If you know VB, the PowerShell syntax should be fairly familiar, but even if you're not familiar with VB, you shouldn't have any problems picking up the syntax if you've done any object oriented programing. So, as much as I like programming in Perl, you are in an environment that is very limited. Might as well use the tools that the environment provides you.

like image 166
David W. Avatar answered Oct 01 '22 03:10

David W.