[28422] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9786 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 1 11:06:06 2006

Date: Sun, 1 Oct 2006 08:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 1 Oct 2006     Volume: 10 Number: 9786

Today's topics:
    Re: fetching own text - $_[0] not a string? <user@domain.invalid>
    Re: fetching own text - $_[0] not a string? <mritty@gmail.com>
    Re: fetching own text - $_[0] not a string? <user@domain.invalid>
    Re: fetching own text - $_[0] not a string? <mritty@gmail.com>
    Re: fetching own text - $_[0] not a string? (reading news)
        Modifying a one-liner <mritty@gmail.com>
    Re: Modifying a one-liner beartiger@gmail.com
    Re: Modifying a one-liner <tadmc@augustmail.com>
    Re: My first socket question <bik.mido@tiscalinet.it>
    Re: My first socket question <bik.mido@tiscalinet.it>
    Re: need syntax help vjp2.at@at.BioStrategist.dot.dot.com
    Re: need syntax help <tadmc@augustmail.com>
    Re: pod - purpose of L<> directive <bol@adv.magwien.gv.at>
        Question about a $SIG{__WARN__} handler <bik.mido@tiscalinet.it>
    Re: Question about a $SIG{__WARN__} handler <rvtol+news@isolution.nl>
        Whats the best method to encrypt a big data file? <thedifferenz@gmail.com>
    Re: Whats the best method to encrypt a big data file? <rvtol+news@isolution.nl>
    Re: Whats the best method to encrypt a big data file? <zentara@highstream.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 01 Oct 2006 12:27:31 +0200
From: Vedran <user@domain.invalid>
Subject: Re: fetching own text - $_[0] not a string?
Message-Id: <efo56n$m6o$1@news1.carnet.hr>

Thanks for helping me:
Ok, here is the complete script in the working and non working versions:

#===this will not work====
use strict;
use warnings;
use Crypt::CBC;
my $cipher = new Crypt::CBC('secret', 'DES');

IRC::print "Script loaded\n";
IRC::add_command_handler("", "crypt_all");

sub crypt_all
{
     my $input = $_[0];
     my $target = IRC::get_info(2);
     IRC::print "To $target -$input-\n";
#-----^--- displays for eg. "To #tehend -bla-"

     my $ciphertext = $cipher->encrypt($input);
#-------^--- fails with: Error in command callback input must be 8 bytes 
long at C:/Perl/site/lib/Crypt/DES.pm line 57.

		return 1;
}


#====the following will work=================
use strict;
use warnings;
use Crypt::CBC;
my $cipher = new Crypt::CBC('secret', 'DES');

IRC::print "Script loaded\n";
IRC::add_command_handler("", "crypt_all");

sub crypt_all
{
     my $input = "bla";
     my $target = IRC::get_info(2);
     IRC::print "To $target -$input-\n";
#-----^--- displays "To #tehend -bla-"

     my $ciphertext = $cipher->encrypt($input);
#-------^--- this time encrypt will work, I also tried to decrypt that 
and works well :)

		return 1;
}


------------------------------

Date: 1 Oct 2006 03:48:35 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: fetching own text - $_[0] not a string?
Message-Id: <1159699715.103674.33520@m73g2000cwd.googlegroups.com>

Vedran wrote:
> Thanks for helping me:

You can best show your appreciation by reading and following the
posting guidlines for this group.  They are posted here twice a week.

Please stop top posting.  Please start quoting a relevant portion of
the text to which you are replying to.

> Ok, here is the complete script in the working and non working versions:

That is a flat-out lie.  These scripts are NOT complete.  They do not
run on their own.

> #====the following will work=================

No, it will not.

