You can create a dictionary with the index as the key and your list value as the value; in your example:
(0:1,1:7,2:2,3:8,...)
Then you sort the hash by value, and iterate through it to determine the index (key) difference of adjacent couples. You should also define what to do if you find...
I can't see a way, other than cycling over all of the cities of the array.
IMHO you are using the wrong array structure. You should have an array with the city name as the key and the corresponding salesman as the value. This would let you search by salesman, cycling with array_search, and of...
Suppress the space between = and ~ (and the i modifier seems not useful)
http://www.xcalcs.com : Online engineering calculations
http://www.megamag.it : Magnetic brakes for fun rides
http://www.levitans.com : Air bearing pads
There is no \f char in Windows systems output strings, \r might be used instead.
With Perl you simply use \n that is converted, when sent to an output device, to the proper sequence depending on operating system.
If you want an additional new line in your string, just append a newline char...
First thing, you don't need to read both files into hashes, but just one, then you read the second file line by line to check if it is in the hash.
Also you should decide what to do with equal lines: you could have two equal lines in a file and only one in the second. Are these files considered...
If your date isn't in the 'seconds from the epoch' format, then you need Date::Calc or a similar module (not in the standard perl distribution though): see here.
http://www.xcalcs.com : Online engineering calculations
http://www.megamag.it : Magnetic brakes for fun rides
http://www.levitans.com...
Before the first line $a = "\"". $a . "\""; you must be doing something that puts your string in numeric context, and, voila, your string is changed by perl (and there is no simple way to come back).
You should inspect your code before that point to see where this numeric context is created...
Chris, the test if($str ne ""){} checks if $str is an empty string, but NOT if $str is undef (uninitialized). That's why Randy continues to see the error. A better test would be if($str){}, though this one is also not perfect, as a value $str="0" returns false. Possibly the best one is...
defined $h{a} is what you need
http://www.xcalcs.com : Online engineering calculations
http://www.megamag.it : Magnetic brakes for fun rides
http://www.levitans.com : Air bearing pads
I would use an array of hashes instead of a hash of hashes.
In short, creation and printing become (untested):for ( my $i = 4 ; $i <= 15 ; $i++ ) {
push @BARCODE, {'enabled',1,'type','qrcode','data',"http:web$i.url",'options','',
'width',"0.$i",'height',0.4,'hscale',0.5,'vscale',1,'x',65...
I would do this in a much faster way not using regexes:$input = 'Tea/Coffee/Eggs/Bacon';
@spl = split(/\//,$input,4);
map{$_=lc}@spl[0..2];
$output=join'/',@spl;
print $output;
http://www.xcalcs.com : Online engineering calculations
http://www.megamag.it : Magnetic brakes for fun rides...
The dot stands for 'any character' in the regex. One way to solve this is to disable the metacharacters by prepending \Q : if($str =~ /\Q$ip/) {
http://www.xcalcs.com : Online engineering calculations
http://www.megamag.it : Magnetic brakes for fun rides
http://www.levitans.com : Air bearing pads
IMHO this is not a task for regexes. Split is much faster and cleaner (and readable) for such a simple task.if($Valid==0){
my($name,$year)=split/\./,$results[$x];
$results[$x]=$name.'<sup>'.$year.'</sup>'if$year>=1800&&$year<2030;
}If the format of the string is incorrect (e.g. no period or...
From your example it is unclear what do you want for something like111112 4000000001 01/01/13 13:05
111112 4000000002 02/02/13 13:05
111113 4000000003 04/01/13 07:05
111113 4000000004 05/01/13 10:05
111112 4000000005 03/03/13 13:05
111113 4000000006 06/01/13 17:05
111114 4000000007 06/01/13...
You can use the -M switch to test the file modification time:my $lasttime=0;
my $myinputfile="myinputfile.log";
while(1){
if(-M $myinputfile<$lasttime){
$lasttime=-M "myinputfile";
open F,$myinputfile;
print $_ while <F>;
close F;
}
sleep 1;
}It is not difficult to add the...
If those documents are permanent and there are hundreds or thousands of them, then you should go with including their full text content in a DB.
However not all pdf's contain text (scanned pages), with those you can only go with an OCR application (that cannot be fully automatic). Also, if you...
OK, touché...[blush]
split on its own splits $_ on multiple space chars (including tabs and newlines), without including in the output null fields for multiple spaces or any starting or ending spaces (it strips off the ending newline, so chomp is not necessary).
http://www.xcalcs.com : Online...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.