[22069] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4291 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 19 18:13:52 2002

Date: Thu, 19 Dec 2002 15:05:16 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 19 Dec 2002     Volume: 10 Number: 4291

Today's topics:
        [Win32::OLE] Lotus Notes database <isresi1@xs4all.nl>
    Re: ActiveState ppm packages <willis3140@com.yahoo>
    Re: Arguing about the advantage of Perl <pierre.rolin@soredi-group.com>
    Re: Arguing about the advantage of Perl <uri@stemsystems.com>
    Re: Arguing about the advantage of Perl <me@privacy.net>
    Re: comparing mangled times perlistically! <krahnj@acm.org>
    Re: Counter <branmh@cox-internet.com>
    Re: Counter <goldbb2@earthlink.net>
    Re: Date Difference <me@privacy.net>
        DBI secure password <willis3140@com.yahoo>
    Re: DBI secure password <yanoff@yahoo.com>
    Re: DBI secure password <uri@stemsystems.com>
    Re: Generated optimized C code gives access violation <echo@quik.com>
    Re: getstore not working - please help (Dennis Macdonald)
    Re: help:  perl script to make all DNA sequence Nmers? <goldbb2@earthlink.net>
    Re: help:  perl script to make all DNA sequence Nmers? <goldbb2@earthlink.net>
    Re: help:  perl script to make all DNA sequence Nmers? <goldbb2@earthlink.net>
        How to sign a MIME message <gallo.famille@wanadoo.fr>
    Re: Image creation/editing <dwilga-MUNGE@mtholyoke.edu>
    Re: Image creation/editing <addi@umich.edu>
    Re: Image creation/editing <mgjv@tradingpost.com.au>
        map and s/// on @list <stremitz@consultant.com>
    Re: map and s/// on @list <uri@stemsystems.com>
    Re: map and s/// on @list <mgjv@tradingpost.com.au>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 19 Dec 2002 20:58:34 +0100
From: smasr <isresi1@xs4all.nl>
Subject: [Win32::OLE] Lotus Notes database
Message-Id: <3e022543$0$996$e4fe514c@dreader7.news.xs4all.nl>

Hi,

I have a Lotus Notes database with lots of attachments. 
(Word/Excel/Wordperfect). I want to detach this attachments and i found 
some VB code to do it.I wanted to port  this code to Perl. I hope someone 
can give me some clues or examples. I am a bit N00b at this.

---

use strict;
use Win32::OLE;

# CONNECT
my $Notes = Win32::OLE->new('Notes.NotesSession')
    or die "Cannot start Lotus Notes Session object.\n";

# SOME GENARAL INFO TO CHECK THE CONNECTION
my ($Version) = ($Notes->{NotesVersion} =~ /\s*(.*\S)\s*$/);
print "The current user is $Notes->{UserName}.\n";
print "Running Notes \"$Version\" on \"$Notes->{Platform}\".\n";

# OPEN DATABASE
my $Database = $Notes->GetDatabase('Server03', 'CB/PS/cb0450.nsf');
my $AllDocuments = $Database->AllDocuments;
my $Count = $AllDocuments->Count;
print "There are $Count documents in the database.\n";

# AS LONG AS THERE ARE DOCUMENTS
for (my $Index = 1 ; $Index <= $Count ; ++$Index) {
    my $Document = $AllDocuments->GetNthDocument($Index);
    #this shows the document view and works nice
    printf "$Index. %s\n", $Document->GetFirstItem('VznNummer')->{Text};

    if ($Document->HasEmbedded) { # <- THIS WORKS BUT THEN I AM STUCK

        # WHAT do i have to put here? I have tried several things but nothing 
        # seems to work.
        # i tried for example:
        # my($itm);                                     # <- works
        # $itm = $Document->GetFirstItem("Body");       # <- works
        # if ($Document->GetFirstItem("Body")->{Type} eq 1) {  # <- no-no
        #       print "Yes\n"; }
        #if ($itm->Type eq 1) {                                # <- no-no
        #       print "Yes\n"; }

    }

}


##VISUAL BASIC EXAMLE WHICH I FOUND ON THE INTERNET