> use strict;
> use warnings;
> use Crypt::CBC;
> my $cipher = new Crypt::CBC('secret', 'DES');
>
> IRC::print "Script loaded\n";
> IRC::add_command_handler("", "crypt_all");
>
> sub crypt_all
> {
>      my $input = "bla";
>      my $target = IRC::get_info(2);
>      IRC::print "To $target -$input-\n";
> #-----^--- displays "To #tehend -bla-"
>
>      my $ciphertext = $cipher->encrypt($input);
> #-------^--- this time encrypt will work, I also tried to decrypt that
> and works well :)
>
> 		return 1;
> }

String found where operator expected at clpm.pl line 6, near
"IRC::print "Script loaded\n""
        (Do you need to predeclare IRC::print?)
String found where operator expected at clpm.pl line 14, near
"IRC::print "To $target -$input-\n""
        (Do you need to predeclare IRC::print?)
syntax error at clpm.pl line 6, near "IRC::print "Script loaded\n""
syntax error at clpm.pl line 14, near "IRC::print "To $target
-$input-\n""
Execution of clpm.pl aborted due to compilation errors.

Which part of "complete" script was unclear to you?

Paul Lalli



------------------------------

Date: Sun, 01 Oct 2006 12:58:47 +0200
From: Vedran <user@domain.invalid>
Subject: Re: fetching own text - $_[0] not a string?
Message-Id: <efo71b$nor$1@news1.carnet.hr>

Paul Lalli wrote:
> That is a flat-out lie.  These scripts are NOT complete.  They do not
> run on their own.
Of course, this is, as I mentioned in the subject of the first post, an 
xchat perl script, you must run them from xchat to get it work :)


------------------------------

Date: 1 Oct 2006 04:02:41 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: fetching own text - $_[0] not a string?
Message-Id: <1159700561.437096.27890@m7g2000cwm.googlegroups.com>

Vedran wrote:
> Paul Lalli wrote:
> > That is a flat-out lie.  These scripts are NOT complete.  They do not
> > run on their own.
> Of course, this is, as I mentioned in the subject of the first post, an
> xchat perl script, you must run them from xchat to get it work :)

I have no idea what "xchat" is, nor do I care.  This is a Perl
newsgroup.  Post a SHORT but COMPLETE *Perl* scirpt which demonstrates
your error.    Pare your script down to the shortest possible script
which still gives you an error.  This should be a standard step you
take in ANY attempt at debugging.

Paul Lalli



------------------------------

Date: Sun, 01 Oct 2006 13:35:56 GMT
From: "Mumia W. (reading news)" <paduille.4058.mumia.w@earthlink.net>
Subject: Re: fetching own text - $_[0] not a string?
Message-Id: <0vPTg.3681$Y24.1743@newsread4.news.pas.earthlink.net>

On 10/01/2006 05:27 AM, Vedran wrote:
> Thanks for helping me:
> Ok, here is the complete script in the working and non working versions:
> 
> #===this will not work====
> use strict;
> use warnings;
> use Crypt::CBC;
> my $cipher = new Crypt::CBC('secret', 'DES');
> 
> IRC::print "Script loaded\n";
> IRC::add_command_handler("", "crypt_all");
> 
> sub crypt_all
> {
>     my $input = $_[0];
>     my $target = IRC::get_info(2);
>     IRC::print "To $target -$input-\n";
> #-----^--- displays for eg. "To #tehend -bla-"
> 
>     my $ciphertext = $cipher->encrypt($input);
> #-------^--- fails with: Error in command callback input must be 8 bytes 
> long at C:/Perl/site/lib/Crypt/DES.pm line 57.
> 
>         return 1;
> }
> 
> 
> #====the following will work=================
> use strict;
> use warnings;
> use Crypt::CBC;
> my $cipher = new Crypt::CBC('secret', 'DES');
> 
> IRC::print "Script loaded\n";
> IRC::add_command_handler("", "crypt_all");
> 
> sub crypt_all
> {
>     my $input = "bla";
>     my $target = IRC::get_info(2);
>     IRC::print "To $target -$input-\n";
> #-----^--- displays "To #tehend -bla-"
> 
>     my $ciphertext = $cipher->encrypt($input);
> #-------^--- this time encrypt will work, I also tried to decrypt that 
> and works well :)
> 
>         return 1;
> }

