Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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


Comment on Re^2: How to split unique patterns
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 (Monsignor) 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?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2014-08-02 00:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (53 votes), past polls