Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here are some methods that do not require manually escaping the perl statement: <br/>(Disclaimer: I'm not sure how robust these are &ndash; they haven't been tested extensively)</p> <ol> <li><p>Cat-in-the-bag technique</p> <pre><code>perl -ne "$(cat)" text </code></pre> <p>You will be prompted for input. To terminate <code>cat</code>, press <kbd>Ctrl</kbd>-<kbd>D</kbd>.</p> <p>One shortcoming of this: The perl statement is not reusable. This is addressed by the variation:</p> <pre><code>$pline=$(cat) perl -ne "$pline" text </code></pre> <p><br/></p></li> <li><p>The bash builtin, <code>read</code></p> <p>Multiple lines:</p> <pre><code>read -rd'^[' pline </code></pre> <p>Single line:</p> <pre><code>read -r pline </code></pre> <p>Reads user input into the variable <code>pline</code>. </p> <p>The meaning of the switches: </p> <ul> <li><code>-r</code>: stop <code>read</code> from interpreting backslashes (e.g. by default <code>read</code> interprets <code>\w</code> as <code>w</code>)</li> <li><code>-d</code>: determines what character ends the <code>read</code> command. <ul> <li><code>^[</code> is the character corresponding to <kbd>Esc</kbd>, you insert <code>^[</code> by pressing <kbd>Ctrl</kbd>-<kbd>V</kbd> then <kbd>Esc</kbd>.<br/><br/></li> </ul></li> </ul></li> <li><p>Heredoc and script.<br/> (You said no scripts, but this is quick and dirty, so might as well...)</p> <pre><code>cat &lt;&lt; 'EOF' &gt; scriptonite print $1 . "\n" if /'(\w+)'/ EOF </code></pre> <p>then you simply</p> <pre><code>perl -n scriptonite text </code></pre></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload