Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > Perl

Perl Discussion for the PERL language - Practical Extraction and Reporting Language, is a programming language often used for creating CGI programs.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-20-2007, 10:59 AM
policy policy is offline
Newbie
 
Join Date: Jul 2006
Posts: 4
Rep Power: 0
policy is on a distinguished road
Default Splitting Error

I'm using this code to split:

Perl Code:
  1. # Split the lines by *
  2. @code = split(/*/, $my_lines);

but I get this error:

"Quantifier follows nothing in regex; marked by <-- HERE in m/* <-- HERE / at c:\projects\line_split.pl line 31"

Any ideas how to fix this or why this error is generated? I can split with:

Perl Code:
  1. # Split the lines by *
  2. @code = split(/'/, $my_lines);

and everything works fine.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 09-20-2007, 05:14 PM
KevinADC KevinADC is offline
Learning Programmer
 
Join Date: Jan 2007
Posts: 91
Rep Power: 7
KevinADC is on a distinguished road
Default

'*' is a quantifier, it means: zero or more when used in a regular expression, which is what split(//) is. If you want to split on a literal * you have to escape it:

@code = split(/\*/, $my_lines);

or use single-quotes:

@code = split('*', $my_lines);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-21-2007, 01:13 PM
policy policy is offline
Newbie
 
Join Date: Jul 2006
Posts: 4
Rep Power: 0
policy is on a distinguished road
Default

That works! Thanks

I didn't think about it being a quantifier.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Php error handling Jaan PHP Tutorials 3 09-07-2008 01:19 PM
need urgent help finding parce error!!! siren C and C++ 3 09-13-2007 10:45 AM
Download problem, internal Server Error j3cubcapt ionFiles 1 07-02-2007 10:45 AM
Php - CGI Error thesquirrel16 General Programming 1 05-19-2007 06:09 PM
can someone help me with my c librarys? bobwrit C and C++ 4 04-27-2007 07:19 PM


All times are GMT -5. The time now is 03:51 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 98%

Ads