Public Sub NotesSaveAttachs(sPathToSave As String)
Dim View As New Domino.NotesView
Dim nDoc As Domino.NotesDocument
'Dim nDoc2Remove As Domino.NotesDocument
'const RICHTEXT = 1
'const EMBED_ATTACHMENT = 1454
Set View = oDB.GetView("($Inbox)")

Set nDoc = View.GetFirstDocument
Dim itm As Variant
While Not (nDoc Is Nothing)
    If nDoc.HasEmbedded Then
        Set itm = nDoc.GetFirstItem("Body")
        If itm.Type = RICHTEXT Then
            Dim attch As Variant
            For Each attch In itm.EmbeddedObjects
                If (attch.Type = EMBED_ATTACHMENT) Then
                    attch.ExtractFile sPathToSave & attch.Name
                End If
            Next

        End If
     ' Following code commented is used to delete mails after
     ' attachments were saved to disk.
        'Set nDoc2Remove = nDoc
    End If

    Set nDoc = View.GetNextDocument(nDoc)
    ' Following code commented is used to delete mails after
    ' attachments were saved to disk
    'If Not (nDoc2Remove Is Nothing) Then
    '    nDoc2Remove.Remove (True)
    '    Set nDoc2Remove = Nothing
    'End If

Wend

End Sub



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

Date: Thu, 19 Dec 2002 22:35:35 GMT
From: w i l l <willis3140@com.yahoo>
Subject: Re: ActiveState ppm packages
Message-Id: <l6g40v8ol9dit00qoiv1alu5uln6jokfau@4ax.com>

here is what you want..

merlyn is da' man! read and learn!

http://www.stonehenge.com/merlyn/LinuxMag/col42.html

-W i l l

On Thu, 19 Dec 2002 17:40:23 GMT, matt <linuxnb@yahoo.com> wrote:

>Hi people,
>
>Just wondering if anyone can help me out with PPM. I am going on a trip, and 
>I won't have Internet access. I downloaded all of the Active State perl 
>.ppd files, and the associated tarballs to my laptop so that I would have 
>all of the modules I might need during my trip. The problem is that I am 
>not running ActiveState perl. I am running the perl that came with my 
>Mandrake Linux 9.0 distro - v5.8.0 built for i386-linux-thread-multi.
>
>I installed PPM, and added the local directory as a repository. The problem 
>is the architechture. PPM fails because it says that there are no valid 
>architectures found. It wants perl 5.8.0 built for i686-linux-thread-multi. 
>Is there a big difference here? Can I get away with installing these 
>modules? 
>
>The .ppd files all have the following line in them:
>
><ARCHITECTURE NAME="i686-linux-thread-multi-5.8" />
>
>Can I just change the 'i686' to 'i386'? I haven't tried it yet, because I 
>don't want to break anything. I thought I would check with the guru's 
>first.
>
>Of course I could just install ActiveState perl and be done with it, but I 
>want the "already configured" mod_perl and Apache instalation to still 
>work.
>
>TIA -- Matt



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

Date: Thu, 19 Dec 2002 20:07:18 +0100
From: "Pierre.synergy.all" <pierre.rolin@soredi-group.com>
Subject: Re: Arguing about the advantage of Perl
Message-Id: <att5ia$q88$1@s1.read.news.oleane.net>


"Uri Guttman" <uri@stemsystems.com> a écrit dans le message de news:
x765tpq3fh.fsf@mail.sysarch.com...
 ...

> ... just use vb and screw
> it up and don't learn perl. you will be much better off outside the perl
> community where things like usenet rules are generally obeyed.
>

Nice try, but what you had to argue is about the use of perl instead of vbs
in the
case of a convert program from JCL, but if you don't know I will understand
it.

by the way, as I'm foreigner and as I'm not used to be rude (I dont think
the perl community or the usenet rules does ... ?) could you explain me the
meaning of "screw it up".

thanks a lot.
Pierre




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

Date: Thu, 19 Dec 2002 19:51:52 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Arguing about the advantage of Perl
Message-Id: <x73cotokh4.fsf@mail.sysarch.com>

