FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 01-04-2011, 09:40 AM
Joao Ferreira gmail
 
Default a perl question

On Tue, 2011-01-04 at 02:27 -0800, S Mathias 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!


jmf@squeeje:~$ 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

jmf@squeeje:~$
jmf@squeeje:~$
jmf@squeeje:~$
jmf@squeeje:~$
jmf@squeeje:~$ cat asdf.txt | perl -e 'my $important =0; while (<>) {if
(/[XYZ]/) {$important = 1;next;}; if (/[/XYZ]/){$important=0;next};
if ($important) {print;}};'
importantthing
another important thing
yet another thing
hello!
jmf@squeeje:~$


>
>
> how can i sovle this question? what is SOMEPERLMAGIC? are there any perl gurus, that have a little spare time?


not a guru... I just love it... perl rules

joao


>
> Thank you! :
>
>
>
>
>



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 1294137620.2467.9.camel@squeeje.critical.pt">http://lists.debian.org/1294137620.2467.9.camel@squeeje.critical.pt
 
Old 01-04-2011, 09:58 AM
Colin Law
 
Default a perl question

On 4 January 2011 10:28, S Mathias <smathias1972@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?

Try
which SOMEPERLMAGIC

Colin

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 01-04-2011, 10:02 AM
"Larry Brower"
 
Default a perl question

You haven't asked a question. Also, this is not a perl mailing list. You keep sending messages asking how to do things instead of doing your own research. We are not Google, but I hear if you actually use Google and do things for yourself once and a while you will magicaly get answers.



Connected by MOTOBLURâ„¢ on T-Mobile

-----Original message-----
From: S Mathias <smathias1972@yahoo.com>
To: users@lists.fedoraproject.org
Sent: Tue, Jan 4, 2011 04:27:35 CST
Subject: a perl question

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?

Thank you! :



--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 01-04-2011, 10:05 AM
Karl Auer
 
Default a perl question

On Tue, 2011-01-04 at 02:28 -0800, S Mathias wrote:

> $ SOMEPERLMAGIC asdf.txt > output.txt
> how can i sovle this question? what is SOMEPERLMAGIC? are there any perl gurus, that have a little spare time?

It's not clear from your "sample data" what it is you are trying to do.
What distinguishes the lines you want to keep from the lines you want to
discard?

Regards, K.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer@biplane.com.au) +61-2-64957160 (h)
http://www.biplane.com.au/kauer/ +61-428-957160 (mob)

GPG fingerprint: DA41 51B1 1481 16E1 F7E2 B2E9 3007 14ED 5736 F687
Old fingerprint: B386 7819 B227 2961 8301 C5A9 2EBC 754B CD97 0156
--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 01-04-2011, 10:05 AM
Joachim Backes
 
Default a perl question

On 01/04/2011 11:27 AM, S Mathias 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?
>
> Thank you! :
>
>
>

Hi,

suppose the input data are saved in the file x.
Then this little command line could help:

perl -e 'while (<>) {/thing|hello/ && print}'<x

resp. create an executable file thing.pl with 2 lines

#!/usr/bin/perl
while (<>) {/thing|hello/ && print}

and call

thing.pl <x
or
cat x|./thing.pl

This is you needed?

Kind regards


--
Joachim Backes <joachim.backes@rhrk.uni-kl.de>

http://www.rhrk.uni-kl.de/~backes

--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 
Old 01-04-2011, 10:13 AM
Joao Ferreira gmail
 
Default a perl question

On Tue, 2011-01-04 at 22:05 +1100, Karl Auer wrote:
> > $ SOMEPERLMAGIC asdf.txt > output.txt
> > how can i sovle this question? what is SOMEPERLMAGIC? are there any
> perl gurus, that have a little spare time?
>
> It's not clear from your "sample data" what it is you are trying to
> do.
> What distinguishes the lines you want to keep from the lines you want
> to
> discard?

from [XYZ] line to [/XYZ] line ... I guess !

solution:

jmf@squeeje:~$ 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

