Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Pattern match and splitting of that

by Nansh (Acolyte)
on Jun 22, 2017 at 13:29 UTC ( [id://1193292]=perlquestion: print w/replies, xml ) Need Help??

Nansh has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Pattern match and splitting of that
by toolic (Bishop) on Jun 22, 2017 at 13:39 UTC
    split is an appropriate tool for this job:
    use strict; use warnings; use Data::Dumper; my $string = "RABBIT 45 -126.06686"; my @parts = split /\s+/, $string; print Dumper(\@parts); __END__ $VAR1 = [ 'RABBIT', '45', '-126.06686' ];

    Also, the code you posted has a compile error.

Re: Pattern match and splitting of that
by Corion (Patriarch) on Jun 22, 2017 at 13:40 UTC

    Which part of your code should extract -126.06686 from your string?

    Also read perlretut and perlre.

Re: Pattern match and splitting of that
by Eily (Monsignor) on Jun 22, 2017 at 13:34 UTC

    Once again, your questions belong in the Seekers of Perl Wisdom section, not PerlMonks Discussion. So you should be posting here.

    Edit: BTW, your code doesn't even compile, so either you did not actually try, or you are not showing us your real test.

Re: Pattern match and splitting of that
by tybalt89 (Monsignor) on Jun 23, 2017 at 01:13 UTC
    #!/usr/bin/perl # http://perlmonks.org/?node_id=1193292 use strict; use warnings; while(<DATA>) { my $n = 1; s/(?<!\S)(?=\S)/ $n++ . ')' /ge; print; } __DATA__ RABBIT 45 -126.06686
Re: Pattern match and splitting of that
by marto (Cardinal) on Jun 22, 2017 at 13:35 UTC

    "Read Where should I post X? if you're not absolutely sure you're posting in the right place."

    This is displayed every time you post, you keep ignoring this and requests to post in the appropriate section of the site.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1193292]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-05-27 22:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found