particle wrote: see quotemeta
Cheer Particle. quotemeta is a great tool to add to my growing arsenal. ;)
After quoting the meta characters, I found my logic was all wrong so I started rewriting.
tadman wrote:
- The real problem seems to be the way you are using your arrays. You're not indexing correctly....
- Better still to just iterate and forget the index unless you actually need it...
- As an explanation, the \Q starts "escaping" special characters, the \E stops...
Very thought provoking stuff, especially the bit about indexing correctly. I am still not positive about what would exactly be the correct way to index with this issue, but I took your advice and did away with it, actually, the code is quite different now, but it _is_ doing what I want. ;)
Here's a snippet
my @new = `cat /path/to/some/file`;
foreach my $new (@new) {
my $args = `rpm -qa | grep $new`;
print $new if ($args =~ m/^$/);
}
The actual application for this code has changed focus since my first posting, This time the definition is truelly what I want to do, where as the last description was simply a secondary function.
I take a listing of "new" RPMs and compare them against the installed RPMs. If there is no match, I will assume (at the moment) the package should be downloaded and installed.
What I am working towards now is:
- Sanity checking in relation to packages versions. Older version "new" packages should not be installed
- Using a hash for the values in @new. This is because when I query an RPM package, I cannot query with the extension in tack, otherwise nothing will match. For example:
- Search for: glibc-2.2.5-34
- Download: glibc-2.2.5-34.i386.rpm
Ok, enough talking back to writing. ;)
BTW: ++ all around guys for the great ideas!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.