Re: out to keyboard

2007-12-19 Thread Jay Savage
On Dec 18, 2007 1:28 PM, Ryan [EMAIL PROTECTED] wrote:
 Here's something I've never done before and I need some help.

 I want to control a terminal program that is proprietary and Curses
 and such won't work.  So instead I'd like to have my perl program
 output chars to the keyboard or mouse port on my UNIX machine, which
 will be plugged into a Windows machine with the terminal.  Will this
 work?  How can I do it?

 Thanks!


You're probably making this more complicated than it needs to be. The
terminal program may be proprietary, but the interface isn't--at least
the important part of the interface--isn't: IO is still being handled
by the OS and drivers installed in the OS. You may not be able to
write a *new interface* in Curses, but as long as you know what sort
of input the program needs, you can *control* the program using a Perl
interface module like Expect, IPC::Open3, or IPC::Run. On Windows, you
might also want to check out Win32::GuiTest.

HTH,

-- jay
--
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.downloadsquad.com  http://www.engatiki.org

values of β will give rise to dom!


Re: regexp for two quotes

2007-12-19 Thread Jay Savage
Please don't top post...

On Dec 18, 2007 6:41 PM, Corin Lawson [EMAIL PROTECTED] wrote:
 Hi ab,

 Can you not simply count the number of quotes mod 2?


No, you can't just count the number of quotes. An even number of
quotes doesn't mean they're all double quotes. Consider something like
q|a'b'c''d'e'f|.

