Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl on U3 flash drive

Status
Not open for further replies.

rvBasic

Programmer
Oct 22, 2000
414
BE
Does there exist a Perl version that can be installed on and run from a U3 Flash Drive (e.g. SanDisk USB stick?)

_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 

Perl needs and operating system to run. You could install perl in any directory/drive, so you could have all installation files under the USB drive. e.g F:\Perl. But you have to use same PC where you installed perl to run your perl scripts. Some environment variales like $PATH etc are configured automatically during perl installation.



dmazzini
GSM/UMTS System and Telecomm Consultant

 
Yes, I'm aware of the $PATH, ... variables that perl adds into the operating system. But some softwares (most notably OpenOffice) manage to be independent and portable (cfr: I wondered if some version of Perl could do the same trick?

_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
I would think you could run the core perl with no problems. I don't know about modules and such with out adding code to the scripts.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
U3 smart drive programs will dynamically add system (i.e. path,..) or file information when the application starts and delete it upon removal of the flash drive. There exist SDKs to upgrade your application (why not Perl?) to that smart behaviour. See e.g.
Unfortunately I'm not that technically qualified to implement it [sad] Hopefully some smart guy on this forum will take up the challenge.



_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
I've successfully done this in a couple of different ways. The one I'm most happy with involves the following (NOTE: This is from the WinX perspective .. any *nix system worth it's salt would simply accept your *.pl file like an old friend)
[ul][li]Place a copy of perl onto your USB drive. If you're comfortable with this, put it anywhere. If not, build a /usr/bin/perl directory and place it under there. I've successfully done this with ActiveState's version of perl. Just xcopy the files. No need to install it into the USB drive. You'll break the ppm utility that comes with ActiveState's perl (which is pretty slick in itself) but your main PC where perl is installed will still be updateable (and copy-able) if needed.[/li]
[li]If you're not familiar with batch programing, goto the next bullet. In a 'bat' file place the following
Code:
@rem = '--*-Perl-*--
@echo off
if "%OS%" == "Windows_NT" goto WinNT
E:\usr\bin\perl\bin\perl.exe -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofperl
:WinNT
E:\usr\bin\perl\bin\perl.exe -x -S %0 %*
if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
if %errorlevel% == 9009 echo You do not have Perl in your PATH.
if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
goto endofperl
@rem ';
#!/usr/bin/perl -w
# your perl code goes here
__END__
:endofperl
There are two real tricks here: Since we're putting this into a *.bat file, WinX will start marching through it as if it is one of it's native batch files. The goto's will effectively cause it to simply branch around all of your perl code. Note that within the 'native' batch code, we're calling perl via the <path/perl.exe> <your code file> method, where <your code file> is the .bat file itself. The second part is that since the first 15 lines (or so) is also valid perl code, the perl interpreter simply sucks it up and otherwise ignores it. (cover up everything between the two @rem statements and what do you see!)[/li]
[li]If you're not familiar with batch programming, you can always type out the <path/perl.exe> <your code file> at a command prompt. I'm going to be a bit of a jerk about this but if you want your program to be user friendly and you want them to just point and click - review the above bullet and learn your craft[/li]
[li]Caveat with the above - WinX is notorious for assigning any letter it pleases to your USB drive when you plug it in. If you're careful / consistent with where you place your source code on the USB, you can use relative path names[/li][/ul]

If someone out there has a cleaner way to do this, I'm always looking for ways to make my life easier - please pass it along. There probably is some *.vbs code that could be wrapped around this to make it a little more bullet proof, but right now I've got bigger fish to fry.
 
Went back and re-read that last post - Wanted to state that I'm not poking jabs at anyone in particular when I said "learn your craft" ... I'm just soapboxing a little this morning. Had a support tech in for a site visit yesterday to work with a specialized piece sfwr/hdwr. Took me about two minutes to figure out he knew less about it than I did.

Please, no offense to anyone in this forum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top