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...
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...
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")...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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]...
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"}}...
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 ...
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...
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.