[Solved] Regex , regular expression [closed]
Are you looking for s/x([0-9a-fA-F]{1,5})/ chr hex $1 /eg 3 solved Regex , regular expression [closed]
Are you looking for s/x([0-9a-fA-F]{1,5})/ chr hex $1 /eg 3 solved Regex , regular expression [closed]
Ok. The object constructor syntax you are using is a bit akward, I’d prefer my $obj = Stats->new(13,4,56,43,33); In Perl, new is not an ordinary keyword, but a simple sub, and should be used as such. The Foo->sub(@args) syntax is…
One thing you could do is extract all numbers, then use the second one: my $astring = “cool more 23423 random words of 1234 random other [wordssssssss] 23”; my @numbers = $astring =~ /[0-9]+/g; print “The second number is $numbers[1]\n”;…
perl -lane ‘splice @F, 2, 3; print “@F”‘ -l removes newlines from input and adds them to output -n reads the input line by line, running the code for each line -a splits each line on whitespace into the @F…
Here is semi-working and working code. Semi-working $ cat x1.pl | so #!/usr/bin/env perl use strict; use warnings; my $a = “$192.168.1.1”; print “$a\n”; $a =~ s/\$//; print “$a\n”; $ perl x1.pl | so Use of uninitialized value $192 in…
If your date formats are static, you have two easy options. Option 1 Strip out the day, month, and year from each date. Compare the two years. If the years are the same, compare the two months. If the months…
It sounds like you are trying to rewrite ls | more. Do you really need to do this? The program below opens the file temp.txt for writing. It then usesqx (the equivalent of backticks) to get the output from a…
You can use substr() as an lvalue and start replacing the string from right side of it, my $string = ‘GATGCAGTTAGGCGTAGCAGAGTGAGACGACGACGATATTAGGACCCGGTAAGGCACAATATAGC’; my %coord_colors = ( 10 => “red”, 48 => “orange”, 60 => “purple”, ); substr($string,$_,0) = $coord_colors{$_} for sort…
Easy in perl perl -pe ‘s-(\d+.?\d*)-($1/1000)-ge’ file add tube 3033.303 2998.20695111 106.1801625 0.060325 6.22260621 y 0 0 0 add cube 3027.18924332 3032.17578955 114.50875 0.1689 6.17076909 y 0 0 0 0 solved Unit conversion from mm to m in text file…
If you want to know if the result of dividing a $dividend by a $divisor is going to be a whole number or a number with a fractional portion, you can test that condition first: if (my $remainder = $dividend…
use File::Find::Rule; my @array = File::Find::Rule->directory->in(‘/home’); File::Find::Rule 1 solved listing directories and sub-directories to an array with path;
You should really learn Perl – it is really fun when you learn it yourself. It is really that simple: my %rev; foreach my $key (keys %hash) { $rev{$hash{$key}} = $key; } 3 solved how to reverse a hash in…
First of all, we need to distill your problem down to the part we actually care about. Your example code is not great because it contains a lot of unrelated errors, so I’ve taken some liberties in stripping out stuff…
The algorithm to sort this problem is simple, just like you said in your question description, sort characters in each word first, then sort these sorted-word again. Like this: $ echo heya64 this is21 a good89 day91 | perl -anE…
If this is about the process remaining around in “server mode” after automation, you can just call the quit method on the application object. I edited by answer at How can I run a macro in an Excel file I…