hai Shlomi

Thank you for your long reply...

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

A. This is the complete code i am using..

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

A. I have added warnings but not strict..

3. Why are you splitting on strings instead of on regexes? << split(/##/,
$variable);

A. Regex i am not very sure about it, so i thought of splitting the string
as PAD told that ## is the seperator..

4. Maybe I don't understand you but arrays in Perl start at 0 - not at 1.

A. I know that arrays start from the 0 and not 1, here zero value in the
array is not required, so i am getting the value of the 1..Hope u check the
code again by running it.

5. You have two many variable names starting with "v" and they all very much
alike. Please give more meaningful names. I wonder how you can follow it.

A. Yes i have too many variables alike.. Thank you for letting me know..
Actually i did it in an hurry, to check, next time ill follow this.

6. Why not use a date-parsing module such as the ones in:

* http://perl-begin.org/topics/date-and-time/

A. I'll check this out..Thank you..

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

A. here i am searching the strring in the array, the grep finds out the no
of occurrences of a particular string in an array..

Hope u got all ur replies..

Regards
Chaitanya


On Wed, Jun 30, 2010 at 4:44 PM, Shlomi Fish <shlo...@iglu.org.il> 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? << split(/##/,
> $variable); >>
>
> > print "First=>".$vale[1]."\n";
> > print "Second=>".$vale[2]."\n";
> >
>
> Maybe I don't understand you but arrays in Perl start at 0 - not at 1.
>
> >
> > $var =$vale[1];
>
> You have two many variable names starting with "v" and they all very much
> alike. Please give more meaningful names. I wonder how you can follow it.
>
> > my @values = split(' ', $var);
> > #print "1 values=>". $values[0]."\n";
> > if($values[1] eq "Oct"){
> > $j=10;
> > }
>
> Why not use a date-parsing module such as the ones in:
>
> * http://perl-begin.org/topics/date-and-time/
>
> > $search = $values[4]."-".$j."-".$values[2]."
> > ".$values[3].".000000000-".$vv[3];
>
> This is better done using interpolation. Also add my there (see "use
> strict;").
>
> > print "Related Item =>".$values[4]."-".$j."-".$values[2]."
> > ".$values[3].".000000000-".$vv[3]."\n";
>
> Again, use interpolating here instead of excessive ".".
>
> >
> > $found = grep /$search/,@vale;
>
> 1. Maybe you want grep /\Q$search\E/ here.
>
> 2. grep returns a list. Either you want List::MoreUtils::any or you want
> $found to be an array.
>
> > print "Found value=> ".$found."\n";
> > if($found eq '1')
> > {
> > print "Value is there in line\n";
> > }
> > else{
> > print "Value is not there in line\n";
> > }
> >
>
> Regards,
>
>        Shlomi Fish
>
> --
> -----------------------------------------------------------------
> Shlomi Fish       http://www.shlomifish.org/
> My Aphorisms - http://www.shlomifish.org/humour.html
>
> God considered inflicting XSLT as the tenth plague of Egypt, but then
> decided against it because he thought it would be too evil.
>
> Please reply to list if it's a mailing list post - http://shlom.in/reply .
>

Reply via email to