split is splitting the scalar into characters!
ok..here is the dilemma. I have a text file, that is deliminated by |'s... I have used the simple code:
@named = split(/|/, $name);
Why is it spliting the scalar at every character? I want it to split at every occurance |. I don't know what else to do..I can easily change the | to a semicolon or something..but it is less likely that someone will put that symbol in my script.
I am going to try and escape that symbol...because I know it is a special character.
If that works I will let you know.
VulKen
If I were moderator...
Pimpin like a pimp with an electrofied pimpin machine!
Orpheus posted this at 20:55 — 6th September 2000.
They have: 568 posts
Joined: Nov 1999
@named = split(/\|/, $name);
Mark Hensler posted this at 05:47 — 7th September 2000.
He has: 4,048 posts
Joined: Aug 2000
what does | mean by itself?
I thought you only needed to escape it in a string when you use it at as the delimiter... Cómo este:
$This =~ m|somehing \| something more|g;
Mark Hensler
If there is no answer on Google, then there is no question.
Ken Elliott posted this at 12:37 — 7th September 2000.
They have: 358 posts
Joined: Jun 1999
It means "or". I found out that this code:
@named = split(/|/, $name);
was actually looking for NOTHING or NOTHING..hehe.
So I escaped the "or" and it worked fine.
Pimpin like a pimp with an electrofied pimpin machine!
Mark Hensler posted this at 21:09 — 7th September 2000.
He has: 4,048 posts
Joined: Aug 2000
I thought that || was 'or'...
Or does that not aply for regex?
Orpheus posted this at 21:27 — 7th September 2000.
They have: 568 posts
Joined: Nov 1999
|| is for things like if, and elsif
| in regex means or
hope that cleared it up for you
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.