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!