MacOSX.com free perl script assoc.

xoot

Got xoot?
Here is how this works:

1) You make a perl script.
2) You distribute it freely within this thread.

Please attach your scripts as text files, and explain how they work.

And, most of all, have fun! :D
 
I'll have to take a look at them -- some of them may be considered to be proprietary, since I wrote almost all of them for work. But if I can edit out any super secret stuff ( ;) ) I'll post them. Give me some time and I'll get at least something up here...
 
My reverse text script (just out of the blue).

Use it to reverse your text. :D

I did this script because I was competing with ksuther's ReverseText program (and because I didn't want to risk installing it on my system).

Note about this thread: You can also modify other people's programs to incorporate more features, or fix bugs.
 

Attachments

  • reversestr.txt
    444 bytes · Views: 14
Save into a text file (MacOSX.com download will make it attachment.php). I use .pl extensions, but it really doesn't matter.

Execute chmod +x filename.

Type ./filename, or perl filename.

Enjoy. :)
 
Here's a really basic one. Comments are in the script. More to come later...
 

Attachments

  • kat.txt
    1 KB · Views: 11
Originally posted by nkuvu
Save into a text file (MacOSX.com download will make it attachment.php). I use .pl extensions, but it really doesn't matter.

Execute chmod +x filename.

Type ./filename, or perl filename.

Enjoy. :)

:D LOL!!!!!!!!!!!!!!!!!

i'm on Windows XP... exactly how do i do such advanced operations?! :D LOL!
 
Sorry, I forgot. :eek:

You don't have Perl built in to the system, I'd suggest going to http://www.activestate.com and downloading their Perl version. The exact link is http://downloads.activestate.com/ActivePerl/Windows/5.6/ActivePerl-5.6.1.631-MSWin32-x86.msi

I gave you the link to skip the registration garbage, but that's optional anyway. It's about an 8MB download, but free.

Double click on that to install (Duh :) ). Once it is all done, do everything I already mentioned, but skip the chmod step. If you have your file associations set properly, you can just type in the filename at a command prompt. Even if you don't have file associations set up, you can type perl filename to run the script.

For file associations, I usually set it to Edit as default. Then I can double click on my Perl scripts and edit them (with your favorite text editor (I can send recommendations if you want)). If you don't change this yourself, the file is automatically run via the Perl interpreter (like running perl filename). The problem with that is that the command prompt window doesn't stick around unless it needs input, so most scripts are pretty useless. I use the command prompt method myself...

If you want further explanation of any of this, feel free to ask -- I've kind of glossed over a lot of detail that I think you can figure out on your own.
 
Here's another script, slightly more complicated than my previous one. ;) Drive mapping is for Windows only -- there isn't a point for OS X. Keep in mind that these scripts were written for work, which is on a Windows machine using ActiveState Perl.
 

Attachments

  • library.txt
    6.9 KB · Views: 2
Of course, you could just get a Mac and Mac OS X, and then install ksuther's text service, which allows you to reverse a piece of text in any Cocoa application, !taht ekil tsuj

.od ot ysae ytterp s'tI

!desrever eb lliw txet eht dna [-dnammoC sserp ,yawyna em rof ,neht dna ,txet eht thgilhgih tsuJ
 
Doh! Darn Windows text!

The scripts posted need to have their line endings converted to run on OS X.
 
*sigh* And each script should have the shebang (#!/usr/bin/perl) added to the first line to be able to be called by ./filename.

But they will work (after line end conversion) with perl filename just fine.

Here's another simple one.
 

Attachments

  • rot13.txt
    956 bytes · Views: 5
Originally posted by simX
Of course, you could just get a Mac and Mac OS X, and then install ksuther's text service, which allows you to reverse a piece of text in any Cocoa application, !taht ekil tsuj
While I appreciate the input (I wouldn't have known about the sevice otherwise), I think you're either A. missing the point or B. being less than serious.

If the only thing you can think of to do with Perl is reverse text, then go check out the service. ;)
 
I'm trying to create a perl reverse text server. You send stuff there and it reverses the text. Cool, huh?

The uncool thing is that i don't know how to program a perl server (insert flame or angry shouting here). Anyone know any web sites that could give a few pointers on this? :confused:
 
Originally posted by xoot
I'm trying to create a perl reverse text server. You send stuff there and it reverses the text. Cool, huh?

The uncool thing is that i don't know how to program a perl server (insert flame or angry shouting here). Anyone know any web sites that could give a few pointers on this? :confused:

Easiest way is to modify your script to take the string from stdin and send the reversed text to stdout. This way you can have it run from inetd without having to worry about networking code.
 
Thanx!

The only question left: How do you run it from inetd?

Attached is the script (designed for inetd).
 

Attachments

  • reverse.txt
    193 bytes · Views: 1
Back
Top