[Solved] Perl — regex issue
the second declaration of $line is erroneous, drop my: $line =~ m/textolibre=(.*?)&translated/g; 2 solved Perl — regex issue
the second declaration of $line is erroneous, drop my: $line =~ m/textolibre=(.*?)&translated/g; 2 solved Perl — regex issue
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
Use Perl. Read the CSV file into a hash, build a regular expression from the hash keys, and do a global subtitution on the text using the hash to translate. It looks like this use strict; use warnings; use 5.010; use autodie; my $str = <<‘__END_TEXT__’; The ripple-necked bird sang melodies by the curling river … Read more
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
awk ‘{ a[$1]+=$2+$3 } END { for (i in a) print i, a[i] }’ input.txt > op.txt solved parse file in perl using awk commands
but I have no knowledge of PERL at all. Then the solution is to hire someone who does, or to start learning. See perl tag wiki. (As an aside, the language is called Perl, and the interpreter used to run Perl programs is called perl. Other capitalizations are a bit frowned upon). Should you decide … Read more
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
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
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
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
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
To get the closest starting tag to ThisIsImportant use a negative assertion on the tag itself. /<tag>(?:(?!<tag>).)*ThisIsImportant.*?<\/tag>/ Formatted: <tag> (?: (?! <tag> ) . )* ThisIsImportant .*? </tag> 0 solved Perl Regex – Search and replace between tags only if string is in-between [closed]
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
If I understand your question, here’s one way to do it: use glob to find all files in the directory and grep to filter them. my $dir=”/usr/test”; my @files = grep { /REGEX_HERE/ } glob(“$dir/*”); 2 solved How to support the searching file based on regular expression
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