[Solved] Executing several commands at once [closed]

You should show what you have written, or we have no way of knowing what might be a “better way” You should probably take a look at Parallel::ForkManager. Using that module your program could look something like this There’s a lot missing from this code, most importantly use strict and use warnings ‘all’, and the … Read more

[Solved] How can I manipulate text in bash? [closed]

With awk: awk ‘BEGIN{FS=”[ ,]”; OFS=”,”} {for (i=2; i<=NF; i++) print $i,$1}’ file Output: foo,ted bar,ted zoo,ted ket,john ben,john See: 8 Powerful Awk Built-in Variables – FS, OFS, RS, ORS, NR, NF, FILENAME, FNR solved How can I manipulate text in bash? [closed]

[Solved] calculating average over many files [closed]

I forgot almost everything about bash scripting. but I think you can do something like this. files=(file1 file2 file3 file4) for i in `seq 4` do j=$(($i-1)) f[$j]=`cat ./temp/${files[$i]} | awk ‘{print $2}’ ` done for i in `seq 0 1799` do sum=0 rowValue=0 for j in `seq 0 3` do fileContent=(${f[$j]}) rowValue=`echo ${fileContent[$i]} ` … Read more

[Solved] Random error with WWW::Mechanize: Protocol scheme ‘https’ is not supported (LWP::Protocol::https not installed)

It is likely a problem with a module not being thread safe. See this Perlmonks discussion, also about LWP and https. The thread (er…discussion) also offers some potential solutions. 1 solved Random error with WWW::Mechanize: Protocol scheme ‘https’ is not supported (LWP::Protocol::https not installed)

[Solved] What does this HTML::Parser() code do in Perl? [closed]

From the documentation: $p = HTML::Parser->new(api_version => 3, text_h => [ sub {…}, “dtext” ]); This creates a new parser object with a text event handler subroutine that receives the original text with general entities decoded. Edit: use HTML::Parser; use LWP::Simple; my $html = get “http://perltraining.stonehenge.com”; HTML::Parser->new(text_h => [\my @accum, “text”])->parse($html); print map $_->[0], @accum; … Read more

[Solved] Regular expressions doubts [closed]

m// is the match operator. // are delimiters of the regex that you are mathing. If you are using default delimiters (//), then you can skip specifying m at the beginning. If you want to use some other charaters as delimiters, for example !, then m is required: m!/some/string/with/slashes!. solved Regular expressions doubts [closed]

[Solved] convert 0 into string

If you think you have zero, but the program thinks you have an empty string, you are probably dealing with a dualvar. A dualvar is a scalar that contains both a string and a number. Perl usually returns a dualvar when it needs to return false. For example, $ perl -we’my $x = 0; my … Read more

[Solved] Text Edit Change Variable Names [closed]

You may catch a few false matches, but this is the jist of it. It backs up the original files by adding a .bak extension, but make sure you have your own backup before overwriting valuable code. I assume these are JavaScript files? perl -i.bak -pe’s/\bm_(\w)/m\u$1/g’ *.js solved Text Edit Change Variable Names [closed]