Tag Info

New answers tagged

0

Substitute "Some...\n...Thing" by the contents of file "new" in one or more input files perl -i -p0e 's/Some.*?thing\n/`cat new`/se' input.txt ... -i to change input.txt directly -p0 slurp input file file and print it in the end s/regexp/.../s in regexp . is .|\n s/.../exp/e replace by eval(exp) new -- a file containing the replacement text (This ...


0

Not to strong (because don't chech second string but it easy to settle) and can be is not posix compilant but very simple: sed '/^Some text/{:1;/another thing$/!{N;b 1} s/.*/this is completely\ndifferent text/g}' input.txt First command add lines from Some text until have met another thing then second line change it to other text. NOTE Limitation is ...


2

sed -e :n -e '$!N;/\n.*\n/!{$!bn }; s/some text,\n* *something else\n* *another thing/this is completely\ different text/;P;D' <infile I fear you're going to have a difficult time coming up with a solution that suits you until you hammer out a concrete description of the problem - but that's what QA is best suited for, as I see it. Maybe this will give ...


1

IO::Socket::SSL verifies that the name in the certificate matches the name you connect to, but Crypt::SSLeay does not. Newer LWP also verify the certificate chain by default, but maybe this was also done with the older LWP version you used. I recommend you call your program with SSL debugging to see the actual cause of the problem: perl ...


1

Try this : perl -0ne 'print $& if /^Host.*?IdentityFile\s+\K[^\n]+/ms' file


0

It seems that bash-script is much simple than perl while read keyword do occurance=$(grep -c -F "$keyword" input.txt) echo "$keyword has occured $occurance time(s)" done < keyword.txt


0

If you are not hard pressed for perl, a simple command line grep -f keyword.txt -c input.txt should do it. In perl, you would need to do also open keyword.txt and loop through each keyword, grepping in turn as you have done for 1 alone in your code.


1

"You could also use find and sed, but I find that this little line of perl works nicely. perl -pi -w -e 's/search/replace/g;' *.php -e means execute the following line of code. -i means edit in-place -w write warnings -p loop over the input file, printing each line after the script is applied to it. " (Extracted from ...


0

I solved the problem. There are many perl modules I forgot to install. I checked the dependencies and installed the modules. Now it runs very well


2

You misunderstand what ack does. It is a grep-analog, not a find-analog. It searches through the contents of files for the given pattern and not for file names matching the pattern. You should instead use find -regex '.*group.*producer.*' Or find -name '*group*producer*' If you insist on using ack (though I see no point in doing so), you can parse ...


1

If grepping over filenames in the current directory is all you need ack matches the contents of files, not their name. To find files whose name matches a regex, run ack over the list of filenames: ls | ack '.*group.*producer.*' What you did, namely ack -n '.*group.*producer.*' will instead look for files in the current directory containing something ...


0

I think the easiest thing is to sort the input first. This solution avoids using an array, which would limit the size of the input file you can handle. If sorting is not a problem, then this should work: sort file | awk '{ if ($1$2 != key) { if (valid == 1) print firstline; firstline=$0; ...


0

I've solved the problem: I FORGOT TO uncomment LoadModule cgi_module modules/mod_cgi.so directive in httpd.conf.


1

You can't modify the existing installation as non-root. But you can install a CPAN module in your home directory (or wherever you have write access) and then load that module preferentially (in most cases. It is possible for there to be conflicts between modules, but you're probably okay here). There are instructions for doing this via the cpan tool in ...


1

First turn up logging level. Change the "LogLevel" directive to LogLevel debug. Use systemctl to stop/start httpd. Mark the perl script executable with chmod ugo+x whatever Next, change the script a little. You need a "blank line" between headers and body: print "Content-type: text/html\r\n"; print "\r\n"; Note that each line in the headers is ...


1

You haven't informed apache when to use the mod_perl extension. Add the following: AddHandler perl-script .pl .cgi to your config instead of the cgi-script handler. Also see How do I make Apache handle .pl (Perl) files, using mod_perl?


2

I think that the answer you are looking for is point 3, but just in case I have added points 1 and 2: If you run perl script.pl then you do not need to make the file executable. If a file is not executable then you pass the name of the script, as an argument, to the perl command. If you can run perl without specifying a path (i.e. /usr/bin/perl ...



Top 50 recent answers are included