[29397] in Perl-Users-Digest
Perl-Users Digest, Issue: 641 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 10 18:10:14 2007
Date: Tue, 10 Jul 2007 15:09:07 -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 Tue, 10 Jul 2007 Volume: 11 Number: 641
Today's topics:
Re: croak/confess from within File::Find <simon.chao@fmr.com>
Re: dollar sign literals <dummy@example.com>
Re: How to turn off taint checking in cgi <spamtrap@dot-app.org>
Re: How to turn off taint checking in cgi <mritty@gmail.com>
Re: How to turn off taint checking in cgi <spamtrap@dot-app.org>
Re: Iterating over a hash <steamaccount2@gmail.com>
Re: Iterating over a hash <steamaccount2@gmail.com>
Re: Iterating over a hash <steamaccount2@gmail.com>
Mail-Webmail-Yahoo-0.601 / yahootils.pl does not seem coder_expert@yahoo.com
Re: Portable general timestamp format, not 2038-limited <nospam-abuse@ilyaz.org>
Re: re-lurking <invalid@invalid.net>
Re: TXL-like capability? <spamtrap@dot-app.org>
Re: Using xargs perl to join lines <dummy@example.com>
Re: Using xargs perl to join lines charissaf@gmail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 10 Jul 2007 12:23:17 -0700
From: it_says_BALLS_on_your forehead <simon.chao@fmr.com>
Subject: Re: croak/confess from within File::Find
Message-Id: <1184095397.976181.56590@q75g2000hsh.googlegroups.com>
On Jul 10, 1:40 pm, Paul Lalli <mri...@gmail.com> wrote:
> I've been staring at this and playing with variations for over an hour
> now. Can someone help me out? My goal is to be able to use croak()
> from within a subroutine that is called by the &wanted subroutine
> which is passed to File::Find::find(). I want the error message
> printed as a result of this croak() to list the line number of the
> call to the final subroutine. Here is a short-but-complete script to
> demonstrate the problem I'm having:
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use Carp;
> use File::Find;
> die "Usage: $0 [croak|confess] [level]\n" unless @ARGV == 2;
> my ($which, $carplevel) = @ARGV;
>
> sub err {
> $Carp::CarpLevel = $carplevel;
> if ($which eq 'croak') {
> croak "You did something bad!"; #line 12
> } else {
> confess "You did something bad!"; #line 14
> }
>
> }
>
> sub wanted {
> err(); #line 19
>
> }
>
> find(\&wanted, '.'); #line 22
> __END__
>
> So, find() is calling wanted() which is calling err() which is calling
> croak(). What I want is an error message saying:
> "You did something bad! at ff_carp.pl line 19". However:
> $ ./ff_carp.pl croak 0
> You did something bad! at /opt2/Perl5_8_4/lib/perl5/5.8.4/File/Find.pm
> line 810
>
> Calling croak with a CarpLevel of 0 shows me where in File::Find the
> wanted() subroutine is being called.
>
> $ ./ff_carp.pl croak 1
> You did something bad! at ./ff_carp.pl line 22
>
> But if I call croak with a CarpLevel of 1, I instead get where in my
> main file find() is being called.
>
> So instead I tried looking at the whole stack trace, to see what's
> going wrong. I tried calling confess() with a CarpLevel of 0:
>
> $ ./ff_carp.pl confess 0
> You did something bad! at ./ff_carp.pl line 14
> main::err() called at ./ff_carp.pl line 19
> main::wanted() called at /opt2/Perl5_8_4/lib/perl5/5.8.4/File/
> Find.pm line 810
> File::Find::_find_dir('HASH(0x13e82c)', ., 2) called at /opt2/
> Perl5_8_4/lib/perl5/5.8.4/File/Find.pm line 690
> File::Find::_find_opt('HASH(0x13e82c)', .) called at /opt2/
> Perl5_8_4/lib/perl5/5.8.4/File/Find.pm line 1193
> File::Find::find('CODE(0x1b66d0)', .) called at ./ff_carp.pl
> line 22
>
> Now this is exactly what I'd expect. It's telling me the actual
> confess was called on line 14, inside the err() function that was
> called on line 19, inside the wanted() function that was called within
> File::Find.pm. Exactly. And furthermore, if I skip a level by
> setting CarpLevel to 1:
>
> $ ./ff_carp.pl confess 1
> You did something bad! at ./ff_carp.pl line 19
> main::wanted() called at /opt2/Perl5_8_4/lib/perl5/5.8.4/File/
> Find.pm line 810
> File::Find::_find_dir('HASH(0x13e82c)', ., 2) called at /opt2/
> Perl5_8_4/lib/perl5/5.8.4/File/Find.pm line 690
> File::Find::_find_opt('HASH(0x13e82c)', .) called at /opt2/
> Perl5_8_4/lib/perl5/5.8.4/File/Find.pm line 1193
> File::Find::find('CODE(0x1b66d0)', .) called at ./ff_carp.pl
> line 22
>
> Again, Exactly what I expect. I skipped a level, so the first level
> being printed is the source of the err() call, line 19.
>
> Now - how do I get croak() to behave the same way? I don't want to
> print the entire stack trace, I just want it to tell me that the
> subroutine was called from line 19, like confess() does when I skip a
> level.
>
> Thank you for any insight you can provide,
> Paul Lalli
I know this isn't much help (on the analysis side), but maybe by
pointing you to Carp::Heavy, I can do you some good.
http://search.cpan.org/src/NWCLARK/perl-5.8.8/lib/Carp/Heavy.pm
In particular, look at:
sub shortmess_heavy
sub short_error_loc
sub ret_summary
sub caller_info
hth!
------------------------------
Date: Tue, 10 Jul 2007 18:33:55 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: dollar sign literals
Message-Id: <niQki.22806$Io4.2043@edtnps89>
Jürgen Exner wrote:
> Jason Williams wrote:
>> Thank you all for you posts; I learned something from each of them. I
>> ended up taking a slightly different approach. I wrote a separate perl
>> program, and then called it from ksh for each file, like so:
>>
>> ksh:
>
> Any particular reason why you are not using Perl for this part?
>
>> --------------------------------
>> #!/bin/ksh
>> PATH=blah
>> for FILE in dc0003*
>
> for my $file (glob(dc0003*))
for my $file (glob("dc0003*"))
>> do
>
> {
>
>> echo $FILE
>
> print $file;
>
>> mv $FILE $FILE.bak
>
> move ($file, "$file.bak"); #from File::Copy
rename( $file, "$file.bak" ); #from perl
>> update_part_maint_jobs.pl $FILE.bak
>
> #rewritten to call a sub:
> update_part_jobs ("$file.bak");
>
>> mv $FILE.bak.new $FILE
>
> move ("$file.bak.new", $file);
rename( "$file.bak.new", $file );
>> echo $FILE done
>
> print "$file done";
>
>> done
>
> }
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Tue, 10 Jul 2007 14:28:36 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: How to turn off taint checking in cgi
Message-Id: <m2k5t8p0yz.fsf@dot-app.org>
Lars Eighner <usenet@larseighner.com> writes:
> I understand I can get around variable taint checking with a do nothing
> sed-like replacement, but is it not clear to me how this could be done with
> the path.
PATH is only used if you don't specify the location of the tool you're using -
if you use `ls` instead of `/bin/ls` for instance.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Tue, 10 Jul 2007 11:56:02 -0700
From: Paul Lalli <mritty@gmail.com>
Subject: Re: How to turn off taint checking in cgi
Message-Id: <1184093762.073607.28900@w3g2000hsg.googlegroups.com>
On Jul 10, 2:28 pm, Sherm Pendley <spamt...@dot-app.org> wrote:
> Lars Eighner <use...@larseighner.com> writes:
> > I understand I can get around variable taint checking with a do nothing
> > sed-like replacement, but is it not clear to me how this could be done with
> > the path.
>
> PATH is only used if you don't specify the location of the tool you're using -
> if you use `ls` instead of `/bin/ls` for instance.
Untrue.
$ perl -Te'system("/bin/ls");'
Insecure $ENV{PATH} while running with -T switch at -e line 1.
Taint checking stops ANY external program from being run until $PATH
is secured, because Perl takes the ultra-paranoid stance that /bin/ls
might call some other program without specifying the full path, and
then that program would be affected by the tainted $PATH.
Paul Lalli
------------------------------
Date: Tue, 10 Jul 2007 15:16:39 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: How to turn off taint checking in cgi
Message-Id: <m28x9ooyqw.fsf@dot-app.org>
Paul Lalli <mritty@gmail.com> writes:
> On Jul 10, 2:28 pm, Sherm Pendley <spamt...@dot-app.org> wrote:
>> Lars Eighner <use...@larseighner.com> writes:
>> > I understand I can get around variable taint checking with a do nothing
>> > sed-like replacement, but is it not clear to me how this could be done with
>> > the path.
>>
>> PATH is only used if you don't specify the location of the tool you're using
>> if you use `ls` instead of `/bin/ls` for instance.
>
> Untrue.
Well, what I said *is* technically true - Perl isn't *using* PATH in this
example, it's just afraid that something else might use it. :-)
Seriously though, point taken. I sit corrected.
> $ perl -Te'system("/bin/ls");'
> Insecure $ENV{PATH} while running with -T switch at -e line 1.
That's why I get for posting from memory - I usually look things up. :-(
In addition to fully-specifying the path to any external programs, I also
empty PATH - untainting it in the process.
perl -Te'$ENV{PATH}=""; system("/bin/ls")'
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Tue, 10 Jul 2007 12:58:09 -0700
From: limitz <steamaccount2@gmail.com>
Subject: Re: Iterating over a hash
Message-Id: <1184097489.601422.206670@k79g2000hse.googlegroups.com>
On Jul 6, 8:19 pm, xhos...@gmail.com wrote:
> limitz <steamaccou...@gmail.com> wrote:
> > Hey I have a question with iterating over a hash.
>
> > For example, if I have a hash table %hash1:
>
> > %hash1(
> > 1 => 1,
> > 2=> 2,
> > 3=> 3,
> > );
>
> > And given this string 123123123123.
>
> > How would increment the values in the hash every time it recognizes
> > the value?
> > For example:
> > $numbers = 123123123123;
>
> You may want to make that a string rather than a number, or at some
> point you will lose precision.
>
> $numbers = '123123123123';
>
>
>
> > $beginning = <STDIN>;
> > print "Input Ending Base Number:\n";
> > $end = <STDIN>;
> > $length = $end-$beginning+1;
>
> Since we don't know what it is you type in for STDIN, this makes a poor
> example. I would be better to hard-code the values you want for testing
> purposes.
>
>
>
> > $one = '1';
> > $onecount = 0;
> > for my $i (0 .. $length-1) {
> > my $count = substr($numbers, $i, 2);
> > if ($count =~ $one) {
> > $onecount++;
> > }
> > }
>
> Assuming this actually does what you want (in which case you want
> something quite strange--counting how many of the overlapping "digraphs"
> (not exactly the right word--every combination of two adjacent letters
> taken together, with some possible weirdenss as the end of the string if
> $length is the same or longer than length $numbers) of a string contain a
> digit in at least one of the two places in the digraph), then you could do
> it something like this:
>
> my %hash1=(
> 1 => 0,
> 2=> 0,
> 3=> 0,
> );
>
> for my $i (0 .. $length-1) {
> foreach (keys %hash1) {
> $hash1{$_}++ if substr($numbers, $i, 2) =~ /$_/;
> }
>
> }
>
> If performance was important, you could use index rather than a regex,
> or try switching the nesting of the inner and outer loops, or a variety
> of other things.
>
> On the other hand, if the code you posted doesn't do what you want in the
> first place, then it isn't clear what you want.
>
> Xho
>
> --
> --------------------http://NewsReader.Com/--------------------
> Usenet Newsgroup Service $9.95/Month 30GB- Hide quoted text -
>
> - Show quoted text -
Actually, that is what I want it to do, something like a sliding
frame. As for the values in STDIN, they are numerical values. This
way, I can specify an arbitrary sequence for it to iterate over.
Although this example seems ridiculous, its actually a simplification
of a first order Markov transitional chain matrix.
I'm actually having an error running this. After I modify my code to
fit this, essentially what you suggested but with a print function at
the end. I get this error: "Use of unintialized value in string C:\Perl
\bin\markovgen2.pl line 107, <STDIN> line 2."
This is my exact code:
print "\nThere are a total of 18990 bases in the entire sequence\n";
print "\nWhat is the starting base number? Keep in mind that Perl
begins the tally";
print "\nwith 0. So if you wanted to start from base 30, input in
29\n";
#Here we can define where we want the sequence to begin and end
print "Input Starting Number:\n";
$beginning_of_sequence = <STDIN>;
print "Input Ending Base Number:\n";
$end_of_sequence = <STDIN>;
$length_of_sequence = $end_of_sequence-$beginning_of_sequence+1;
%dinucleotidepair = (
AT => 0,
AC => 0,
AG => 0,
AA => 0,
TA => 0,
TC => 0,
TG => 0,
TT => 0,
CA => 0,
CT => 0,
CG => 0,
CC => 0,
GA => 0,
GT => 0,
GC => 0,
GG => 0,
);
#$AC = 'AC';
#$ACcountss = 0;
#for my $i (0 .. $length_of_sequence-1) {
# my $dinuc = substr($fastasequence, $i, 2);
# if ($dinuc =~ $AC) {
# $ACcountss++;
# }
#}
for my $i (0 .. $length_of_sequence-1) {
foreach (keys %dinucleotidepair) {
$dinucleotidepair{$_}++ if substr($fastasequence, $i, 2) =~ /$_/;
}
}
print "$dinucleotidepair";
Can anyone explain to me the reason the error is popping up? Thanks.
~Frank
------------------------------
Date: Tue, 10 Jul 2007 14:43:47 -0700
From: limitz <steamaccount2@gmail.com>
Subject: Re: Iterating over a hash
Message-Id: <1184103827.654204.114800@o61g2000hsh.googlegroups.com>
On Jul 10, 3:58 pm, limitz <steamaccou...@gmail.com> wrote:
> On Jul 6, 8:19 pm, xhos...@gmail.com wrote:
>
>
>
>
>
> > limitz <steamaccou...@gmail.com> wrote:
> > > Hey I have a question with iterating over a hash.
>
> > > For example, if I have a hash table %hash1:
>
> > > %hash1(
> > > 1 => 1,
> > > 2=> 2,
> > > 3=> 3,
> > > );
>
> > > And given this string 123123123123.
>
> > > How would increment the values in the hash every time it recognizes
> > > the value?
> > > For example:
> > > $numbers = 123123123123;
>
> > You may want to make that a string rather than a number, or at some
> > point you will lose precision.
>
> > $numbers = '123123123123';
>
> > > $beginning = <STDIN>;
> > > print "Input Ending Base Number:\n";
> > > $end = <STDIN>;
> > > $length = $end-$beginning+1;
>
> > Since we don't know what it is you type in for STDIN, this makes a poor
> > example. I would be better to hard-code the values you want for testing
> > purposes.
>
> > > $one = '1';
> > > $onecount = 0;
> > > for my $i (0 .. $length-1) {
> > > my $count = substr($numbers, $i, 2);
> > > if ($count =~ $one) {
> > > $onecount++;
> > > }
> > > }
>
> > Assuming this actually does what you want (in which case you want
> > something quite strange--counting how many of the overlapping "digraphs"
> > (not exactly the right word--every combination of two adjacent letters
> > taken together, with some possible weirdenss as the end of the string if
> > $length is the same or longer than length $numbers) of a string contain a
> > digit in at least one of the two places in the digraph), then you could do
> > it something like this:
>
> > my %hash1=(
> > 1 => 0,
> > 2=> 0,
> > 3=> 0,
> > );
>
> > for my $i (0 .. $length-1) {
> > foreach (keys %hash1) {
> > $hash1{$_}++ if substr($numbers, $i, 2) =~ /$_/;
> > }
>
> > }
>
> > If performance was important, you could use index rather than a regex,
> > or try switching the nesting of the inner and outer loops, or a variety
> > of other things.
>
> > On the other hand, if the code you posted doesn't do what you want in the
> > first place, then it isn't clear what you want.
>
> > Xho
>
> > --
> > --------------------http://NewsReader.Com/--------------------
> > Usenet Newsgroup Service $9.95/Month 30GB- Hide quoted text -
>
> > - Show quoted text -
>
> Actually, that is what I want it to do, something like a sliding
> frame. As for the values in STDIN, they are numerical values. This
> way, I can specify an arbitrary sequence for it to iterate over.
> Although this example seems ridiculous, its actually a simplification
> of a first order Markov transitional chain matrix.
>
> I'm actually having an error running this. After I modify my code to
> fit this, essentially what you suggested but with a print function at
> the end. I get this error: "Use of unintialized value in string C:\Perl
> \bin\markovgen2.pl line 107, <STDIN> line 2."
>
> This is my exact code:
>
> print "\nThere are a total of 18990 bases in the entire sequence\n";
> print "\nWhat is the starting base number? Keep in mind that Perl
> begins the tally";
> print "\nwith 0. So if you wanted to start from base 30, input in
> 29\n";
>
> #Here we can define where we want the sequence to begin and end
> print "Input Starting Number:\n";
> $beginning_of_sequence = <STDIN>;
> print "Input Ending Base Number:\n";
> $end_of_sequence = <STDIN>;
> $length_of_sequence = $end_of_sequence-$beginning_of_sequence+1;
>
> %dinucleotidepair = (
> AT => 0,
> AC => 0,
> AG => 0,
> AA => 0,
>
> TA => 0,
> TC => 0,
> TG => 0,
> TT => 0,
>
> CA => 0,
> CT => 0,
> CG => 0,
> CC => 0,
>
> GA => 0,
> GT => 0,
> GC => 0,
> GG => 0,
> );
>
> #$AC = 'AC';
> #$ACcountss = 0;
> #for my $i (0 .. $length_of_sequence-1) {
> # my $dinuc = substr($fastasequence, $i, 2);
> # if ($dinuc =~ $AC) {
> # $ACcountss++;
> # }
> #}
>
> for my $i (0 .. $length_of_sequence-1) {
> foreach (keys %dinucleotidepair) {
> $dinucleotidepair{$_}++ if substr($fastasequence, $i, 2) =~ /$_/;
> }}
>
> print "$dinucleotidepair";
>
> Can anyone explain to me the reason the error is popping up? Thanks.
>
> ~Frank- Hide quoted text -
>
> - Show quoted text -
Actually, I solved my own problem, but have a fresh problem. Here is
the working script:
print "\nThere are a total of 18990 bases in the entire sequence\n";
print "\nWhat is the starting base number? Keep in mind that Perl
begins the tally";
print "\nwith 0. So if you wanted to start from base 30, input in
29\n";
#Here we can define where we want the sequence to begin and end
print "Input Starting Number:\n";
$beginning_of_sequence = <STDIN>;
print "Input Ending Base Number:\n";
$end_of_sequence = <STDIN>;
$length_of_sequence = $end_of_sequence-$beginning_of_sequence+1;
%dinucleotidepair = (
AT => 0,
AC => 0,
AG => 0,
AA => 0,
TA => 0,
TC => 0,
TG => 0,
TT => 0,
CA => 0,
CT => 0,
CG => 0,
CC => 0,
GA => 0,
GT => 0,
GC => 0,
GG => 0,
);
#$AC = 'AC';
#$ACcountss = 0;
#for my $i (0 .. $length_of_sequence-1) {
# my $dinuc = substr($fastasequence, $i, 2);
# if ($dinuc =~ $AC) {
# $ACcountss++;
# }
#}
for my $i (0 .. $length_of_sequence-1) {
foreach (keys %dinucleotidepair) {
$dinucleotidepair{$_}++ if substr($fastasequence, $i, 2) =~ /$_/;
}
}
while ( my($keys,$values) = each(%dinucleotidepair) ) {
print "$keys $values\n";
}
#print "The Fasta sequence segment has $ACcountss AC's in
$beginning_of_sequence to $end_of_sequence",
#printf "for a relative frequency of %f\n", $ACcountss/
$length_of_sequence;
My new problem is this. I have to calculate the relative frequencies
for everything. So, what that means, is that if one of the keys in my
hash has an occurence, I have to divide that by $length_of_sequence to
find the relative frequency. Then, that relative frequency will be
used in another Perl script.
My question is this: How do I manipulate individual elements in a hash
given the value of the key is not zero.
Secondly, how do I save that as a variable that can be used by another
Perl script for calcuation purposes?
Thanks!
~Frank
------------------------------
Date: Tue, 10 Jul 2007 14:50:30 -0700
From: limitz <steamaccount2@gmail.com>
Subject: Re: Iterating over a hash
Message-Id: <1184104230.655645.37200@22g2000hsm.googlegroups.com>
On Jul 10, 3:58 pm, limitz <steamaccou...@gmail.com> wrote:
> On Jul 6, 8:19 pm, xhos...@gmail.com wrote:
>
>
>
>
>
> > limitz <steamaccou...@gmail.com> wrote:
> > > Hey I have a question with iterating over a hash.
>
> > > For example, if I have a hash table %hash1:
>
> > > %hash1(
> > > 1 => 1,
> > > 2=> 2,
> > > 3=> 3,
> > > );
>
> > > And given this string 123123123123.
>
> > > How would increment the values in the hash every time it recognizes
> > > the value?
> > > For example:
> > > $numbers = 123123123123;
>
> > You may want to make that a string rather than a number, or at some
> > point you will lose precision.
>
> > $numbers = '123123123123';
>
> > > $beginning = <STDIN>;
> > > print "Input Ending Base Number:\n";
> > > $end = <STDIN>;
> > > $length = $end-$beginning+1;
>
> > Since we don't know what it is you type in for STDIN, this makes a poor
> > example. I would be better to hard-code the values you want for testing
> > purposes.
>
> > > $one = '1';
> > > $onecount = 0;
> > > for my $i (0 .. $length-1) {
> > > my $count = substr($numbers, $i, 2);
> > > if ($count =~ $one) {
> > > $onecount++;
> > > }
> > > }
>
> > Assuming this actually does what you want (in which case you want
> > something quite strange--counting how many of the overlapping "digraphs"
> > (not exactly the right word--every combination of two adjacent letters
> > taken together, with some possible weirdenss as the end of the string if
> > $length is the same or longer than length $numbers) of a string contain a
> > digit in at least one of the two places in the digraph), then you could do
> > it something like this:
>
> > my %hash1=(
> > 1 => 0,
> > 2=> 0,
> > 3=> 0,
> > );
>
> > for my $i (0 .. $length-1) {
> > foreach (keys %hash1) {
> > $hash1{$_}++ if substr($numbers, $i, 2) =~ /$_/;
> > }
>
> > }
>
> > If performance was important, you could use index rather than a regex,
> > or try switching the nesting of the inner and outer loops, or a variety
> > of other things.
>
> > On the other hand, if the code you posted doesn't do what you want in the
> > first place, then it isn't clear what you want.
>
> > Xho
>
> > --
> > --------------------http://NewsReader.Com/--------------------
> > Usenet Newsgroup Service $9.95/Month 30GB- Hide quoted text -
>
> > - Show quoted text -
>
> Actually, that is what I want it to do, something like a sliding
> frame. As for the values in STDIN, they are numerical values. This
> way, I can specify an arbitrary sequence for it to iterate over.
> Although this example seems ridiculous, its actually a simplification
> of a first order Markov transitional chain matrix.
>
> I'm actually having an error running this. After I modify my code to
> fit this, essentially what you suggested but with a print function at
> the end. I get this error: "Use of unintialized value in string C:\Perl
> \bin\markovgen2.pl line 107, <STDIN> line 2."
>
> This is my exact code:
>
> print "\nThere are a total of 18990 bases in the entire sequence\n";
> print "\nWhat is the starting base number? Keep in mind that Perl
> begins the tally";
> print "\nwith 0. So if you wanted to start from base 30, input in
> 29\n";
>
> #Here we can define where we want the sequence to begin and end
> print "Input Starting Number:\n";
> $beginning_of_sequence = <STDIN>;
> print "Input Ending Base Number:\n";
> $end_of_sequence = <STDIN>;
> $length_of_sequence = $end_of_sequence-$beginning_of_sequence+1;
>
> %dinucleotidepair = (
> AT => 0,
> AC => 0,
> AG => 0,
> AA => 0,
>
> TA => 0,
> TC => 0,
> TG => 0,
> TT => 0,
>
> CA => 0,
> CT => 0,
> CG => 0,
> CC => 0,
>
> GA => 0,
> GT => 0,
> GC => 0,
> GG => 0,
> );
>
> #$AC = 'AC';
> #$ACcountss = 0;
> #for my $i (0 .. $length_of_sequence-1) {
> # my $dinuc = substr($fastasequence, $i, 2);
> # if ($dinuc =~ $AC) {
> # $ACcountss++;
> # }
> #}
>
> for my $i (0 .. $length_of_sequence-1) {
> foreach (keys %dinucleotidepair) {
> $dinucleotidepair{$_}++ if substr($fastasequence, $i, 2) =~ /$_/;
> }}
>
> print "$dinucleotidepair";
>
> Can anyone explain to me the reason the error is popping up? Thanks.
>
> ~Frank- Hide quoted text -
>
> - Show quoted text -
Actually, I solved my own problem, but have a fresh problem. Here is
the working script:
print "\nThere are a total of 18990 bases in the entire sequence\n";
print "\nWhat is the starting base number? Keep in mind that Perl
begins the tally";
print "\nwith 0. So if you wanted to start from base 30, input in
29\n";
#Here we can define where we want the sequence to begin and end
print "Input Starting Number:\n";
$beginning_of_sequence = <STDIN>;
print "Input Ending Base Number:\n";
$end_of_sequence = <STDIN>;
$length_of_sequence = $end_of_sequence-$beginning_of_sequence+1;
%dinucleotidepair = (
AT => 0,
AC => 0,
AG => 0,
AA => 0,
TA => 0,
TC => 0,
TG => 0,
TT => 0,
CA => 0,
CT => 0,
CG => 0,
CC => 0,
GA => 0,
GT => 0,
GC => 0,
GG => 0,
);
#$AC = 'AC';
#$ACcountss = 0;
#for my $i (0 .. $length_of_sequence-1) {
# my $dinuc = substr($fastasequence, $i, 2);
# if ($dinuc =~ $AC) {
# $ACcountss++;
# }
#}
for my $i (0 .. $length_of_sequence-1) {
foreach (keys %dinucleotidepair) {
$dinucleotidepair{$_}++ if substr($fastasequence, $i,
2) =~ /$_/;
}
}
while ( my($keys,$values) = each(%dinucleotidepair) ) {
print "$keys $values\n";
}
#print "The Fasta sequence segment has $ACcountss AC's in
$beginning_of_sequence to $end_of_sequence",
#printf "for a relative frequency of %f\n", $ACcountss/
$length_of_sequence;
My new problem is this. I have to calculate the relative frequencies
for everything. So, what that means, is that if one of the keys in my
hash has an occurence, I have to divide that by $length_of_sequence
to
find the relative frequency. Then, that relative frequency will be
used in another Perl script.
My question is this:
How do I manipulate individual elements in a hash
given the value of the key is not zero?
For example. In $fastasequence, the first 30 nucleotide bases contain
4 occurences of the variable "AC" yet no occurences of the base
combination "TG".
Thus, the variable frequency of AC is 0.133.
Secondly, how do I save 0.133 as a variable that can be carried over
and used by another
Perl script for calcuation purposes?
Thanks!
~Frank
------------------------------
Date: Tue, 10 Jul 2007 20:17:45 -0000
From: coder_expert@yahoo.com
Subject: Mail-Webmail-Yahoo-0.601 / yahootils.pl does not seem to work ?
Message-Id: <1184098665.340326.173040@i13g2000prf.googlegroups.com>
Any idea why its not working... valid username and passwd are
supplied...
Any hints how to proceed ?
C:\Perl\site\lib\Mail\Webmail>c:\Perl\bin\perl.exe yahootils.pl --user
some_user -pass changed_password --trace 4
Mail::Webmail::Yahoo: connected.
Mail::Webmail::Yahoo: requesting login page 'http://mail.yahoo.com'.
Mail::Webmail::Yahoo: requesting uri 'http://mail.yahoo.com' via GET.
Mail::Webmail::Yahoo: returned code 200 .
Use of uninitialized value in string eq at c:/Perl/site/lib/Mail/
Webmail/Yahoo.p
m line 269.
Use of uninitialized value in string eq at c:/Perl/site/lib/Mail/
Webmail/Yahoo.p
m line 269.
Use of uninitialized value in string eq at c:/Perl/site/lib/Mail/
Webmail/Yahoo.p
m line 269.
Mail::Webmail::Yahoo: requesting uri 'http://
world.yahoo.com/?.tries=1&.src=ym&
.md5=&.hash=&.js=&.last=&promo=&.intl=us&.bypass=&.partner=&.u=78p6q5d397pib&.v=
0&.challenge=6RkFwkHuehCwrXSmscdqPp3jqGae&.yplus=&.emailCode=&pkg=&stepid=&.ev=&
hasMsgr=0&.chkP=Y&.done=http%3A%2F%2Fmail.yahoo.com&.pd=ym_ver
%253d0%2526c%3D&lo
gin=chakhaaa&passwd=winchester&.save=Sign%20In' via GET.
Mail::Webmail::Yahoo:
parameters: .tries=1&.src=ym&.md5=&.hash=&.js=&.last=&pro
mo=&.intl=us&.bypass=&.partner=&.u=78p6q5d397pib&.v=0&.challenge=6RkFwkHuehCwrXS
mscdqPp3jqGae&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=0&.chkP=Y&.done=http
%3A%2F%2Fmail.yahoo.com&.pd=ym_ver%253d0%2526c
%3D&login=chakhaaa&passwd=winchest
er&.save=Sign%20In
Mail::Webmail::Yahoo: returned code 200 .
Mail::Webmail::Yahoo: Unable to log in (welcome page did not contain
welcome tex
t).
get_mail_messages: Unable to log in (welcome page did not contain
welcome text).
C:\Perl\site\lib\Mail\Webmail>
------------------------------
Date: Tue, 10 Jul 2007 20:59:56 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Portable general timestamp format, not 2038-limited
Message-Id: <f70s0c$2t4i$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
greg
<greg@cosc.canterbury.ac.nz>], who wrote in article <5fh0imF3cjte7U1@mid.individual.net>:
> Ilya Zakharevich wrote:
> > In pedantic mode: negative timestamps make sense with Big Bang as the
> > epoch as well. (AFAIU, the current way of thinking is that it was
> > "just too hot" before the big bang, it is not that "there was
> > nothing".)
>
> If Stephen Hawking is right, the shape of the universe
> is such that there isn't any time "before" the big bang
> at all. It's like asking what's north of the North Pole.
I do not remember any statement like this - even from 70s... Could
you provide a reference? There were conjectures about "initial
singularity", but I do not recollect them related to SH.
> Of course, this may have been replaced with some other
> equally bizarre idea by now...
Nothing as bizzare as the "initial singularity". There was a hot soup
not very far from a phase transition point; stochastically, some
micro-regions (bubbles) cool a little bit, and are subject to a phase
transition; due to transition, the metric in them grows (inflation),
so the "size" after transition [as seen from inside] is (hundreds?
thousands? millions? - I do not remember) orders of magnitude larger
than before transition - you get the universe-as-we-know-it as what sits
inside a "visible horizon" in such a babble. Wiki for "inflation".
> Another thought: If the cosmologists ever decide if
> and when the Big Crunch is going to happen, we may be
> able to figure out once and for all how many bits we
> need in the timestamp.
In the "hot soup", it is very hard to construct a watch. There may be
even some quantum-mechanical restrictions on bit storage in so hot a
matter (but I do not recollect seeing this). If so, then indeed,
"nothing measurable" happens before and after inflation/collapse of
the universe-as-we-know-it; so timestamp would be restricted to the
interval between the bangs.
Hope this helps,
Ilya
------------------------------
Date: Tue, 10 Jul 2007 16:04:02 -0400
From: "merl the perl" <invalid@invalid.net>
Subject: Re: re-lurking
Message-Id: <YoidnYPGOtOoew7bnZ2dnUVZ_u-unZ2d@comcast.com>
"Joe Smith" <joe@inwap.com> wrote in message
news:kaCdnf_hBIw_xA7bnZ2dnUVZ_urinZ2d@comcast.com...
> merl the perl wrote:
>
>>> Have you ever tried highlighting a message (in OE) and then going to
>>> File and Save As? This will save the raw article, headers & all (what is
>>> sometimes referred to as "mbox format".)
>>>
>>> Also, you can right click a highlighted message and use "Copy to Folder"
>>> to save a copy in your local OE folders.
> >
>> That they are local OE folders is precisely my bitch about it.
>
> The "Save As..." function saves the text in locations outside any OE
> folders.
> So what's the problem?
Indeed, this does create a .nws file outside of OE. If you had 80 such
messages, you'd have to do it 80 times.
One thing I've learned recently with OE is to use the combine and decode
option off of the right click for a bunch of messages. Had I used both
techniques together, I would have saved myself a good chunk of time.
Hindsight: 20-20.
--
mp
------------------------------
Date: Tue, 10 Jul 2007 14:33:05 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: TXL-like capability?
Message-Id: <m2fy3wp0ri.fsf@dot-app.org>
SomeDeveloper <somedeveloper@gmail.com> writes:
> Can I do source to source transformations elegantly in Perl?
Check out the Filter module on CPAN:
<http://search.cpan.org/~pmqs/Filter-1.34/perlfilter.pod>
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Tue, 10 Jul 2007 19:05:51 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: Using xargs perl to join lines
Message-Id: <jMQki.32638$xk5.5430@edtnps82>
charissaf@gmail.com wrote:
> Hello,
> FreeBSD 4.10
> #!/bin/ksh
>
> I'm looking for some guidance on how to use a combination of grep and
> xargs to find lines in multpile files beginning with > and append them
> to the previous line.
>
> For example, ideally I would like to use:
>
> grep -r -l '^>' . | xargs perl -pi -e :a -e '$!N;s/\n>/>/;ta' -e 'P;D'
>
> I am basing this one liner on the following sed example:
>
> # if a line begins with an equal sign, append it to the previous line
> # and replace the "=" with a single space
> # sed -e :a -e '$!N;s/\n=/ /;ta' -e 'P;D'
>
> The error I receive is: N: Event not found.
Of course Perl cannot run sed code just as sed cannot run Python code.
> A sample file would have a line similar to
> <htm
>
> The ideal result is to bring the closing > up to the preceeding line:
> <htm>
>
> Please look at my syntax or let me know if there is another way of
> doing this operation using xargs perl.
$ echo "
<html
>
" | perl -076pe's/\s+>$/>/'
<html>
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Tue, 10 Jul 2007 14:48:02 -0700
From: charissaf@gmail.com
Subject: Re: Using xargs perl to join lines
Message-Id: <1184104082.931076.297380@i13g2000prf.googlegroups.com>
On Jul 10, 12:05 pm, "John W. Krahn" <d...@example.com> wrote:
> charis...@gmail.com wrote:
> > Hello,
> > FreeBSD 4.10
> > #!/bin/ksh
>
> > I'm looking for some guidance on how to use a combination of grep and
> > xargs to find lines in multpile files beginning with > and append them
> > to thepreviousline.
>
> > For example, ideally I would like to use:
>
> > grep -r -l '^>' . | xargs perl -pi -e :a -e '$!N;s/\n>/>/;ta' -e 'P;D'
>
> > I am basing this one liner on the followingsedexample:
>
> > # if alinebegins with an equal sign, append it to thepreviousline
> > # and replace the "=" with a single space
> > #sed-e :a -e '$!N;s/\n=/ /;ta' -e 'P;D'
>
> > The error I receive is: N: Event not found.
>
> Of course Perl cannot runsedcode just assedcannot run Python code.
>
> > A sample file would have alinesimilar to
> > <htm
>
> > The ideal result is to bring the closing > up to the preceedingline:
> > <htm>
>
> > Please look at my syntax or let me know if there is another way of
> > doing this operation using xargs perl.
>
> $ echo "
> <html
>
> >
> " | perl -076pe's/\s+>$/>/'
>
> <html>
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you
> can special-order certain sorts of tools at low cost and
> in short order. -- Larry Wall- Hide quoted text -
>
> - Show quoted text -
Wow, thank you for your help!
------------------------------
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 V11 Issue 641
**************************************