>>>>> "Psa" == Pierre synergy all <pierre.rolin@soredi-group.com> writes:

  Psa> "Uri Guttman" <uri@stemsystems.com> a écrit dans le message de news:
  Psa> x765tpq3fh.fsf@mail.sysarch.com...
  Psa> ...

  >> ... just use vb and screw
  >> it up and don't learn perl. you will be much better off outside the perl
  >> community where things like usenet rules are generally obeyed.
  >> 

  Psa> Nice try, but what you had to argue is about the use of perl
  Psa> instead of vbs in the case of a convert program from JCL, but if
  Psa> you don't know I will understand it.

did you ever think that posting in a perl newsgroup would get you answer
like 'use VB'? this is comp.lang.perl.misc. 

  Psa> by the way, as I'm foreigner and as I'm not used to be rude (I
  Psa> dont think the perl community or the usenet rules does ... ?)
  Psa> could you explain me the meaning of "screw it up".

foreign has nothing to do with it. you have been rude yourself here. you
posted the same message in multiple groups.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 20 Dec 2002 08:22:28 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: Arguing about the advantage of Perl
Message-Id: <attdam$24doi$1@ID-172104.news.dfncis.de>


"Pierre.synergy.all" <pierre.rolin@soredi-group.com> wrote in message
news:atsfbo$bu3$1@s1.read.news.oleane.net...
> "Tintin" <me@privacy.net> a écrit dans le message de news:
> atsc6p$28djr$1@ID-172104.news.dfncis.de...
> >
> > Please read http://www.cs.tut.fi/~jkorpela/usenet/xpost.html before you
> get
> > the urge to multi-post again.
>
> Dear Tintin,
>
> This message is the only one on the net, as the one sent on
> "comp.lang.perl.misc"
> have been corrected ...

It is not the only version.  You multi-posted to alt.perl
(atqju5$98v$1@s1.read.news.oleane.net)


> I gess that the urge of correcting one to another
> and the willing to be the "wise guy" have
> made you forget the reality of things.

I await your apology.




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

Date: Thu, 19 Dec 2002 22:14:18 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: comparing mangled times perlistically!
Message-Id: <3E02446F.3E2357C5@acm.org>

qanda wrote:
> 
> And for John ...
> 
> > >     while( <DATA> ) {
> > >         my @flds = split( /,/, $_, -1 );
> >                                ^^^^^^^^
> > Where do people learn this stuff?  :-)
> Sorry, I'm not sure what you mean (spaces?), can you explain.

Using a negative number for the third argument to split is probably not
what you need.

$ perl -e'
$a = "a,b,c,,,,,,,,";
@a = split /,/, $a, -1;
@b = split /,/, $a;

print "\@a: " . @a . " "; print ">$_< " for @a; print "\n";
print "\@b: " . @b . " "; print ">$_< " for @b; print "\n";
'
@a: 11 >a< >b< >c< >< >< >< >< >< >< >< >< 
@b: 3 >a< >b< >c< 


The negative third argument causes split to do more work then it needs
to.  In your example you are only using the first and third elements of
@flds so it would be more effecient to do either:

my ( $name, undef, $time ) = split /,/;

# OR

my ( $name, $time ) = (split /,/)[0,2];



John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 19 Dec 2002 13:06:41 -0600
From: "Brandon Holland" <branmh@cox-internet.com>
Subject: Re: Counter
Message-Id: <v0468hie1q3v4a@corp.supernews.com>

Ok, now I have found this script and added $print ='1'; and if ($print eq
'1') { print "$count"; }
--------------------------------------------------------------------
#!/usr/bin/perl

# Directory location & name of the log file.
$count_file = "/path/to/counter/data.txt";

# "1" counts users, "0" counts all hits.
$no_double_count = 1;

$print = '1';

#  As simple as that!
#-----------------------------------------------------

$user = $ENV{'REMOTE_ADDR'};

