[Solved] Web Server Block libwww-perl requests

Use agent method provided by LWP::UserAgent to change “user agent identification string”. It should solve blocking based on client identification string. It will not solve blocking based on abusive behavior. perldoc LWP::UserAgent agent my $agent = $ua->agent; $ua->agent(‘Checkbot/0.4 ‘); # append the default to the end $ua->agent(‘Mozilla/5.0’); $ua->agent(“”); # don’t identify Get/set the product token … Read more

[Solved] Perl : Get array of all possible cases of a string

If you’re aiming to use if for glob anyway then you can use glob‘s built-in pattern generation my $filename=”File.CSV”; my $test = $filename =~ s/([a-z])/sprintf ‘{%s,%s}’, uc($1), lc($1)/iegr; say $test, “\n”; say for glob $test; output {F,f}{I,i}{L,l}{E,e}.{C,c}{S,s}{V,v} FILE.CSV FILE.CSv FILE.CsV FILE.Csv FILE.cSV FILE.cSv FILE.csV FILE.csv FILe.CSV FILe.CSv FILe.CsV FILe.Csv FILe.cSV FILe.cSv FILe.csV FILe.csv FIlE.CSV FIlE.CSv … Read more

[Solved] how to pass hash reference to a subroutine

You never assigned to $hash_1 and $hash_2! my ($hash_1, $hash_2) = @_; You have more problems than that, however, both keys and values in scalar context return the number of elements in a hash, so you are simply checking if both hashes are of the same size! sub are_hashes_equal { my ($hash1, $hash2) = @_; … Read more

[Solved] How to align table headers to rows in Perl

#!/usr/bin/env perl use strict; use warnings; use Text::Table::Tiny; my @pName = ( { “Type” => “xxxxxComponent”, “Name” => “xyz_abc_1234LDO_c7rp1avrusevrmdtop”, “Rev_Id” => “PROD_2_5”, “ZZZ_ID” => ’99ccccc1′, “IP_Group” => “ABC RIP xxxxx”, “Date_Released” => “2015-05-03 6:59:09”, “AA_Category” => “Hard”, “Project_IDs” => ” “, }, { “Type” => “xxxxxComponent”, “Name” => “xyz_abc_1234LDO_c7rp1avrusevrmdtop”, “Rev_Id” => “PROD_2_5”, “ZZZ_ID” => ’99ccccc1′, … Read more

[Solved] What Perl variables are used for the positions of the start and end of last successful regex match? [closed]

As the perlvar man-page explains: $+[0] is the offset into the string of the end of the entire [last successful] match. This is the same value as what the pos function returns when called on the variable that was matched against. $-[0] is the offset of the start of the last successful match. solved What … Read more

[Solved] Double hash entries while printing

You have a foreach loop inside a while which will print all of the keys of the %position hash for every line of input That will cause symptoms like what you’re describing. Is that what you’re looking for? solved Double hash entries while printing

[Solved] Perl regex for char ‘&’ [closed]

There must be an error somewhere else in your program. This works as expected: $s1 = ‘M&M chocolates’; $s2 = ‘Tom & Jerry’; printf(“$s1\n”) if $s1 =~ m/\w\W\w\s\w+/; printf(“$s2\n”) if $s2 =~ m/\w+\s&\s\w+/; outputs M&M chocolates Tom & Jerry solved Perl regex for char ‘&’ [closed]

[Solved] Separate a row of strings into separate rows [closed]

Python Power Unleased : import csv,sys filename=”a.csv” with open(filename,’rb’) as csvfile: reader = csv.reader(csvfile,delimiter=”,”) try: for row in reader: if row[1].find(‘,’) == -1: line=”,”.join(row) print line else: for i in range(0,row[1].count(‘,’)+1): line = row[0]+’,’+row[1].split(‘,’)[i]+’,’+row[2].split(‘,’)[i] print line except csv.Error as e: sys.exit(‘file %s, line %d: %s’ % (filename, reader.line_num, e)) solved Separate a row of strings … Read more

[Solved] perl parsing inserting new line and ^M

My guess is, that you are working with a linux file on some windows. Perl automatically converts \n into \r\n on dos-compatible machines after reading and before writing. To get rid of this behaviour, you can use binmode <FILE> on your filehandles, but it sets your filehandle into “raw binary mode”. If you want to … Read more

[Solved] Reading a file and output in a particular format in Perl [closed]

I think I know what you want: perl -F’\s’ -anE’BEGIN{$/=”\n\n”;}$i=$F[6];say”$_ – “,$i–for($F[0]..$F[2])’ Simple, isn’t it? BTW, your example output is wrong. I see the image (copy) mirrored. Left value is bigger than right. So values in second column should go down. If it can vary in your input data you have to use little bit … Read more