Shlomi Fish wrote:
On Wednesday 30 Jun 2010 13:52:19 Chaitanya Yanamadala wrote:
try this..

now to get the $variable,
read each line of the file by just opening it..
in this one only thing u need to do is value of $j....


Let me comment on your code.

1. Please show us all your code, not just part of it.

2. Add "use strict;" and "use warnings;" to the beginning and fix all the
problems it reports..

$variable = "name1##Thu Oct 18 14:33:23 2007    ##2007-10-18
14:33:23.000000000-0400";
my @vv = split('-',$variable);
my @vale = split('##',$variable);

Why are you splitting on strings instead of on regexes?

The first argument to split() *is* a regex. Any expression will be converted to a regex, even strings.

<<  split(/##/, $variable);>>

Or perhaps:

split(m'##',$variable);


$found = grep /$search/,@vale;

1. Maybe you want grep /\Q$search\E/ here.

2. grep returns a list.

And in scalar context grep returns the number of matches.




John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to