print "Content-type: text/html\n\n";
if (-e "$count_file") {
   open(FILE,"$count_file") || &error('can not read count file');
   $line = <FILE>;
   chop($line) if $line =~ /\n$/;
   close(FILE);
   ($count,$c_user) = split(/-/,$line);
}
else {
   $count = 0;
   &build_file;
}

if ( ( $user ne $c_user) || !( $no_double_count ) ) {
  $count++;
}


if ($print eq '1') { print "$count"; }
&build_file;
exit;

sub build_file {
  open(FILE,">$count_file") || &error('can not write log file');
  print FILE "$count-$user";
  close(FILE);
}

sub error {
  $error = shift(@_);
  print "Error: $error";
  exit;
}
--------------------------------------------------------------------
How would I put the log information (below) in the script (above)?

--------------------------------------------------------------------
    open (LOG, ">>data/$log");
    print "Content-type: text/plain\n\n ";
    print LOG "Time: $shortdate\n";
    print LOG "IP:   $ENV{'REMOTE_ADDR'}\n";
    print LOG "Host: $ENV{'REMOTE_HOST'}\n";
    print LOG "With: $ENV{'HTTP_USER_AGENT'}\n";
    print LOG "From: $ENV{'HTTP_REFERER'}\n";
    print LOG "Page: $ENV{'DOCUMENT_NAME'}?$ENV{'QUERY_STRING'}\n\n";
    close (LOG);




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

Date: Thu, 19 Dec 2002 17:58:59 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Counter
Message-Id: <3E024F33.2A36CD1D@earthlink.net>

Brandon Holland wrote:
> 
> I found this counter script
[snip]

   perldoc -q increment

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: Thu, 19 Dec 2002 23:02:52 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: Date Difference
Message-Id: <att8o3$2g8ap$1@ID-172104.news.dfncis.de>


"Chris" <christopher.naugle@fmr.com> wrote in message
news:rV5M9.115$O3.18@news-srv1.fmr.com...
> Hi,
>
> I was wondering if someone could help me.  I'm somewhat new to Perl
> and am having a small coding problem.
>
> I have this program that I'm writing.   One of the things that it needs to
> do
> is take a string that represents a date in the format "YYYYMMDD" and
> figure out if this date is N number of days old where N is some arbitrary
> number.
>
> I know that there are a bunch of date modules for working with dates
> but the ones I've come across seemed overly complicated for what
> I need to do and lacked clear code examples.  I was hoping someone
> might be able to post a small code snippet as I would think this problem
> is very common.

Seeing as you are using a sensible date format, you can do simple
calculations.

#!/usr/bin/perl

use POSIX;

my $today = strftime("%Y%m%d",localtime);
my $date = '20021201';
my $n = 18;

print "Older than $n days" if ( ( $today - $date) >= $n);





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

Date: Thu, 19 Dec 2002 21:37:49 GMT
From: w i l l <willis3140@com.yahoo>
Subject: DBI secure password
Message-Id: <aj840v8mt9hirur6p5e7ae9tgr2n7g5lnq@4ax.com>

Hello,

I'm writing a web app that uses DBI, I've read somewhere about
securing the DB password by placing it in a file outside the web
server so that crackers can't uuuummmm, crack your DB.

What is a good way of implementing this?

thanks, in advance.....


here's what ive tried->

#!/usr/bin/perl
# connect.pl


use strict;
use CGI;
use DBI;
use CGI::Carp qw(fatalsToBrowser);
require '/usr/home/user007/secure/thing'; # get file with pswd



my $dbh = DBI->connect("$host", "$user", "$pass") || die $DBI::errstr;

# stuff
# here
# end file

-----------

and my file /usr/home/user007/secure/thing looks like this->

my $host = 'DBI:mysql:dbname:host.ispr.com';
my $user = 'username';
my $pass = 'passwd';

###end file


I get an error saying that these 3 variables requires explicit package
name ...


any ideas?

thanks again.

-w i l l




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

Date: Thu, 19 Dec 2002 16:27:21 -0600
From: Scott Yanoff <yanoff@yahoo.com>
Subject: Re: DBI secure password
Message-Id: <3e02456a$0$583$39cecf19@nnrp1.twtelecom.net>

