Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Running perl scripts on the fly (http://www.velocityreviews.com/forums/t902694-running-perl-scripts-on-the-fly.html)

jrosik@gmail.com 04-14-2007 10:42 PM

Running perl scripts on the fly
 
Hi all,

I would like to run perl scripts as in the following scenario:

1. I open a text editor - for example Notepad, Wordpad, Word.
2. I paste some text into this text editor.
3. I press a magic key - let's say I double press the Shift key.
4. A magic window appears and I enter the following script:
while (<>) {
s/you/You/;
print;
}
5. I execute the script.
6. Now there are two text editor windows - one with the source text
and another with the output text.

Is this possible?

One note: I have not saved any document during my scenario!

Regards,
Jiri Rosicky


krakle@visto.com 04-15-2007 06:38 AM

Re: Running perl scripts on the fly
 
On Apr 14, 4:42 pm, jro...@gmail.com wrote:
> Hi all,
>
> I would like to run perl scripts as in the following scenario:
>
> 1. I open a text editor - for example Notepad, Wordpad, Word.
> 2. I paste some text into this text editor.
> 3. I press a magic key - let's say I double press the Shift key.
> 4. A magic window appears and I enter the following script:
> while (<>) {
> s/you/You/;
> print;
> }
> 5. I execute the script.
> 6. Now there are two text editor windows - one with the source text
> and another with the output text.
>
> Is this possible?
>
> One note: I have not saved any document during my scenario!
>
> Regards,
> Jiri Rosicky


Check out SciTe!


Mumia W. 04-15-2007 07:33 AM

Re: Running perl scripts on the fly
 
On 04/14/2007 05:42 PM, jrosik@gmail.com wrote:
> Hi all,
>
> I would like to run perl scripts as in the following scenario:
>
> 1. I open a text editor - for example Notepad, Wordpad, Word.
> 2. I paste some text into this text editor.
> 3. I press a magic key - let's say I double press the Shift key.
> 4. A magic window appears and I enter the following script:
> while (<>) {
> s/you/You/;
> print;
> }
> 5. I execute the script.
> 6. Now there are two text editor windows - one with the source text
> and another with the output text.
>
> Is this possible?
>
> One note: I have not saved any document during my scenario!
>
> Regards,
> Jiri Rosicky
>


It sounds like you want an IDE (Integrated Development Environment) for
Perl. Do a yahoo search for it.

However, the Perl debugger might suffice for some of your needs, e.g:

C:\> perl -de 42

Read the "perldebug" document:

Start->Run->"perldoc perldebug"


HTH

--
Count the YOYOs:
http://home.earthlink.net/~mumia.w.18.spam/games_fever/

jrosik@gmail.com 04-15-2007 06:21 PM

Re: Running perl scripts on the fly
 
Yes Len, I need to do more complex things. The scenario can look like
this:

1. I open a text editor - for example Notepad, Wordpad, Word.
2. I paste some text into this text editor.
3. I press a magic key - let's say I double press the Shift key.
4. A magic window appears and I enter the following script:
while (<>) {
next if (/Start ignoring HERE/) .. (/End ingnoring HERE/);
s/AAA(\d+)(.+?)BBB(\d+)/AAA$3$2BBB$1/;
print;
}
5. I execute the script.
6. Now there are two text editor windows - one with the source text

Another variant of the 4th step could be just the removal of comment
marks from the line beginnings:
4.
while (<>) {
s/^> >//;
print;
}

I am trying to accomplish the most simple way to filter text data
using perl script.

The text data usually come from a "text editor" (it also can be a web
form). I need to pick the data -> process it -> put it back as
simple / fast as possible.

The problem with common perl filtering process is that:
- I need to save the source data somewhere,
- I need to save the perl script somewhere,
- I need to execute the perl script .. "perl script.pl data.txt",
- I need to capture the output,

Regards,
Jiri Rosicky

l v napsal:
> jrosik@gmail.com wrote:
> > Hi all,
> >
> > I would like to run perl scripts as in the following scenario:
> >
> > 1. I open a text editor - for example Notepad, Wordpad, Word.
> > 2. I paste some text into this text editor.
> > 3. I press a magic key - let's say I double press the Shift key.
> > 4. A magic window appears and I enter the following script:
> > while (<>) {
> > s/you/You/;
> > print;
> > }
> > 5. I execute the script.
> > 6. Now there are two text editor windows - one with the source text
> > and another with the output text.
> >
> > Is this possible?
> >
> > One note: I have not saved any document during my scenario!
> >
> > Regards,
> > Jiri Rosicky
> >

>
> Are you trying to run more complex Perl scripts than what you listed in
> step 4? If not, the magic key in notepad is Control-H.
>
> What are you really trying to accomplish?
>
> --
>
> Len



Jim Ford 04-15-2007 08:13 PM

Re: Running perl scripts on the fly
 
jrosik@gmail.com wrote:
> Hi all,
>
> I would like to run perl scripts as in the following scenario:
>
> 1. I open a text editor - for example Notepad, Wordpad, Word.
> 2. I paste some text into this text editor.
> 3. I press a magic key - let's say I double press the Shift key.
> 4. A magic window appears and I enter the following script:
> while (<>) {
> s/you/You/;
> print;
> }
> 5. I execute the script.
> 6. Now there are two text editor windows - one with the source text
> and another with the output text.
>
> Is this possible?
>
> One note: I have not saved any document during my scenario!


I believe you can do just this sort of thing easily with the Plan9 O.S..
Try running Plan9 with Qemu and have a fiddle - it's weird, but fun!

Jim Ford

JussiJ 04-17-2007 03:55 AM

Re: Running perl scripts on the fly
 
On Apr 15, 8:42 am, jro...@gmail.com wrote:

> I would like to run perl scripts as in the following scenario:
>
> 1. I open a texteditor- for example Notepad, Wordpad, Word.
> 2. I paste some text into this texteditor.
> 3. I press a magic key - let's say I double press the Shift key.
> 4. A magic window appears and I enter the following script:
> while (<>) {
> s/you/You/;
> print;
> }
> 5. I execute the script.


FWIW the Zeus IDE can be configured to do this.

The "magic window" would be nothing more than a new or existing
document window and the "magic key" would be any key bound to
a Zeus macro.

For example this macro script:

http://www.zeusedit.com/forum/viewtopic.php?t=220

does something very similar for SQL scripts. It takes the text
from the current document and sends it to iSql and captures the
output.

So all that is needed is the command line contained in the script
is changed to run Perl instead of iSql.exe utility.

> 6. Now there are two texteditorwindows - one with the source text
> and another with the output text.


In the case of Zeus you would be left with the original document
window and a new tool output window containing the output generated
by the perl script.

> Is this possible?


Yes.

> One note: I have not saved any document during my scenario!


Zeus will run the script whether the document is save or not saved.

Jussi Jumppanen
Author: Zeus for Windows IDE


jrosik@gmail.com 05-24-2007 09:10 PM

Re: Running perl scripts on the fly
 
Jussi,

I have tried Zeus and the example of a macro running iSql.exe. I did
not figure out where to place the perl script. Actually I need two
windows - one with the text to process and another one with the perl
script. The "iSql.exe" macro example operates only with one window.

Jiri


JussiJ napsal:
> On Apr 15, 8:42 am, jro...@gmail.com wrote:
>
> > I would like to run perl scripts as in the following scenario:
> >
> > 1. I open a texteditor- for example Notepad, Wordpad, Word.
> > 2. I paste some text into this texteditor.
> > 3. I press a magic key - let's say I double press the Shift key.
> > 4. A magic window appears and I enter the following script:
> > while (<>) {
> > s/you/You/;
> > print;
> > }
> > 5. I execute the script.

>
> FWIW the Zeus IDE can be configured to do this.
>
> The "magic window" would be nothing more than a new or existing
> document window and the "magic key" would be any key bound to
> a Zeus macro.
>
> For example this macro script:
>
> http://www.zeusedit.com/forum/viewtopic.php?t=220
>
> does something very similar for SQL scripts. It takes the text
> from the current document and sends it to iSql and captures the
> output.
>
> So all that is needed is the command line contained in the script
> is changed to run Perl instead of iSql.exe utility.
>
> > 6. Now there are two texteditorwindows - one with the source text
> > and another with the output text.

>
> In the case of Zeus you would be left with the original document
> window and a new tool output window containing the output generated
> by the perl script.
>
> > Is this possible?

>
> Yes.
>
> > One note: I have not saved any document during my scenario!

>
> Zeus will run the script whether the document is save or not saved.
>
> Jussi Jumppanen
> Author: Zeus for Windows IDE




All times are GMT. The time now is 12:51 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.