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 strongm 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: travs69
  • Content: Threads
  • Order by date
  1. travs69

    Data parsing

    id:2 name:test1 longname:test2 with space longname description:here is my description.id:10 name:test3 longname:test 4 long name description:a discription of test 5 I have data like above and I'd like to get it into a hash like %hash { 'id:2' => {name => test1 longname => test2 with space...
  2. travs69

    Regex help

    I have a regex written like this and it works fine $data = '01:16:43.7'; ($cdr{dhour}, $cdr{dmin}, $cdr{dsec}, $cdr{dfsec}) = $data =~ /(.*):(.*):(.*)(\..*)/; print "H:$cdr{dhour}\n"; print "M:$cdr{dmin}\n"; print "S:$cdr{dsec}\n"; print "fs:$cdr{dfsec}\n"; output: H:01 M:16 S:43 fs:.7 but...
  3. travs69

    Reading in a file path from a file results in weirdness

    The following code is printing out: D:/temp 2/temp /test.rtf when I would have expected D:/temp D:/temp 2 D:/temp/test.rtf config.txt contains one line temp_dir=D:/temp use strict; my %config; my $config_file = 'config.txt'; #Get the config data open(CONFIG, "<$config_file")...
  4. travs69

    Moving definition from subroutine to config hash

    Currently I have a sub like this (scrubbed for public display) sub decode_data { my $type = shift @_; my $date = shift @_; my (%return_data, $csv); if ($type =~ /TYPE1/i) { $csv = Text::CSV_XS->new({binary => 1, allow_loose_quotes => 1, allow_loose_escapes => 1, verbatim => 1, escape_char...
  5. travs69

    Can this regex be written better?

    use strict; my $val = 'Rpc:0xf98103'; my $test = join('=',map(hex,$val =~ /(\w{2})(\w{2})(\w{2})$/)); print "$test\n"; I was thinking there would have to be a way to say do 3 (\w{2})'s with out hand putting them in. Thanks! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [noevil] Travis - Those...
  6. travs69

    Permutations..??

    I'm not sure if this is considered a permutation or not. I'm looking to find every combination of a..z,0..9 X wide. so 2 wide would start like a a a b a c and end up like z y z z 3 wide would be a a a a a b a a c etc etc.. All the permutations I have found just go as wide as the available...
  7. travs69

    User configurable output

    I would like to provide a easy way for an end user to provide output configuration to my script. for example if I have a few var's my ($first_name, $last_name, $middle_name); [/code] I was thinking of having them just put in the configuration file (that they control) ex: Output=$last_name...
  8. travs69

    regex help

    my %month = ( 'JAN' => 1, 'FEB' => 2, 'MAR' => 3, 'APR' => 4, 'MAY' => 5, 'JUN' => 6, 'JUL' => 7, 'AUG' => 8, 'SEP' => 9, 'OCT' => 10, 'NOV' => 11, 'DEC' => 12); $col[5] = 'MAY052010'; ($c{month}, $c{day}, $c{year}) = $col[5] =~ /(.{3})(\d{2})(\d{4})/; $c{month} = $month{$c{month}} #or...
  9. travs69

    Regex match question

    I currently have this code but I'm sure there's a way to do it in a one line match. Regex to pull both out=/(.*):.*\/(.*):/ If the second IP address is 0.0.0.0 return the first IP else keep the second $test = '1.1.1.1:1234/0.0.0.0:4321'; ($test2) = $test =~ /.*\/(.*):/; if ($test2 eq...
  10. travs69

    Finding values in a hash that match but returning the keys

    I know there is a lot going on here so i'm sorry for the huge amount to read.. but I appreciate any help. I have upwards of 20M lines of data that I have to read in. The current code reads it in, creates 2 hashes of epoch times (start and stop) with a common ID (this can match any number of...
  11. travs69

    File::Find trying to pass variables to the wanted subroutine

    use File::Find; my $test = 1; my $test3; my $dir = 'c:/temp'; find(\&wanted, $dir); for (0..0) { my $test2 = 2; find(\&wanted2, $dir); } for (0..0) { $test3 = 3; find(\&wanted3, $dir); } sub wanted { print "T1:$test\n"; } sub wanted2 { print "T2:$test2\n"; } sub wanted3 { print...
  12. travs69

    Keeping track of hundres of file handles

    I need to parse through millions of lines of dataand parse them into smaller files. The original data is all mixed up and I might need to write to file A once or hundreds of times. Instead of opening/closing every file handle I thought I'd open it up if needed, mark it in an hash to I know...
  13. travs69

    Exit codes for system call, work great execpt for rm

    I running system command on a remote box (not my favorite thing to do but I deal with it) and all the commands come back correct except for the rm command. I wrote a simple test script #!/usr/bin/perl if (`rm -f /tmp/travis.txt`) { print "success\n"; } else { print "Failure\n"; } This code...
  14. travs69

    Dynamic colors on map

    I'm looking for a way to take a base image (US State map) and to be able to color in certain states on demand (with out having to pre color in every possible combination). Many moons ago I ran across a script that someone had written that would do exactly what I'm looking for. I'm 99% sure...
  15. travs69

    A simple join question..

    table a number in_use table b source destination I'm stuck on trying to join these with out returning multiple rows select b.source,b.destination where (a.number = b.source and a.in_use = '0') or (a.number = b.destination and a.in_use = '0') limit 1; but that of course returns two rows...
  16. travs69

    Sprint if inside of popup_menu in CGI?

    I'm trying to do something like popup_menu(start_hour,[sprintf("%02d", (0..31))] without making a array of 0..31 formated the way I like in advance. Any advice? Thanks. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [noevil] Travis - Those who say it cannot be done are usually interrupted by...
  17. travs69

    Lil regex help..

    my $data = 'AS5300 chassis, Hw Serial#: 27539697, Hw Revision: A.32'; if ($data =~ /Serial#: (.*?), Hw Revision: (.*?)/i) { print "$1\n"; print "$2\n"; } Not working as expected output is only. 27539697 Thanks in advance as always..!! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [noevil]...
  18. travs69

    hash of subroutines.. not quite working

    I'm 99% sure you can do this but I can't get it. Any help is appreciated my %equipment_sub_map = { 'CISCO 2651 ROUTER' => \&cisco_2651, 'CISCO 3845-V/K9 VOICE BUNDLE ROUTER' => sub{print "Hi\n";}, }; sub cisco_2651 { print "Hi 2\n"; } &{$equipment_sub_map{"CISCO 2651 ROUTER"}}...
  19. travs69

    Another math question.

    Right now I have a hash that looks like %hash = ( 1 => 1, 2 => 1, 3 => 2, 4 => 2, 5 => 3, 6 => 3, 7 => 4, 8 => 4, ); Is there a way to do this other than hard coding them in? (In my best red neck voice) Maybe one of them their fangled dangled mathmatical formulas? Thanks ...
  20. travs69

    How do you get every possible permutation..

    permutation may not be the correct word here.. but I'm guessing :) How do you get every possible 2 part permutation of a list of strings? ie @array = qw(5501 5502 5503); I want 5501 5502 5502 5501 5501 5503 5503 5501 5502 5503 5503 5502 I do not want 5501 5501, 5502 5502, or 5503 5503...

Part and Inventory Search

Back
Top