I don't have xchat. If you want people to be able to help you, you need
to post a program that you want tested but does not depend upon anything
outside of Perl. In this case, I see that would not be possible :-)

These are what you should do:

1) Make sure that you submit at least eight bytes which is what 
Crypt::Blowfish seems to require (given the error message). If it works 
*without* eight bytes, then assume something is wrong with the code that 
works without eight bytes.

2) At the top of crypt_all, do this:

use Data::Dumper;
print Dumper(\@_);

What's in @_ might not be what you think.

3) Another idea is to do this:

my $input = '' . $_[0];
-or this-
my $input = unpack 'a*',$_[0];

This might force that value to be converted to a normal perl string. 
Read the posting guidelines, 
http://www.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html , 
"perldoc  -f pack", and "perldoc Crypt::Blowfish".

HTH


-- 
paduille.4058.mumia.w@earthlink.net



------------------------------

Date: 1 Oct 2006 03:53:25 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Modifying a one-liner
Message-Id: <1159700005.350869.245080@i42g2000cwa.googlegroups.com>

vjp2.at@at.BioStrategist.dot.dot.com wrote:
> Mind if I piggyback a request here?

Yes.  I do.  There is no reason to post this message in an existing
thread.  Start a new topic.

> (pls cc email)

No.  You posted the message here, you read the responses here.

> Two years ago, someone wrote me this PERL

Perl.  Not PERL.

> script on a piece of
> scrap paper and I had difficulty figuring out some of the writting.
>
> esp: is that x or *???

What happened when you tried each?  Did one "work" while the other
didn't?

Do you know the difference between the two operators?  You can look
them up in
perldoc perlop

> perl -pe 'if ($.%4==2){$_.="-" x 37} elseif {$.%4==0) {$_.="=" x 37} $_.="\n"'
> < %1 >%1
>
>
> Then I want to make it double spaced.
> Every second blank (fourth of the total) line should then
> be replace with a line of 37 "-" characters..
> and then every second dashed line (every fourth blank aka every eighth
> actual) should be replace wit a line of 37 "=" characters..
>
> This script does not have fold/justify at col 37,
> but it would be nice if it did.

What have you tried so far, and how did it not work the way you wanted?

Paul Lalli



------------------------------

Date: 1 Oct 2006 07:05:44 -0700
From: beartiger@gmail.com
Subject: Re: Modifying a one-liner
Message-Id: <1159711544.199693.150220@e3g2000cwe.googlegroups.com>

Paul Lalli wrote:
> vjp2.at@at.BioStrategist.dot.dot.com wrote:
> > Mind if I piggyback a request here?
>
> Yes.  I do.  There is no reason to post this message in an existing
> thread.  Start a new topic.
>
> > (pls cc email)
>
> No.  You posted the message here, you read the responses here.

You are a spectacular asshole.

> > Two years ago, someone wrote me this PERL
>
> Perl.  Not PERL.

Then why do *you* spell it PERL here?

     http://cgi2.cs.rpi.edu/~lallip/perl/spring06/index.shtml

Dumbshit.


J



------------------------------

Date: Sun, 1 Oct 2006 09:05:15 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Modifying a one-liner
Message-Id: <slrnehvior.jkv.tadmc@magna.augustmail.com>

Paul Lalli <mritty@gmail.com> wrote:
> vjp2.at@at.BioStrategist.dot.dot.com wrote:
>> Mind if I piggyback a request here?
> 
> Yes.  I do.  There is no reason to post this message in an existing
> thread.  Start a new topic.


That reply was pretty unAmerican of you!

   Message-ID: <cnn76h$551$1@reader1.panix.com>


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 1 Oct 2006 14:13:51 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: My first socket question
Message-Id: <391vh29tucem6f5krki5nq4pmedbk0bmf9@4ax.com>

