[19761] in Perl-Users-Digest
Perl-Users Digest, Issue: 1956 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 18 09:10:26 2001
Date: Thu, 18 Oct 2001 06:10:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1003410611-v10-i1956@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 18 Oct 2001 Volume: 10 Number: 1956
Today's topics:
Re: Programmer Newbie <jasper@guideguide.com>
Re: push, pop, shift, unshift, splice et al <goldbb2@earthlink.net>
readdir probs??? (Bruno Boettcher)
Re: readdir probs??? <bernard.el-hagin@lido-tech.net>
Re: readdir probs??? <dtweed@acm.org>
Re: Running a .pl as a background. <mtsouk@freemail.gr>
Re: Scaling a DNA string <DocDodge@hotmail.com>
Re: sendmail not sending mail anymore <tintin@snowy.calculus>
Re: Writing and reading encrypted string (password) <bart.lateur@skynet.be>
Re: Writing and reading encrypted string (password) <dump@the-core.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 18 Oct 2001 12:32:16 +0100
From: Jasper McCrea <jasper@guideguide.com>
Subject: Re: Programmer Newbie
Message-Id: <3BCEBDC0.8D553E26@guideguide.com>
Wyzelli wrote:
>
> "Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
> news:87zo6pu0w0.fsf@limey.hpcc.uh.edu...
> > >> On Wed, 17 Oct 2001 22:39:54 -0400,
> > >> Mike Ragsdale <mragsdal@utk.edu> said:
> >
> > > Charles Jessop wrote:
> > >> Good evening!
> > >>
> > >> I am learning perl on my own and need a little
> > >> help. May I ask, if I had the following array:
> > >>
> > >> @chkbrd = ("xoxoxoxo", "oxoxoxox");
> > >>
> > >> how would I have it print out eight total rows of
> > >> alternating elements to make a checkerboard?
>
> <snip>
>
> > Hmmm, to be brutal, that looks like horribly C-like; more
> > perlish might be:
> >
> > for (1..4) {
> > print "$_\n" for @chkbrd;
> > }
>
> Just for fun, here is a way to do it with a single scalar, rather than the
> array:
>
> $brd = 'xoxoxoxo';
>
> for (1..8) {
> print "$brd\n";
> $brd = reverse $brd;
> }
print (($brd = reverse $brd), "\n");
might have been better?
or we could go mad
for my $y (0..7) {
print qw(O X)[($_ + $y) % 2] for (0..7);
print $/;
}
I really should get out more
Jasper
--
split//,'019617511192'.
'17011111610114101114'.
'21011141011840799901'.
'17101174';
foreach(0.. # my
$#_){$_[$_ # signature is too
++]^=$_[$_ # bignature
--]^=$_[$_
]^=$_[++ $_]if!($_%
2)}$g.=$_ ,chr($g)=~
/(\w)/&&($o.=$1and
$g='')foreach@_;
print"$o\n"
------------------------------
Date: Thu, 18 Oct 2001 06:09:43 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: push, pop, shift, unshift, splice et al
Message-Id: <3BCEAA67.CA54F7@earthlink.net>
JRoot wrote:
> Thelma Lubkin wrote:
[snip]
> > Is there a reason that you need to remove the elements one at a
> > time? Why not print the elements and then set the array empty?
[snip]
> Actually there is ... in real life I will be testing each
> element of the array and what doesn't pass the test will
> be left in the array. The remaining array elements will
> then be used in the next step of the program.
Then you want to be using grep.
--
"What does stupid old man mean pidgin talk?
Shampoo does not talk like a bird."
------------------------------
Date: Thu, 18 Oct 2001 12:25:43 +0000 (UTC)
From: bboett@bboett.dyndns.org (Bruno Boettcher)
Subject: readdir probs???
Message-Id: <9qmho7$r72$1@neon.noos.net>
hello,
i have the following:
if(open(THISDIR,'/home/bboett/test/'))
{
my @dirlist = readdir(THISDIR);
print "error: $!\n";
print "openend list: '@dirlist'\n";
foreach my $filename (@dirlist)
{
print "processing $filename\n";
}
}
the dir exists, i can make an 'ls' on it, and the opendir runs fine
(means reports no error...) but the readdir gives me:
error: Bad file descriptor
i nearly cut&pasted this example from the perl doc, so i don't
understand what's going wrong....
and as expected @dirlist is empty....
--
ciao bboett
==============================================================
bboett@earthling.net
http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
------------------------------
Date: 18 Oct 2001 12:34:49 GMT
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: readdir probs???
Message-Id: <slrn9stiml.85e.bernard.el-hagin@gdndev25.lido-tech>
On Thu, 18 Oct 2001 12:25:43 +0000 (UTC), Bruno Boettcher
<bboett@bboett.dyndns.org> wrote:
> hello,
> i have the following:
> if(open(THISDIR,'/home/bboett/test/'))
open is for files. opendir is for directories.
Cheers,
Bernard
------------------------------
Date: Thu, 18 Oct 2001 12:51:43 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: readdir probs???
Message-Id: <3BCECF00.D36B3D11@acm.org>
Bruno Boettcher wrote:
> if(open(THISDIR,'/home/bboett/test/'))
if(opendir(THISDIR,'/home/bboett/test/'))
-- Dave Tweed
------------------------------
Date: Thu, 18 Oct 2001 15:15:32 +0300
From: "Mihalis Tsoukalos" <mtsouk@freemail.gr>
Subject: Re: Running a .pl as a background.
Message-Id: <9qmh4c$1v9u$1@ulysses.noc.ntua.gr>
Look at book "Network Programming with Perl" by L. Stein.
Very nice book. Covers many things including what you want.
Mihalis.
--
---
Mihalis Tsoukalos
mtsouk@freemail.gr
Scott Bell <news@scottbell.org> wrote in message
news:NIiz7.10202$nT1.1610816@news6-win.server.ntlworld.com...
> Is it possible to make a perl script run as a background process? If so,
> how?
>
>
> ~scott
------------------------------
Date: Thu, 18 Oct 2001 08:37:36 -0400
From: "DocDodge" <DocDodge@hotmail.com>
Subject: Re: Scaling a DNA string
Message-Id: <9qmi58$1tr$1@bob.news.rcn.net>
"Jay Tilton" <tiltonj@erols.com> wrote in message
news:3bce660d.407138606@news.erols.com...
> On Wed, 17 Oct 2001 22:52:57 -0400, "DocDodge" <DocDodge@hotmail.com>
wrote:
>
> >a motif composed of four G's or
> >four C's in a row might have implications for how some genes are
regulated.
> >
> >So, I grabbed 2000 characters from nearby an important gene and stored it
in
> >a string. I replaced all the unimportant characters with at dash so we
can see
> >where these motifs are:
> >
> >...----------GGGGGG---------CCCC--------GGGG----------...
> >
> >What I need to do is scale the
> >string down to a reasonable size. What I've tried to do is use a for
loop
> >with and index of 10 to replace all the instances or 10 dashes with a
single
> >dash. If a G or C is found in the 10 character region, a single G or C
is
> >printed.
> >
> >The last GGGG gets counted twice because it is crosses over
> >two different 10 character long chunks.
> >And, if I scale the string by looking for GGGG or CCCC in any 10
character
> >long chunk, I will underestimated the number of motifs
> >
> >What I really want to scale the string to is this ...-GC-G--... ( or this
> >...-GC--G-..., small position shifts are inconsequential as long as the
> >number of motifs is accurate).
>
> Summarizing the apparent key points,
> 1. Sequences of four G's or four C's in the string are important.
> 2. Condense sequences of -'s in the string.
> 3. Chewing on the string in 10-character chunks is not working well
because
> a single motif may cross the boundary between chunks.
>
> How about crunching four or more G's or C's down to one,
> $sequence =~ s/([GC])\1{3,}/$1/g;
> then crunching multiple -'s down to one, so the motifs are visually
> separate.
> $sequence =~ s/(-)+/$1/g;
>
> What should happen where there are three or fewer C's or G's in a row?
Keep
> them, discard them, or some other notation indicating "something there,
but
> not what I'm really looking for"?
Hi Jay,
Thanks for your quick response. I'll answer your last question first. If
there are three or fewer C's or G's in a row they can be ignore (replaced
with -'s).
The problem with crunching four or more G's or C's down to one and then
crunching multiple -'s down to one is that the string would not be evenly
scaled. What I need to know is not only how many motifs are in the
sequence, but were they are in relation to each other and to the ends of the
string. For example if a GGGG is at the far right of the string, I would
want it to look like this when scaled:
-----------------------G---
But if two GGGG motifs are in the middle of the string, it should look like
this:
----------G-G--------------
Your answer does give me an idea though. If I scale by 2, i.e.. replace
all --'s with a single dash and all GG or CC with a single G or C I won't
have the problem of a motif crossing a boundary. I could then repeat this
two more times, leaving a string of length 125. This might be small enough
for my purposes. The only glitch now, is how to tell GGGGGG that scaled to
G or GGGGGGGG (two motifs) that also scales to G.
TIA
------------------------------
Date: Thu, 18 Oct 2001 21:04:20 +1000
From: "Tintin" <tintin@snowy.calculus>
Subject: Re: sendmail not sending mail anymore
Message-Id: <7Iyz7.26$ha2.35876@news.interact.net.au>
"No Idea" <nospam@nospam.com> wrote in message
news:dDxz7.1637$IR4.1088096@news1.denver1.co.home.com...
> Hey guys,
>
> I was trying out some new Form2Email scripts today and now all of
> a sudden sendmail doesnt want to send mail....
>
> Now, one of the scripts had something unusual (at least something
> Ive never seen):
>
> # Mailer command flags: if you want sendmail to queue the mail
> until the next run
> # (typically around every 10 minutes, use these flags
> (recomended, as the script
> # can finish faster)
> $mail_flags = '-oi -t -odq';
>
> # However, if you can't wait up to ten minutes for the email, and
> don't mind the
> # script taking a little longer to process, use these flags
> (uncomment):
> #$mail_flags = '-oi -t';
>
>
> Now, I tried both options, as the script was only sending 1
> email, when supposed to send 2...... and from what I can tell,
> my server doesnt run sendmail at regular intervals (afaik)....
> So, did the first option set some kind of option to query emails
> until sendmail is run????
>
> Also, Im not 100% sure that the above has anything to do with it,
> as i was trying several different scripts throughout the night,
> but if Im correct, sendmail stopped sending mail when I was
> messing with this script....
>
> Is there anyway to get sendmail working again... easily?
Why are you asking sendmail questions in a Perl newsgroup? Try
comp.mail.sendmail
------------------------------
Date: Thu, 18 Oct 2001 11:48:21 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Writing and reading encrypted string (password)
Message-Id: <1bftst8ihubtobk16tkpbrifo2rlvn3g89@4ax.com>
Lars Oeschey wrote:
>On Wed, 17 Oct 2001 22:42:38 GMT, Bart Lateur <bart.lateur@skynet.be>
>wrote:
>
>>But what if the key is a digest (MD::Digest, a CRC or something like
>>that) of the script itself? Once the hacker edits the source to get at
>
>That's a cool idea indeed. I also thought about it today when looking
>at the Blowfish module. But how could I get a CRC of the script source
>itself from within the program? (First I thought about using the
>source of the prog itself as key, but that would be too long)
With a module? There's String::CRC, there's Digest::MD5... (Such a
digest is like a CRC, but resulting in a longer bit sequence,
Digest::MD5 returns 128 bits.) I recently saw a MD5 Digest generator
written in pure Javascript on some website. So doing it in pure Perl
shouldn't be that hard. As for CRC in pure Perl: check out the CRC64
module on <http://swissknife.sourceforge.net/>.
In a very simple, but less safe version, you can simply use the checksum
option built into unpack().
--
Bart.
------------------------------
Date: Thu, 18 Oct 2001 15:02:18 +0200
From: Lars Oeschey <dump@the-core.net>
Subject: Re: Writing and reading encrypted string (password)
Message-Id: <5ektst45mfl36q1fohtimi8kr9vi7jaqbu@4ax.com>
On Thu, 18 Oct 2001 08:54:03 GMT, Bart Lateur <bart.lateur@skynet.be>
wrote:
> $enc = pack 'C*', map { $_^int(32*r()) } unpack 'C*', $_;
> print $enc;
I tried this one now (although I didn't really understand it ;)), but
I think I get unprintable characters with it since I get a beep and
special characters like musical notes and the like. Probably this
would be a problem...
the Code I use:
somewhere at the top of the program:
{
my $s;
sub r { $s=shift if @_;$s*=31421;($s%=0x10000)/0x10000}
}
later on:
if (@ARGV[0] eq "-p") {
print "You have indicated that you want to change the
password.\n";
print "Enter old password: ";
$passin=<STDIN>;
chomp $passin;
if ($Pass ne $passin) {
print "Password doesn't match!"; exit 0;}
else {
print "Enter new Password: ";
$newpass=<STDIN>;
chomp $newpass;
r(125);
$enc=pack'C*',map{$newpass ^int(32*r())} unpack
'C*',$newpass;
print $enc;}
exit 0}
the "print $enc" gives me the weird characters...
btw, I know that the password is visible when entered, but it seems
there's only Term::ReadPassword to prevent that. A Module again :(
Lars
Lars
--
GPZ900R xxMm+2,5Mm http://www.oeschey.de
GS400 xxMm+1,5Mm http://www.the-core.net
------------------------------
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 1956
***************************************