From the lack of response so far, we're not sure what you were expecting these statements to do.

What's in $columns[0] before you start playing with it? What do you want to extract? Are you trying to delete features from the string?

All we might try to do, which may or may not be helpful, is tell you what your code actually does. This way, you can figure out how we're misunderstanding your problem.

($columns[0] =~ /(["\/home"]*)/)
The first regular expression has one captured group, consisting of zero or more consecutive occurrences of ehmo"/ characters, such as in 'mh/ehh///e"hoe/mmm"me/o'. If found in $columns[0], such a span would be copied and assigned to $1, which you don't seem to be assigning to anything more useful. $columns[0] is not modified. The statement is missing a terminator (like a semicolon) before the next statement.
($columns[0] =~ /(["\/mail"]*)/)
The second regular expression is similar; it has one captured group, consisting of zero or more consecutive occurrences of ailm"/ characters. If found in $columns[0], such a span would be assigned to $1, which you again fail to save anywhere. $columns[0] is not modified. The statement is missing a terminator (like a semicolon) before the next statement.
($columns[0] =~ "cat: cannot open /home/$username/$file")
The third expression has no effect. It uses a string as a regular expression, one which would match any occurrence of a very literal error message, if found. $columns[0] is not modified. No results are captured anywhere.

If you're looking to modify $columns[0], such as removing various substrings, you need the s/search/replace/ operator, not the plain matching /match/ operator. If you meant to match specific strings, don't put them in [...] character classes. If there won't be quotes in your original string, don't put quotes in your matching expression.

--
[ e d @ h a l l e y . c c ]


In reply to Re: Fiddling around with reg-ex by halley
in thread Fiddling around with reg-ex by JoeJaz

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.