[Solved] My code to write a .txt file from my @data isn’t working :(. What am I doing wrong? I am using a while loop

Your errors come from : $fh=$headers; print “$fh\n”; and $fh=join(‘\t’,@riteline); print “$fh\n”; You’ d write: print $fh $headers,”\n”; and print $fh join(“\t”,@riteline),”\n”; for the last one I think you want: print $fh @riteline,”\n”; Also, don’t use @DAY[$ii] but $DAY[$ii] 4 solved My code to write a .txt file from my @data isn’t working :(. What … Read more

[Solved] Generating sets of array in perl

Loop over @nobreak? my $s=”MALWMRLLPLLALLALWGPDPAAAFVNQHLCGSHLVEALYLVCGERGFFYTPKTRREAEDLQVGQVELGGGPGAGSLQPLALEGSLQKRGIVEQCCTSICSLYQLENYCN”; print “Results of 1-Missed Cleavage:\n\n”; my @nobreak = (37,45,57,59); for my $nobreak (@nobreak) { substr($s, $nobreak-1, 1) = “\0”; my @a = split(/E(?!P)/, $s); substr($s, $nobreak-1, 1) = ‘E’; $_ =~ s/\0/E/g foreach (@a); $result = join (“E,”, @a); @final = split(/,/, $result); print “@final\n”; } solved Generating sets of … Read more

[Solved] Finding the modules where changes were checked with svn

Three separate tasks: call svn properly to create the log parse the log Write the parsed values somewhere 1. import subprocess as sp svn_url = “svn://repo-path.com/project” revisions = [12345, 12346] revision_clargs = [“-r%i” % revision for revision in revisions] popen = sp.Popen([“svn”, “log”, “-v”] + revision_clargs + [svn_url],stdout=sp.PIPE,stderr=sp.PIPE) out,err = popen.communicate() 2. input_ = “”” … Read more

[Solved] Generateing all possible 16 digit number requireling less storage location

If I understand you correctly then all that code is just to avoid printing numbers that have more than eight zeroes You can do that like this my $credit_card_number = “$a$b$c$d$e$Fc$g$h$i$j$k$l$m$n$o$p”; print $credit_card_number, “\n” unless $credit_card_number =~ tr/0// > 8; But I still think your enterprise is a fruitless one solved Generateing all possible 16 … Read more

[Solved] perl script error: Can’t exec “module”: No such file or directory at ./prog line 2 [closed]

From the Perl documentation for system: If there are no shell metacharacters in the argument, it is split into words and passed directly to execvp. So, your command is being passed in as three separate commands. Try putting quotes around it for a start. i.e. system (‘”module add openssl”‘); If that does not fix it, … Read more

[Solved] Comparing two files in perl [closed]

the code maybe looks like this: #!/usr/bin/perl use strict; use warnings; my @array = (‘1′,’2′,’3′,’5′,’6’); my @array2 = (‘1’, ‘3’, ‘7’, ‘6’); for my $item(@array2) { if (grep($_ == $item, @array) > 0) { print “$item, Match\n”; } else { print “$item, Not Match\n”; } } Output 1, Match 3, Match 7, Not Match 6, … Read more

[Solved] What is an alternative for split in Perl? [closed]

Howzabout this: #!/usr/bin/perl use warnings; use strict; my $s = q/a: b d: e f: a:b:c g: a b c d f:g:h h: d d:dd:d f /; open my $input, “<“, \$s or die $!; my @left; my @right; while (<$input>) { chomp; my ($left, $right) = /^(.):?\s+(.*)$/; push @left, $left; push @right, $right; } … Read more

[Solved] perl different time format output

Use Time::Piece. It’s a standard part of the Perl distribution. Use strptime (string parse time) to parse your string into a Time::Piece object. Then use strftime (string format time) to display your Time::Piece object in whatever format you want. #!/usr/bin/perl use strict; use warnings; use 5.010; use Time::Piece; my $in_format=”%Y-%m-%d %H:%M:%S”; my $out_format=”%Y-%m-%dT%H:%M:%SZ”; my $in_date=”2015-08-18 … Read more

[Solved] Read address from another file using Perl

I’m going to assume that the file will always only have one line in it… First, always put use warnings; and use strict; at the top of your scripts. This catches the most common and basic problems before you even get going (like not declaring your variables with my for instance). You need to open … Read more