sometimes, it's just easier to chain together a couple of expressions:

  unless ( /'/ and ( /'''/ or /[^']'[^']/ ) ) {do something}


HTH,

-- jay
--
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.downloadsquad.com  http://www.engatiki.org

values of β will give rise to dom!


help in variable pattern matching

2007-12-19 Thread Jin Zhisong
HI, I'm looking for some advice of how to do this?

 

I need to match some variable pattenrs so 

 

I define a $match variable and use it in the patterr below.

However it didn't match anything for the sample data. 

 

If I change the match critia to hardcode

   next  unless /\s+BCV\s+N/Grp/;  it works

if I 

  next  unless /\s+BCV\s+N\/Grp/;  it didn't work

 

so my question are

1.  what is the proper way to use \ within regex? 

2.  can I use $match within regex , sun as / $match ../, should I quote
' or  for $match ?

3.  can I use ${match} to make it more readiable? 

 

Thanks.

Jason

 

= code segment ===

my $sid   = $ARGV[0]; 

my $type = $ARGV[1];

 

my @devices  = find_avaiable_devices (); 

 

sub find_available_devices {

my @finds = ();

my $match = ( $type eq 'bcv' ) ? 'BCV' : 'RAID-5' ;

 

open (AVAIL, $symdev list -sid $sid -noport -$type | ) or die
cannot open $!\n;

 

while ( AVAIL ) {

 

next unless /Not Visible.*\d\d[A-D]:[A-D][0-3]\s+${match}\s+N\/Grp/;

 

my ($device , $type, $size) = ( split )[0,5,8];

push @finds , $device  if defined $device ;

} 

return @finds;

 

 

__END__

 

# Sample output from $symdev list -sid $sid -noport -$type below 

__DATA__

05F3 Not Visible???:? 16A:CF  RAID-5N/Grp'd  RW
9492

05F4 Not Visible???:? 01A:DF  RAID-5N/Grp'd  RW
9492

05F5 Not Visible???:? 16A:D10 RAID-5   N/Grp'd  RW
9492

05F6 Not Visible???:? 01A:C10 RAID-5   N/Grp'd  RW
9492

05F7 Not Visible???:? 16A:CF  RAID-5N/Grp'd  RW
9492

 

05FA Not Visible ???:? 16A:D0  BCVN/Asst'd RW
9492

05FB Not Visible ???:? 16D:C0  BCVN/Asst'd RW
9492

05FC Not Visible ???:? 01A:C0  BCVN/Asst'd RW
9492

05FD Not Visible ???:? 16B:C0  BCVN/Asst'd RW
9492

 



Hi... Help regarding chdir

2007-12-19 Thread Ravindra Ugaji
Hi Monks,
I am trying the following code to change the directory

chdir ( '/opt/application') || die (Can't change directory: $!\n);
tried this also
chdir /opt/application || die Can't change directory: $!\n;


But i am unable to change the directory to  /opt/application  from
present working directory

I am using perl 5.6.1 built for sun4-solaris-64int and it wont support
File::chdir  
can any one suggest the alternative solution for this problem?

:-)


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Hi... Help regarding chdir

2007-12-19 Thread Roberto Etcheverry
It should work unless the user you are using to run the script doesn't
have the rights to chdir to that directory.

Ravindra Ugaji wrote:
 Hi Monks,
 I am trying the following code to change the directory

 chdir ( '/opt/application') || die (Can't change directory: $!\n);
 tried this also
 chdir /opt/application || die Can't change directory: $!\n;


 But i am unable to change the directory to  /opt/application  from
 present working directory

 I am using perl 5.6.1 built for sun4-solaris-64int and it wont support
 File::chdir  
 can any one suggest the alternative solution for this problem?

 :-)


   


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Hi... Help regarding chdir

2007-12-19 Thread Tom Phoenix
On 12/18/07, Ravindra Ugaji [EMAIL PROTECTED] wrote:

 Hi Monks,

The Perl Monks are two doors down, on the left. But maybe we can help you here.

 I am trying the following code to change the directory

 chdir ( '/opt/application') || die (Can't change directory: $!\n);

 But i am unable to change the directory to  /opt/application  from
 present working directory

Do you get an error message? What does it say?

If there is no error message, perhaps you mean that, after the program
has finished running, you find that the shell is still using the
original working directory. That's a feature of your operating system,
not a bug. You can't change the working directory of another program
without that program's knowledge and consent, else programs would
unexpectedly find themselves working in the wrong directories and
wreaking havoc. This is covered in the Unix FAQ, question 2.8, among
other places; but the answer is about the same in principle on any
other OS.

http://www.faqs.org/faqs/unix-faq/faq/part2/
http://packetstormsecurity.org/unix-humor/awesome.unix.chdir.program.html

Check the documentation for your shell program, too, because it may
have a suggestion on how you can do what you want.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Date::manip query

2007-12-19 Thread pauld
im sorting it on a key of the hash
my @daylistsorted = sort { $$a{'START_DS'} = $$b{'START_DS'} }
@daylist;
 generates a
Argument 2007:09:30 13:41 isn't numeric in numeric comparison (=)
at ./518573

error

my @daylistsorted = sort { $$a{'START'} = $$b{'START'} } @daylist;

works


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: help in variable pattern matching

2007-12-19 Thread Roberto Etcheverry
Jin Zhisong wrote:
 HI, I'm looking for some advice of how to do this?

  

 I need to match some variable pattenrs so 

  

 I define a $match variable and use it in the patterr below.

 However it didn't match anything for the sample data. 

  

 If I change the match critia to hardcode

next  unless /\s+BCV\s+N/Grp/;  it works
   
This line gives me a syntax error (Bareword found where operator expected)
 if I 

   next  unless /\s+BCV\s+N\/Grp/;  it didn't work
   
This regular expression matches one or more spaces, BCV, one or more
spaces and N/Grp (i.e.,  BCV N/Grp)
  

 so my question are

 1.  what is the proper way to use \ within regex? 
   
You use '\' when you want to match literally some character that
otheways would be interpreted as an operator ('+', '*', etc.) or end of
regex (like '/' in the example above). Just to be sure, escape with '\'
any non alphanumeric you want to match literally.
 2.  can I use $match within regex , sun as / $match ../, should I quote
 ' or  for $match ?
   
You can use $match alone or ${match} (safer).
 3.  can I use ${match} to make it more readiable? 
   
Yes, it's better.
  

 Thanks.

 Jason

  

 = code segment ===

 my $sid   = $ARGV[0]; 

 my $type = $ARGV[1];

  

 my @devices  = find_avaiable_devices (); 

  

 sub find_available_devices {

 my @finds = ();

 my $match = ( $type eq 'bcv' ) ? 'BCV' : 'RAID-5' ;

  

 open (AVAIL, $symdev list -sid $sid -noport -$type | ) or die
 cannot open $!\n;

  

 while ( AVAIL ) {

  

 next unless /Not Visible.*\d\d[A-D]:[A-D][0-3]\s+${match}\s+N\/Grp/;

  

 my ($device , $type, $size) = ( split )[0,5,8];

 push @finds , $device  if defined $device ;

 } 

 return @finds;

  

  

 __END__

  

 # Sample output from $symdev list -sid $sid -noport -$type below 

 __DATA__

 05F3 Not Visible???:? 16A:CF  RAID-5N/Grp'd  RW
 9492

 05F4 Not Visible???:? 01A:DF  RAID-5N/Grp'd  RW
 9492

 05F5 Not Visible???:? 16A:D10 RAID-5   N/Grp'd  RW
 9492

 05F6 Not Visible???:? 01A:C10 RAID-5   N/Grp'd  RW
 9492

 05F7 Not Visible???:? 16A:CF  RAID-5N/Grp'd  RW
 9492

  

 05FA Not Visible ???:? 16A:D0  BCVN/Asst'd RW
 9492

 05FB Not Visible ???:? 16D:C0  BCVN/Asst'd RW
 9492

 05FC Not Visible ???:? 01A:C0  BCVN/Asst'd RW
 9492

 05FD Not Visible ???:? 16B:C0  BCVN/Asst'd RW
 9492

  


   


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: help in variable pattern matching

2007-12-19 Thread Tom Phoenix
On 12/19/07, Jin Zhisong [EMAIL PROTECTED] wrote:

next  unless /\s+BCV\s+N/Grp/;  it works

Oh, I hope it doesn't work. The number of forward slashes is all wrong.

   next  unless /\s+BCV\s+N\/Grp/;  it didn't work

But this one might actually parse. If it doesn't match when it's
supposed to, and fail when it's supposed to, that's another problem.
(Does it matter that no line in your sample data has both BCV and
N/Grp?)

 1.  what is the proper way to use \ within regex?

If you need to use the quoting character (/ in your pattern above)
as an actual literal character in the pattern, you need to backslash
it, as you did in your second pattern above. That tells Perl that this
isn't the end-of-pattern delimiter, this is a literal character. But
because patterns like this:

/^\/usr\/bin\//

... are hard to read and write, Perl lets you choose a different
punctuation mark than the forward slash as a quoting character. In
exchange, you have to warn Perl that you want a pattern match by
putting the letter m in front of your pattern. That ugly pattern above
might thus become:

m#^/usr/bin/#

... if you choose the #-sign as a delimiter.

On the other hand, the backslash character is always special in Perl.
If you mean a literal backslash character within a string or a
pattern, you always need to use two of them.

 2.  can I use $match within regex , sun as / $match ../, should I quote
 ' or  for $match ?

I'm not completely sure what you're asking, but I think you want to
know about building a pattern at run-time by interpolating a variable
into a pattern. Yes, you can interpolate a variable such as $match
into a pattern; you'll generally want the qr// operator to quote the
pieces you use to make $match.

http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators

 3.  can I use ${match} to make it more readiable?

If you think it's more readable, then you should be able to use it.
But maybe you really want to add the /x flag to your pattern, and
write it so that it's _really_ readable.

While you're still developing your program and trying to get your
pattern to match, you don't need to keep running your external
program. Run it once, save the output to a file, then have your
program read that file. That makes it easier to step through your code
with the debugger, and it's better for testing because the data
doesn't change from one run to the next.

In fact, it would be arguably better to design your program so that it
can work on either a given data file or the external program's output.
That would allow you to easily make a test program that checks that
your program behaves correctly when given known test data, so you
could have more confidence in its behavior when its data comes from
the external program.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: help in variable pattern matching

2007-12-19 Thread Dr.Ruud
Jin Zhisong schreef:

 I define a $match variable and use it in the patterr below.
 However it didn't match anything for the sample data.

perldoc -f qr

-- 
Affijn, Ruud

Gewoon is een tijger.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Date::manip query

2007-12-19 Thread Tom Phoenix
On 12/19/07, pauld [EMAIL PROTECTED] wrote:

 im sorting it on a key of the hash
 my @daylistsorted = sort { $$a{'START_DS'} = $$b{'START_DS'} }
 @daylist;
  generates a
 Argument 2007:09:30 13:41 isn't numeric in numeric comparison (=)
 at ./518573

Have you tried using a string comparison when you want to compare
strings? In Perl, that's the cmp operator.

http://perldoc.perl.org/perlop.html

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Date::manip query

2007-12-19 Thread Gunnar Hjalmarsson

pauld wrote:

Gunnar Hjalmarsson wrote:

pauld wrote:

im using Date::Manip to convert dates  and times eg  2007:08:02 12:23
to allow me to sort them,


Why are you doing that?

C:\hometype test.pl
@dates = ( '2007:08:02 12:23', '2007:10:21 04:40',
  '2007:06:05 16:08', '2007:09:11 22:20', );
print $_\n for sort @dates;

C:\hometest.pl
2007:06:05 16:08
2007:08:02 12:23
2007:09:11 22:20
2007:10:21 04:40


im sorting it on a key of the hash
my @daylistsorted = sort { $$a{'START_DS'} = $$b{'START_DS'} }
@daylist;
 generates a
Argument 2007:09:30 13:41 isn't numeric in numeric comparison (=)
at ./518573


My point is that the format :mm:dd hh:mm is sortable without 
conversion. However, you need to sort lexically, i.e. use the cmp 
operator instead of the = operator.


--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Hi... Help regarding chdir

2007-12-19 Thread Chas. Owens
On Dec 19, 2007 2:29 AM, Ravindra Ugaji [EMAIL PROTECTED] wrote:
 Hi Monks,
 I am trying the following code to change the directory

 chdir ( '/opt/application') || die (Can't change directory: $!\n);
 tried this also
 chdir /opt/application || die Can't change directory: $!\n;
snip

In addition to what others have already said, never do the second*.
The || operator has a higher precedence than function calls, so

func string || die oops;

is really saying

func(string || die(oops));

Since string is truthy, the die will never occur.  If you want to
avoid the use of parenthesis you can use the lower precedence or:

func string or die oops;

* unless, of course, it is what you really mean

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: testing for a file type

2007-12-19 Thread Chas. Owens
On Dec 18, 2007 4:49 PM, Rob Dixon [EMAIL PROTECTED] wrote:
snip
 if (grep { not /\.mdb\z/ } @ARGV) {
print All parameters must be MDB files\n;
exit;
 }
snip

Or in Perl 5.10, coming to stores near you soon*, you can use the
smart match operator:

@ARGV ~~ /\.mdb\z/
or die All parameters must be MDB files

See smart matching in perldoc perlsyn or
http://search.cpan.org/dist/perl/pod/perlsyn.pod#Smart_matching_in_detail

* I just checked and in fact it was released yesterday.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Hi... Help regarding chdir

2007-12-19 Thread Tom Phoenix
On 12/19/07, Chas. Owens [EMAIL PROTECTED] wrote:

 On Dec 19, 2007 2:29 AM, Ravindra Ugaji [EMAIL PROTECTED] wrote:

  chdir ( '/opt/application') || die (Can't change directory: $!\n);
  tried this also
  chdir /opt/application || die Can't change directory: $!\n;

 In addition to what others have already said, never do the second*.
 The || operator has a higher precedence than function calls, so

 func string || die oops;

 is really saying

 func(string || die(oops));

 Since string is truthy, the die will never occur.

You have the right idea about functions in general; but chdir() is a
named unary operator, so it has higher precedence than the ||
operator:

  chdir /any/wrong/path || die This will indeed die: $!;

That means that the OP's code isn't so wrong as it may seem, even
though there's surely a better way to write it.

Cheers!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Hi... Help regarding chdir

2007-12-19 Thread Paul Lalli
On Dec 19, 2:29 am, [EMAIL PROTECTED] (Ravindra Ugaji) wrote:
 I am trying the following code to change the directory

 chdir ( '/opt/application') || die (Can't change directory: $!\n);
 tried this also
 chdir /opt/application || die Can't change directory: $!\n;

 But i am unable to change the directory to  /opt/application  from
 present working directory

What is your indication of that?  How do you know the directory has
not changed?  Do you get an error message, and if so, what is it?   Do
you have some code below this later that proves you're not in /opt/
application?

Or do you mean that when your program exits, you are back where you
started the program from?  That is, you are in /home/jsmith, you run
this program, and when the program exits, you're still in /home/
jsmith.   If that's the error you're talking about, please read:
perldoc -q directory
Found in /usr/lib/perl5/5.8/pods/perlfaq8.pod
   I {changed directory, modified my environment} in a perl
script.  How
   come the change disappeared when I exited the script?  How do I
get my
   changes to be visible?


Paul Lalli


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: help in variable pattern matching

2007-12-19 Thread Jin Zhisong


Thanks every one that helps. I find my problem.  Now how 
can I have a $pattern that contain some special characters
to pass it into  regex?  


I want to extract the line that contains either 
RAID-5N/Grp'd  
Or 
BCV   N/Asst'd 


The following code didn't work.   


My $type = $ARGV[1]

my $match = ( $type eq 'bcv' ) ? 'BCV' : 'RAID-5' ;
my $pattern = ( $type eq 'bcv' ) ? ${match}\s+N\/Asst :
${match}\s+N\/Grp ;

while ( DATA ) {
next unless /$pattern/;
print $_ ; 

} 

__DATA__
05F3 Not Visible???:? 16A:CF  RAID-5N/Grp'd  RW9492
05F5 Not Visible???:? 16A:D10 RAID-5N/Grp'd  RW9492
0031 Not Visible???:? 01C:C0  2-Way Mir N/Grp'd  RW9492
05FA Not Visible???:? 16A:D0  BCV   N/Asst'd RW
9492
05FC Not Visible???:? 01A:C0  BCV   N/Asst'd RW
9492

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: help in variable pattern matching

2007-12-19 Thread Tom Phoenix
On 12/19/07, Jin Zhisong [EMAIL PROTECTED] wrote:

 The following code didn't work.

 my $pattern = ( $type eq 'bcv' ) ? ${match}\s+N\/Asst :
 ${match}\s+N\/Grp ;

Did it not work because it did not use qr//? That's at least part of
the problem. It may help you during development if you output the
value of $pattern, so you can see whether it's getting built as you
expect.

Cheers!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regexp for two quotes

2007-12-19 Thread Dr.Ruud
Rob Dixon schreef:
 Dr.Ruud wrote:
 Rob Dixon schreef:
 scooter:

 Can someone help me with the regexp that will match exactly two
 quotes(') or no quotes in the string.
 If a single quote exists, then will break out.

 eg:
 aabbcc -  Should Match
 aa''bb''c''c - Should Match
 a''b - Should Match
 ab'' - Should Match


 aa'bbcc - Should not Match
 aa''bb'cc - Should not Match (since there is a single quote)
 'aabcc - Should not Match

 This does what you have described. It looks for a single quote,
 preceded by a character other than a single quote or the start of
 the string, and followed by a character other than a single quote
 or the end of the string.

 if (not /(?:\A|[^'])'(?:\Z|[^'])/) {
print matches\n
 }

 That would fail q{ab}.

 What do you mean by fail?

 use strict;
 use warnings;

 for (q{ab}) {

if (not /(?:\A|[^'])'(?:\Z|[^'])/) {
  print matches\n
}

 }
 __END__

 prints 'matches'.

 I understand this to be correct as the string doesn't contain a
 solitary single quote.

I guess I meant that the regex inside fails to treat q{} as two
instances of q{''}, or as two matches of qr/'[^']*'/.

So what about q{'''} then? The above code prints 'matches' for it.

-- 
Affijn, Ruud

Gewoon is een tijger.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regexp for two quotes

2007-12-19 Thread Dr.Ruud
Jay Savage schreef:
 Corin Lawson wrote:

 Can you not simply count the number of quotes mod 2?

 No, you can't just count the number of quotes. An even number of
 quotes doesn't mean they're all double quotes. Consider something like
 q|a'b'c''d'e'f|.

I haven't read anywhere yet that the quotes should be touching.

-- 
Affijn, Ruud

Gewoon is een tijger.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Crypt SQLite

2007-12-19 Thread fsantiago
On Dec 9, 7:03 am, [EMAIL PROTECTED] (Octavian Rasnita) wrote:
 From: David Filmer [EMAIL PROTECTED]





  On Dec 6, 10:47 am, [EMAIL PROTECTED] (Octavian Rasnita) wrote:
  I've seen a program made in C# that uses an SQLite database which is
  crypted.

  I doubt that.  SQLite does not (AFAIK) have an encrypted database
  engine.  The only way that such a program could do this is if the C#
  program somehow augmented the SQLite source code.

  Can we do the same thing with perl?

  You can do the same thing that the C# program (probably) did - namely
  encrypt the values before inserting them into the database.  Perl can
  do all sorts of encryption - search the Crypt:: namespace at
 http://cpan.org.
  You probably want some sort of bi-directional encryption instead of a
  hash encryption (which is usually used for password checking and
  such).  Symmetrical pass-key encryption is easy but not especially
  strong (though probably adequate for most situations, as cracking a
  good pass-key is still a ponderous task). Some sort of certificate-
  based (PPK) encryption is pretty good.

  Of course, since a SQLite database is just a simple file, you can
  store it on an encrypted filesystem, which offers a good measure of
  protection in some circumstances (lost hard drive, stolen powered-off
  laptop, etc).

 Well, here it is an archive that contains the following files:
 sqlt_fruit.exe - a sample program made in C# that uses a crypted SQLite
 database
 sqlt_fruit.cs - the source code for that program
 CompileSqlt_fruit.bat - a bat file with the command line used for compiling
 that program
 System.Data.SQLite.DLL - a dll file needed for running the program

 http://www.tranzactiibursiere.ro/static/CryptedSQLite.zip

 So it seems that this is possible, and when working with an SQLite database,
 C# has a big advantage when it is compared it with perl.

 Octavian- Hide quoted text -

 - Show quoted text -

I've tried this and it works fine with my C# application running on
XP, however, I cannot run it on Windows Vista? complaining about a
problem signature on System.Data.SQLite.DLL.

Any ideas?

Thanks!


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Crypt SQLite

2007-12-19 Thread Octavian Rasnita

From: [EMAIL PROTECTED]


On Dec 9, 7:03 am, [EMAIL PROTECTED] (Octavian Rasnita) wrote:

 I've seen a program made in C# that uses an SQLite database which is
 crypted.

 I doubt that.  SQLite does not (AFAIK) have an encrypted database
 engine.  The only way that such a program could do this is if the C#
 program somehow augmented the SQLite source code.

 Can we do the same thing with perl?

 You can do the same thing that the C# program (probably) did - namely
 encrypt the values before inserting them into the database.  Perl can
 do all sorts of encryption - search the Crypt:: namespace at
http://cpan.org.
 You probably want some sort of bi-directional encryption instead of a
 hash encryption (which is usually used for password checking and
 such).  Symmetrical pass-key encryption is easy but not especially
 strong (though probably adequate for most situations, as cracking a
 good pass-key is still a ponderous task). Some sort of certificate-
 based (PPK) encryption is pretty good.

 Of course, since a SQLite database is just a simple file, you can
 store it on an encrypted filesystem, which offers a good measure of
 protection in some circumstances (lost hard drive, stolen powered-off
 laptop, etc).

Well, here it is an archive that contains the following files:
sqlt_fruit.exe - a sample program made in C# that uses a crypted SQLite
database
sqlt_fruit.cs - the source code for that program
CompileSqlt_fruit.bat - a bat file with the command line used for 
compiling

that program
System.Data.SQLite.DLL - a dll file needed for running the program

http://www.tranzactiibursiere.ro/static/CryptedSQLite.zip

So it seems that this is possible, and when working with an SQLite 
database,

C# has a big advantage when it is compared it with perl.

Octavian- Hide quoted text -

- Show quoted text -


I've tried this and it works fine with my C# application running on
XP, however, I cannot run it on Windows Vista? complaining about a
problem signature on System.Data.SQLite.DLL.

Any ideas?

Thanks!


Sorry. No idea. I didn't wrote that C# program because I don't know C# well 
enough. That's why I was interested in a perl solution, but unfortunately it 
is not possible in perl.


I don't even have Windows Vista to test the program under that OS.

Octavian



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: testing for a file type

2007-12-19 Thread Jenda Krynicky
From: Chas. Owens [EMAIL PROTECTED]
 On Dec 18, 2007 4:49 PM, Rob Dixon [EMAIL PROTECTED] wrote:
 snip
  if (grep { not /\.mdb\z/ } @ARGV) {
 print All parameters must be MDB files\n;
 exit;
  }
 snip
 
 Or in Perl 5.10, coming to stores near you soon*, you can use the
 smart match operator:
 
 @ARGV ~~ /\.mdb\z/
 or die All parameters must be MDB files
 
 See smart matching in perldoc perlsyn or
 http://search.cpan.org/dist/perl/pod/perlsyn.pod#Smart_matching_in_detail
 
 * I just checked and in fact it was released yesterday.

I did not install it yet so I can't check but I think you have it 
wrong. According to the docs you point to

   @ARGV ~~ /\.mdb\z/

is equivalent to

   grep /\.mdb\z/, @ARGV

which is true whenever at least one item in the array matches the 
regexp. So it would be

 @ARGV ~~ /\.mdb\z/
 or die At least one of the parameters must be an MDB file;

Probably not what Rob (or whoever posted the original post) intended.

   grep {not condition} @ARRAY 

 is not equivalent to

   not grep {condition} @ARRAY 

not even in boolean context.


   @ARGV ~~ /\.mdb\z/
is
   any(@ARGV) =~ /\.mdb\z/
not
   all(@ARGV) =~ /\.mdb\z/

I think there should have been a !~~ operator as well.

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regexp for two quotes

2007-12-19 Thread Rob Dixon

Dr.Ruud wrote:

Jay Savage schreef:

Corin Lawson wrote:



Can you not simply count the number of quotes mod 2?

No, you can't just count the number of quotes. An even number of
quotes doesn't mean they're all double quotes. Consider something like
q|a'b'c''d'e'f|.


I haven't read anywhere yet that the quotes should be touching.


Scooter is leaving us all speculating about his true requirement, but I
read his OP as meaning all single quotes should occur in (touching)
pairs, and any isolated single quote in the string is an error. Whether
or not groups of three or more are allowed is another matter.

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: help in variable pattern matching

2007-12-19 Thread Gunnar Hjalmarsson

Jin Zhisong wrote:
The following code didn't work.   



My $type = $ARGV[1]

my $match = ( $type eq 'bcv' ) ? 'BCV' : 'RAID-5' ;
my $pattern = ( $type eq 'bcv' ) ? ${match}\s+N\/Asst :
${match}\s+N\/Grp ;

while ( DATA ) {

next unless /$pattern/;
print $_ ; 

} 


In addition to Tom's comment, you'd better add

use strict;
use warnings;

at the beginning of your script. That makes Perl give you an indication 
of what the problem is.


--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/