Hi,
WARNING: If you run these scripts, you will probably
get character corruption of your terminal, which can be
cleared with "reset". My first question: is there a simple
print code that I can print as the last line of my script to
reset the screen without losing the data printout?
If I type clear or reset after the script runs, it wipes
out my previous output. Is there some way of printing
a last line, say
print '[[asc', "done\n" ;
or something similar that will just reset my next line only?
Question 2:
I'm playing with a homemade virusscanner.
I've learned to do binary regexes, learned the value
of precompiling regexes, and now I'm working on
storing the precompiled binary regexes to a file
using Storable.
What I can do sucessfully, is convert hex signatures
to binary values, and store them in a hash via Storable.
I can retreive the hash, and do regexes sucessfully on
binary files.
What I want to do, is precompile the binary regexes and
store them with Storable. This isn't working for me, and
I'm stumped.
I've tried everything in my small toolbox, to get
$sigs{$name}= qr/\Q$valbin\E/;
to be accurately recovered.
Tried
"qr/\Q$valbin\E/";
and
quotemeta qr/\Q$valbin\E/;
with differing results.
2 scripts below demonstrate my roadblock.
########################################
#!/usr/bin/perl
#create the Storable file
use warnings;
use Storable;
my %sigs;
while (<DATA>){
chomp;
($name,$value) = split(/=/,$_);
$valbin = pack 'H*', $value;
$sigs{$name}= $valbin; # this one works
# $sigs{$name}= qr/\Q$valbin\E/; # this one dosn't
}
foreach $name (keys %sigs){print "$name\t$sigs{$name}\n";}
store(\%sigs, 'z1.bin') or die "Can't store %a in z1.bin !\n";
exit;
__DATA__
10 past 3 (B)=ec020e1ff3a4b82125061fbab300cd21
10 past 3 (C)=b840008ed8a11300b106d3e02d00088e
100-Years=fe3a558bec50817e0400c0730c2ea147
1024-PrScr #1=8cc0488ec026a103002d800026a30300
1024-PrScr #2=a172041f3df0f07505a10301cd0526a1
##############################################
#############################################
#!/usr/bin/perl
#read the Storable file
#use strict;
use warnings;
use Storable;
my %sigs = %{retrieve('z1.bin')} or die "Unable to retrieve from z1.bi
+n:$!\n" ;
foreach $name (keys %sigs){print "$name\t$sigs{$name}\n";}
#################################################
Edit by tye to escape [s
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.