On 01 Oct 2006 05:40:31 GMT, xhoster@gmail.com wrote:

>For what is worth, I do not like this idiom, despite using it myself
>on occasion.  "accept" should never return false, except on error.
>If the loop is going to be effectively an infinite loop, it should look
>like one.
>
>while (1) {
>  my $client = $server->accept or die $!;
>  # other stuff here
>};

Good point!

>> Point is, in the *real* application I have in mind, when in server
>> mode the program will be doing other stuff as well. To be fair, its
>> main purpose will be doing other stuff. The C/S ipc's purpose will be
>> exactly of gathering information on how other stuff is being done or
>> influence how it is. Thus the actual code may be of the form
>>
>>   while (1) {
>>       do_stuff;
>>       ???
>>   }
>>
>> where ??? is the code to handle incoming requests. What should I put
>> there?
>
>That depends on what you want to do.  Most likely you need a different
>structure, rather than just substituting the ???.  Do you want to do_stuff

Well, that is the structure of the actual program, which is running
and doing its job, but doesn't do ipc. Of course I didn't expect ???
to be a single statement (unless it's a sub call, but that's the same
thing). It still seems to be the "right" structure, provided that one
suitable ??? can be made to fit into the picture...

>only once per control/inquiry connection (that is perhaps what your
>proposed structure suggests)?  Do you want to do_stuff as long as there is
>not a pending control/inquiry connection?  Can you suspeding do(ing)_stuff

The second one. I want to do_stuff all the time independently on
whether there's a connection or not. But if there's a connection, an
action must be taken accordingly.

>while handling an incoming control/inquiry connection, or do you need to
>handle stuff and connections concurrently?

I don't need concurrency. I can happily stopo do(ing)_stuff to handle
an incoming request.

Anyway, I didn't followup, but it seems that IO::Select's can_read()
as suggested by Gim Gibson was actually what I needed. I adapted my
minimal example to it:


  #!/usr/bin/perl
  
  use strict;
  use warnings;
  use IO::Socket;
  use IO::Select;
  use constant PORT => 9000;
  
  if (@ARGV) {
      my $sock=IO::Socket::INET->new(PeerAddr => 'localhost',
                                     PeerPort => PORT,
                                     Proto    => 'tcp') or
        die "Cannot connect to server: $!\n";
      my $cmd=shift;
      print "Client mode, sending command `$cmd'\n";
      print $sock "$cmd\r\n";
      print scalar <$sock>;
      close $sock or die "Cannot disconnect from server: $!\n";
      exit;
  }
  
  my $server=IO::Socket::INET->new(Listen    => 5,
                                   LocalPort => PORT,
                                   Proto => 'tcp') or
    die "Cannot start in server mode: $!\n";
  print "Server mode\n";
  
  $SIG{INT}=$SIG{TERM}=sub { 
      close $server or 
        die "Cannot stop server mode: $!\n";
      exit;
  };
  
  my $sel=IO::Select->new($server);
  my ($cnt,$val);
  
  while (1) {
      $cnt++;
      $val=rand;  # these are the important calculations!!
      next unless $sel->can_read(0.2);
      my $client=$server->accept or
        die "Can't handle incoming connection: $!\n";
      (my $cmd=<$client>) =~ tr/\r\n//d;
      my %answer=(count => "count: $cnt",
                  value => "value: $val",
                  info  => "info: count => $cnt, value => $val");
      print $client
        $answer{$cmd} || "Unknown command: `$cmd'", "\r\n";        
      
  }
  
  __END__


