Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: How to split unique patterns

by cornelius80 (Initiate)
on Jun 10, 2013 at 08:55 UTC ( #1038015=note: print w/replies, xml ) Need Help??


in reply to Re: How to split unique patterns
in thread How to split unique patterns

Hi Corion, Thank you for your suggestion. However, I might have left out some criteria though. 1. A,B,C,D.. are headers that I would need to have with their preceding values equated to. eg. A=undef,B=123-456 hh:mm, C=undef,D=789... 2. This would mean that the RHS of the headers would change over time keeping the LHS headers constant. How would you suggest that I overcome this, please? Thank you. Kind Regards, Cornelius

Replies are listed 'Best First'.
Re^3: How to split unique patterns
by Corion (Pope) on Jun 10, 2013 at 09:15 UTC

    I don't understand the additional requirements from your text. Can you maybe post some (anonymized) more relevant input data?

      Hi Corion, Sorry for the misunderstanding. Here goes... I have a string as follows that I will collate into an array: info::gmdate:2013-06-07 05:57:tccat_cico::r From that array, I am intending to split the data based on ':' such that I get the following, info gmdate 2013-06-07 05:57 tccat_cico r However, the "2013-06-07 05:57" gets separated into 2013-06-07 05 57 which is not what is intended.

        Ah - if you want to capture different parts, you need to adjust the parentheses appropriately:

        my $line= q{info::gmdate:2013-06-07 05:57:tccat_cico::r}; my @columns= qw( type tstype timestamp + info1 info2 rest); $line=~ /^(\w+)::(gmdate):(20\d\d-[01]\d-[0123]\d [012]\d:[0-6]\ +d):(\w+):(\w*):(.*)/ or die "Malformed input [$line] in line $."; my %info; @info{ @columns }= ($1,$2,$3,$4,$5,$6);

        Update: Fixed $info{ @columns }= ... to be the correct @info{ @columns }= ...

Re^3: How to split unique patterns
by AnomalousMonk (Chancellor) on Jun 10, 2013 at 14:08 UTC
    ... I might have left out some criteria ...

    Oh, of course you left out critical criteria! Answering these questions would not be near as much fun if we actually had accurate problem statements to begin with. I'm sure Corion appreciates the opportunity to waste... er, devote his or her time to providing a useful and insightful answer to a fundamentally mis-stated question.

    Many ++ to Corion for truly humble monkish patience, forbearance and generosity in dealing with a miserable sinner.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1038015]
help
Chatterbox?
[usemodperl]: what the hell happened to the monastery?
usemodperl gets scolded by little old ladies on every dang post
[usemodperl]: did we get invaded by soy boys or what? it wasn't like this 20 years ago :-)
[usemodperl]: i can see the old tgimers hiding out on reddit! lol
[usemodperl]: no wonder this place is so... popular
[marto]: your account is 7 days old, how old are these 'old tgimers'?
[choroba]: usemodpoerl Do you have a question? Do you want to help someone? Or do you just want to troll?

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2018-06-24 15:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (126 votes). Check out past polls.

    Notices?