a perl question
Dave Cross
davorg at gmail.com
Tue Jan 4 12:33:36 UTC 2011
On 4 January 2011 10:27, S Mathias <smathias1972 at yahoo.com> wrote:
> cat asdf.txt
> bla-bla
> bla-bla
> bla[XYZ]
> importantthing
> another important thing
> [/XYZ]
> bla-bla
> bla-bla
> [XYZ]
> yet another thing
> hello!
> [/XYZ]
> bla-bla
> etc.
> $ SOMEPERLMAGIC asdf.txt > output.txt
> $ cat output.txt
> importantthing
> another important thing
> yet another thing
> hello!
>
>
> how can i sovle this question? what is SOMEPERLMAGIC? are there any perl gurus, that have a little spare time?
It looks like you need something a bit like this.
#!/usr/bin/perl
use strict;
use warnings;
while (<>) {
if (m|\[XYZ]| .. m|\[/XYZ]|) {
next if m|\[/?XYZ]|;
print;
}
}
But I can't be sure as you haven't actually explained what you question is.
For Perl questions, you might be better advised to try Stack Overflow
or your local Perl Mongers group.
Dave...
--
Dave Cross :: dave at dave.org.uk
http://dave.org.uk/
@davorg
More information about the users
mailing list