w i l l wrote:
> #!/usr/bin/perl
> # connect.pl
> require '/usr/home/user007/secure/thing'; # get file with pswd
> my $dbh = DBI->connect("$host", "$user", "$pass") || die $DBI::errstr;
> -----------
> 
> and my file /usr/home/user007/secure/thing looks like this->
> 
> my $host = 'DBI:mysql:dbname:host.ispr.com';
> my $user = 'username';
> my $pass = 'passwd';
> 
> I get an error saying that these 3 variables requires explicit package
> name ...

I think you want the following in that script:

use vars qw($host $user $pass);

Good luck,
-- 
-Scott
yanoff@yahoo.com | http://www.yanoff.org | AOL IM: SAY KJY



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

Date: Thu, 19 Dec 2002 22:33:11 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: DBI secure password
Message-Id: <x7u1h9ljvd.fsf@mail.sysarch.com>

>>>>> "SY" == Scott Yanoff <yanoff@yahoo.com> writes:

  SY> w i l l wrote:
  >> #!/usr/bin/perl
  >> # connect.pl
  >> require '/usr/home/user007/secure/thing'; # get file with pswd
  >> my $dbh = DBI->connect("$host", "$user", "$pass") || die $DBI::errstr;
  >> -----------
  >> and my file /usr/home/user007/secure/thing looks like this->
  >> my $host = 'DBI:mysql:dbname:host.ispr.com';
  >> my $user = 'username';
  >> my $pass = 'passwd';
  >> I get an error saying that these 3 variables requires explicit package
  >> name ...

  SY> I think you want the following in that script:

  SY> use vars qw($host $user $pass);

that won't do much good. the problem is that the required file declares
those vars lexically so they will not be visible in the mail file. he is
not using strict (which he should) so just removing the my part will fix
it. there are other proper ways to make it work with strict. the
simplest is to not make the file perl source but some config file and
load it with a proper module/parser. assign those values to a my'ed hash and
then you don't need any other vars or declarations.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Thu, 19 Dec 2002 20:10:40 GMT
From: "David Ladd" <echo@quik.com>
Subject: Re: Generated optimized C code gives access violation
Message-Id: <3JpM9.81$R64.34319@newsfeed.intelenet.net>


"Peter Veprek" <pveprek@research.panasonic.com> wrote in message
news:AWW_8.882$h5.70806@news.uswest.net...
> Hi,
>
> I use ActivePerl-5.6.1.631-MSWin32-x86.msi and I have foo.pl:
>
>     print "Howdy!\n";
>
> I do:
>
>     perl -MO=CC,-O2,-ofoo.c foo.pl
>     perl \perl\lib\b\cc_harness -o foo foo.c
>
> When I run foo.exe (Win2000Pro) it gives an exception.
>
> I made a VC++ v6 console project, set options (#defs, include dirs, and
> libs)
> according to the harness. When I run release, I get the exception. When I
> run debug, it shows 'access violation' in foo.c on line
>
>     av_store(CvPADLIST(PL_main_cv),0,SvREFCNT_inc((AV*)&sv_list[0]));
>
> which is at the end of perl_init().
>
> I tried an alternate foo.pl:
>
>     $a=0;
>
> but it has the same problem.
>
> Any ideas?
>
> (I do everything (well, almost) in perl and need to speed up execution.)
>
> Thanks,
>
> Peter
>
>




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

Date: 19 Dec 2002 14:37:56 -0800
From: newsgroups@bandwood.com (Dennis Macdonald)
Subject: Re: getstore not working - please help
Message-Id: <d98b592e.0212191437.6b652598@posting.google.com>

Bob,

I'm running on a server and want to download to the user. Similar
effect to them linking on a file link and the browser asking to
download and requesting the file name.

Thanks,
Dennis.