It *exactly* does what I wanted:


  $ ./cs3.pl
  Server mode
  
  [1]+  Stopped                 ./cs3.pl
  $ bg
  [1]+ ./cs3.pl &
  $ ./cs3.pl count
  Client mode, sending command `count'
  count: 50
  $ ^count^value
  ./cs3.pl value
  Client mode, sending command `value'
  value: 0.484312856457549
  $ ^value^info
  ./cs3.pl info
  Client mode, sending command `info'
  info: count => 216, value => 0.436477334785103
  $ ^info^foo
  ./cs3.pl foo
  Client mode, sending command `foo'
  Unknown command: `foo'


Of course any additional suggestion is mostly welcome!


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: 1 Oct 2006 14:13:52 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: My first socket question
Message-Id: <rd1vh2977fs0og00mhf62mjugdbt94rjeg@4ax.com>

On 29 Sep 2006 17:30:27 +0200, Michele Dondi <bik.mido@tiscalinet.it>
wrote:

>  $SIG{INT}=$SIG{TERM}=sub { 
>      close $server or 
>        die "Cannot stop server mode: $!\n";
>      exit;
>  };
[snip]
>  $ diff -u cs*.pl
>  --- cs1.pl      2006-09-29 15:46:28.662294000 +0200
>  +++ cs2.pl      2006-09-29 15:46:32.950562000 +0200
[snip]
>   while ( my $client=$server->accept ) {
>  +    next if fork;
>       (my $cmd=<$client>) =~ tr/\r\n//d;
>       my %answer=(foo => "foo: that's what I wanted!");
>       print $client
>         $answer{$cmd} || "Unknown command: `$cmd'", "\r\n";
>  +    exit;
        ^^^^^
        ^^^^^
>   }

Now that I think of it, that still doesn't call close(), so I'd better
substitute it with

  $SIG{INT}->();

although in a real world example I'd use a (suitably) named sub
altogether for both uses: handling signals and explicit call.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Sun, 1 Oct 2006 09:14:34 +0000 (UTC)
From: vjp2.at@at.BioStrategist.dot.dot.com
Subject: Re: need syntax help
Message-Id: <efo0tq$i3h$3@reader1.panix.com>

Mind if I piggyback a request here? (pls cc email)

Two years ago, someone wrote me this PERL script on a piece of 
scrap paper and I had difficulty figuring out some of the writting.

esp: is that x or *???

perl -pe 'if ($.%4==2){$_.="-" x 37} elseif {$.%4==0) {$_.="=" x 37} $_.="\n"'
< %1 >%1


Then I want to make it double spaced.
Every second blank (fourth of the total) line should then
be replace with a line of 37 "-" characters..
and then every second dashed line (every fourth blank aka every eighth
actual) should be replace wit a line of 37 "=" characters..

This script does not have fold/justify at col 37, 
but it would be nice if it did.

Much obliged.


------------------------------

Date: Sun, 1 Oct 2006 09:01:35 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: need syntax help
Message-Id: <slrnehvihv.jkv.tadmc@magna.augustmail.com>

vjp2.at@at.BioStrategist.dot.dot.com <vjp2.at@at.BioStrategist.dot.dot.com> wrote:

> Mind if I piggyback a request here? 


yes.


> (pls cc email)


no.


> Two years ago, someone wrote me this PERL script 


It is not a Perl, nor perl, nor PERL script...


> esp: is that x or *???


The x operator is described in:

   perldoc perlop


> perl -pe 'if ($.%4==2){$_.="-" x 37} elseif {$.%4==0) {$_.="=" x 37} $_.="\n"'
                                       ^^^^^^ ^
                                       ^^^^^^ ^

Perl does not have an "elseif" keyword. It does have an "elsif" 
keyword though.

The condition must be in properly balanced parenthesis.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sun, 1 Oct 2006 14:40:54 +0200
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: Re: pod - purpose of L<> directive
Message-Id: <1159706454.850671@proxy.dienste.wien.at>

Christian Winter:

