I'm relatively comfortable using perl's regex language, but have a feeling that command line items speak a different form of the regex-speak.

No, Perl stays the same whether it is on the command line or in a script.

But a line like:
open(TAR,"tar -czpf $target_file $logs/access_log\.d+\.gz |");

Well, that line looks pretty broken to me. You can't just use a regex anywhere... In your first example, your regex was clearly sitting in the match operator. In this example, it is just sitting in a string. It looks like you are hoping perl will search the directory for you and return the files that match. It won't. You'll have to do that yourself.1

By the way, Perl doesn't change on the command line, but how you have to quote things sometimes does. That doesn't have anything to do with perl actually. It stems from the fact that the shell is between you and perl.

On *nix systems, you'll want to use single quotes. Perl variables inside double quotes can look like variables to your shell. Backwhacks in double quotes are also recognized escapes by your shell. You can put anything in single quotes except more single quotes. If you find yourself really needing single quotes in your perl code on the command line, you can use perl's q() operator.

1. Or, as others have pointed out, let the shell do it for you.

-sauoq
"My two cents aren't worth a dime.";

In reply to Re: Acceptable regular expressions within command line type syntax by sauoq
in thread Acceptable regular expressions within command line type syntax by Hagbone

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.