Bob Walton <bwalton@rochester.rr.com> wrote in message news:<3E013269.6040804@rochester.rr.com>...
> Dennis Macdonald wrote:
> 
> > THanks for your help. In deed it does work, but puts the file on my
> > web server. What I was after is to scrpit the download to a user not
> > onto the server. Do you know how to do this. I seem to be totally
> > off-beam with this one.
> ...
> 
> 
> > Dennis.
> > 
> 
> Well, um, are you running the script on the computer to which you want 
> to download the file, or are you running it on your web server?  It will 
> be downloaded to the computer on which the script is executed.  And 
> also, to the directory where the script is located, unless you specify 
> otherwise in the "local" file name argument to getstore.


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

Date: Thu, 19 Dec 2002 17:27:18 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: help:  perl script to make all DNA sequence Nmers?
Message-Id: <3E0247C6.90595E9D@earthlink.net>

Benjamin Goldberg wrote:
[snip]
> my @acids = qw(A T C G);
> my $N = shift(@ARGV);
> my @Nmers;
> my $count = "";
> local $" = "";
> until( vec $count, $N, 2 ) {
>    push @Nmers, "@acids[map vec($count, $_, 2), 0 .. $N-1]";
> } continue {
>    my $i = 0; 1 until ++vec $count, $i++, 32;
> }
> # deal with @Nmers.
> __END__

After Xho mentioned that the code didn't work, I realized that using ",
32" at the end of that 'until ++vec...' would cause problems unless $N
was a multiple of 16, due to vec() dealing with multibyte numbers in a
bigendian way.  Changing the '32' to '8' fixes the problem.

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: Thu, 19 Dec 2002 17:42:41 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: help:  perl script to make all DNA sequence Nmers?
Message-Id: <3E024B61.86E42EB7@earthlink.net>

ctcgag@hotmail.com wrote:
> 
> Benjamin Goldberg <goldbb2@earthlink.net> wrote:
> > ctcgag@hotmail.com wrote:
> > >
> > > isen@molbio.mgh.harvard.edu (isen) wrote:
> > > > does anyone have a perl script to make all possible DNA sequence
> > > > Nmers (and put in an array preferably) when given N as an input?
> > >
> > > warn "Untested Code";
> > > sub Nmer {
> > >   die unless $_[0];
> > >   return qw/A C T G/ if $_[0]==1;
> > >   return map {$_.'A', $_.'C', $_.'T', $_.'G'} Nmer($_[0]-1);
> > > };
> >
> > This puts everything on the stack -- kinda wasteful of memory, ne?
> 
> Well, the poster didn't ask for an efficient solution :)
> 
> I figure if you have memory, it's as much of a waste to not use
> it as it is to use it.  Does Perl treat stack different
> than heap?  I've never paid much attention to where my data
> would be going, I that I know haven't suffered from it.  It
> seems perl will dynamically allocate as much stack as it needs.

That's not the problem -- the problem with putting everything on the
stack, is that if he's going to eventually store it in an array, you
first put all your data on the stack, and then allocate an array to have
the same number of elements, then copy the stack into that array.

If you store it in the array in the first place, then you don't end up
allocating double the memory, and you don't end up copying so much.

> Anyway, mine worked right out of the box, and took few seconds of my
> time.

Mine only took me a few seconds to write, too.

> I spent a bit of time working on yours, and still haven't gotten
> it to work properly.

It took me just a couple seconds to fix mine, as soon as I knew
something was wrong.

I set $N = 5, changed the push to a print, and saw that it was printing
out "AAAAA" lots of times.

I immediately realized that ++vec($count, $i, 32) was modifying parts of
$count that weren't visible to vec($count, $_, 2).

Since I know how vec() works, I realized that this is because when vec
treats a string as a vector of 32-bit numbers, it does so in a bigendian
way.

Changing 32 to 8 fixed the problem.

Remember kiddies, premature optomization is the root of all evil :)  I
used 32 there since it would be faster to do a small number of
increments on 32-bit numbers, than to do a larger number of increments
on 2-bit numbers.  Sadly, this didn't work.

> In my book, that's the biggest test of efficiency, at least for a
> program I'm not being paid to write.

Yes, you're absolutely correct -- a program that works, or can be fixed
quickly, is much more efficient than a program that doesn't work :)

But I still like my design better :)

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: Thu, 19 Dec 2002 17:57:20 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: help:  perl script to make all DNA sequence Nmers?
Message-Id: <3E024ED0.204DB424@earthlink.net>

