daggett has asked for the wisdom of the Perl Monks concerning the following question:

I have searched the Internet (1) and am unable to find how to read from the memory buffer from which I have copied text (using Ctrl-C, Select->Copy, ...) into a perl script. (2)

An example would be, from news.google.com, the story "Bank dividends may not be sacrosanct after all" at http://www.smh.com.au/business/banking-and-finance/bank-dividends-may-not-be-sacrosanct-after-all-20150930-gjy7hk.html (3) .

I would like to transform the above title into :

BankDividendsMayNotBeSacrosanctAfterAll

... and ultimately into :

20151001_smh_BankDividendsMayNotBeSacrosanctAfterAll.html

... which would be the name of the file to which I would save the HTML.

Footnote

(1) I have used the search terms "perl how-to read memory buffer" and "perl how-to read memory buffer -file".

(2) For now, I am trying to write a perl script to run from the command line on an xterm window. I would prefer to create a small rudimentary X11 input form. Is that possible with perl?

(3) Where the URL itself describes the page content, as in the given example, I use text fromm that URL, but many web pages don't have such descriptive URLs. I those cases, I copy the title of the page and begin to laboriously transform the title as I have shown.

  • Comment on How to read from text previously copied into memory buffer into perl script?

Replies are listed 'Best First'.
Re: How to read from text previously copied into memory buffer into perl script? (clipboard)
by Anonymous Monk on Oct 01, 2015 at 00:08 UTC
Re: How to read from text previously copied into memory buffer into perl script?
by perlron (Pilgrim) on Oct 01, 2015 at 05:06 UTC
    Hi
    (1) I have used the search terms "perl how-to read memory buffer" and "perl how-to read memory buffer -file".
    Can you be a bit more explicit with your use case ? what exactly you are trying to achieve by copying the content to your buffer by Ctrl-C, Ctrl-V.
    (2)I would prefer to create a small rudimentary X11 input form. Is that possible with perl?
    I'm only making a suggestion. Try X11::XCB. You should check on metacpan for your need
    (3)...I those cases, I copy the title of the page and begin to laboriously transform the title as I have shown.
    Try HTML::LinkExtractor..Again what exactly is your requirement ? Is it to simplify the transformation of the page/title into the format mentioned ?
    There are n number of string manipulation functions available like join, pack and an exhaustive list in perlfunc.
    I think you need to first come up with a basic flow diagram design OR pseudo code(better) to convey your understanding, and update/rewrite your post with the same, you would get better answers, else you will be constantly iterating and revising your perl code.

    The Great Programmer is one who inspires others to code, not just one who writes great code