jmf@squeeje:~$
jmf@squeeje:~$
jmf@squeeje:~$
jmf@squeeje:~$
jmf@squeeje:~$ cat asdf.txt | perl -e 'my $important =0; while (<>) {if
(/[XYZ]/) {$important = 1;next;}; if (/[/XYZ]/){$important=0;next};
if ($important) {print;}};'
importantthing
another important thing
yet another thing
hello!
jmf@squeeje:~$




--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 01-04-2011, 10:21 AM
Colin Law
 
Default a perl question

On 4 January 2011 10:58, Colin Law <clanlaw@googlemail.com> wrote:
> On 4 January 2011 10:28, S Mathias <smathias1972@yahoo.com> wrote:
>> [...]
>> how can i sovle this question? what is SOMEPERLMAGIC? are there any perl gurus, that have a little spare time?
>
> Try
> which SOMEPERLMAGIC

Methinks I misunderstood the question. Stupid boy (me).

Colin

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 01-04-2011, 10:30 AM
Javier Barroso
 
Default a perl question

On Tue, Jan 4, 2011 at 11:40 AM, Joao Ferreira gmail
<joao.miguel.c.ferreira@gmail.com> wrote:
> On Tue, 2011-01-04 at 02:27 -0800, S Mathias 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!
>
>
> jmf@squeeje:~$ 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
>
> jmf@squeeje:~$
> jmf@squeeje:~$
> jmf@squeeje:~$
> jmf@squeeje:~$
> jmf@squeeje:~$ cat asdf.txt *| perl -e 'my $important =0; while (<>) {if
> (/[XYZ]/) {$important = 1;next;}; if (/[/XYZ]/){$important=0;next};
> if ($important) {print;}};'
> importantthing
> another important thing
> yet another thing
> hello!

Or use ".." range operator:
perl -ne 'print if (/[XYZ]/../[/XYZ]/ and not /[/?XYZ]/)'

PD: Should I add "OT: " to subject , or is it not ok doing that when
thread is started??


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: AANLkTikFyL3-JhVchVR56Arbh+6QeJXsSF3y4TpMGmxu@mail.gmail.com">h ttp://lists.debian.org/AANLkTikFyL3-JhVchVR56Arbh+6QeJXsSF3y4TpMGmxu@mail.gmail.com
 
Old 01-04-2011, 10:55 AM
Chris Davies
 
Default a perl question

S Mathias <smathias1972@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?


What are your criteria? Matching "important" or "hello" somewhere in the
text? Something else? It's really not clear by your example what is to
be captured.

For example, if it's "important" or "hello" then personally I'd use
egrep and avoid the complexity of perl entirely:

$ egrep 'important|hello' asdf.txt
importantthing
another important thing
yet another thing
hello!

$ perl -ne '/important|hello/ && print' asdf.txt
importantthing
another important thing
yet another thing
hello!

Chris


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: dfebv7xbgl.ln2@news.roaima.co.uk">http://lists.debian.org/dfebv7xbgl.ln2@news.roaima.co.uk
 
Old 01-04-2011, 11:12 AM
Michael Schwendt
 
Default a perl question

On Tue, 04 Jan 2011 12:05:29 +0100, Joachim wrote:

> On 01/04/2011 11:27 AM, S Mathias 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?
> >
> > Thank you! :
> >
> >
> >
>
> Hi,
>
> suppose the input data are saved in the file x.
> Then this little command line could help:
>
> perl -e 'while (<>) {/thing|hello/ && print}'<x
>
> resp. create an executable file thing.pl with 2 lines
>
> #!/usr/bin/perl
> while (<>) {/thing|hello/ && print}
>
> and call
>
> thing.pl <x
> or
> cat x|./thing.pl
>
> This is you needed?

Very likely not. As I understand it, he wants a Perl script to filter
out arbitrary text between the opening and closing tags [XYZ] … [/XYZ].
It doesn't need a Perl "guru" to program something like that, but it's
a little bit of an exercize for somebody who wants to start programming
in Perl.
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
 

Thread Tools




All times are GMT. The time now is 10:35 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org