isen wrote:
> 
> does anyone have a perl script to make all possible DNA sequence Nmers
> (and put in an array preferably) when given N as an input?  Please
> reply by email (sindriATmacDOTcom) if possible.

my $N = 5; # or whatever;
my @Nmers = ("");
for my $i ( 1 .. $N ) {
   my $j = $#Nmers;
   for my $k ( 0 .. $j ) {
      my $a = \$Nmers[$k];
      push @Nmers, $$a.$_ for qw(T C G);
      $$a .= q(A);
   }
}
print $_, "\n" for @Nmers;
__END__
[tested]

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: Thu, 19 Dec 2002 21:54:00 +0100
From: "Jean-Luc Gallo" <gallo.famille@wanadoo.fr>
Subject: How to sign a MIME message
Message-Id: <attbku$1o6$1@news-reader10.wanadoo.fr>

I want to sign MIME messages with X509 and pkcs7 standard

The messages are currently built (unsigned) by a perl program using
MIME::Lite module in a small linux box.
What is the best way to build a signed message from this point?
Do I have to save to a file the MIME message built with the MIME::Lite
module and after that run "openssl" to sign the file and then read the
output file generated and send it though sendmail?
Or can I do everything in Perl with another module (which one?)

All ideas are welcome.

Thanks
jean-luc





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

Date: Thu, 19 Dec 2002 20:41:04 GMT
From: Dan Wilga <dwilga-MUNGE@mtholyoke.edu>
Subject: Re: Image creation/editing
Message-Id: <dwilga-MUNGE-4E6A4C.15410319122002@nap.mtholyoke.edu>

In article <atsfkf$ubc$1@news5.svr.pol.co.uk>,
 "DM" <daby55@NO23SPAM.com> wrote:

> I`ve had a look through the perl packages and can`t find anything that looks
> suitable. Basically I want to be able to create a new image (preferably a
> .png) and then paste other images into it images into it, one after the
> other (vertically). Any perl modules capable of doing this?

Image::Magick is one:

http://search.cpan.org/author/JCRISTY/PerlMagick-5.51/Magick.pm

-- 
Dan Wilga          dwilga-MUNGE@mtholyoke.edu
** Remove the -MUNGE in my address to reply **


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

Date: 19 Dec 2002 16:07:00 -0500
From: Arnar Mar Hrafnkelsson <addi@umich.edu>
Subject: Re: Image creation/editing
Message-Id: <xfsvsmwt90qz.fsf@blue.engin.umich.edu>

"DM" <daby55@NO23SPAM.com> writes:

> I`ve had a look through the perl packages and can`t find anything that looks
> suitable. Basically I want to be able to create a new image (preferably a
> .png) and then paste other images into it images into it, one after the
> other (vertically). Any perl modules capable of doing this?
> 

Image::Magick 
Imager 
GD

All of those should work fine.

-- Arnar.
> 
> 
> 
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.431 / Virus Database: 242 - Release Date: 17/12/2002


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

Date: Thu, 19 Dec 2002 21:08:15 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Image creation/editing
Message-Id: <slrnb04ddn.865.mgjv@verbruggen.comdyn.com.au>

On Thu, 19 Dec 2002 12:54:23 -0000,
	DM <daby55@NO23SPAM.com> wrote:
> I`ve had a look through the perl packages and can`t find anything that looks
> suitable. Basically I want to be able to create a new image (preferably a
> .png) and then paste other images into it images into it, one after the
> other (vertically). Any perl modules capable of doing this?

Image::Magick has built in methods that do thumbnailing and thumbnail
sheeting. It also has lots of other methods that can be used for this.

GD can do this as well (with some limitations).

Imager can also do this.

> Outgoing mail is certified Virus Free.

This, of course, is nonsense.

Martien
-- 
                        | 
Martien Verbruggen      | Useful Statistic: 75% of the people make up
Trading Post Australia  | 3/4 of the population.
                        | 


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

