CINXE.COM
Quoting constructs | Raku Documentation
<!DOCTYPE html> <html lang="en" class="fontawesome-i2svg-active fontawesome-i2svg-complete" style="scroll-padding-top:60px"> <head> <title>Quoting constructs | Raku Documentation</title> <meta charset="UTF-8" /> <link href="/assets/images/Camelia.ico" rel="icon" type="image/x-icon"/> <link rel="stylesheet" href="/assets/css/Website.css"/> <link rel="stylesheet" href="/assets/css/css/page-styling-main.css"/> <link rel="stylesheet" href="/assets/css/css/page-styling-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/page-styling-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/css/chyronToggle-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/chyronToggle-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/css/centreToggle-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/centreToggle-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/listf-styling-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/listf-styling-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/options-search-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/css/options-search-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/all.min.css"/> <link rel="stylesheet" href="/assets/css/css/rainbow-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/rainbow-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/css/filtered-toc-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/filtered-toc-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/tm-styling.css"/> <link rel="stylesheet" href="/assets/css/tm-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/tm-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/css/announce-light.css" title="light"/> <link rel="stylesheet" href="/assets/css/css/announce-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/typegraph-styling.css"/> <link rel="stylesheet" href="/assets/css/typegraph-dark.css" title="dark"/> <link rel="stylesheet" href="/assets/css/typegraph-light.css" title="light"/> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.7/dist/css/autoComplete.min.css" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-light.min.css" title="light" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-dark.min.css" title="dark" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script src="/assets/scripts/all.min.js"></script><script src="/assets/scripts/filter-script.js"></script><script src="/assets/scripts/tableManager.js"></script><script src="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.7/dist/autoComplete.min.js"></script><script src="https://cdn.jsdelivr.net/npm/fuzzysort@2.0.4/fuzzysort.min.js"></script><script src="/assets/scripts/options-search.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/haskell.min.js"></script><script src="/assets/scripts/filtered-toc.js"></script><script src="/assets/scripts/page-styling.js"></script><script src="/assets/scripts/rainbow.js"></script><script src="/assets/scripts/announcements.js"></script> </head> <body class="has-navbar-fixed-top"> <div id="Quoting_constructs" class="top-of-page"></div> <nav class="navbar is-fixed-top is-flex-touch" role="navigation" aria-label="main navigation"> <div class="navbar-item" style="margin-left: auto;"> <div class="left-bar-toggle" title="Toggle Table of Contents & Index"> <label class="chyronToggle left"> <input id="navbar-left-toggle" type="checkbox"> <span class="text">Contents</span> </label> </div> </div> <div class="container is-justify-content-space-around"> <div class="navbar-brand"> <div class="navbar-logo"> <a class="navbar-item" href="/"> <img src="/assets/images/camelia-recoloured.png" alt="Raku" width="52.83" height="38"> </a> <span class="navbar-logo-tm">tm</span> </div> <a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="navMenu"> <span aria-hidden="true"></span> <span aria-hidden="true"></span> <span aria-hidden="true"></span> </a> </div> <div id="navMenu" class="navbar-menu"> <div class="navbar-start"> <a class="navbar-item" href="/introduction" title="Getting started, Tutorials, Migration guides"> Introduction </a> <a class="navbar-item" href="/reference" title="Fundamentals, General reference"> Reference </a> <a class="navbar-item" href="/miscellaneous" title="Programs, Experimental"> Miscellaneous </a> <a class="navbar-item" href="/types" title="The core types (classes) available"> Types </a> <a class="navbar-item" href="/routines" title="Searchable table of routines"> Routines </a> <a class="navbar-item" href="https://raku.org" title="Home page for community"> Raku<sup>®</sup> </a> <a class="navbar-item" href="https://web.libera.chat/#raku" title="IRC live chat"> Chat </a> <div class="navbar-item has-dropdown is-hoverable"> <a class="navbar-link"> More </a> <div class="navbar-dropdown is-right is-rounded"> <hr class="navbar-divider"> <a class="navbar-item js-modal-trigger" data-target="download-ebook"> Download E-Book (epub) </a> <hr class="navbar-divider"> <a class="navbar-item" href="/about"> About </a> <hr class="navbar-divider"> <a class="navbar-item has-text-red" href="https://github.com/raku/doc-website/issues"> Report an issue with this site </a> <hr class="navbar-divider"> <a class="navbar-item" href="https://github.com/raku/doc/issues"> Report an issue with the documentation content </a> <hr class="navbar-divider"> <label class="navbar-item centreToggle" title="Enable/Disable Announcements" style="--switch-width: 18"> <input id="cancelAnnouncements" type="checkbox"> <span class="text">Announcements</span> <span class="on">suppressed</span> <span class="off">allowed</span> </label> </div> </div> </div> <div class="navbar-end navbar-search-wrapper"> <div class="navbar-item"> <div class="field has-addons"> <div class="autoComplete_options"> <input class="control input" id="autoComplete" type="search" dir="ltr" spellcheck=false autocorrect="off" autocomplete="off" autocapitalize="off" placeholder="🔍 Type f to search for ..."> </div> <div class="control" title="Search options"> <a class="button is-primary js-modal-trigger" data-target="options-search-info"> <span class="icon"> <i class="fas fa-cogs"></i> </span> </a> </div> </div> </div> </div> <div id="options-search-info" class="modal"> <div class="modal-background"></div> <div class="modal-content"> <div class="box"> <p>The last search was: <span id="selected-candidate" class="ss-selected"></span></p> <div class="control is-grouped is-grouped-centered options-search-controls"> <label class="centreToggle" title="Include extra information (Alt-E)" style="--switch-width: 10.5"> <input id="options-search-extra" type="checkbox"> <span class="text">Extra info</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>The search response can be shortened by excluding the extra information line (Alt-E)</p> <label class="centreToggle" title="Search engine type Strict/Loose (Alt-L)" style="--switch-width: 10.5"> <input id="options-search-loose" type="checkbox"> <span class="text">Search type</span> <span class="on">loose</span> <span class="off">strict</span> </label> <p> The search engine can perform a strict search (only the characters in the search box) or a loose search (Alt-L)</p> <label class="centreToggle" title="Search in headings (Alt-H)" style="--switch-width: 10.5"> <input id="options-search-headings" type="checkbox"> <span class="text">Headings</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>Search through headings in all web-pages (Alt-H)</p> <label class="centreToggle" title="Search indexed items (Alt-I)" style="--switch-width: 10.5"> <input id="options-search-indexed" type="checkbox"> <span class="text">Indexed</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>Search through all indexed items (Alt-I)</p> <label class="centreToggle" title="Search composite pages (Alt-C)" style="--switch-width: 10.5"> <input id="options-search-composite" type="checkbox"> <span class="text">Composite</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>Search in the names of composite pages, which combine similar information from the main web pages (Alt-C)</p> <label class="centreToggle" title="Search primary sources (Alt-P)" style="--switch-width: 10.5"> <input id="options-search-primary" type="checkbox"> <span class="text">Primary</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>Search through the names of the main web pages (Alt-P)</p> <label class="centreToggle" title="Open in new tab (Alt-Q)" style="--switch-width: 10.5"> <input id="options-search-newtab" type="checkbox"> <span class="text">New tab</span> <span class="on">yes</span> <span class="off">no</span> </label> <p>Once a search candidate has been chosen, it can be opened in a new tab or in the current tab (Alt-Q)</p> <p>If all else fails, an item is added to use the Google search engine on the whole site</p> <button class="button is-warning" id="options-search-reset-defaults">Clear options, reset to defaults</button> <p>Exit this page by pressing <Escape>, or clicking on X or on the background.</p> </div> </div> </div> <button class="modal-close is-large" aria-label="close"></button> </div> </div> <div id="download-ebook" class="modal"> <div class="modal-background"></div> <div class="modal-content"> <div class="box"> <p><a href="/RakuDocumentation.epub" download>RakuDocumentation.epub</a> is a work in progress e-book. It targets the <a href="https://www.w3.org/publishing/epub3/">EPUB v3 specification</a>. It needs testing on a variety of ereaders (some of which may still implicitly expect compliance with EPUB v2). The CSS definitely needs enhancing (especially for code snippets). The Ebook opens in a Calibre reader, which is available on all operating systems.</p> <p>Suggestions are welcome and should be addressed by opening an issue on the Raku/doc-website repository</p> <p>Exit this popup by pressing <Escape>, or clicking on X or on the background.</p> </div> </div> <button class="modal-close is-large" aria-label="close"></button> </div> <div id="announcement-modal" class="modal"> <div class="modal-background"></div> <div class="modal-content"> <div class="box"> <div id="raku-doc-announcement"></div> <p>For more see <a href="/announcements">Announcements page</a>.</p> <p>Exit this popup by pressing <Escape>, or clicking on X or on the background.</p> </div> </div> <button class="modal-close is-large" aria-label="close"></button> </div> </div> </nav> <div class="tile is-ancestor section"> <div class="page-edit"> <a class="button page-edit-button" href="https://github.com/Raku/doc/edit/main/doc/Language/quoting.rakudoc" title="Edit this page. Commit: a89742bdf 2024-07-14"> <span class="icon is-right"> <i class="fas fa-pen-alt is-medium"></i> </span> </a> </div> <div id="left-column" class="tile is-parent is-2 is-hidden"> <div id="left-col-inner"> <div class="tabs" id="tabs"> <ul> <li class="is-active" id="toc-tab"> <a>Table of Contents</a> </li> <li id="index-tab"> <a>Index</a> </li> </ul> </div> <div class="field"> <div class="control has-icons-right"> <input id="toc-filter" class="input" type="text" placeholder="Filter"> <span class="icon is-right has-text-grey"> <i class="fas fa-search is-medium"></i> </span> </div> </div> <div class="raku-sidebar"> <aside id="toc-menu" class="menu"> <ul class="menu-list"> <li><a href="#The_Q_lang">The Q lang</a></li> <ul> <li><a href="#Literal_strings:_Q">Literal strings: Q</a></li> <li><a href="#Escaping:_q">Escaping: q</a></li> <li><a href="#Interpolation:_qq">Interpolation: qq</a></li> <ul> <li><a href="#Interpolating_variables">Interpolating variables</a></li> <li><a href="#Interpolating_closures">Interpolating closures</a></li> <li><a href="#Interpolating_escape_codes">Interpolating escape codes</a></li> <li><a href="#preventing_interpolation_and_handling_missing_values">preventing interpolation and handling missing values</a></li> </ul> <li><a href="#Word_quoting:_qw">Word quoting: qw</a></li> <li><a href="#Word_quoting:_<_>">Word quoting: < ></a></li> <li><a href="#Word_quoting_with_quote_protection:_qww">Word quoting with quote protection: qww</a></li> <li><a href="#Word_quoting_with_interpolation:_qqw">Word quoting with interpolation: qqw</a></li> <li><a href="#Word_quoting_with_interpolation_and_quote_protection:_qqww">Word quoting with interpolation and quote protection: qqww</a></li> <li><a href="#Word_quoting_with_interpolation_and_quote_protection:_«_»">Word quoting with interpolation and quote protection: « »</a></li> <li><a href="#Shell_quoting:_qx">Shell quoting: qx</a></li> <li><a href="#Shell_quoting_with_interpolation:_qqx">Shell quoting with interpolation: qqx</a></li> <li><a href="#Heredocs:_:to">Heredocs: :to</a></li> <li><a href="#Unquoting">Unquoting</a></li> </ul> </aside> <aside id="index-menu" class="menu is-hidden"> <ul class="menu-list"> <li>Adverbs<ul> <li><a href="#index-entry-:a_(quoting_adverb)">:a </a></li> <li><a href="#index-entry-:array_(quoting_adverb)">:array </a></li> <li><a href="#index-entry-:b_(quoting_adverb)">:b </a></li> <li><a href="#index-entry-:backslash_(quoting_adverb)">:backslash </a></li> <li><a href="#index-entry-:c_(quoting_adverb)">:c </a></li> <li><a href="#index-entry-:closure_(quoting_adverb)">:closure </a></li> <li><a href="#index-entry-:double_(quoting_adverb)">:double </a></li> <li><a href="#index-entry-:exec_(quoting_adverb)">:exec </a></li> <li><a href="#index-entry-:f_(quoting_adverb)">:f </a></li> <li><a href="#index-entry-:function_(quoting_adverb)">:function </a></li> <li><a href="#index-entry-:h_(quoting_adverb)">:h </a></li> <li><a href="#index-entry-:hash_(quoting_adverb)">:hash </a></li> <li><a href="#index-entry-:heredoc_(quoting_adverb)">:heredoc </a></li> <li><a href="#index-entry-:q_(quoting_adverb)">:q </a></li> <li><a href="#index-entry-:qq_(quoting_adverb)">:qq </a></li> <li><a href="#index-entry-:quotewords_(quoting_adverb)">:quotewords </a></li> <li><a href="#index-entry-:s_(quoting_adverb)">:s </a></li> <li><a href="#index-entry-:scalar_(quoting_adverb)">:scalar </a></li> <li><a href="#index-entry-:single_(quoting_adverb)">:single </a></li> <li><a href="#index-entry-:to_(quoting_adverb)">:to </a></li> <li><a href="#index-entry-:v_(quoting_adverb)">:v </a></li> <li><a href="#index-entry-:val_(quoting_adverb)">:val </a></li> <li><a href="#index-entry-:w_(quoting_adverb)">:w </a></li> <li><a href="#index-entry-:words_(quoting_adverb)">:words </a></li> <li><a href="#index-entry-:ww_(quoting_adverb)">:ww </a></li> <li><a href="#index-entry-:x_(quoting_adverb)">:x </a></li> </ul></li> <li>Language<ul> </ul></li> <li>Syntax<ul> <li><a href="#index-entry-&_(interpolation)">& </a></li> <li><a href="#index-entry-\_(quoting)">\ </a></li> <li><a href="#index-entry-escaping_quote">escaping quote</a></li> </ul></li> </ul> </aside> </div> </div> </div> <div id="main-column" class="tile is-parent" style="overflow-x: hidden;"> <div id="main-col-inner"> <section class="raku page-header"> <div class="container px-4"> <div class="raku page-title has-text-centered"> Quoting constructs </div> <div class="raku page-subtitle has-text-centered"> <p>Writing strings and word lists, in Raku</p> </div> </div> </section> <section class="raku page-content"><div class="container px-4"><div class="columns one-col"> <h1 id="The_Q_lang" class="raku-h1"><a href="#Quoting_constructs" title="go to top of document">The Q lang<a class="raku-anchor" title="direct link" href="#The_Q_lang">§</a></a></h1> <p>Strings are usually represented in Raku code using some form of quoting construct. The most minimalistic of these is <code>Q</code>, usable via the shortcut <code>「…」</code>, or via <code>Q</code> followed by any pair of delimiters surrounding your text, including many <a href="https://github.com/Raku/roast/blob/aa4994a7f6b3f6b450a9d231bebd5fba172439b0/S02-literals/quoting-unicode.t#L49-L65">Unicode pairs</a>. Most of the time, though, the most you'll need is <code>'…'</code> or <code>"…"</code>, described in more detail in the following sections.</p><p>For information about quoting as applied in regexes, see the <a href="/language/regexes">regular expression documentation</a>.</p> <h2 id="Literal_strings:_Q" class="raku-h2"><a name="index-entry-Q-「_」-Literal_strings:_Q" data-indexedheader="Syntax;Q"></a><a href="#Quoting_constructs" title="go to top of document">Literal strings: Q<a class="raku-anchor" title="direct link" href="#Literal_strings:_Q">§</a></a></h2> <!-- defnmark Literal_strings:_Q 2 --> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-STRING_DELIMITER">Q</span><span class="highlite-STRING_DELIMITER">[</span><span class="highlite-STRING">A literal string</span><span class="highlite-STRING_DELIMITER">]</span> <span class="highlite-STRING_DELIMITER">「</span><span class="highlite-STRING">More plainly.</span><span class="highlite-STRING_DELIMITER">」</span> <span class="highlite-STRING_DELIMITER">Q</span><span class="highlite-STRING_DELIMITER">^</span><span class="highlite-STRING">Almost any non-word character can be a delimiter!</span><span class="highlite-STRING_DELIMITER">^</span> <span class="highlite-STRING_DELIMITER">Q</span><span class="highlite-STRING_DELIMITER">「「</span><span class="highlite-STRING">Delimiters can be repeated/nested if they are adjacent.</span><span class="highlite-STRING_DELIMITER">」」</span> <span class="highlite-STRING_DELIMITER">Q</span><span class="highlite-STRING_DELIMITER">⦅</span><span class="highlite-STRING">Quoting with fancy unicode pairs</span><span class="highlite-STRING_DELIMITER">⦆</span> </pre> </div> </div> <p>Delimiters can be nested, but in the plain <code>Q</code> form, backslash escapes aren't allowed. In other words, basic <code>Q</code> strings are as literal as possible.</p><p>Some delimiters are not allowed immediately after <code>Q</code>, <code>q</code>, or <code>qq</code>. Any characters that are allowed in <a href="/language/syntax#Identifiers">identifiers</a> are not allowed to be used, since in such a case, the quoting construct together with such characters are interpreted as an identifier. In addition, <code>( )</code> is not allowed because that is interpreted as a function call. If you still wish to use those characters as delimiters, separate them from <code>Q</code>, <code>q</code>, or <code>qq</code> with a space. Please note that some natural languages use a left delimiting quote on the right side of a string. <code>Q</code> will not support those as it relies on unicode properties to tell left and right delimiters apart.</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-STRING_DELIMITER">Q</span><span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">this will not work!</span><span class="highlite-STRING_DELIMITER">'</span> Q(this won<span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">t work either!) </span><span class="highlite-STRING_DELIMITER"></span></pre> </div> </div> <p>The examples above will produce an error. However, this will work</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-STRING_DELIMITER">Q</span><span class="highlite-STRING_DELIMITER"> (</span><span class="highlite-STRING">this is fine, because of space after Q</span><span class="highlite-STRING_DELIMITER">)</span> <span class="highlite-STRING_DELIMITER">Q</span><span class="highlite-STRING_DELIMITER"> '</span><span class="highlite-STRING">and so is this</span><span class="highlite-STRING_DELIMITER">'</span> <span class="highlite-STRING_DELIMITER">Q</span><span class="highlite-STRING_DELIMITER"><</span><span class="highlite-STRING">Make sure you <match</span><span class="highlite-STRING_DELIMITER">></span> opening <span class="highlite-OPERATOR">and</span> closing delimiters> <span class="highlite-STRING_DELIMITER">Q</span><span class="highlite-STRING_DELIMITER">{</span><span class="highlite-STRING">This is still a closing curly brace → \</span><span class="highlite-STRING_DELIMITER">}</span> </pre> </div> </div> <p>These examples produce:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights">this <span class="highlite-KEYWORD">is</span> fine<span class="highlite-OPERATOR">,</span> because <span class="highlite-KEYWORD">of</span> space <span class="highlite-OPERATOR">after</span> Q <span class="highlite-OPERATOR">and</span> <span class="highlite-OPERATOR">so</span> <span class="highlite-KEYWORD">is</span> this Make sure you <<span class="highlite-ROUTINE">match</span>> opening <span class="highlite-OPERATOR">and</span> closing delimiters This <span class="highlite-KEYWORD">is</span> still a closing curly brace → \ </pre> </div> </div> <p><a name="index-entry-:x_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:exec_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:w_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:words_(quoting_adverb)" class="index-entry"></a> <a name="index-entry-:ww_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:quotewords_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:q_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:single_(quoting_adverb)" class="index-entry"></a> <a name="index-entry-:qq_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:double_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:s_(quoting_adverb)" class="index-entry"></a> <a name="index-entry-:scalar_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:a_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:array_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:h_(quoting_adverb)" class="index-entry"></a> <a name="index-entry-:hash_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:f_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:function_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:c_(quoting_adverb)" class="index-entry"></a> <a name="index-entry-:closure_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:b_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:backslash_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:to_(quoting_adverb)" class="index-entry"></a> <a name="index-entry-:heredoc_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:v_(quoting_adverb)" class="index-entry"></a><a name="index-entry-:val_(quoting_adverb)" class="index-entry"></a></p><p>The behavior of quoting constructs can be modified with adverbs, as explained in detail in later sections.</p><table class="table is-bordered centered pod-table"> <tbody> <tr><td>Short</td><td>Long</td><td>Meaning</td></tr> <tr><td>:x</td><td>:exec</td><td>Execute as command and return results</td></tr> <tr><td>:w</td><td>:words</td><td>Split result on words (no quote protection)</td></tr> <tr><td>:ww</td><td>:quotewords</td><td>Split result on words (with quote protection)</td></tr> <tr><td>:q</td><td>:single</td><td>Interpolate \\, \qq[...] and escaping the delimiter with \</td></tr> <tr><td>:qq</td><td>:double</td><td>Interpolate with :s, :a, :h, :f, :c, :b</td></tr> <tr><td>:s</td><td>:scalar</td><td>Interpolate $ vars</td></tr> <tr><td>:a</td><td>:array</td><td>Interpolate @ vars (when followed by postcircumfix)</td></tr> <tr><td>:h</td><td>:hash</td><td>Interpolate % vars (when followed by postcircumfix)</td></tr> <tr><td>:f</td><td>:function</td><td>Interpolate & calls</td></tr> <tr><td>:c</td><td>:closure</td><td>Interpolate {...} expressions</td></tr> <tr><td>:b</td><td>:backslash</td><td>Enable backslash escapes (\n, \qq, \$foo, etc)</td></tr> <tr><td>:to</td><td>:heredoc</td><td>Parse result as heredoc terminator</td></tr> <tr><td>:v</td><td>:val</td><td>Convert to allomorph if possible</td></tr> </tbody> </table> <p>These adverbs can be used together with <code>Q</code>, so that it will interpolate even if the quoting operator does not:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_HASH">%þ</span> <span class="highlite-OPERATOR">=</span> :is-mighty; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">Q</span><span class="highlite-STRING_DELIMITER"> "</span><span class="highlite-STRING">Þor %þ<></span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-COMMENT"># OUTPUT: «Þor %þ<>» </span><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">Q:h</span><span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">Þor </span><span class="highlite-NAME_HASH">%þ</span><span class="highlite-STRING"><></span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-COMMENT"># OUTPUT: «Þor is-mighty True» </span><span class="highlite-NAME_HASH">%þ</span> <span class="highlite-OPERATOR">=</span> :42foo<span class="highlite-OPERATOR">,</span> :33bar; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">Q:h:c</span><span class="highlite-STRING_DELIMITER"> "</span><span class="highlite-STRING">Þor </span><span class="highlite-NAME_HASH">%þ</span><span class="highlite-STRING"><> → </span><span class="highlite-ESCAPE">{</span> [<span class="highlite-OPERATOR">+</span>] <span class="highlite-NAME_HASH">%þ</span>.<span class="highlite-ROUTINE">values</span><span class="highlite-ESCAPE">}</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-COMMENT"># OUTPUT: «Þor bar 33foo 42 → 75» </span><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@þ</span>= <span class="highlite-STRING_DELIMITER"><</span><span class="highlite-STRING">33 44</span><span class="highlite-STRING_DELIMITER">></span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">Q:a</span><span class="highlite-STRING_DELIMITER"> "</span><span class="highlite-STRING">Array contains </span><span class="highlite-NAME_ARRAY">@þ</span><span class="highlite-STRING">[]</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-COMMENT"># OUTPUT: «Array contains 33 44» </span><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">Q:v</span><span class="highlite-STRING_DELIMITER"><</span><span class="highlite-STRING">33</span><span class="highlite-STRING_DELIMITER">></span> <span class="highlite-OPERATOR">+</span> 3; <span class="highlite-COMMENT"># OUTPUT: «36» </span></pre> </div> </div> <p>By default, and as shown, <code>Q</code> quotes directly without any kind of transformation of the quoted string. The adverbs will modify its behavior, converting, for instance, the string into an allomorph (with the <code>:v</code> adverb) or allowing interpolation of hashes (via <code>:h</code>) or <code>{}</code> code sections (via <code>:c</code>). Arrays and hashes must be <em>followed by a postcircumfix</em>; that is, the sigiled identifier will not interpolate, but followed by an indexing, decont operator or a method call with parentheses, it will:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@þ</span>= <span class="highlite-STRING_DELIMITER"><</span><span class="highlite-STRING">33 44</span><span class="highlite-STRING_DELIMITER">></span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">Q:a</span><span class="highlite-STRING_DELIMITER"> "</span><span class="highlite-STRING">Array contains </span><span class="highlite-NAME_ARRAY">@þ</span><span class="highlite-STRING">.elems()</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-COMMENT"># OUTPUT: «Array contains 2» </span></pre> </div> </div> <p>The same code without the parentheses will simply not interpolate, absent the post-circumfix operator.</p><p><a name="index-entry-escaping_quote" class="index-entry"></a></p> <h2 id="Escaping:_q" class="raku-h2"><a name="index-entry-q-'_'-Escaping:_q" data-indexedheader="Syntax;q"></a><a href="#Quoting_constructs" title="go to top of document">Escaping: q<a class="raku-anchor" title="direct link" href="#Escaping:_q">§</a></a></h2> <!-- defnmark Escaping:_q 2 --> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">Very plain</span><span class="highlite-STRING_DELIMITER">'</span>; <span class="highlite-STRING_DELIMITER">q</span><span class="highlite-STRING_DELIMITER">[</span><span class="highlite-STRING">This back\slash stays</span><span class="highlite-STRING_DELIMITER">]</span>; <span class="highlite-STRING_DELIMITER">q</span><span class="highlite-STRING_DELIMITER">[</span><span class="highlite-STRING">This back</span><span class="highlite-ESCAPE">\\</span><span class="highlite-STRING">slash stays</span><span class="highlite-STRING_DELIMITER">]</span>; <span class="highlite-COMMENT"># Identical output </span><span class="highlite-STRING_DELIMITER">q</span><span class="highlite-STRING_DELIMITER">{</span><span class="highlite-STRING">This is not a closing curly brace → </span><span class="highlite-ESCAPE">\}</span><span class="highlite-STRING">, but this is → </span><span class="highlite-STRING_DELIMITER">}</span>; Q :q <span class="highlite-NAME_SCALAR">$There</span> are <span class="highlite-KEYWORD">no</span> backslashes here<span class="highlite-OPERATOR">,</span> only lots <span class="highlite-KEYWORD">of</span> \$\$\$<span class="highlite-OPERATOR">!</span>$; <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">(Just kidding. There</span><span class="highlite-ESCAPE">\'</span><span class="highlite-STRING">s no money in that string)</span><span class="highlite-STRING_DELIMITER">'</span>; <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">No $interpolation {here}!</span><span class="highlite-STRING_DELIMITER">'</span>; <span class="highlite-STRING_DELIMITER">Q:q</span><span class="highlite-STRING_DELIMITER">!</span><span class="highlite-STRING">Just a literal "\n" here</span><span class="highlite-STRING_DELIMITER">!</span>; </pre> </div> </div> <p>The <code>q</code> form allows for escaping characters that would otherwise end the string using a backslash. The backslash itself can be escaped, too, as in the third example above. The usual form is <code>'…'</code> or <code>q</code> followed by a delimiter, but it's also available as an adverb on <code>Q</code>, as in the fifth and last example above.</p><p>These examples produce:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>「text」 without highlighting</label> <div> <pre class="nohighlights"><pre class="nohighlights"> Very plain This back\slash stays This back\slash stays This is not a closing curly brace → } but this is → There are no backslashes here, only lots of $$$! (Just kidding. There's no money in that string) No $interpolation {here}! Just a literal "\n" here </pre> </pre> </div> </div> <p>The <code>\qq[...]</code> escape sequence enables <a href="/language/quoting#Interpolation:_qq"><code>qq</code> interpolation</a> for a portion of the string. Using this escape sequence is handy when you have HTML markup in your strings, to avoid interpretation of angle brackets as hash keys:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$var</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">foo</span><span class="highlite-STRING_DELIMITER">'</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING"><code>$var</code> is <var></span><span class="highlite-ESCAPE">\</span><span class="highlite-STRING_DELIMITER">qq</span><span class="highlite-STRING_DELIMITER">[</span><span class="highlite-NAME_SCALAR">$var</span><span class="highlite-STRING">.uc()</span><span class="highlite-STRING_DELIMITER">]</span><span class="highlite-STRING"></var></span><span class="highlite-STRING_DELIMITER">'</span>; <span class="highlite-COMMENT"># OUTPUT: «<code>$var</code> is <var>FOO</var>»</span></pre> </div> </div> <h2 id="Interpolation:_qq" class="raku-h2"><a name="index-entry-qq-"_"-Interpolation:_qq" data-indexedheader="Syntax;qq"></a><a href="#Quoting_constructs" title="go to top of document">Interpolation: qq<a class="raku-anchor" title="direct link" href="#Interpolation:_qq">§</a></a></h2> <!-- defnmark Interpolation:_qq 2 --> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$color</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">blue</span><span class="highlite-STRING_DELIMITER">'</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">My favorite color is </span><span class="highlite-NAME_SCALAR">$color</span><span class="highlite-STRING">!</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-COMMENT"># OUTPUT: «My favorite color is blue!» </span></pre> </div> </div> <p><a name="index-entry-\_(quoting)" class="index-entry"></a></p><p>The <code>qq</code> form – usually written using double quotes – allows for interpolation of backslash escape sequences (like <code>q:backslash</code>), all sigiled variables (like <code>q:scalar:array:hash:function</code>), and any code inside <code>{...}</code> (like <code>q:closure</code>).</p> <h3 id="Interpolating_variables" class="raku-h3"><a href="#Quoting_constructs" title="go to top of document">Interpolating variables<a class="raku-anchor" title="direct link" href="#Interpolating_variables">§</a></a></h3> <p>Inside a <code>qq</code>-quoted string, you can use variables with a sigil to trigger interpolation of the variable's value. Variables with the <code>$</code> sigil are interpolated whenever the occur (unless escaped); that's why, in the example above, <code>"$color"</code> became <code>blue</code>.</p><p>Variables with other sigils, however, only trigger interpolation when you follow the variable with the appropriate postfix (<code>[]</code> for Arrays, <code><></code>, for Hashes, <code>&</code> for Subs). This allows you to write expressions like <code>"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f99d969a8c949c978d988d909697b98b98928cd7968b9e">[email protected]</a>"</code> without interpolating the <code>@raku</code> variable.</p><p>To interpolate an Array (or other <a href="/type/Positional"><code>Positional</code></a> variable), append a <code>[]</code> to the variable name:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@neighbors</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">Felix</span><span class="highlite-STRING_DELIMITER">"</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">Danielle</span><span class="highlite-STRING_DELIMITER">"</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">Lucinda</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-NAME_ARRAY">@neighbors</span><span class="highlite-STRING">[] and I try our best to coexist peacefully.</span><span class="highlite-STRING_DELIMITER">"</span> <span class="highlite-COMMENT"># OUTPUT: «Felix Danielle Lucinda and I try our best to coexist peacefully.» </span></pre> </div> </div> <p>Alternatively, rather than using <code>[]</code>, you can interpolate the Array by following it with a method call with parentheses after the method name. Thus the following code will work:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-NAME_ARRAY">@neighbors</span><span class="highlite-STRING">.join(', ') and I try our best to coexist peacefully.</span><span class="highlite-STRING_DELIMITER">"</span> <span class="highlite-COMMENT"># OUTPUT: «Felix, Danielle, Lucinda and I try our best to coexist peacefully.» </span></pre> </div> </div> <p>However, <code>"@example.com"</code> produces <code>@example.com</code>.</p><p>To call a subroutine, use the <code>&</code>-sigil and follow the subroutine name with parentheses. <a name="index-entry-&_(interpolation)" class="index-entry"></a></p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">uc 'word'</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-COMMENT"># OUTPUT: «uc 'word'» </span><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-NAME_CODE">&uc</span><span class="highlite-STRING"> 'word'</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-COMMENT"># OUTPUT: «&uc 'word'» </span><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-NAME_CODE">&uc</span><span class="highlite-STRING">('word')</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-COMMENT"># OUTPUT: «WORD» </span><span class="highlite-COMMENT"># OUTPUT: «abcDEFghi»</span></pre> </div> </div> <p>To interpolate a Hash (or other <a href="/type/Associative"><code>Associative</code></a> variable), use the <code><></code> postcircumfix operator.</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_HASH">%h</span> <span class="highlite-OPERATOR">=</span> :1st; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">abc</span><span class="highlite-NAME_HASH">%h</span><span class="highlite-STRING"><st>ghi</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-COMMENT"># OUTPUT: «abc1ghi»</span></pre> </div> </div> <p>The way <code>qq</code> interpolates variables is the same as <code>q:scalar:array:hash:function</code>. You can use these adverbs (or their short forms, <code>q:s:a:h:f</code>) to interpolate variables without enabling other <code>qq</code> interpolations.</p> <h3 id="Interpolating_closures" class="raku-h3"><a href="#Quoting_constructs" title="go to top of document">Interpolating closures<a class="raku-anchor" title="direct link" href="#Interpolating_closures">§</a></a></h3> <p>Another feature of <code>qq</code> is the ability to interpolate Raku code from within the string, using curly braces:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> (<span class="highlite-NAME_SCALAR">$x</span><span class="highlite-OPERATOR">,</span> <span class="highlite-NAME_SCALAR">$y</span><span class="highlite-OPERATOR">,</span> <span class="highlite-NAME_SCALAR">$z</span>) <span class="highlite-OPERATOR">=</span> 4<span class="highlite-OPERATOR">,</span> 3.5<span class="highlite-OPERATOR">,</span> 3; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">This room is </span><span class="highlite-ESCAPE">{</span><span class="highlite-NAME_SCALAR">$x</span><span class="highlite-ESCAPE">}</span><span class="highlite-STRING">m by </span><span class="highlite-ESCAPE">{</span><span class="highlite-NAME_SCALAR">$y</span><span class="highlite-ESCAPE">}</span><span class="highlite-STRING">m by </span><span class="highlite-ESCAPE">{</span><span class="highlite-NAME_SCALAR">$z</span><span class="highlite-ESCAPE">}</span><span class="highlite-STRING">m.</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-COMMENT"># OUTPUT: «This room is 4m by 3.5m by 3m.» </span><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">Therefore its volume should be </span><span class="highlite-ESCAPE">{</span> <span class="highlite-NAME_SCALAR">$x</span> <span class="highlite-OPERATOR">*</span> <span class="highlite-NAME_SCALAR">$y</span> <span class="highlite-OPERATOR">*</span> <span class="highlite-NAME_SCALAR">$z</span> <span class="highlite-ESCAPE">}</span><span class="highlite-STRING">m³!</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-COMMENT"># OUTPUT: «Therefore its volume should be 42m³!» </span></pre> </div> </div> <p>This provides the same functionality as the <code>q:closure</code>/<code>q:c</code> quoting form.</p> <h3 id="Interpolating_escape_codes" class="raku-h3"><a href="#Quoting_constructs" title="go to top of document">Interpolating escape codes<a class="raku-anchor" title="direct link" href="#Interpolating_escape_codes">§</a></a></h3> <p>The <code>qq</code> quoting form also interpolates backslash escape sequences. Several of these print invisible/whitespace ASCII control codes or whitespace characters:</p><table class="table is-bordered centered pod-table"> <tbody> <tr><td>Sequence</td><td>Hex Value</td><td>Character</td><td>Reference URL</td></tr> <tr><td>\0</td><td>\x0000</td><td>Nul</td><td>https://util.unicode.org/UnicodeJsps/character.jsp?a=0000</td></tr> <tr><td>\a</td><td>\x0007</td><td>Bel</td><td>https://util.unicode.org/UnicodeJsps/character.jsp?a=0007</td></tr> <tr><td>\b</td><td>\x0008</td><td>Backspace</td><td>https://util.unicode.org/UnicodeJsps/character.jsp?a=0008</td></tr> <tr><td>\e</td><td>\x001B</td><td>Esc</td><td>https://util.unicode.org/UnicodeJsps/character.jsp?a=001B</td></tr> <tr><td>\f</td><td>\x000C</td><td>Form Feed</td><td>https://util.unicode.org/UnicodeJsps/character.jsp?a=000C</td></tr> <tr><td>\n</td><td>\x000A</td><td>Newline</td><td>https://util.unicode.org/UnicodeJsps/character.jsp?a=000A</td></tr> <tr><td>\r</td><td>\x000D</td><td>Carriage Return</td><td>https://util.unicode.org/UnicodeJsps/character.jsp?a=000D</td></tr> <tr><td>\t</td><td>\x0009</td><td>Tab</td><td>https://util.unicode.org/UnicodeJsps/character.jsp?a=0009</td></tr> </tbody> </table> <p><code>qq</code> also supports two multi-character escape sequences: <code>\x</code> and <code>\c</code>. You can use <code>\x</code> or <code>\x[]</code> with the hex-code of a Unicode character or a list of characters:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$s</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">I </span><span class="highlite-ESCAPE">\x</span><span class="highlite-STRING">2665 Raku!</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_SCALAR">$s</span>; <span class="highlite-COMMENT"># OUTPUT: «I ♥ Raku!» </span> <span class="highlite-NAME_SCALAR">$s</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">I really </span><span class="highlite-ESCAPE">\x</span><span class="highlite-STRING">[2661,2665,2764,1f495] Raku!</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_SCALAR">$s</span>; <span class="highlite-COMMENT"># OUTPUT: «I really ♡♥❤💕 Raku!»</span></pre> </div> </div> <p>You can also create a Unicode character with <code>\c</code> and that character's <a href="/language/unicode#Entering_unicode_codepoints_and_codepoint_sequences">unicode name</a> , <a href="/language/unicode#Named_sequences">named sequences</a> or <a href="/language/unicode#Name_aliases">name alias</a>:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$s</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">Camelia </span><span class="highlite-ESCAPE">\c</span><span class="highlite-STRING">[BROKEN HEART] my </span><span class="highlite-ESCAPE">\c</span><span class="highlite-STRING">[HEAVY BLACK HEART]!</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_SCALAR">$s</span>; <span class="highlite-COMMENT"># OUTPUT: «Camelia 💔 my ❤!»</span></pre> </div> </div> <p>See the description of <a href="/language/unicode#Entering_unicode_codepoints_and_codepoint_sequences">\c[]</a> on the <a href="/language/unicode">Unicode</a> documentation page for more details.</p><p><code>qq</code> provides the same interpolation of escape sequences as that provided by <code>q:backslash</code>/<code>q:b</code>.</p> <h3 id="preventing_interpolation_and_handling_missing_values" class="raku-h3"><a href="#Quoting_constructs" title="go to top of document">preventing interpolation and handling missing values<a class="raku-anchor" title="direct link" href="#preventing_interpolation_and_handling_missing_values">§</a></a></h3> <p>You can prevent any undesired interpolation in a <code>qq</code>-quoted string by escaping the sigil or other initial character:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">The </span><span class="highlite-ESCAPE">\$</span><span class="highlite-STRING">color variable contains the value '</span><span class="highlite-NAME_SCALAR">$color'</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-COMMENT"># OUTPUT: «The $color variable contains the value 'blue'» </span></pre> </div> </div> <p>Interpolation of undefined values will raise a control exception that can be caught in the current block with <a href="/language/phasers#CONTROL">CONTROL</a>.</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">sub</span> niler {<span class="highlite-TYPE">Nil</span>}; <span class="highlite-KEYWORD">my</span> <span class="highlite-TYPE">Str</span> <span class="highlite-NAME_SCALAR">$a</span> <span class="highlite-OPERATOR">=</span> niler; <span class="highlite-ROUTINE">say</span>(<span class="highlite-STRING_DELIMITER">"</span><span class="highlite-NAME_SCALAR">$a</span><span class="highlite-STRING">.html</span><span class="highlite-STRING_DELIMITER">"</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">sometext</span><span class="highlite-STRING_DELIMITER">"</span>); <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">alive</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-COMMENT"># this line is dead code </span><span class="highlite-KEYWORD">CONTROL</span> { .<span class="highlite-ROUTINE">die</span> }; </pre> </div> </div> <h2 id="Word_quoting:_qw" class="raku-h2"><a href="#Quoting_constructs" title="go to top of document">Word quoting: qw <a name="index-entry-qw_word_quote" data-indexedheader="Syntax;qw word quote"></a><span class="glossary-entry-heading"></span><a class="raku-anchor" title="direct link" href="#Word_quoting:_qw">§</a></a></h2> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-STRING_DELIMITER">qw</span><span class="highlite-STRING_DELIMITER">|</span><span class="highlite-STRING">! @ # $ % ^ & * \</span><span class="highlite-STRING_DELIMITER">|</span> <span class="highlite-STRING_DELIMITER"><</span><span class="highlite-STRING"> </span><span class="highlite-STRING_DELIMITER">></span> <span class="highlite-OPERATOR">|</span> <span class="highlite-OPERATOR">eqv</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">! @ # $ % ^ & * | < ></span><span class="highlite-STRING_DELIMITER">'</span>.<span class="highlite-ROUTINE">words</span>.<span class="highlite-ROUTINE">list</span>; <span class="highlite-STRING_DELIMITER">q:w</span><span class="highlite-STRING_DELIMITER"> {</span><span class="highlite-STRING"> [ ] \{ </span><span class="highlite-ESCAPE">\}</span><span class="highlite-STRING"> </span><span class="highlite-STRING_DELIMITER">}</span> <span class="highlite-OPERATOR">eqv</span> (<span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">[</span><span class="highlite-STRING_DELIMITER">'</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">]</span><span class="highlite-STRING_DELIMITER">'</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">{</span><span class="highlite-STRING_DELIMITER">'</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">}</span><span class="highlite-STRING_DELIMITER">'</span>); Q:w <span class="highlite-OPERATOR">|</span> [ ] { } <span class="highlite-OPERATOR">|</span> <span class="highlite-OPERATOR">eqv</span> (<span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">[</span><span class="highlite-STRING_DELIMITER">'</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">]</span><span class="highlite-STRING_DELIMITER">'</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">{</span><span class="highlite-STRING_DELIMITER">'</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">}</span><span class="highlite-STRING_DELIMITER">'</span>); </pre> </div> </div> <p>The <code>:w</code> form, usually written as <code>qw</code>, splits the string into "words". In this context, words are defined as sequences of non-whitespace characters separated by whitespace. The <code>q:w</code> and <code>qw</code> forms inherit the interpolation and escape semantics of the <code>q</code> and single quote string delimiters, whereas <code>Qw</code> and <code>Q:w</code> inherit the non-escaping semantics of the <code>Q</code> quoter.</p><p>This form is used in preference to using many quotation marks and commas for lists of strings. For example, where you could write:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@directions</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">left</span><span class="highlite-STRING_DELIMITER">'</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">right,</span><span class="highlite-STRING_DELIMITER">'</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">up</span><span class="highlite-STRING_DELIMITER">'</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">down</span><span class="highlite-STRING_DELIMITER">'</span>;</pre> </div> </div> <p>It's easier to write and to read this:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@directions</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">qw</span><span class="highlite-STRING_DELIMITER">|</span><span class="highlite-STRING">left right up down</span><span class="highlite-STRING_DELIMITER">|</span>;</pre> </div> </div> <h2 id="Word_quoting:_<_>" class="raku-h2"><a href="#Quoting_constructs" title="go to top of document">Word quoting: <code>< ></code> <a name="index-entry-<_>_word_quote" data-indexedheader="Syntax;< > word quote"></a><span class="glossary-entry-heading"></span><a class="raku-anchor" title="direct link" href="#Word_quoting:_<_>">§</a></a></h2> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> <a b c> <span class="highlite-OPERATOR">eqv</span> (<span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">a</span><span class="highlite-STRING_DELIMITER">'</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">b</span><span class="highlite-STRING_DELIMITER">'</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">c</span><span class="highlite-STRING_DELIMITER">'</span>); <span class="highlite-COMMENT"># OUTPUT: «True» </span><span class="highlite-ROUTINE">say</span> <a b 42> <span class="highlite-OPERATOR">eqv</span> (<span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">a</span><span class="highlite-STRING_DELIMITER">'</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">b</span><span class="highlite-STRING_DELIMITER">'</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">42</span><span class="highlite-STRING_DELIMITER">'</span>); <span class="highlite-COMMENT"># OUTPUT: «False», the 42 became an IntStr allomorph </span><span class="highlite-ROUTINE">say</span> <span class="highlite-OPERATOR"><</span> 42 <span class="highlite-OPERATOR">></span> <span class="highlite-OPERATOR">~~</span> <span class="highlite-TYPE">Int</span>; <span class="highlite-COMMENT"># OUTPUT: «True» </span><span class="highlite-ROUTINE">say</span> <span class="highlite-OPERATOR"><</span> 42 <span class="highlite-OPERATOR">></span> <span class="highlite-OPERATOR">~~</span> <span class="highlite-TYPE">Str</span>; <span class="highlite-COMMENT"># OUTPUT: «True» </span></pre> </div> </div> <p>The angle brackets quoting is like <code>qw</code>, but with extra feature that lets you construct <a href="/language/glossary#Allomorph">allomorphs</a> or literals of certain numbers:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> <42 4/2 1e6 1+1i abc>.<span class="highlite-ROUTINE">raku</span>; <span class="highlite-COMMENT"># OUTPUT: «(IntStr.new(42, "42"), RatStr.new(2.0, "4/2"), NumStr.new(1000000e0, "1e6"), ComplexStr.new(<1+1i>, "1+1i"), "abc")»</span></pre> </div> </div> <p>To construct a <a href="/type/Rat"><code>Rat</code></a> or <a href="/type/Complex"><code>Complex</code></a> literal, use angle brackets around the number, without any extra spaces:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> <42/10>.^<span class="highlite-ROUTINE">name</span>; <span class="highlite-COMMENT"># OUTPUT: «Rat» </span><span class="highlite-ROUTINE">say</span> <1+42i>.^<span class="highlite-ROUTINE">name</span>; <span class="highlite-COMMENT"># OUTPUT: «Complex» </span><span class="highlite-ROUTINE">say</span> <span class="highlite-OPERATOR"><</span> 42/10 <span class="highlite-OPERATOR">></span>.^<span class="highlite-ROUTINE">name</span>; <span class="highlite-COMMENT"># OUTPUT: «RatStr» </span><span class="highlite-ROUTINE">say</span> <span class="highlite-OPERATOR"><</span> 1+42i <span class="highlite-OPERATOR">></span>.^<span class="highlite-ROUTINE">name</span>; <span class="highlite-COMMENT"># OUTPUT: «ComplexStr»</span></pre> </div> </div> <p>Compared to <code>42/10</code> and <code>1+42i</code>, there's no division (or addition) operation involved. This is useful for literals in routine signatures, for example:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">sub</span> close-enough-π (<span class="highlite-STRING_DELIMITER"><</span><span class="highlite-STRING">355/113</span><span class="highlite-STRING_DELIMITER">></span>) { <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">Your π is close enough!</span><span class="highlite-STRING_DELIMITER">"</span> } close-enough-π 710/226; <span class="highlite-COMMENT"># OUTPUT: «Your π is close enough!» </span></pre> </div> </div> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-COMMENT"># WRONG: can't do this, since it's a division operation </span><span class="highlite-KEYWORD">sub</span> compilation-failure (355/113) {} </pre> </div> </div> <h2 id="Word_quoting_with_quote_protection:_qww" class="raku-h2"><a name="index-entry-qww-Word_quoting_with_quote_protection:_qww" data-indexedheader="Syntax;qww"></a><a href="#Quoting_constructs" title="go to top of document">Word quoting with quote protection: qww<a class="raku-anchor" title="direct link" href="#Word_quoting_with_quote_protection:_qww">§</a></a></h2> <!-- defnmark Word_quoting_with_quote_protection:_qww 2 --> <p>The <code>qw</code> form of word quoting will treat quote characters literally, leaving them in the resulting words:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">qw</span><span class="highlite-STRING_DELIMITER">{"</span><span class="highlite-STRING">a b" c}.raku; # OUTPUT: «("\"a", "b\"", "c")»</span><span class="highlite-STRING_DELIMITER"></span></pre> </div> </div> <p>Using the <code>qww</code> variant allows you to use quote characters for embedding strings in the word quoting structure:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">qww</span><span class="highlite-STRING_DELIMITER">{"</span><span class="highlite-STRING">a b" c}.raku; # OUTPUT: «("a b", "c")»</span><span class="highlite-STRING_DELIMITER"></span></pre> </div> </div> <p>Other kinds of quotes are also supported with their usual semantics:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$one</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">here</span><span class="highlite-STRING_DELIMITER">'</span>; <span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$other</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">there</span><span class="highlite-STRING_DELIMITER">'</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">qww</span><span class="highlite-STRING_DELIMITER">{</span><span class="highlite-STRING"> ’this and that’ “$one or $other” 「infinity and beyond」 </span><span class="highlite-STRING_DELIMITER">}</span>.<span class="highlite-ROUTINE">raku</span>; <span class="highlite-COMMENT"># OUTPUT: «("this and that", "here or there", "infinity and beyond")»</span></pre> </div> </div> <p>The delimiters of embedded strings are always considered word splitters:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">qww</span><span class="highlite-STRING_DELIMITER">{'</span><span class="highlite-STRING">alpha'beta'gamma' 'delta'"epsilon"}.raku; # OUTPUT: «("alpha", "beta", "gamma", "delta", "epsilon")»</span><span class="highlite-STRING_DELIMITER"></span></pre> </div> </div> <h2 id="Word_quoting_with_interpolation:_qqw" class="raku-h2"><a name="index-entry-qqw-Word_quoting_with_interpolation:_qqw" data-indexedheader="Syntax;qqw"></a><a href="#Quoting_constructs" title="go to top of document">Word quoting with interpolation: qqw<a class="raku-anchor" title="direct link" href="#Word_quoting_with_interpolation:_qqw">§</a></a></h2> <!-- defnmark Word_quoting_with_interpolation:_qqw 2 --> <p>The <code>qw</code> form of word quoting doesn't interpolate variables:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$a</span> <span class="highlite-OPERATOR">=</span> 42; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">qw</span><span class="highlite-STRING_DELIMITER">{</span><span class="highlite-STRING">$a b c</span><span class="highlite-STRING_DELIMITER">}</span>; <span class="highlite-COMMENT"># OUTPUT: «$a b c»</span></pre> </div> </div> <p>Thus, if you wish for variables to be interpolated within the quoted string, you need to use the <code>qqw</code> variant:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$a</span> <span class="highlite-OPERATOR">=</span> 42; <span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@list</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">qqw</span><span class="highlite-STRING_DELIMITER">{</span><span class="highlite-NAME_SCALAR">$a</span><span class="highlite-STRING"> b c</span><span class="highlite-STRING_DELIMITER">}</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_ARRAY">@list</span>; <span class="highlite-COMMENT"># OUTPUT: «[42 b c]»</span></pre> </div> </div> <p>Note that variable interpolation happens before word splitting:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$a</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">a b</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@list</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">qqw</span><span class="highlite-STRING_DELIMITER">{</span><span class="highlite-NAME_SCALAR">$a</span><span class="highlite-STRING"> c</span><span class="highlite-STRING_DELIMITER">}</span>; .<span class="highlite-ROUTINE">say</span> <span class="highlite-KEYWORD">for</span> <span class="highlite-NAME_ARRAY">@list</span>; <span class="highlite-COMMENT"># OUTPUT: «abc»</span></pre> </div> </div> <h2 id="Word_quoting_with_interpolation_and_quote_protection:_qqww" class="raku-h2"><a name="index-entry-qqww-Word_quoting_with_interpolation_and_quote_protection:_qqww" data-indexedheader="Syntax;qqww"></a><a href="#Quoting_constructs" title="go to top of document">Word quoting with interpolation and quote protection: qqww<a class="raku-anchor" title="direct link" href="#Word_quoting_with_interpolation_and_quote_protection:_qqww">§</a></a></h2> <!-- defnmark Word_quoting_with_interpolation_and_quote_protection:_qqww 2 --> <p>The <code>qqw</code> form of word quoting will treat quote characters literally, leaving them in the resulting words:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$a</span> <span class="highlite-OPERATOR">=</span> 42; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">qqw</span><span class="highlite-STRING_DELIMITER">{"</span><span class="highlite-NAME_SCALAR">$a</span><span class="highlite-STRING"> b" c}.raku; # OUTPUT: «("</span><span class="highlite-ESCAPE">\"</span><span class="highlite-STRING">42", "b</span><span class="highlite-ESCAPE">\"</span><span class="highlite-STRING">", "c")»</span><span class="highlite-STRING_DELIMITER"></span></pre> </div> </div> <p>Using the <code>qqww</code> variant allows you to use quote characters for embedding strings in the word quoting structure:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$a</span> <span class="highlite-OPERATOR">=</span> 42; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">qqww</span><span class="highlite-STRING_DELIMITER">{"</span><span class="highlite-NAME_SCALAR">$a</span><span class="highlite-STRING"> b" c}.raku; # OUTPUT: «("42 b", "c")»</span><span class="highlite-STRING_DELIMITER"></span></pre> </div> </div> <p>The delimiters of embedded strings are always considered word splitters:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">qqww</span><span class="highlite-STRING_DELIMITER">{'</span><span class="highlite-STRING">alpha'beta'gamma' 'delta'"epsilon"}.raku; # OUTPUT: «("alpha", "beta", "gamma", "delta", "epsilon")»</span><span class="highlite-STRING_DELIMITER"></span></pre> </div> </div> <p>Unlike the <code>qqw</code> form, interpolation also always splits (except for interpolation that takes place in an embedded string):</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$time</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">now</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-NAME_SCALAR">$_</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">ni</span><span class="highlite-STRING_DELIMITER">'</span>; <span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_ARRAY">@list</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">qqww</span><span class="highlite-STRING_DELIMITER"><</span><span class="highlite-NAME_SCALAR">$time</span><span class="highlite-NAME_SCALAR">$time</span><span class="highlite-STRING"> </span><span class="highlite-ESCAPE">{</span>6*7<span class="highlite-ESCAPE">}</span><span class="highlite-ESCAPE">{</span>7*6<span class="highlite-ESCAPE">}</span><span class="highlite-STRING"> "</span><span class="highlite-NAME_SCALAR">$_</span><span class="highlite-NAME_SCALAR">$_</span><span class="highlite-STRING">"</span><span class="highlite-STRING_DELIMITER">></span>; .<span class="highlite-ROUTINE">say</span> <span class="highlite-KEYWORD">for</span> <span class="highlite-NAME_ARRAY">@list</span>; <span class="highlite-COMMENT"># OUTPUT: «nownow4242nini»</span></pre> </div> </div> <p>Quote protection happens before interpolation, and interpolation happens before word splitting, so quotes coming from inside interpolated variables are just literal quote characters:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$a</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">1 2</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">qqww</span><span class="highlite-STRING_DELIMITER">{"</span><span class="highlite-NAME_SCALAR">$a</span><span class="highlite-STRING">" </span><span class="highlite-NAME_SCALAR">$a</span><span class="highlite-STRING">}.raku; # OUTPUT: «("1 2", "1", "2")» my </span><span class="highlite-NAME_SCALAR">$b</span><span class="highlite-STRING"> = "1 </span><span class="highlite-ESCAPE">\"</span><span class="highlite-STRING">2 3</span><span class="highlite-ESCAPE">\"</span><span class="highlite-STRING">"; say qqww</span><span class="highlite-ESCAPE">{</span><span class="highlite-STRING_DELIMITER">"</span><span class="highlite-NAME_SCALAR">$b</span><span class="highlite-STRING_DELIMITER">"</span> <span class="highlite-NAME_SCALAR">$b</span><span class="highlite-ESCAPE">}</span><span class="highlite-STRING">.raku; # OUTPUT: «("1 </span><span class="highlite-ESCAPE">\"</span><span class="highlite-STRING">2 3</span><span class="highlite-ESCAPE">\"</span><span class="highlite-STRING">", "1", "</span><span class="highlite-ESCAPE">\"</span><span class="highlite-STRING">2", "3</span><span class="highlite-ESCAPE">\"</span><span class="highlite-STRING">")»</span><span class="highlite-STRING_DELIMITER"></span></pre> </div> </div> <h2 id="Word_quoting_with_interpolation_and_quote_protection:_«_»" class="raku-h2"><a name="index-entry-<<_>>-«_»-Word_quoting_with_interpolation_and_quote_protection:_«_»" data-indexedheader="Syntax;<< >>"></a><a href="#Quoting_constructs" title="go to top of document">Word quoting with interpolation and quote protection: « »<a class="raku-anchor" title="direct link" href="#Word_quoting_with_interpolation_and_quote_protection:_«_»">§</a></a></h2> <!-- defnmark Word_quoting_with_interpolation_and_quote_protection:_«_» 2 --> <p>This style of quoting is like <code>qqww</code>, but with the added benefit of constructing <a href="/language/glossary#Allomorph">allomorphs</a> (making it functionally equivalent to <a href="#index-entry-:val_(quoting_adverb)">qq:ww:v</a>). The ASCII equivalent to <code>« »</code> are double angle brackets <code><< >></code>.</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-COMMENT"># Allomorph Construction </span><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$a</span> <span class="highlite-OPERATOR">=</span> 42; <span class="highlite-ROUTINE">say</span> <span class="highlite-OPERATOR">«</span> <span class="highlite-NAME_SCALAR">$a</span> b c ».<span class="highlite-ROUTINE">raku</span>; <span class="highlite-COMMENT"># OUTPUT: «(IntStr.new(42, "42"), "b", "c")» </span><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$a</span> <span class="highlite-OPERATOR">=</span> 42; <span class="highlite-ROUTINE">say</span> <span class="highlite-OPERATOR"><<</span> <span class="highlite-NAME_SCALAR">$a</span> b c ><span class="highlite-OPERATOR">></span>.<span class="highlite-ROUTINE">raku</span>; <span class="highlite-COMMENT"># OUTPUT: «(IntStr.new(42, "42"), "b", "c")» </span> <span class="highlite-COMMENT"># Quote Protection </span><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$a</span> <span class="highlite-OPERATOR">=</span> 42; <span class="highlite-ROUTINE">say</span> <span class="highlite-OPERATOR">«</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-NAME_SCALAR">$a</span><span class="highlite-STRING"> b</span><span class="highlite-STRING_DELIMITER">"</span> c ».<span class="highlite-ROUTINE">raku</span>; <span class="highlite-COMMENT"># OUTPUT: «("42 b", "c")» </span><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$a</span> <span class="highlite-OPERATOR">=</span> 42; <span class="highlite-ROUTINE">say</span> <span class="highlite-OPERATOR"><<</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-NAME_SCALAR">$a</span><span class="highlite-STRING"> b</span><span class="highlite-STRING_DELIMITER">"</span> c ><span class="highlite-OPERATOR">></span>.<span class="highlite-ROUTINE">raku</span>; <span class="highlite-COMMENT"># OUTPUT: «("42 b", "c")»</span></pre> </div> </div> <h2 id="Shell_quoting:_qx" class="raku-h2"><a name="index-entry-qx-Shell_quoting:_qx" data-indexedheader="Syntax;qx"></a><a href="#Quoting_constructs" title="go to top of document">Shell quoting: qx<a class="raku-anchor" title="direct link" href="#Shell_quoting:_qx">§</a></a></h2> <!-- defnmark Shell_quoting:_qx 2 --> <p>To run a string as an external program, not only is it possible to pass the string to the <code>shell</code> or <code>run</code> functions but one can also perform shell quoting. There are some subtleties to consider, however. <code>qx</code> quotes <em>don't</em> interpolate variables. Thus</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$world</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">there</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">qx</span><span class="highlite-STRING_DELIMITER">{</span><span class="highlite-STRING">echo "hello $world"</span><span class="highlite-STRING_DELIMITER">}</span></pre> </div> </div> <p>prints simply <code>hello</code>. Nevertheless, if you have declared an environment variable before calling <code>raku</code>, this will be available within <code>qx</code>, for instance</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights">WORLD=<span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">there</span><span class="highlite-STRING_DELIMITER">"</span> <span class="highlite-ROUTINE">raku</span> <span class="highlite-OPERATOR">></span> <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">qx</span><span class="highlite-STRING_DELIMITER">{</span><span class="highlite-STRING">echo "hello $WORLD"</span><span class="highlite-STRING_DELIMITER">}</span> </pre> </div> </div> <p>will now print <code>hello there</code>.</p><p>The result of calling <code>qx</code> is returned, so this information can be assigned to a variable for later use:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$output</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">qx</span><span class="highlite-STRING_DELIMITER">{</span><span class="highlite-STRING">echo "hello!"</span><span class="highlite-STRING_DELIMITER">}</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_SCALAR">$output</span>; <span class="highlite-COMMENT"># OUTPUT: «hello!»</span></pre> </div> </div> <p>See also <a href="/routine/shell">shell</a>, <a href="/routine/run">run</a> and <a href="/type/Proc/Async"><code>Proc::Async</code></a> for other ways to execute external commands.</p> <h2 id="Shell_quoting_with_interpolation:_qqx" class="raku-h2"><a name="index-entry-qqx-Shell_quoting_with_interpolation:_qqx" data-indexedheader="Syntax;qqx"></a><a href="#Quoting_constructs" title="go to top of document">Shell quoting with interpolation: qqx<a class="raku-anchor" title="direct link" href="#Shell_quoting_with_interpolation:_qqx">§</a></a></h2> <!-- defnmark Shell_quoting_with_interpolation:_qqx 2 --> <p>If one wishes to use the content of a Raku variable within an external command, then the <code>qqx</code> shell quoting construct should be used:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$world</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">there</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">qqx</span><span class="highlite-STRING_DELIMITER">{</span><span class="highlite-STRING">echo "hello </span><span class="highlite-NAME_SCALAR">$world</span><span class="highlite-STRING">"</span><span class="highlite-STRING_DELIMITER">}</span>; <span class="highlite-COMMENT"># OUTPUT: «hello there»</span></pre> </div> </div> <p>Again, the output of the external command can be kept in a variable:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$word</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">cool</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$option</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">-i</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$file</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">/usr/share/dict/words</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$output</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">qqx</span><span class="highlite-STRING_DELIMITER">{</span><span class="highlite-STRING">grep </span><span class="highlite-NAME_SCALAR">$option</span><span class="highlite-STRING"> </span><span class="highlite-NAME_SCALAR">$word</span><span class="highlite-STRING"> </span><span class="highlite-NAME_SCALAR">$file</span><span class="highlite-STRING_DELIMITER">}</span>; <span class="highlite-COMMENT"># runs the command: grep -i cool /usr/share/dict/words </span><span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_SCALAR">$output</span>; <span class="highlite-COMMENT"># OUTPUT: «CooleyCooley'sCoolidgeCoolidge'scool...»</span></pre> </div> </div> <p>Be aware of the content of the Raku variable used within an external command; malicious content can be used to execute arbitrary code. See <a href="/language/traps#Beware_of_variables_used_within_qqx"><code>qqx</code> traps</a></p><p>See also <a href="/routine/run">run</a> and <a href="/type/Proc/Async"><code>Proc::Async</code></a> for better ways to execute external commands.</p> <h2 id="Heredocs:_:to" class="raku-h2"><a name="index-entry-heredocs_:to-Heredocs:_:to" data-indexedheader="Syntax;heredocs :to"></a><a href="#Quoting_constructs" title="go to top of document">Heredocs: :to<a class="raku-anchor" title="direct link" href="#Heredocs:_:to">§</a></a></h2> <!-- defnmark Heredocs:_:to 2 --> <p>A convenient way to write a multi-line string literal is by using a <em>heredoc</em>, which lets you choose the delimiter yourself:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">q:to/END/</span>; <span class="highlite-STRING">Here is some multi-line string</span><span class="highlite-STRING_DELIMITER"> END</span> </pre> </div> </div> <p>The contents of the <em>heredoc</em> always begin on the next line, so you can (and should) finish the line.</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$escaped</span> <span class="highlite-OPERATOR">=</span> my-escaping-function(<span class="highlite-STRING_DELIMITER">q:to/TERMINATOR/</span><span class="highlite-OPERATOR">,</span> language <span class="highlite-OPERATOR">=></span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">html</span><span class="highlite-STRING_DELIMITER">'</span>); <span class="highlite-STRING">Here are the contents of the heredoc. Potentially multiple lines.</span><span class="highlite-STRING_DELIMITER"> TERMINATOR</span> </pre> </div> </div> <p>If the terminator is indented, that amount of indention is removed from the string literals. Therefore this <em>heredoc</em></p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">q:to/END/</span>; <span class="highlite-STRING"> Here is some multi line string</span><span class="highlite-STRING_DELIMITER"> END</span> </pre> </div> </div> <p>produces this output:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>「text」 without highlighting</label> <div> <pre class="nohighlights"><pre class="nohighlights"> Here is some multi line string </pre> </pre> </div> </div> <p><em>Heredocs</em> include the newline from before the terminator.</p><p>To allow interpolation of variables use the <code>qq</code> form, but you will then have to escape metacharacters <code>\{</code> as well as <code>$</code> if it is not the sigil for a defined variable. For example:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$f</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">db.7.3.8</span><span class="highlite-STRING_DELIMITER">'</span>; <span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$s</span> <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">qq:to/END/</span>; <span class="highlite-STRING">option </span><span class="highlite-ESCAPE">\{</span><span class="highlite-STRING"> file "</span><span class="highlite-NAME_SCALAR">$f</span><span class="highlite-STRING">"; };</span><span class="highlite-STRING_DELIMITER"> END</span> <span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_SCALAR">$s</span>;</pre> </div> </div> <p>would produce:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>「text」 without highlighting</label> <div> <pre class="nohighlights"><pre class="nohighlights"> option { file "db.7.3.8"; }; </pre> </pre> </div> </div> <p>Some other situations to pay attention to are innocent-looking ones where the text looks like a Raku expression. For example, the following generates an error:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>「text」 without highlighting</label> <div> <pre class="nohighlights"><pre class="nohighlights"> my $title = 'USAFA Class of 1965'; say qq:to/HERE/; <a href='https://usafa-1965.org'>$title</a> HERE # Output: Type Str does not support associative indexing. in block <unit> at here.raku line 2 </pre> </pre> </div> </div> <p>The angle bracket to the right of '$title' makes it look like a hash index to Raku when it is actually a <a href="/type/Str"><code>Str</code></a> variable, hence the error message. One solution is to enclose the scalar with curly braces which is one way to enter an expression in any interpolating quoting construct:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>「text」 without highlighting</label> <div> <pre class="nohighlights"><pre class="nohighlights"> say qq:to/HERE/; <a href='https://usafa-1965.org'>{$title}</a> HERE </pre> </pre> </div> </div> <p>Another option is to escape the `<` character to avoid it being parsed as the beginning of an indexing operator:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>「text」 without highlighting</label> <div> <pre class="nohighlights"><pre class="nohighlights"> say qq:to/HERE/; <a href='https://usafa-1965.org'>$title\</a> HERE </pre> </pre> </div> </div> <p>Because a <em>heredoc</em> can be very long but is still interpreted by Raku as a single line, finding the source of an error can sometimes be difficult. One crude way to debug the error is by starting with the first visible line in the code and treating is as a <em>heredoc</em> with that line only. Then, until you get an error, add each line in turn. (Creating a Raku program to do that is left as an exercise for the reader.)</p><p>You can begin multiple Heredocs in the same line. If you do so, the second heredoc will not start until after the first heredoc has ended.</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> (<span class="highlite-NAME_SCALAR">$first</span><span class="highlite-OPERATOR">,</span> <span class="highlite-NAME_SCALAR">$second</span>) <span class="highlite-OPERATOR">=</span> <span class="highlite-STRING_DELIMITER">qq:to/END1/</span><span class="highlite-OPERATOR">,</span> <span class="highlite-STRING_DELIMITER">qq:to/END2/</span>; <span class="highlite-STRING"> FIRST MULTILINE STRING</span><span class="highlite-STRING_DELIMITER"> END1</span> <span class="highlite-STRING"> SECOND MULTILINE STRING</span><span class="highlite-STRING_DELIMITER"> END2</span> <span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_SCALAR">$first</span>; <span class="highlite-COMMENT"># OUTPUT: «FIRSTMULTILINESTRING» </span><span class="highlite-ROUTINE">say</span> <span class="highlite-NAME_SCALAR">$second</span>; <span class="highlite-COMMENT"># OUTPUT: «SECONDMULTILINESTRING» </span></pre> </div> </div> <h2 id="Unquoting" class="raku-h2"><a name="index-entry-Unquoting-Unquoting" data-indexedheader="Language;Unquoting"></a><a href="#Quoting_constructs" title="go to top of document">Unquoting<a class="raku-anchor" title="direct link" href="#Unquoting">§</a></a></h2> <!-- defnmark Unquoting 2 --> <p>Literal strings permit interpolation of embedded quoting constructs by using the escape sequences such as these:</p> <div class="raku-code raku-lang"> <button class="copy-code" title="Copy code"><i class="far fa-clipboard"></i></button> <label>Raku highlighting</label> <div> <pre class="nohighlights"><span class="highlite-KEYWORD">my</span> <span class="highlite-NAME_SCALAR">$animal</span>=<span class="highlite-STRING_DELIMITER">"</span><span class="highlite-STRING">quaggas</span><span class="highlite-STRING_DELIMITER">"</span>; <span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">These animals look like </span><span class="highlite-ESCAPE">\</span><span class="highlite-STRING_DELIMITER">qq</span><span class="highlite-STRING_DELIMITER">[</span><span class="highlite-NAME_SCALAR">$animal</span><span class="highlite-STRING_DELIMITER">]</span><span class="highlite-STRING_DELIMITER">'</span>; <span class="highlite-COMMENT"># OUTPUT: «These animals look like quaggas» </span><span class="highlite-ROUTINE">say</span> <span class="highlite-STRING_DELIMITER">'</span><span class="highlite-STRING">These animals are </span><span class="highlite-ESCAPE">\</span><span class="highlite-STRING_DELIMITER">qqw</span><span class="highlite-STRING_DELIMITER">[</span><span class="highlite-NAME_SCALAR">$animal</span><span class="highlite-STRING"> or zebras</span><span class="highlite-STRING_DELIMITER">]</span><span class="highlite-STRING_DELIMITER">'</span>; <span class="highlite-COMMENT"># OUTPUT: «These animals are quaggas or zebras»</span></pre> </div> </div> <p>In this example, <code>\qq</code> will do double-quoting interpolation, and <code>\qqw</code> word quoting with interpolation. Escaping any other quoting construct as above will act in the same way, allowing interpolation in literal strings.</p> </div></div></section> </div> </div> </div> <footer class="footer main-footer"> <div class="container px-4"> <nav class="level"> <div class="level-left"> <div class="level-item"> <a href="/about">About</a> </div> <div class="level-item"> <a id="toggle-theme">Toggle theme</a> </div> <div class="level-item" title="a89742bdf 2024-07-14"> <a>Commit</a> </div> </div> <div class="level-right"> <div class="level-item"> <a href="/license">License</a> </div> </div> </nav> </div> </footer> <script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script></body> </html>