Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Editing Listed Data

by kcott (Chancellor)
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1025228]
help
Chatterbox?
[erix]: who can explain to me why Primary Key Fragmentation (whatever it may be) might be a problem?
[jedikaiti]: Pretty!
[erix]: ( TBH, I think it's a load of bull -- but maybe I'm mistaken )
[erix]: Hey that's Hungary - wave down ambrus and tell him to reboot his systems!
[choroba]: it might be a problem if you expect to reach the maximal possible value soon without squashing the ids
[erix]: that's really impossible with bigint
[erix]: and the site is still only 'hopefully' active :)

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2017-06-23 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (550 votes). Check out past polls.