Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Editing Listed Data

by kcott (Canon)
on Mar 25, 2013 at 04:34 UTC ( #1025228=note: print w/replies, xml ) Need Help??

in reply to Editing Listed Data

G'day jtucker,

Welcome to the monastery.

As you haven't shown any code, it's difficult to know where you're getting stuck with this. For instance, your earlier comment "What I an hung on is the third bullet." [sic] is meaningless to me: it's the first and only time you've mentioned bullets; there are no bulleted lists; how does the 3rd bullet (not shown) differ from the 1st and 2nd bullets (also not shown). In order to get a better answer when you post here, you'd do well to read these guidelines: How do I post a question effectively?

The following skeleton code may help resolve whatever problem you're experiencing. If not, please post any follow-up questions in line with the guidelines I've linked to above.

$ perl -Mstrict -Mwarnings -E ' my @data = ( q{1:1 word1}, q{1:1 word2}, q{1:1 word3}, q{1:1 word4}, q{1:2 word1}, q{1:2 word2}, q{1:2 word3}, q{1:3 word1}, q{1:3 word2}, q{1:3 word3} ); my $old_head = q{}; for (@data) { my $new_head = (split)[0]; if ($new_head ne $old_head) { say "> $new_head"; $old_head = $new_head; } say; } ' > 1:1 1:1 word1 1:1 word2 1:1 word3 1:1 word4 > 1:2 1:2 word1 1:2 word2 1:2 word3 > 1:3 1:3 word1 1:3 word2 1:3 word3

-- Ken

Replies are listed 'Best First'.
Re^2: Editing Listed Data
by jtucker (Initiate) on Mar 25, 2013 at 16:40 UTC

    To clarify, my comment regarding the bullets was in conjunction to another's response. It probably would have been best to read the comment as a response, since it appears, at least on my display, indented to the aforesaid comment.

    I appreciate the response. I am aware of the forum guidelines. But since my question was a very limited subset of data, namely an array, I was just needing a prompt in how to compare a scalar item to the previous item on the stack. The fence post error served as a necessary reminder to debug, as mentioned by the previous comments.

    So my code was
    @line = split /\r/m, $file; for my $line (@line) { my $header = ((split(/\t/, $line))[0]); ##stuck here as I was unsure how to compare $header to previously seen + header }
    So, thanks for your response too. It showed me another way to resolve the issue. Much appreciated.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025228]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2017-01-17 02:19 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (151 votes). Check out past polls.