> OK, that's as expected. perlred.pod resides in
> /usr/lib/perl5/5.8.5/pod/perlref.pod, so I'll give /usr/lib/perl5/5.8.5
> as the podroot and directories "." (for the standard .pm files) and
> "pod" (for the perlxxxx.pod docs) as podpaths.
>
> h64183:~ # pod2html --podroot=/usr/lib/perl5/5.8.5 \
>    --podpath=pod:. --infile lala.pod --outfile lala.html
> h64183:~ #

That's exactly what I wanted. Many thanks!

> It runs without complaint, the only thing leaving a bad taste
> is that the generated link isn't at all clean, making an absolute
> link like <a href="/pod/perlref.html"> making it neccessary to
> set --htmlroot. I'd use "." there as the parameter to get relative
> links.

I used --podpath=pod --htmlroot=/

yielding an absolute path of http://<server>/<documentroot>/pod

and that's OK.

> But seeing from the mail you sent me that you want your solution
> to be runnable on different platforms and versions, you might be
> better off using Pod::Tree which adds some handy features to the
> pod2html functionality (like perl2html searching @INC paths or
> Pod::Tree::HTML letting you define your own link mapper).

It seems that the path given in podroot is used only for verification
purposes (and as default if no podpath and htmlroot are given).
There are no version-dependend components in the generated
links, so that's OK. I can access other HTML-perldocs from my
document and my document from other perldocs, so all works
fine now.

Again, many thanks for your help!

BTW: I really would appreciate some examples about directive
usage in pod2html's (and related!) documentation...

Greetings, Ferry

-- 
Ing Ferry Bolhar
Magistrat der Stadt Wien - MA 14
A-1010 Wien
E-Mail: bol@adv.magwien.gv.at




------------------------------

Date: 1 Oct 2006 14:13:53 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Question about a $SIG{__WARN__} handler
Message-Id: <kb6vh21tlatlfg3i39c3br1f7inhnnii39@4ax.com>

I was trying a tiny modification of Tassilo Parseval's minimal example
of $SIG{__WARN__} handler (posted here a few days ago), namely:

  #!/usr/bin/perl
  
  use strict;
  use warnings;
  
  $SIG{__WARN__} = sub {
      if ($_[0] =~ /^Use of uninitialized value/) {
          require Carp;
          Carp::cluck;
      } else {
          warn @_;
      }
  };
  
  sub foo { print undef }
  sub bla { foo }
  
  bla(42);      # Special treatment;
  'aa' < 'bb';  # Ordinary one.
  
  __END__

