Running perl scripts on the fly

Discussion in 'Perl Misc' started by jrosik@gmail.com, Apr 14, 2007.

  1. Guest

    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
     
    , Apr 14, 2007
    #1
    1. Advertising

  2. Guest

    On Apr 14, 4:42 pm, 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!
     
    , Apr 15, 2007
    #2
    1. Advertising

  3. Mumia W. Guest

    On 04/14/2007 05:42 PM, 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/
     
    Mumia W., Apr 15, 2007
    #3
  4. Guest

    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:
    > 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
     
    , Apr 15, 2007
    #4
  5. Jim Ford Guest

    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
     
    Jim Ford, Apr 15, 2007
    #5
  6. JussiJ Guest

    On Apr 15, 8:42 am, 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
     
    JussiJ, Apr 17, 2007
    #6
  7. Guest

    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, 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
     
    , May 24, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hal Vaughan

    Running Perl Scripts

    Hal Vaughan, Jan 22, 2004, in forum: Javascript
    Replies:
    5
    Views:
    136
    Hal Vaughan
    Jan 22, 2004
  2. Lisa
    Replies:
    19
    Views:
    297
    A. Sinan Unur
    Dec 19, 2004
  3. Replies:
    13
    Views:
    580
    Anno Siegel
    Sep 10, 2007
  4. Brian

    Fly outmenu on the fly

    Brian, Apr 8, 2005, in forum: Javascript
    Replies:
    0
    Views:
    127
    Brian
    Apr 8, 2005
  5. yawnmoth
    Replies:
    2
    Views:
    107
    Lasse Reichstein Nielsen
    Jul 8, 2006
Loading...

Share This Page