Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Text::ParseWords and pipe delimiter

by LanceDeeply (Chaplain)
on Jul 29, 2002 at 17:38 UTC ( [id://186028]=perlquestion: print w/replies, xml ) Need Help??

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

guys:

i'm having trouble using a pipe delimiter in parse_line.
can anyone help out?
thanks

use strict; use warnings; use Text::ParseWords; s1 ("just|another|perl|hacker"); s2 ("just|another|perl|hacker"); sub s1 { my $text = shift; my @words = split /\|/, $text; foreach my $word ( @words ) { print "[$word]"; } print "\n"; } sub s2 { my $text = shift; my @words = parse_line("|", 0, $text); foreach my $word ( @words ) { print "[$word]"; } print "\n"; }

Replies are listed 'Best First'.
(jeffa) Re: Text::ParseWords and pipe delimiter
by jeffa (Bishop) on Jul 29, 2002 at 17:46 UTC
    You need to do two things: escape the pipe and use single quotes:
    my @words = parse_line('\|', 0, $text);

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
      thanks alot!
      you would laugh if you saw all the stuff i was trying to push into that function

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-03-28 17:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found