when I noticed that the warnings come out like this:

  C:\TEMP>perl stack.pl
  Argument "bb" isn't numeric in numeric lt (<) at stack.pl line 23.
  Argument "aa" isn't numeric in numeric lt (<) at stack.pl line 23.
   at stack.pl line 13
          main::__ANON__('Use of uninitialized value in print at
stack.pl line 19.
  \x{a}') called at stack.pl line 19
          main::foo() called at stack.pl line 20
          main::bla(42) called at stack.pl line 22

i.e. in reverse order. I'm just curious: why does this happen?
Changing the code for the successful match to just C<warn 'foo';>
doesn't change this, so it must be a warn() thing, but appearently I
could not find anything relevant in

  perldoc -f warn


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Sun, 1 Oct 2006 14:40:56 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Question about a $SIG{__WARN__} handler
Message-Id: <efokd7.1g8.1@news.isolution.nl>

Michele Dondi schreef:

> I was trying a tiny modification of Tassilo Parseval's minimal example
> of $SIG{__WARN__} handler (posted here a few days ago), namely:
>
>   #!/usr/bin/perl
>
>   use strict;
>   use warnings;
>
>   $SIG{__WARN__} = sub {
>       if ($_[0] =~ /^Use of uninitialized value/) {
>           require Carp;
>           Carp::cluck;
>       } else {
>           warn @_;
>       }
>   };
>
>   sub foo { print undef }
>   sub bla { foo }
>
>   bla(42);      # Special treatment;
>   'aa' < 'bb';  # Ordinary one.
>
>   __END__
>
> when I noticed that the warnings come out like this:
>
>   C:\TEMP>perl stack.pl
>   Argument "bb" isn't numeric in numeric lt (<) at stack.pl line 23.
>   Argument "aa" isn't numeric in numeric lt (<) at stack.pl line 23.
>    at stack.pl line 13
>           main::__ANON__('Use of uninitialized value in print at
> stack.pl line 19.
>   \x{a}') called at stack.pl line 19
>           main::foo() called at stack.pl line 20
>           main::bla(42) called at stack.pl line 22
>
> i.e. in reverse order. I'm just curious: why does this happen?

What exactly do you consider reverse about it?

  perl -MO=Deparse -we "'aa' < 'bb'"

-- 
Affijn, Ruud

"Gewoon is een tijger."




------------------------------

Date: 1 Oct 2006 02:54:31 -0700
From: "thedifferenZ" <thedifferenz@gmail.com>
Subject: Whats the best method to encrypt a big data file?
Message-Id: <1159696471.638497.237100@c28g2000cwb.googlegroups.com>

Hi group,

I am trying to encrypt/decrypt a data file using asymmetic keys. I
tried using Crypt:RSA (Blowfish)

The source file is just 500kb, and its taking more than 20 mins to
encrypt it. Is there any way to encrypt a file with out taking whole
file content to memory?

========================================================
use strict;
use Crypt::RSA;
my $rsa = new Crypt::RSA;
my $public = new Crypt::RSA::Key::Public(Filename => 'public.txt');
my $private = new Crypt::RSA::Key::Private(Filename => 'private.txt');

open(DAT,"data.mpg");
my $message;
while(<DAT>){
    $message.=$_;
}
close(DAT);
my $cyphertext = $rsa->encrypt (
        Message    => $message,
        Key        => $public,
        Armour     => 1,
    ) || die $rsa->errstr();

open(WRT,">encrypted.txt");
print WRT $cyphertext;
close(WRT);
========================================================

thanks



------------------------------

Date: Sun, 1 Oct 2006 14:55:55 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Whats the best method to encrypt a big data file?
Message-Id: <efol03.1g8.1@news.isolution.nl>

thedifferenZ schreef:

> my $message;
> while(<DAT>){
>     $message.=$_;
> }


Alternative:

  my $message = do { local $/; <DAT> } ;

-- 
Affijn, Ruud

"Gewoon is een tijger."




------------------------------

Date: Sun, 01 Oct 2006 14:43:06 GMT
From: zentara <zentara@highstream.net>
Subject: Re: Whats the best method to encrypt a big data file?
Message-Id: <egkvh29euqb5lbooeth96lrla7eukdjpap@4ax.com>

On 1 Oct 2006 02:54:31 -0700, "thedifferenZ" <thedifferenz@gmail.com>
wrote:

>Hi group,

Hi, I'm not an expert on encryption, but I'll tell you what I think. :-)

>I am trying to encrypt/decrypt a data file using asymmetic keys. I
>tried using Crypt:RSA (Blowfish)

Blowfish can use Crypt::CBC, which allows you to read the file
chunks at a time. Crypt::CBC DOES NOT support RSA.

>
>The source file is just 500kb, and its taking more than 20 mins to
>encrypt it. Is there any way to encrypt a file with out taking whole
>file content to memory?

You might look at
GnuPG::Tie::Encrypt;
http://aspn.activestate.com/ASPN/CodeDoc/GnuPG/GnuPG/Tie.html

It allows you to encrypt by printing to a filehandle.

I havn't tested it, so I can't say it would be faster than loading the
whole file to memory.

Since you are using asymmetric keys, why not switch to c, and use
gpg? That would give you more speed.  You can pipe to gpg on stdin too, 
so you could work out a scheme of feeding your large file to gpg's
stdin.



-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9786
***************************************


home help back first fref pref prev next nref lref last post