in reply to Re: Regex - counting number of '|'
in thread Regex - counting number of '|'
I have to use the split command on the same file to split each input record on its delimiters and and assign it to an array. I am trying to use eval here also (as specified above), but, it is throwing an error. One of the error msg is
"Bareword "per" not allowed while "strict subs" in use at (eval 2) line 1."
Thanks for your help!!!#!/usr/bin/perl use Fcntl; use strict; print "starting script..."; my $inp_row = "per|l|mo|nks|rock|s"; my $de = '|'; my @cl_data_row; my $count = (eval "\$inp_row =~ tr/$de//"); die $@ if $@; print "count is $count\n"; chop($inp_row); #@cl_data_row=split(/\|/,$inp_row); @cl_data_row=(eval"\split(/\$de/,$inp_row)"); for (my $x=0;$x<$count;$x++) { print "row element is $cl_data_row[$x]\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Regex - counting number of '|'
by ww (Archbishop) on Mar 18, 2008 at 00:57 UTC | |
|
Re^3: Regex - counting number of '|'
by ikegami (Patriarch) on Mar 18, 2008 at 03:10 UTC | |
|
Re^3: Regex - counting number of '|'
by ikegami (Patriarch) on Mar 18, 2008 at 03:13 UTC | |
|
Re^3: Regex - counting number of '|'
by poolpi (Hermit) on Mar 18, 2008 at 09:23 UTC |