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.
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] =~ /(["\/home"]*)/)
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] =~ /(["\/mail"]*)/)
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.($columns[0] =~ "cat: cannot open /home/$username/$file")
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |