Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  • Users: prex1
  • Order by date
  1. prex1

    question about numpy 1-D array

    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...
  2. prex1

    Get Key from Array Value

    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...
  3. prex1

    Strange behaviour in substitution

    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
  4. prex1

    Convert Form Feed to new line

    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...
  5. prex1

    How to efficiently implement file comparison

    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...
  6. prex1

    Given date is 6 months older or not

    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...
  7. prex1

    How to assign bit shift to a variable?

    $logMsg .= "OK!! Child($$, $pid) $res ended with ". ($? >> 8) ."\n"; http://www.xcalcs.com : Online engineering calculations http://www.megamag.it : Magnetic brakes for fun rides http://www.levitans.com : Air bearing pads
  8. prex1

    How to print string with comma in single column of csv

    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...
  9. prex1

    print and display values

    for(...){ push @{$set{$key}},$value; } for(sort keys%set){ if(@{$set{$_}}>$limit){ print"@{$set{$_}}[0..$limit-1]\n"; print"@{$set{$_}}[$limit..$#{$set{$_}}]\n"; }else{ print"@{$set{$_}}\n"; } } http://www.xcalcs.com : Online engineering calculations http://www.megamag.it ...
  10. prex1

    Enumerate AD

    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...
  11. prex1

    Distinguish x=undef vs x=''

    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
  12. prex1

    assistance with a better way to do this

    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...
  13. prex1

    simple regex issue

    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...
  14. prex1

    String match issue

    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
  15. prex1

    A bit of a regex problem

    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...
  16. prex1

    How do I fix notice "Undefined index"

    if(array_key_exists('doRegister',$_POST) && $_POST['doRegister'] == 'Register') http://www.xcalcs.com : Online engineering calculations http://www.megamag.it : Magnetic brakes for fun rides http://www.levitans.com : Air bearing pads
  17. prex1

    Concatenate based on 1st column in a file of records

    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...
  18. prex1

    Open file and print new line that is appended

    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...
  19. prex1

    searchable pdf / word docs

    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...
  20. prex1

    regex ?

    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...

Part and Inventory Search

Back
Top