Date: Thu, 19 Dec 2002 17:20:15 -0500
From: Alexander Stremitzer <stremitz@consultant.com>
Subject: map and s/// on @list
Message-Id: <3E02461F.5010002@consultant.com>

I am trying to apply the s/// operator to a list. I know I should use 
"map" in this context but am unsure about the correct syntax. I know my 
attempt did not work. Thanks for any help.

Regards,
Alex

-- 
All man's miseries derive from not being able to sit quietly in a room 
alone. (Pascal)

#!/usr/local/bin/perl

use strict;
use diagnostics;

open (TEST, "<conf/upd_db.in") || die "problem";
my @list = <TEST>;
close (TEST);

@list =~ s/PSMB/PCHS/;

__DATA__
0

001S13OT02PSBM
12

upd_db.an
1



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

Date: Thu, 19 Dec 2002 22:26:46 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: map and s/// on @list
Message-Id: <x765tpmyqi.fsf@mail.sysarch.com>

>>>>> "AS" == Alexander Stremitzer <stremitz@consultant.com> writes:

  AS> I am trying to apply the s/// operator to a list. I know I should use
  AS> "map" in this context but am unsure about the correct syntax. I know my
  AS> attempt did not work. Thanks for any help.

you shouldn't be using map as map returns a list of values and s/// does
not return the modified string.


  AS> -- 

don't put code BELOW your signature. 

  AS> #!/usr/local/bin/perl

  AS> use strict;
  AS> use diagnostics;

diagnostics will slow down your program as it is a large module. i think
you probably meant to use warnings

  AS> open (TEST, "<conf/upd_db.in") || die "problem";

you should print the file and and $! in die

  AS> my @list = <TEST>;
  AS> close (TEST);


  AS> @list =~ s/PSMB/PCHS/;

well, have you read perldoc perlop on =~? it works on a scalar and not a
list.

since you seem to want to modify it in place, a for modifier is the
proper solution:

	s/PSMB/PCHS/ for @list ;


  AS> __DATA__

you don't use your DATA so why show it?


uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Thu, 19 Dec 2002 22:35:24 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: map and s/// on @list
Message-Id: <slrnb04ih4.865.mgjv@verbruggen.comdyn.com.au>

[Please, when you include code, don't put it after your signature.
Most decent newsreading software will automatically remove anything
after the sigdash line when replying.]

On Thu, 19 Dec 2002 17:20:15 -0500,
	Alexander Stremitzer <stremitz@consultant.com> wrote:
> I am trying to apply the s/// operator to a list. I know I should use 
> "map" in this context but am unsure about the correct syntax. I know my 
> attempt did not work. Thanks for any help.

I don't think you should use map. You _can_, but I wouldn't.  for is
going to be much more natural, and more efficient on older versions of
Perl [1].


> #!/usr/local/bin/perl

use warnings;

> use strict;
> use diagnostics;
> 
> open (TEST, "<conf/upd_db.in") || die "problem";
> my @list = <TEST>;
> close (TEST);
> 
> @list =~ s/PSMB/PCHS/;
> 
> __DATA__
> 0
> 
> 001S13OT02PSBM
> 12
> 
> upd_db.an
> 1

I don't see any attempted use of map in there, nor do I see any use of
the data after __DATA__.

Anyway:

for my $elem (@list)
{
    $elem =~ s/PSMB/PCHS/;
}

or

for (@list) { s/PSMB/PCHS/; }

or

s/PSMB/PCHS/ for @list;


I prefer the last one.


for loops are special in that the loop variable is aliased to the
element of the list the iteration is working on, which allows you to
do this. See the perlsyn documentation.

Martien

[1] Using map in a void context used to create a result list in memory
anyway, which then got discarded. Newer versions of Perl, IIRC, don't
do this anymore. A map-in-void-context version of the above for loop:

    map { s/PSMB/PCHS/ } @list;

but I find that much less readable than the for loop, and it doesn't
work well WRT the semantics of map.

-- 
                        | 
Martien Verbruggen      | Begin at the beginning and go on till you
Trading Post Australia  | come to the end; then stop.
                        | 


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

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.  

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 4291
***************************************


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