I'm about to parse the output of xlsclients -la. It's like this:
Window 0x800022: Machine: genus Name: xterm Icon Name: xterm Command: xterm -u8 -geometry 156x62+190+-2 Instance/Class: xterm/XTerm Window 0xc00022: Machine: genus Name: ~ Icon Name: psh Command: xterm -e /usr/bin/psh Instance/Class: xterm/XTerm Window 0xe00001: Machine: genus Name: Gecko Icon Name: mozilla-bin Command: mozilla-bin Instance/Class: mozilla-bin/Mozilla-bin
There's no blank link between "paragraphs" so I can't use $/ = "\n\n". I want to do something simple that gives me whole paragraphs without eating anything (so $/ = "\nWindow" wouldn't fit). I'm thinking about reading six lines at a time but I find it ugly:
open my $fd, 'xlsclients -la|' or die "open: $!"; WHILE: while (1) { my @para; foreach (1..6) { my $line = <$fd>; defined $line or last WHILE; push @para, $line; } print "@para\n"; ## quotes intended in this small example } close $fd;
Is there anything more I can do?
--
David Serrano
In reply to Reading chunks of text by Hue-Bond
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |