Re: split an html file

2014-04-21 Thread Uday Vernekar
Awesome..Lesley



On Mon, Apr 21, 2014 at 4:00 PM, lesleyb  wrote:

> On Thu, Apr 17, 2014 at 10:01:35AM -0700, Mike McClain wrote:
> > Hi,
> > My brother Rick, a windrider, put together a webpage,
> > http://www.photographers1.com/Sailing/NauticalTerms&Nomenclature.html
> > about sailing and wind surfing that has grown too large and should be
> > split into smaller sections to reduce load time.
> > Can anyone point me to any tools/modules that would automate the
> > process of fixing all the links?
> That's an awesome effort by your brother, Mike.
>
> As far as automating the re-assigment of links: Use something like
> HTML::TokeParser::Simple -
> https://metacpan.org/pod/HTML::TokeParser::Simple
>
> Then you can replace
> http://www.photographers1.com/Sailing/NauticalTerms&Nomenclature.html#Knot
> with something like
> http://www.photographers1.com/Sailing/Encyclopedia/K.html/#Knot
> assuming you have all the entries starting with K split to K.html of
> course.
>
> The anchor tags e.g. Knot  won't need to be changed.
>
> Kind regards
>
> Lesley
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Need to Grep only fail count from the Pattern.

2014-06-23 Thread Uday Vernekar
Hi All,


I have following Pattern from which I need to grep only the Fail count and
store that in a variable.

U/A/S|Test|Test   |Loop  | Run |Pass |Fail|
Arguments
 |  Name |Count|Count|Count|Count |
-++---+-+-+-+-+--+---
 |  72| Traffic Test |  1|  11| 11|
0| (none)

based on fail count value need to print

if 0--Sucess
if >0--Fail


with Regards
Uday V G

-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: Need to Grep only fail count from the Pattern.

2014-06-24 Thread Uday Vernekar
Thanks everybody will work out the Feasible option from all
these..Thanks a lot



On Mon, Jun 23, 2014 at 10:12 PM, Charles DeRykus  wrote:

> On Mon, Jun 23, 2014 at 2:42 AM, Uday Vernekar 
> wrote:
> > Hi All,
> >
> >
> > I have following Pattern from which I need to grep only the Fail count
> and
> > store that in a variable.
> >
> > U/A/S|Test|Test   |Loop  | Run |Pass |Fail|
> > Arguments
> >  |  Name |Count|Count|Count|Count |
> >
> -++---+-+-+-+-+--+---
> >  |  72| Traffic Test |  1|  11| 11|
>   0|
> > (none)
> >
> > based on fail count value need to print
> >
> > if 0--Sucess
> > if >0--Fail
> >
>
> Another way:
>
>while ( ) {
> ...
> my $fail_count - ( split( /\|/, $_  ) )[-2];
>...
>}
>
> See: perldoc -f split
>
> --
> Charles DeRykus
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: Need to Grep only fail count from the Pattern.

2014-06-24 Thread Uday Vernekar
Hi all,

I tried this its working fine when we have this pattern at hand,but the
pattern is in a log file which is very large and i need to grep this
pattern first from the generated log file then Match.how do i do it?

with Regards
Uday V G



On Tue, Jun 24, 2014 at 1:30 PM, Uday Vernekar 
wrote:

> Thanks everybody will work out the Feasible option from all
> these..Thanks a lot
>
>
>
> On Mon, Jun 23, 2014 at 10:12 PM, Charles DeRykus 
> wrote:
>
>> On Mon, Jun 23, 2014 at 2:42 AM, Uday Vernekar 
>> wrote:
>> > Hi All,
>> >
>> >
>> > I have following Pattern from which I need to grep only the Fail count
>> and
>> > store that in a variable.
>> >
>> > U/A/S|Test|Test   |Loop  | Run |Pass |Fail|
>> > Arguments
>> >  |  Name |Count|Count|Count|Count |
>> >
>> -++---+-+-+-+-+--+---
>> >  |  72| Traffic Test |  1|  11| 11|
>>   0|
>> > (none)
>> >
>> > based on fail count value need to print
>> >
>> > if 0--Sucess
>> > if >0--Fail
>> >
>>
>> Another way:
>>
>>while ( ) {
>> ...
>> my $fail_count - ( split( /\|/, $_  ) )[-2];
>>...
>>}
>>
>> See: perldoc -f split
>>
>> --
>> Charles DeRykus
>>
>> --
>> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
>> For additional commands, e-mail: beginners-h...@perl.org
>> http://learn.perl.org/
>>
>>
>>
>
>
> --
> *
> Don't ask them WHY they hurt you,
> because all they'll tell you is lies and excuses.
>  Just know they were wrong, and try to move on.
> **
>



-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: Need to Grep only fail count from the Pattern.

2014-06-24 Thread Uday Vernekar
Dear All,

Please correct Me If i am wrong:Here's the code which I wrote

[code]
#!/usr/bin/perl

use 5.10.0;
use strict;
use warnings;

my $var=`grep -nr "|  72| Traffic Test  |1|  561|  561|
1| (none)"  /tmp/EO-PCPE-23-10GT`;

# extract the "failed" field i.e., 6th field
my $failed = (split /\|/, $var)[6];

# strip leading spaces
$failed =~ s/^\s+//;
printf "$failed";


if ($failed) {
say 'Failed';
}
else {
say 'Sucsess';
}

[code]

Regards Uday V G



On Tue, Jun 24, 2014 at 4:25 PM, Charles DeRykus  wrote:

> On Tue, Jun 24, 2014 at 3:15 AM, Uday Vernekar 
> wrote:
> > Hi all,
> >
> > I tried this its working fine when we have this pattern at hand,but the
> > pattern is in a log file which is very large and i need to grep this
> pattern
> > first from the generated log file then Match.how do i do it?
> >
>
> Once $pattern grepped out from log, then:
>
> $fail_count = ( (split(/\Q$pattern/, $_) )[-2];
>
> or maybe:
>
> my $re = qr/\Q$pattern/;
> $fail_count = ( split( /$re/, $_) )[-2];
>
>For explanation of "qr", see: Regexp Quote-Like Operators in perlop.
>
> > On Tue, Jun 24, 2014 at 1:30 PM, Uday Vernekar 
> > wrote:
> >>
> >> Thanks everybody will work out the Feasible option from all
> >> these..Thanks a lot
> >>
> >>
> >>
> >> On Mon, Jun 23, 2014 at 10:12 PM, Charles DeRykus 
> >> wrote:
> >>>
> >>> On Mon, Jun 23, 2014 at 2:42 AM, Uday Vernekar  >
> >>> wrote:
> >>> > Hi All,
> >>> >
> >>> >
> >>> > I have following Pattern from which I need to grep only the Fail
> count
> >>> > and
> >>> > store that in a variable.
> >>> >
> >>> > U/A/S|Test|Test   |Loop  | Run |Pass |Fail|
> >>> > Arguments
> >>> >  |  Name |Count|Count|Count|Count |
> >>> >
> >>> >
> -++---+-+-+-+-+--+---
> >>> >  |  72| Traffic Test |  1|  11| 11|
> >>> > 0|
> >>> > (none)
> >>> >
> >>> > based on fail count value need to print
> >>> >
> >>> > if 0--Sucess
> >>> > if >0--Fail
> >>> >
> >>>
> >>> Another way:
> >>>
> >>>while ( ) {
> >>> ...
> >>> my $fail_count - ( split( /\|/, $_  ) )[-2];
> >>>...
> >>>}
> >>>
> >>> See: perldoc -f split
> >>>
> >>> --
> >>> Charles DeRykus
> >>>
> >>> --
> >>> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> >>> For additional commands, e-mail: beginners-h...@perl.org
> >>> http://learn.perl.org/
> >>>
> >>>
> >>
> >>
> >>
> >> --
> >> *
> >> Don't ask them WHY they hurt you,
> >> because all they'll tell you is lies and excuses.
> >>  Just know they were wrong, and try to move on.
> >> **
> >
> >
> >
> >
> > --
> > *
> > Don't ask them WHY they hurt you,
> > because all they'll tell you is lies and excuses.
> >  Just know they were wrong, and try to move on.
> > **
>



-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: Need to Grep only fail count from the Pattern.

2014-06-24 Thread Uday Vernekar
Dear All,

Slight Correction Made in Above Code.
I am grepping this Pattern depending on run count which will Always same
Pass count and Fail count will Vary.
|  72| Traffic Test  |1|  561|

[Code]
#!/usr/bin/perl

use 5.10.0;
use strict;
use warnings;

my $var=`grep -nr "|  72| Traffic Test  |1|  561|"
/tmp/EO-PCPE-23-10GT`;
print "$var";
my $failed = (split /\|/, $var)[6];

print "failed=$failed\n";

$failed =~ s/^\s+//;

print "failed=$failed\n";


if ($failed) {
say 'Failed';
}
else {
say 'Sucsess';
}

[code]




output: for Fail condition

43629: |  72| Traffic Test  |1|  561|  560|1| (none)
failed=1
failed=1
Failed


output:for pass condition

43629: |  72| Traffic Test  |1|  561|  561|0| (none)
failed=0
failed=0
Sucsess


Please suggest..

with Regards
Uday V G




On Tue, Jun 24, 2014 at 5:31 PM, Uday Vernekar 
wrote:

> Dear All,
>
> Please correct Me If i am wrong:Here's the code which I wrote
>
> [code]
> #!/usr/bin/perl
>
> use 5.10.0;
> use strict;
> use warnings;
>
> my $var=`grep -nr "|  72| Traffic Test  |1|  561|  561|
> 1| (none)"  /tmp/EO-PCPE-23-10GT`;
>
>
> # extract the "failed" field i.e., 6th field
> my $failed = (split /\|/, $var)[6];
>
>
> # strip leading spaces
> $failed =~ s/^\s+//;
> printf "$failed";
>
>
>
> if ($failed) {
> say 'Failed';
> }
> else {
> say 'Sucsess';
> }
>
> [code]
>
> Regards Uday V G
>
>
>
> On Tue, Jun 24, 2014 at 4:25 PM, Charles DeRykus 
> wrote:
>
>> On Tue, Jun 24, 2014 at 3:15 AM, Uday Vernekar 
>> wrote:
>> > Hi all,
>> >
>> > I tried this its working fine when we have this pattern at hand,but the
>> > pattern is in a log file which is very large and i need to grep this
>> pattern
>> > first from the generated log file then Match.how do i do it?
>> >
>>
>> Once $pattern grepped out from log, then:
>>
>> $fail_count = ( (split(/\Q$pattern/, $_) )[-2];
>>
>> or maybe:
>>
>> my $re = qr/\Q$pattern/;
>> $fail_count = ( split( /$re/, $_) )[-2];
>>
>>For explanation of "qr", see: Regexp Quote-Like Operators in
>> perlop.
>>
>> > On Tue, Jun 24, 2014 at 1:30 PM, Uday Vernekar 
>> > wrote:
>> >>
>> >> Thanks everybody will work out the Feasible option from all
>> >> these..Thanks a lot
>> >>
>> >>
>> >>
>> >> On Mon, Jun 23, 2014 at 10:12 PM, Charles DeRykus 
>> >> wrote:
>> >>>
>> >>> On Mon, Jun 23, 2014 at 2:42 AM, Uday Vernekar <
>> vernekaru...@gmail.com>
>> >>> wrote:
>> >>> > Hi All,
>> >>> >
>> >>> >
>> >>> > I have following Pattern from which I need to grep only the Fail
>> count
>> >>> > and
>> >>> > store that in a variable.
>> >>> >
>> >>> > U/A/S|Test|Test   |Loop  | Run |Pass |Fail|
>> >>> > Arguments
>> >>> >  |  Name |Count|Count|Count|Count |
>> >>> >
>> >>> >
>> -++---+-+-+-+-+--+---
>> >>> >  |  72| Traffic Test |  1|  11| 11|
>> >>> > 0|
>> >>> > (none)
>> >>> >
>> >>> > based on fail count value need to print
>> >>> >
>> >>> > if 0--Sucess
>> >>> > if >0--Fail
>> >>> >
>> >>>
>> >>> Another way:
>> >>>
>> >>>while ( ) {
>> >>> ...
>> >>> my $fail_count - ( split( /\|/, $_  ) )[-2];
>> >>>...
>> >>>}
>> >>>
>> >>> See: perldoc -f split
>> >>>
>> >>> --
>> >>> Charles DeRykus
>> >>>
>> >>> --
>> >>> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
>> >>> For additional commands, e-mail: beginners-h...@perl.org
>> >>> http://learn.perl.org/
>> >>>
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> *
>> >> Don't ask them WHY they hurt you,
>> >> because all they'll tell you is lies and excuses.
>> >>  Just know they were wrong, and try to move on.
>> >> **
>> >
>> >
>> >
>> >
>> > --
>> > *
>> > Don't ask them WHY they hurt you,
>> > because all they'll tell you is lies and excuses.
>> >  Just know they were wrong, and try to move on.
>> > **
>>
>
>
>
> --
> *
> Don't ask them WHY they hurt you,
> because all they'll tell you is lies and excuses.
>  Just know they were wrong, and try to move on.
> **
>



-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: Need to Grep only fail count from the Pattern.

2014-06-25 Thread Uday Vernekar
Dear Ron,

How wud i grep the string  |  72| Traffic Test  |1|  561|
from log file which is Very large.

with Regards
Uday V G


On Tue, Jun 24, 2014 at 8:56 PM, Ron Bergin  wrote:

> Uday Vernekar wrote:
> > Dear All,
> >
> > Slight Correction Made in Above Code.
> > I am grepping this Pattern depending on run count which will Always same
> > Pass count and Fail count will Vary.
> > |  72| Traffic Test  |1|  561|
> >
> > [Code]
> > #!/usr/bin/perl
> >
> > use 5.10.0;
> > use strict;
> > use warnings;
> >
> > my $var=`grep -nr "|  72| Traffic Test  |1|  561|"
> > /tmp/EO-PCPE-23-10GT`;
> > print "$var";
> > my $failed = (split /\|/, $var)[6];
> >
> > print "failed=$failed\n";
> >
> > $failed =~ s/^\s+//;
> >
> > print "failed=$failed\n";
> >
> >
> > if ($failed) {
> > say 'Failed';
> > }
> > else {
> > say 'Sucsess';
> > }
> >
> > [code]
> >
> >
> >
> >
> > output: for Fail condition
> >
> > 43629: |  72| Traffic Test  |1|  561|  560|1|
> > (none)
> > failed=1
> > failed=1
> > Failed
> >
> >
> > output:for pass condition
> >
> > 43629: |  72| Traffic Test  |1|  561|  561|0|
> > (none)
> > failed=0
> > failed=0
> > Sucsess
> >
> >
> > Please suggest..
> >
> > with Regards
> > Uday V G
> >
> Why shell out to the grep command when Perl is perfectly capable of doing
> the same?
>
> Here's an example that uses split and tests the relevant fields.  This
> could also be accomplished with a regex, but I think the split approach is
> cleaner.
>
> [code]
> #!/usr/bin/perl
>
> use 5.10.0;
> use strict;
> use warnings;
>
> # throw away the first 3 lines
>  for 1..3;
>
> while (my $line = ) {
> my ($test, $run, $failed) = (split /\|/, $line)[1,4,6];
> next unless ($test == 72 and $run == 561);
>
> print "Line $.:$line";
> $failed =~ s/^\s+//;
> say "failed=$failed";
> say $failed ? 'Failed' : 'Success';
> }
>
>
>
> __DATA__
> U/A/S|Test|Test   |Loop  | Run |Pass |Fail|
> Arguments
>  |  Name |Count|Count|Count|Count |
>
> -++---+-+-+-+-+--+---
>  |  72| Traffic Test |  1|  11| 11|
> 0| (none)
>  |  72| Traffic Test |  1|  561| 11|
> 1| (none)
> [/code]
>
> If you need to process multiple files in a directory tree as the -r option
> in your grep command implies, then make use of the File::Find module.
>
> http://search.cpan.org/~rjbs/perl-5.20.0/ext/File-Find/lib/File/Find.pm
>
>


-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: Need to Grep only fail count from the Pattern.

2014-06-25 Thread Uday Vernekar
I got it thanks jim :)


On Wed, Jun 25, 2014 at 7:12 PM, Jim Gibson  wrote:

>
> On Jun 25, 2014, at 12:11 AM, Uday Vernekar 
> wrote:
>
> > Dear Ron,
>
> You are better off addressing your questions to the entire mailing list,
> rather than asking information from one person. Ron is not obligated to
> help you and may not be available, but others may be willing to help you.
>
> > How wud i grep the string  |  72| Traffic Test  |1|
>  561| from log file which is Very large.
>
> You would:
>
> 1. open the file for reading
> 2. read each line in the file
> 3. check each line for your desired pattern
>
> That is what grep does. By doing this in Perl, you save having to create
> another process. You can combine the step of finding the pattern and
> extracting information from the desired line. You can also quit after you
> have found the line you are seeking, if you only need to find one match;
> grep will continue to read the rest of the file looking for more matches.
>
> Let us know if you have problems with any of these steps.
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: Need to Grep only fail count from the Pattern.

2014-06-26 Thread Uday Vernekar
Please suggest if any Corrections Needed.

[code]
#!/usr/bin/perl

use 5.10.0;
use strict;
use warnings;
#Pattern
#U/A/S|Test|Test   |Loop | Run |Pass |Fail |  Arguments
# | #  |Name   |Count|Count|Count|Count|
#-++---+-+-+-+-+---
# |  72| Traffic Test  |1|  561|  560|1| (none)


my $pattern;
open (my $Log_file, '<', '/tmp/EO-PCPE-23-10GT') || die "Couldn't open
/tmp/EO-PCPE-23-10GT\n\t $!";
while(<$Log_file>)
{

if($_ =~
m/^(.+?)\|(.+72)\|(.+?)\|(.+?)\|(.+[0-9]|[0-9]|[0-9])\|(.+[0-9]|[0-9]|[0-9])\|(.+?)\|(.+?)$/)
{
 $pattern=$_;


}

}
print "Pattern Found:\n$pattern";
my $uas=(split /\|/, $pattern)[0];
$uas =~ s/^\s+//;
my $test=(split /\|/, $pattern)[1];
$test =~ s/^\s+//;
my $test_name=(split /\|/, $pattern)[2];
$test_name =~ s/^\s+//;
my $loop_count=(split /\|/, $pattern)[3];
$loop_count =~ s/^\s+//;
my $run_count=(split /\|/, $pattern)[4];
$run_count =~ s/^\s+//;
my $pass_count=(split /\|/, $pattern)[5];
$pass_count =~ s/^\s+//;
my $fail_count=(split /\|/, $pattern)[6];
$fail_count =~ s/^\s+//;
my $arguments=(split /\|/, $pattern)[7];
$arguments =~ s/^\s+//;


print '-' x 30, "\n";
print "  Test Data   \n";
print '-' x 30, "\n";
print "UAS : $uas\n";
print "Test : $test\n";
print "Test Name : $test_name\n";
print "Loop Count : $loop_count\n";
print "Run Count : $run_count\n";
print "Pass Count : $pass_count\n";
print "Fail Count : $fail_count\n";
print "Arguments : $arguments\n";
print '-' x 30, "\n";
print "  RESULTS   \n";
print '-' x 30, "\n";

if($fail_count != 0 && $run_count >= 0) {
print "Result: Fail\n";
} elsif($fail_count == 0 && $run_count > 0) {
print "Result: Pass\n";
}
[code]


output-1 PASS condition
---
Pattern Found:
 |  72| Traffic Test  |1|  561|  561|0| (none)
--
  Test Data
--
UAS :
Test : 72
Test Name : Traffic Test
Loop Count : 1
Run Count : 561
Pass Count : 561
Fail Count : 0
Arguments : (none)

--
  RESULTS
--
Result: Pass


output-2 FAIL condition
--
Pattern Found:
 |  72| Traffic Test  |1|  561|  560|1| (none)
--
  Test Data
------
UAS :
Test : 72
Test Name : Traffic Test
Loop Count : 1
Run Count : 561
Pass Count : 560
Fail Count : 1
Arguments : (none)

------
  RESULTS
--
Result: Fail












On Thu, Jun 26, 2014 at 11:06 AM, Uday Vernekar 
wrote:

> I got it thanks jim :)
>
>
> On Wed, Jun 25, 2014 at 7:12 PM, Jim Gibson  wrote:
>
>>
>> On Jun 25, 2014, at 12:11 AM, Uday Vernekar 
>> wrote:
>>
>> > Dear Ron,
>>
>> You are better off addressing your questions to the entire mailing list,
>> rather than asking information from one person. Ron is not obligated to
>> help you and may not be available, but others may be willing to help you.
>>
>> > How wud i grep the string  |  72| Traffic Test  |1|
>>  561| from log file which is Very large.
>>
>> You would:
>>
>> 1. open the file for reading
>> 2. read each line in the file
>> 3. check each line for your desired pattern
>>
>> That is what grep does. By doing this in Perl, you save having to create
>> another process. You can combine the step of finding the pattern and
>> extracting information from the desired line. You can also quit after you
>> have found the line you are seeking, if you only need to find one match;
>> grep will continue to read the rest of the file looking for more matches.
>>
>> Let us know if you have problems with any of these steps.
>>
>>
>> --
>> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
>> For additional commands, e-mail: beginners-h...@perl.org
>> http://learn.perl.org/
>>
>>
>>
>
>
> --
> *
> Don't ask them WHY they hurt you,
> because all they'll tell you is lies and excuses.
>  Just know they were wrong, and try to move on.
> **
>



-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: Need to Grep only fail count from the Pattern.

2014-06-27 Thread Uday Vernekar
Thanks to allcheers


On Thu, Jun 26, 2014 at 10:28 PM, Jim Gibson  wrote:

>
> On Jun 26, 2014, at 2:05 AM, Uday Vernekar wrote:
>
> > Please suggest if any Corrections Needed.
>
> There are several improvements you could make.
>
> >
> > [code]
> > #!/usr/bin/perl
> >
> > use 5.10.0;
> > use strict;
> > use warnings;
> >
> #Pattern
> > #U/A/S|Test|Test   |Loop | Run |Pass |Fail |
>  Arguments
> > # | #  |Name   |Count|Count|Count|Count|
> >
> #-++---+-+-+-+-+---
> > # |  72| Traffic Test  |1|  561|  560|1| (none)
> >
> 
> > my $pattern;
>
> "$pattern" is not a good variable name for holding a string that matches
> some pattern. The 'pattern' is embedded in your regular expression. I would
> use something like "$match" or $found.
>
> > open (my $Log_file, '<', '/tmp/EO-PCPE-23-10GT') || die "Couldn't open
> /tmp/EO-PCPE-23-10GT\n\t $!";
>
> When posting programs to a mailing list, you can use the special 
> file handle and put the lines at the end of your program after a line
> containing just a '__DATA__' marker. That way, people who do not have
> access to your data file will be able to run your program.
>
> > while(<$Log_file>)
>
> It is usually better to use explicit variables:
>
>   while( my $line = <$Log_file> ) {
> if( $line =~ ... ) {
>
> > {
> >
> > if($_ =~
> m/^(.+?)\|(.+72)\|(.+?)\|(.+?)\|(.+[0-9]|[0-9]|[0-9])\|(.+[0-9]|[0-9]|[0-9])\|(.+?)\|(.+?)$/)
>
> This reqular expression is very long and hard to read. You seem to want
> match any line that:
>
> 1. Has seven '|' characters delimiting eight fields.
> 2. Has '72' in field 2.
> 3. Has numbers in fields 5 and 6.
>
> I would recommend first splitting the line, then checking the individual
> fields for their desired content.
>
> In addition, the regex fragment '(.+[0-9]|[0-9]|[0-9])' may not be doing
> what you think. This fragment will match:
>
> 1. At least one character followed by a digit (0-9) OR
> 2. A digit (0-9) OR
> 3. A digit (0-9)
>
> The | character is alternation. You seem to be treating it as
> concatenation. The second and third alternatives are identical, and the
> third one is redundant.
>
> If you want to match three successive digits, these will all work:
>
> [0-9][0-9][0-9]
> [0-9]{3}
> \d\d\d
> \d{3}
>
>
> > {
> >  $pattern=$_;
> >
> >
> > }
> >
> > }
> > print "Pattern Found:\n$pattern";
> > my $uas=(split /\|/, $pattern)[0];
> > $uas =~ s/^\s+//;
> > my $test=(split /\|/, $pattern)[1];
> > $test =~ s/^\s+//;
> > my $test_name=(split /\|/, $pattern)[2];
> > $test_name =~ s/^\s+//;
> > my $loop_count=(split /\|/, $pattern)[3];
> > $loop_count =~ s/^\s+//;
> > my $run_count=(split /\|/, $pattern)[4];
> > $run_count =~ s/^\s+//;
> > my $pass_count=(split /\|/, $pattern)[5];
> > $pass_count =~ s/^\s+//;
> > my $fail_count=(split /\|/, $pattern)[6];
> > $fail_count =~ s/^\s+//;
> > my $arguments=(split /\|/, $pattern)[7];
> > $arguments =~ s/^\s+//;
>
> You can perform the split only once. You can also include optional
> whitespace in the delimiter string, which means the saved substrings will
> not include the whitespace:
>
>   my( $uas, $test, $test_name, $loop_count, $run_count, $pass_count,
> $fail_count,
> $arguments ) = split('\s*\|\s*',$line);
>
> > print '-' x 30, "\n";
> > print "  Test Data   \n";
> > print '-' x 30, "\n";
> > print "UAS : $uas\n";
> > print "Test : $test\n";
> > print "Test Name : $test_name\n";
> > print "Loop Count : $loop_count\n";
> > print "Run Count : $run_count\n";
> > print "Pass Count : $pass_count\n";
> > print "Fail Count : $fail_count\n";
> > print "Arguments : $arguments\n";
> > print '-' x 30, "\n";
> > print "  RESULTS   \n";
> > print '-' x 30, "\n";
>
> You can use a 'HERE' document to print these lines:
>
> print < --
>   Test Data
> --

Re: Need to Grep only fail count from the Pattern.

2014-06-30 Thread Uday Vernekar
please Explain

next if $line =~ /^-/;
  my @f = split('\s*\|\s*',$line);
  next unless scalar @f == 8;



On Fri, Jun 27, 2014 at 6:44 PM, Uday Vernekar 
wrote:

> Thanks to allcheers
>
>
> On Thu, Jun 26, 2014 at 10:28 PM, Jim Gibson  wrote:
>
>>
>> On Jun 26, 2014, at 2:05 AM, Uday Vernekar wrote:
>>
>> > Please suggest if any Corrections Needed.
>>
>> There are several improvements you could make.
>>
>> >
>> > [code]
>> > #!/usr/bin/perl
>> >
>> > use 5.10.0;
>> > use strict;
>> > use warnings;
>> >
>> #Pattern
>> > #U/A/S|Test|Test   |Loop | Run |Pass |Fail |
>>  Arguments
>> > # | #  |Name   |Count|Count|Count|Count|
>> >
>> #-++---+-+-+-+-+---
>> > # |  72| Traffic Test  |1|  561|  560|1| (none)
>> >
>> 
>> > my $pattern;
>>
>> "$pattern" is not a good variable name for holding a string that matches
>> some pattern. The 'pattern' is embedded in your regular expression. I would
>> use something like "$match" or $found.
>>
>> > open (my $Log_file, '<', '/tmp/EO-PCPE-23-10GT') || die "Couldn't open
>> /tmp/EO-PCPE-23-10GT\n\t $!";
>>
>> When posting programs to a mailing list, you can use the special 
>> file handle and put the lines at the end of your program after a line
>> containing just a '__DATA__' marker. That way, people who do not have
>> access to your data file will be able to run your program.
>>
>> > while(<$Log_file>)
>>
>> It is usually better to use explicit variables:
>>
>>   while( my $line = <$Log_file> ) {
>> if( $line =~ ... ) {
>>
>> > {
>> >
>> > if($_ =~
>> m/^(.+?)\|(.+72)\|(.+?)\|(.+?)\|(.+[0-9]|[0-9]|[0-9])\|(.+[0-9]|[0-9]|[0-9])\|(.+?)\|(.+?)$/)
>>
>> This reqular expression is very long and hard to read. You seem to want
>> match any line that:
>>
>> 1. Has seven '|' characters delimiting eight fields.
>> 2. Has '72' in field 2.
>> 3. Has numbers in fields 5 and 6.
>>
>> I would recommend first splitting the line, then checking the individual
>> fields for their desired content.
>>
>> In addition, the regex fragment '(.+[0-9]|[0-9]|[0-9])' may not be doing
>> what you think. This fragment will match:
>>
>> 1. At least one character followed by a digit (0-9) OR
>> 2. A digit (0-9) OR
>> 3. A digit (0-9)
>>
>> The | character is alternation. You seem to be treating it as
>> concatenation. The second and third alternatives are identical, and the
>> third one is redundant.
>>
>> If you want to match three successive digits, these will all work:
>>
>> [0-9][0-9][0-9]
>> [0-9]{3}
>> \d\d\d
>> \d{3}
>>
>>
>> > {
>> >  $pattern=$_;
>> >
>> >
>> > }
>> >
>> > }
>> > print "Pattern Found:\n$pattern";
>> > my $uas=(split /\|/, $pattern)[0];
>> > $uas =~ s/^\s+//;
>> > my $test=(split /\|/, $pattern)[1];
>> > $test =~ s/^\s+//;
>> > my $test_name=(split /\|/, $pattern)[2];
>> > $test_name =~ s/^\s+//;
>> > my $loop_count=(split /\|/, $pattern)[3];
>> > $loop_count =~ s/^\s+//;
>> > my $run_count=(split /\|/, $pattern)[4];
>> > $run_count =~ s/^\s+//;
>> > my $pass_count=(split /\|/, $pattern)[5];
>> > $pass_count =~ s/^\s+//;
>> > my $fail_count=(split /\|/, $pattern)[6];
>> > $fail_count =~ s/^\s+//;
>> > my $arguments=(split /\|/, $pattern)[7];
>> > $arguments =~ s/^\s+//;
>>
>> You can perform the split only once. You can also include optional
>> whitespace in the delimiter string, which means the saved substrings will
>> not include the whitespace:
>>
>>   my( $uas, $test, $test_name, $loop_count, $run_count, $pass_count,
>> $fail_count,
>> $arguments ) = split('\s*\|\s*',$line);
>>
>> > print '-' x 30, "\n";
>> > print "  Test Data   \n";
>> > print '-' x 30, "\n";
>> > print "UAS : $uas\n";
>> > print "Test : $test\n";
>&

Re: Need to Grep only fail count from the Pattern.

2014-07-01 Thread Uday Vernekar
The script works fine without
next if $line =~ /^-/;

How it helps.



On Mon, Jun 30, 2014 at 9:06 PM, Jim Gibson  wrote:

>
> On Jun 30, 2014, at 2:44 AM, Uday Vernekar  wrote:
>
> > please Explain
> >
> > next if $line =~ /^-/;
>
> “Skip this input line if it starts with a dash ‘-‘ character.”
>
> >   my @f = split('\s*\|\s*',$line);
>
> "Break the input line into files separated by the vertical pipe character
> ‘|’ and any whitespace before or after the pipe character, i.e., don’t
> include the whitespace in the extracted fields."
>
> >   next unless scalar @f == 8;
>
> “Skip this input line unless it consists of exactly 8 fields.”
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: want to write to file in different format

2014-07-08 Thread Uday Vernekar
when i try to install Path::Tiny it gives me following error

# The following REQUIRED prerequisites were not satisfied:
#
# File::Spec version '3.33' is not in required range '3.40'
#
t/00-report-prereqs.t . ok
t/basename.t .. File::Spec version 3.4 required--this
is only version 3.33 at
/root/.cpan/build/Path-Tiny-0.055-9ghu3X/blib/lib/Path/Tiny.pm line 12.
BEGIN failed--compilation aborted at
/root/.cpan/build/Path-Tiny-0.055-9ghu3X/blib/lib/Path/Tiny.pm line 12.
Compilation failed in require at t/basename.t line 9.
BEGIN failed--compilation aborted at t/basename.t line 9.





On Tue, Jul 8, 2014 at 6:47 AM, Kent Fredric  wrote:

>
> I'm not about to write my own version here, just offer some pointers I
> find makes life easier for myself, and they may help others too if you're
> not bound to "I don't want to use CPAN".
>
> These days, I find it easier and safer to just use
>
> > use Path::Tiny qw(path);
> >
> > my $infile = path('numbers.txt')->openr;
> > my $outfile = path('sumfile.txt')->openw;
>
> Those will open files and do the right things with error handling by
> default.
>
> If you decide you want a unfiltered IO stream ( ie: not subject to the
> CRLF filter on win32 ), its easy to simply switch to
>
> openr_raw and openw_raw, and it will do the right thing.
>
> Likewise, if you decide you want utf8, just openr_utf8 and openw_utf8  (
> there's a lot of complex messy bugs in utf8 io that this avoids )
>
>
> Similarly, instead of:
>
>
> > chomp( my @lines = <$infile> );
>
> You can simply do:
>
> > my (@lines) = path('numbers.txt')->lines({ chomp => 1 });
>
> ( And again, you can just bolt on the _raw and _utf8 suffixes and get the
> right result )
>
> If you want to avoid handling close yourself and you have a mass of data
> you just want to write and have errors handled correctly:
>
> > path('sumfile.txt')->spew(map { "$_\n"} @lines );
>
> And again, you can just bolt on _utf8 and _raw suffixes and get the right
> thing.
>
> Spew also adds extra protection by writing to a temporary file , and then
> moving it over the original one, so that if spew for some reason fails half
> way through, the original file should not be affected.
>
> --
> Kent
>
> *KENTNL* - https://metacpan.org/author/KENTNL
>
>


-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


How to Upgrade Perl to latest Stable Version.

2014-07-08 Thread Uday Vernekar
Hi All,

Currently I am using  perl 5, version 12, subversion 4 (v5.12.4)

Kindly suggest on how to upgrade to latest version of Perl

with regards
Uday V G

-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Need to understand what this script does.

2014-08-08 Thread Uday Vernekar
Hi All,


please help me in understanding this script.


##1./dbopt/mounts/apps/irfora/utils/scr

use DBI;
use lib "$ENV{IRF_ORA_HOME}/utils/scr";
use UTILS_ORA('mailing', 'db_connect');--The script location
/dbopt/mounts/apps/irfora/utils/scr

sub SendErr;
#sub mailing;

my @FN = split /\//, $0;
my $scn = $FN[$#FN];
my $stErr = "";
my $lfe = 0;
my $strFl;
unless (@ARGV)  {
  print "The program $scn always should run with DMS_Key as an argment!\n";
  exit 1;
}
$addr = 'irf2_load_supp...@listhost.uchicago.edu';
$imid = $ARGV[0];   ### data move key
$loadzone_dir = $ENV{IRF_ORA_LOADZONE};
$run_dir = $ENV{IRF_ORA_LOADZONE}.'/run/acrv';
%cntr_fas = (PAR => [],
 CONTROL_PAR => []);
$cdErr = 0;
my %MON = ( JAN => '01',
FEB => '02',
MAR => '03',
APR => '04',
MAY => '05',
JUN => '06',
JUL => '07',
AUG => '08',
SEP => '09',
OCT => '10',
NOV => '11',
DEC => '12');

@els = ();

### get move id by executing "select init_dms_key(, ,
) from dual"
$dbh = db_connect($ENV{IRF_ORA_INST_AR}, $ENV{IRF_ORA_DB_LOGIN});


### get control data for Audit 2 from DATA_MOVE_SUMMARY table
$str = "SELECT dms_load_id, dms_loadsource_cd, dms_loadtype,
dms_paypdend_dt,
   dms_parrun_dt, dms_filecreate_dt
  FROM irfetl.data_move_summary
 WHERE dms_key = ".$imid;
$dms_dt = $dbh->selectrow_hashref($str);
@dat = split(/\-/,  $$dms_dt{DMS_PAYPDEND_DT});
$pped = "20$dat[2]$MON{$dat[1]}$dat[0]";
unless ($$dms_dt{DMS_PARRUN_DT}){
  $dbh->do("call irf_mdmv.ins_move_log($imid, '$scn', 0, 'It si missing PAR
Run Date')");
  mailing($addr, "Error in ACRV Audit 2", "It si missing PAR Run Date");
  exit 1;
}

open LOG, ">$$dms_dt{DMS_LOADTYPE}.log";
$strFl = `ls $loadzone_dir | grep $imid.ACRV.`;
@fls = split (/\n/, $strFl);
#print "$_\n" foreach (@fls);
unless (@fls) {
  $stErr = "The file set of $imid.$$dms_dt{DMS_LOADTYPE}.* is missing in
$loadzone_dir!";
  $dbh->do ("call irf_mdmv.ins_move_log($imid, '$scn', 0, '$stErr')");
  exit 1;
} elsif (@fls != 2){
  $stErr = "The file set of $imid.$$dms_dt{DMS_LOADTYPE}.* is not
consistent in $loadzone_dir!";
  $dbh->do ("call irf_mdmv.ins_move_log($imid, '$scn', 0, '$stErr')");
  exit 1;
} else  {
  open(RCF, "<$loadzone_dir/$fls[0]")
or SendErr("Cannot open file $loadzone_dir/$fls[0]!", 1, 0, $fls[0]);
  $cln = ;
  close(RCF);
  @els = split(/\|\*\|/, $cln);
  $lfe = chomp($cln);### get the length of the line end character.

  SendErr("Pay Period End Date is different from table DATA_MOVE_SUMMARY
for $fls[0]!", 1, 0, $fls[0])
if ($els[0] - $pped);
  SendErr("The BatchID is different from table DATA_MOVE_SUMMARY for
$fls[0]!", 1, 0, $fls[0])
if ($els[1] - $$dms_dt{DMS_LOAD_ID});
  SendErr("The two BatchIDs are different from each other in $fls[0]!
$els[1] - $els[22]", 1, 0, $fls[0])
if ($els[1] - $els[22]);
### write into control data file
  open(WCF, ">$run_dir/$imid.CONTROL_PAR.dat")
or SendErr("Cannot open file $run_dir/$imid.CONTROL_PAR!", 1, 0,
"$imid.CONTROL_PAR");
  printf(WCF "%10s\|\*\|%s\n", $imid, $cln);
  close(WCF);
### insert record into Data move log table
}
unless ($stErr) {
  $dbh->do("call irf_mdmv.ins_move_log($imid, '$scn', 1, 'File
$imid.CONTROL_PAR.dat created in $run_dir')");
}
open(RCF, "<$loadzone_dir/$fls[1]")
or SendErr("Cannot open file $loadzone_dir/$fls[1]}!", 1, 0, $fls[1]);
@cdf = ;
close(RCF);
open(WCF, ">$run_dir/$imid.PAR.dat")
or SendErr("Cannot open file $imid.PAR.dat!", 1, 0, $scn);
for($i=0; $i < @cdf; $i++)  {
  ### gets substring from the line
  $dfped = substr($cdf[$i], 33, 8);
  $dfbtc = substr($cdf[$i], 1106, 6);
  $dfnam = substr($cdf[$i], 60, 30);
  $dfbeg = substr($cdf[$i], 0, 60);
  $dfend = substr($cdf[$i], 90);
  #$dfnam =~ s/\s+//g;
  $dfend =~ s/\|\*\|NULL/\|\*\|/g;
  ### separate last and first name
  ($ln, $fn) = split(/\,/, $dfnam);
  $lln = length($cdf[$i]) - $els[3] - $lfe;
  if ($lln) {
SendErr("Inconsistent row length in $fls[1]", 1, 0, $scn);
last;
  }
  if($dfbtc eq $els[1]) { ### checks for batch
$els[7]--;
  } elsif($dfbtc eq $els[22])  {  ### checks for batch
$els[24]--;
  } else  {
stErr("Different BatchID in $fls[1] for linr # $i");
last;
  }
  printf(WCF "%10s|*|%s%-30s|*|%-30s%s", $imid, $dfbeg, $ln, $fn, $dfend);
}
SendErr("Different number of lines between the number in control file and
$fls[1]", 1, 0, $scn)
  if ($els[7] + $els[24]);
SendErr($stErr, 1, 0, $scn) if ($stErr);

close(LOG);
close(WCF);
$dbh->do("call irf_mdmv.ins_move_log($imid, '$scn', 1, 'File $imid.PAR.dat
created in $run_dir')");
unlink "$$dms_dt{DMS_LOADTYPE}.log";
exit 0;


 SUBS ###

### sub SendErr (, , , )
sub SendErr {
  my $str_s = "call irf_mdmv.ins_audit_log($imid, '$_[3]', $_[2], '$_[0]',
'$scn')";

  print LOG $_[0], "\n" unless ($_[2]);
  $dbh->do($str_s);
  if ($_[1])  {
close

Re: Need to understand what this script does.

2014-08-10 Thread Uday Vernekar
i din't understand what the whole script is doing.I need to understand
first what this script is all about.

On Sat, Aug 9, 2014 at 12:58 PM, Kent Fredric  wrote:

>
> On 9 August 2014 16:32, Uday Vernekar  wrote:
>
>> Hi All,
>>
>>
>> please help me in understanding this script.
>>
>
> Please explain what it is about this script you want to understand / don't
> quite understand.
>
> Also, if there's something not working in this script, a primary candidate
> list of potential problems will self-report if you take the time to include:
>
>
> use strict;
> use warnings;
>
>
> Somewhere near the top before the "use DBI" statement.
>
> And it is generally recommended all code use those two statements unless
> you know better.
>
>
> --
>  Kent
>
>  *KENTNL* - https://metacpan.org/author/KENTNL
>
>


-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: Need to understand what this script does.

2014-08-11 Thread Uday Vernekar
thanks david


On Mon, Aug 11, 2014 at 3:54 PM, David Precious 
wrote:

> On Mon, 11 Aug 2014 11:12:34 +0100
> David Precious  wrote:
>
> > On Sun, 10 Aug 2014 16:40:07 +0530
> > Uday Vernekar  wrote:
> >
> > > i din't understand what the whole script is doing.I need to
> > > understand first what this script is all about.
> >
> > Well, it calls some Oracle stored procedures, [...]
>
> I guess I should expand on that, in case you're not familiar with them
> - stored procedures are essentially functions stored in the database
> itself, written in PL/SQL or Java typically:
>
> http://en.wikipedia.org/wiki/Stored_procedure
>
> So, that means that there's code in the database system itself that
> we're not seeing, so could only guess at what that code does.
>
> I think you're somewhat beyond what this list can help with - we can
> help with specific beginner questions etc, but giving a whole script
> you've no idea about, and not being able to give the missing chunks
> (stored procs) is somewhat beyond that.  We're not here to do the work
> for you :)
>
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Difference between list and arrays.

2014-09-16 Thread Uday Vernekar
Confusion on array and list. can anybody explain me the difference between
list and arrays.

my @xyz = ( 4, 5, 6 );

The right-hand side of the equals sign is a list.here I assign that list to
the variable @xyz.
its an array,list can be assigned to an array.

on similiar lines
we can assign Lists to hashes
my %zzz = ( a => 42, b => 43, b => 44 );




-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: Regular expression: option match after a greedy/non-greedy match

2014-09-17 Thread Uday Vernekar
When i run this script i get following Error

bash-4.2$ ./regex.pl
feature version v5.16.0 required--this is only version v1.160.0 at ./
regex.pl line 4.
BEGIN failed--compilation aborted at ./regex.pl line 4.



But I am using perl version as swon below.

bash-4.2$ perl -v

This is perl 5, version 16, subversion 3 (v5.16.3) built for i686-linux

Copyright 1987-2012, Larry Wall

Perl may be copied only under the terms of either the Artistic License or
the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.




On Wed, Sep 17, 2014 at 8:52 AM, Jing Yu  wrote:

> Hi Viet-Duc Le,
> On 17 Sep 2014, at 10:23, Viet-Duc Le  wrote:
>
> Greeting from S. Korea !
>
> I am parsing the output of ffmpeg with perl. Particular, I want to print
> only
> these lines among the output and capturing the resolution, i.e. 1280x720.
> 
>
> Stream #0:0: Video: h264 (High), yuv420p, 1280x720, SAR 1:1 DAR 16:9, 23.98 
> fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
> Stream #0:1(jpn): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
> Stream #0:2(eng): Subtitle: ass (default)
> .
>
> My code is following:
> # INFO is pipe to ffmpeg
> # Here, the  is for debugging .
> while (  ) {
> if (   ) {
> print "$1 $2 $3 $4\n";
> }
> }
>
> Desirable outputs:
> -> Video 1280 720
>  Audio
>  Subtitle
>
> Regarding the :
> 1. /Stream #\d:\d.*(Video|Audio|Subtitle).*(\d+)x(\d+)/ (greedy)
> -> Video 0 720
>
> Q: why does $2 give  0? I remember .* match backward starting from the end of 
> the string. Then it should be  "Video 1280 720" as output.
>
> that '0' is from 128'0', since the '.*' consumes 128. What it does under
> the hood is .* first will reach to the end of the target string, and then
> backtract according to the following regex. Once the whole regex is
> satisfied, it will stop backtracting, although further retracting will
> possibly also satisfy the regex.
>
>
> 2. /Stream #\d:\d.*(Video|Audio|Subtitle).*?(\d+)x(\d+)/ (non greedy)
> -> Video 1280 720
> Q: I can understand this, but again I think (1) should work too.
>
>
> 3. /Stream #\d:\d.*(Video|Audio|Subtitle).*?(?:(\d+)x(\d+))?/ ( non-capturing 
> optional group )
> -> Video
> Audio
> Subtitle
> Q: It seems that the resolution part
> is ignored because it is optional. Otherwise, the output will contains 
> "Video" only as (1) and (2). How can I circumvent this ?
>
> that ?: prevents $ variables to capture the matching regex group. I guess
> you can get rid of it. The trailing ? already tells the regex group to
> match optionally. It is equivalent to {0,1}. The big problem coming with it
> is the middle .*?. Since the last part is optional, .*? will just match the
> least number of char possible, which is nothing.
>
>
> 4. /Stream #\d:\d.*(Video|Audio|Subtitle).+?(?:(\d+)x(\d+))?.*?$/
> -> Video
>  Audio
>  Subtitle
>
> Q: I tried to match things after the resolution, hoping that it will be 
> captured.
>
>
> Again the ?: prevents it being captured. .+? in the middle is better, now
> it matches ':'.
>
>
>
> 5. /Stream #\d:\d.*(Video|Audio|Subtitle).+?(?:(\d+)x(\d+))?(.*?)$/ ( let's 
> capture the last part)
>
> -> Videoh264 (High), yuv420p, 1280x720, SAR 1:1 DAR 16:9, 23.98 fps, 
> 23.98 tbr, 1k tbn, 47.95 tbc (default)
> Audioac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
> Subtitleass (default)
> Q: Now $2 and $3 is undef, and the rest of the string went to $4. Again, I am
> quite puzzled by the output.
>
> If it is optional, it is non greedy. So everything goes to the (.*?)$.
>
>
> Please pardon my long email. I hope someone can point out the flaws in my 
> logic.
> Here, I can match and print Video/Audio/Subtitle separately.
> But I wish for one expression to match them all, one expression to print
> them.
>
> In general, it is a better practise to add 'x' to your regex to make it
> more readable. My regex might not be the best, but it works as expected.
>
> use strict;
> use warnings;
> use 5.16.0;
>
> while(){
> / (Video|Audio|Subtitle)  (?: (?:.) +? (\d+x\d+) || (?:.)+ ) /x
> and say $1, $2, $3, $4;
> }
>
>
> __DATA__
> Stream #0:0: Video: h264 (High), yuv420p, 1280x720, SAR 1:1 DAR 16:9,
> 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
> Stream #0:1(jpn): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
> Stream #0:2(eng): Subtitle: ass (default)
>
> The '||' operator will first check the group before it. It will only look
> at the other group if the first group fails. This puts your resolution
> group matching as priority, but not necessity.
>
> Hope this helps.
> Jing
>
>


-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know

Re: Regular expression: option match after a greedy/non-greedy match

2014-09-17 Thread Uday Vernekar
when i change
use 5.16.0; to use feature ':5.10';

it works i get following output

bash-4.2$ ./regex.pl
Use of uninitialized value $3 in say at ./regex.pl line 7,  line 1.
Use of uninitialized value $4 in say at ./regex.pl line 7,  line 1.
Video1280x720
Use of uninitialized value $2 in say at ./regex.pl line 7,  line 2.
Use of uninitialized value $3 in say at ./regex.pl line 7,  line 2.
Use of uninitialized value $4 in say at ./regex.pl line 7,  line 2.
Audio
Use of uninitialized value $2 in say at ./regex.pl line 7,  line 3.
Use of uninitialized value $3 in say at ./regex.pl line 7,  line 3.
Use of uninitialized value $4 in say at ./regex.pl line 7,  line 3.
Subtitle


how these two use statements differ.

use 5.16.0;

perl regex.pl works

why ./regex.pl doesnt work.

it gives following error
feature version v5.16.0 required--this is only version v1.160.0 at ./
regex.pl line 4.
BEGIN failed--compilation aborted at ./regex.pl line 4.



On Wed, Sep 17, 2014 at 2:38 PM, Uday Vernekar 
wrote:

> When i run this script i get following Error
>
> bash-4.2$ ./regex.pl
> feature version v5.16.0 required--this is only version v1.160.0 at ./
> regex.pl line 4.
> BEGIN failed--compilation aborted at ./regex.pl line 4.
>
>
>
> But I am using perl version as swon below.
>
> bash-4.2$ perl -v
>
> This is perl 5, version 16, subversion 3 (v5.16.3) built for i686-linux
>
> Copyright 1987-2012, Larry Wall
>
> Perl may be copied only under the terms of either the Artistic License or
> the
> GNU General Public License, which may be found in the Perl 5 source kit.
>
> Complete documentation for Perl, including FAQ lists, should be found on
> this system using "man perl" or "perldoc perl".  If you have access to the
> Internet, point your browser at http://www.perl.org/, the Perl Home Page.
>
>
>
>
> On Wed, Sep 17, 2014 at 8:52 AM, Jing Yu  wrote:
>
>> Hi Viet-Duc Le,
>> On 17 Sep 2014, at 10:23, Viet-Duc Le  wrote:
>>
>> Greeting from S. Korea !
>>
>> I am parsing the output of ffmpeg with perl. Particular, I want to print
>> only
>> these lines among the output and capturing the resolution, i.e. 1280x720.
>> 
>>
>> Stream #0:0: Video: h264 (High), yuv420p, 1280x720, SAR 1:1 DAR 16:9, 23.98 
>> fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
>> Stream #0:1(jpn): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
>> Stream #0:2(eng): Subtitle: ass (default)
>> .
>>
>> My code is following:
>> # INFO is pipe to ffmpeg
>> # Here, the  is for debugging .
>> while (  ) {
>> if (   ) {
>> print "$1 $2 $3 $4\n";
>> }
>> }
>>
>> Desirable outputs:
>> -> Video 1280 720
>>  Audio
>>  Subtitle
>>
>> Regarding the :
>> 1. /Stream #\d:\d.*(Video|Audio|Subtitle).*(\d+)x(\d+)/ (greedy)
>> -> Video 0 720
>>
>> Q: why does $2 give  0? I remember .* match backward starting from the end 
>> of the string. Then it should be  "Video 1280 720" as output.
>>
>> that '0' is from 128'0', since the '.*' consumes 128. What it does under
>> the hood is .* first will reach to the end of the target string, and then
>> backtract according to the following regex. Once the whole regex is
>> satisfied, it will stop backtracting, although further retracting will
>> possibly also satisfy the regex.
>>
>>
>> 2. /Stream #\d:\d.*(Video|Audio|Subtitle).*?(\d+)x(\d+)/ (non greedy)
>> -> Video 1280 720
>> Q: I can understand this, but again I think (1) should work too.
>>
>>
>> 3. /Stream #\d:\d.*(Video|Audio|Subtitle).*?(?:(\d+)x(\d+))?/ ( 
>> non-capturing optional group )
>> -> Video
>> Audio
>> Subtitle
>> Q: It seems that the resolution part
>> is ignored because it is optional. Otherwise, the output will contains 
>> "Video" only as (1) and (2). How can I circumvent this ?
>>
>> that ?: prevents $ variables to capture the matching regex group. I guess
>> you can get rid of it. The trailing ? already tells the regex group to
>> match optionally. It is equivalent to {0,1}. The big problem coming with it
>> is the middle .*?. Since the last part is optional, .*? will just match the
>> least number of char possible, which is nothing.
>>
>>
>> 4. /Stream #\d:\d.*(Video|Audio|Subtitle).+?(?:(\d+)x(\d+))?.*?$/
>> -> Video
>>  Audio
>>  Subtitle
>>
>> Q: I tried to match things after the resolution, hoping that it will be 
>> captured.
>>
>>
>> Again the ?: prevents it bei

ignoring bad Prompt argument Warning.

2014-12-29 Thread Uday Vernekar
Hi All,

I am doing Pattern matching of the expected string  if matched then pass
the next command.my code works as expected but gives warning.

can any body please Explain me why i am getting this at every match.

ignoring bad Prompt argument "'/>>/'": missing opening delimiter of match
operator at linux_diagnostics.pl line 189

Second matchstr: '/>>/'
/bin/rm: remove write-protected regular file
`/var/www/cgi-bin/lbd/user_input_192.168.240.253.log'? y
ignoring bad Prompt argument "'/>>/'": missing opening delimiter of match
operator at linux_diagnostics.pl line 189
cmd_arg[0]: command
Command: cardtest 1 1 prompt : cardtest 1 1,
Prompt: StarTDate\(dd\) : EnD timeout : StarTDate\(dd\) : EnD
Timeout: 600 : 600

 Second matchstr: '/Date\(dd\) : /'
/bin/rm: remove write-protected regular file
`/var/www/cgi-bin/lbd/user_input_192.168.240.253.log'? y
ignoring bad Prompt argument "'/Date\(dd\) : /'": missing opening delimiter
of match operator at linux_diagnostics.pl line 189
cmd_arg[0]: command
Command: 10 prompt : 10,
Prompt: month\(mm\) : EnD timeout : month\(mm\) : EnD
Timeout: 600 : 600

 Second matchstr: month\(mm\) : /'
/bin/rm: remove write-protected regular file
`/var/www/cgi-bin/lbd/user_input_192.168.240.253.log'? y
ignoring bad Prompt argument "month\(mm\) : /'": missing opening delimiter
of match operator at linux_diagnostics.pl line 189
cmd_arg[0]: command
Command: 10 prompt : 10,
Prompt: month\(mm\) : EnD timeout : month\(mm\) : EnD
Timeout: 600 : 600

 Second matchstr: month\(mm\) : /'
/bin/rm: remove write-protected regular file
`/var/www/cgi-bin/lbd/user_input_192.168.240.253.log'? y
ignoring bad Prompt argument "month\(mm\) : /'": missing opening delimiter
of match operator at linux_diagnostics.pl line 189
cmd_arg[0]: command
Command: 10 prompt : 10,
Prompt: StarTHour\(24 hour format\) : EnD timeout : StarTHour\(24 hour
format\) : EnD
Timeout: 600 : 600


with Regards
Uday V G


-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: ? getting appended to file name while writing o file

2015-03-20 Thread Uday Vernekar
when i use $numberOfPingPackets=2;

I get following warning?

PING 192.168.240.55 (192.168.240.55) 56(84) bytes of data.

 --- 192.168.240.55 ping statistics ---
 2 packets transmitted, 0 received, 100% packet loss, time 11000ms

Use of uninitialized value in index at ./pinglog.pl line 26,  line 4.


On Thu, Mar 19, 2015 at 5:19 PM, Satya Prasad Nemana 
wrote:

> Bill, Carl, Andrew,
>
> Thanks a lot for your answers.
> yes, i will make the change to use the perl utilities as it will make the
> code platform independent.
>
> Regards,
> Satya
>
>
>
>
> On 19 March 2015 at 16:58, Carl Inglis  wrote:
>
>> It's not actually ending up with a ? character at the end - it's ending
>> up with a new line character. Your terminal is (as Andrew implied)
>> displaying a ? character for a character code outside the range of
>> characters it knows it can display.
>>
>> Regards,
>>
>> Carl
>>
>> On 19 March 2015 at 11:19, Andrew Solomon  wrote:
>>
>>> No - that one's a mystery to me:) I suspect it's something to do with
>>> the terminal and character encoding
>>>
>>>
>>> http://stackoverflow.com/questions/5306153/how-to-get-terminals-character-encoding
>>>
>>> Andrew
>>>
>>>
>>> On Thu, Mar 19, 2015 at 7:41 AM, Satya Prasad Nemana 
>>> wrote:
>>>
 Great Andrew.
 it is all good now.

 Could you please tell how new line ended up as ? in the file name

 Thanks,
 Satya


 On 19 March 2015 at 12:53, Andrew Solomon  wrote:

> my $logFileName="log_ping_".`date +"%d_%b_%y_%H_%M_%S"`;
>
> should be followed by
>
> chomp($logFileName)
>
> otherwise there's a trailing newline character in $logFileName on
> account of the call to date
>
> Andrew
>
> On Thu, Mar 19, 2015 at 6:08 AM, Satya Prasad Nemana  > wrote:
>
>> Hi
>>
>> I have a small program listed below where i am writing ping results
>> to a file.
>> The program works file except that the file name in the output file
>> is coming as log_ping_19_Mar_15_11_27_49? (please note the ? at the end 
>> of
>> the name)
>>
>> The initial output looks like
>> bats3 snemana/perlprogs> perl pingTest.pl hostInfo.txt
>>
>> Logfile is log_ping_19_Mar_15_11_38_53
>>
>> File name is hostInfo.txt
>>
>> .
>>
>> Could someone please tell why the ? is getting added to the file name
>> although it looks fine in the initial print of the file name.
>>
>> use Data::Dumper;
>> use strict;
>> use warnings;
>> my $numberOfPingPackets=1;
>>
>> my $fullFileName=$ARGV[0];
>> my $logFileName="log_ping_".`date +"%d_%b_%y_%H_%M_%S"`;
>> print "\nLogfile is $logFileName";
>> print ("\nFile name is $fullFileName");
>> open FILE, $fullFileName or die $!;
>> my $logFile;
>> open $logFile, '>', $logFileName or die $!;
>> my @fileContents=;
>> print ("\nFile contents are ".Dumper(@fileContents));
>> for(my $i=0;$i < @fileContents; $i++)
>> {
>> my $line=$fileContents[$i];
>> my @data=split(/\t/,$line);
>> my $host=$data[0];
>> my $ip=substr($data[1],0,-1);
>> my @pingResults=`ping -c $numberOfPingPackets $ip`;
>> my $succesString="$numberOfPingPackets packets transmitted,
>> $numberOfPingPackets received, 0% packet loss";
>> my $index=3+$numberOfPingPackets;
>> if(index($pingResults[$index],$succesString) >= 0)
>> {
>> print "\nPing to host $host ip $ip is successful";
>> print $logFile "\nPing to host $host ip $ip is successful";
>> }
>> else
>> {
>> print "\nPing to host $host ip $ip is failure";
>> print $logFile "\nPing to host $host ip $ip is failure";
>> }
>> }
>> close $logFile;
>>
>>
>> --
>> Satya Prasad
>>
>
>
>
> --
> Andrew Solomon
>
> Mentor@Geekuni http://geekuni.com/
> http://www.linkedin.com/in/asolomon
>



 --
 Satya Prasad

>>>
>>>
>>>
>>> --
>>> Andrew Solomon
>>>
>>> Mentor@Geekuni http://geekuni.com/
>>> http://www.linkedin.com/in/asolomon
>>>
>>
>>
>
>
> --
> Satya Prasad
>



-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: last statement in a package

2015-05-21 Thread Uday Vernekar
As Per my Understanding...

The last line file must contain the line with the 1; statement. As This in
effect returns a true value to the program using the module. if you are Not
using the 1; statement it will not let the module be loaded correctly.

On Thu, May 21, 2015 at 11:43 AM, Sunita Pradhan <
sunita.pradhan.2...@hotmail.com> wrote:

> Hi
>
> Why a perl programmer use 1 or any number as last statement in module or
> package (like : 1;)?
> I checked without that also package gets loaded .
>
> Can somebody please explain properly , it would be good with examples ?
>
> Thanks
> Sunita
>



-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: last statement in a package

2015-05-21 Thread Uday Vernekar
When a module is loaded (via use) the compiler will complain unless the
last statement executed when it is loaded is true. This line ensures that
this is the case (as long as you don't place any code after this line).
Perl's way of making sure that it successfully parsed all the way to the
end of the file.

On Thu, May 21, 2015 at 12:44 PM, Uday Vernekar 
wrote:

> As Per my Understanding...
>
> The last line file must contain the line with the 1; statement. As This
> in effect returns a true value to the program using the module. if you
> are Not using the 1; statement it will not let the module be loaded
> correctly.
>
> On Thu, May 21, 2015 at 11:43 AM, Sunita Pradhan <
> sunita.pradhan.2...@hotmail.com> wrote:
>
>> Hi
>>
>> Why a perl programmer use 1 or any number as last statement in module or
>> package (like : 1;)?
>> I checked without that also package gets loaded .
>>
>> Can somebody please explain properly , it would be good with examples ?
>>
>> Thanks
>> Sunita
>>
>
>
>
> --
> *
> Don't ask them WHY they hurt you,
> because all they'll tell you is lies and excuses.
>  Just know they were wrong, and try to move on.
> **
>



-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: Perl hash

2015-07-30 Thread Uday Vernekar
Hashes are complex list data, like arrays except they link a key to a
value.
Hashes can be used for counting, uniqueness, searching, and dispatch and
lot more than just mapping from one thing to another and More.

On Fri, Jul 31, 2015 at 9:15 AM, Uri Guttman  wrote:

> On 07/30/2015 11:38 PM, bikram behera wrote:
>
>> Hi Team,
>>
>> hi,
>
> we aren't a team. this is a public mailing list.
>
> Please send me  hash uses and concept
>>
>
> think of them as arrays but instead of integers for indexing, you use
> strings. the uses are too many to list here. some are data structures,
> tables, data validation, data conversion, database records and much more.
>
> uri
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Factorial of a number.

2015-09-21 Thread Uday Vernekar
Hi all,

I wrote a simple Perl code to find the factorial of a number.
Need feed back on the same.please correct me if i have done anything wrong

#!/usr/bin/perl
use warnings;
use strict;
my $fact=1;
print("Enter Number:");
my $num=;
if($num==0)
{
 print("factorial of $num=$fact\n");
}
elsif($num<0)
{
print("please enter only positive integers \n");
}
else
{
   for (1..$num)
{
 $fact*=$_;
}
print("factorial of $num=$fact\n");

}


with Regards
Uday V G

-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: Factorial of a number.

2015-09-21 Thread Uday Vernekar
Thanks Shlomi for your Valuable comments.

On Mon, Sep 21, 2015 at 3:41 PM, Shlomi Fish  wrote:

> Hi Uday,
>
> please reply to the list.
>
> I'm going to comment on your code.
>
> On Mon, 21 Sep 2015 15:06:49 +0530
> Uday Vernekar  wrote:
>
> > Hi all,
> >
> > I wrote a simple Perl code to find the factorial of a number.
> > Need feed back on the same.please correct me if i have done anything
> wrong
> >
> > #!/usr/bin/perl
> > use warnings;
> > use strict;
>
> It's good that you used string and warnings, but you should have some empty
> lines between paragraphs.
>
> > my $fact=1;
>
> You should avoid pre-declaring your variables.
>
> > print("Enter Number:");
>
> This may not get output in time. You need to flush the output - see perldoc
> IO::Handle .
>
> > my $num=;
>
> I personally prefer using  or <> for short consistently than 
> which is more limited.
>
> > if($num==0)
> > {
> >  print("factorial of $num=$fact\n");
> > }
>
> No need for this special case, and you have some duplicate code.
>
> Furthermore , you should have spaces between the expressions, like:
>
> «
> if ($num == 0)
> {
> print ("The factorial of $num is $fact\n");
> }
> »
>
> > elsif($num<0)
> > {
> > print("please enter only positive integers \n");
> > }
>
> Your code is missing indentation and furthermore, this note should be
> outputted
> to STDERR or use die or warn.
>
> > else
> > {
> >for (1..$num)
> > {
> >  $fact*=$_;
> > }
>
> It's a good idea not to use $_ as an implicit looping construct because it
> can
> be overrided very easily. Use a lexical variable:
>
> for my $i (1 .. $num)
> {
> $fact *= $i
> }
>
> It will also be a good idea to extract the code calculating the factorial
> into
> its own subroutine, which will accept a number and return the result.
>
> Finally note that Math::BigInt and Math::GMP already provide ->bfac() for
> calculating the factorial, so you should use them instead of your own
> homebrewed routines.
>
> Regards,
>
> Shlomi Fish
>
> --
> -
> Shlomi Fish   http://www.shlomifish.org/
> http://is.gd/i5eMQd - Emma Watson’s Interview for a Software Dev Job
>
> If a tree falls down in the middle of the forest, and there's nobody in its
> vicinity, it will still make a sound, because Chuck Norris can hear it.
> — http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/
>
> Please reply to list if it's a mailing list post - http://shlom.in/reply .
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


my makefile. Doesn’t work the way I intend it to

2015-11-19 Thread Uday Vernekar
Hello Group,


I have the following in my makefile. Doesn’t work the way I intend it to.
  How do I do conditional test with a regular expression ?





ifeq (${HOST_TYPE},x86_64)--
à works

  ifeq (${LATTICE_VERSION},d3.*)  --à
doesn’t work

LATTICE_EXE_PATH  = ${ISPFPGA}/bin/lin64

  else

LATTICE_EXE_PATH  = ${ISPFPGA}/bin/lin

  endif

else

  LATTICE_EXE_PATH  = ${ISPFPGA}/bin/lin
endif


with Regards
Uday V G




-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Parsing Logfiles and fetching Macs programmed and putting in another file.

2017-01-31 Thread Uday Vernekar
Requirement:

I have Test log files with filename as SerialNumber of tested Product and
the log file consist of
 below data and other Text.the IP addresses can be repeated need to fetch
only mac starting with 00:05:95:XX:XX:XX


Board IP address  : 192.168.1.1:ff00
Host IP address   : 192.168.1.100
Gateway IP address:
Run from flash/host/tftp (f/h/c)  : f
Default host run file name: vmlinux
Default host flash file name  : bcm963xx_fs_kernel
Boot delay (0-9 seconds)  : 1
Default host ramdisk file name:
Default ramdisk store address :
Board Id (0-5): 968500CHERRY
Number of MAC Addresses (1-32): 10
Base MAC Address  : 00:05:95:37:17:8b
PSI Size (1-64) KBytes: 24
Enable Backup PSI [0|1]   : 0
System Log Size (0-256) KBytes: 0
Auxillary File System Size Percent: 0
Main Thread Number [0|1]  : 0
MC memory allocation (MB) : 0
TM memory allocation (MB) : 0


The data in the Test logs get appended everytime it is tested.

I need to fetch "Base MAC Address  : 00:05:95:37:17:8b"
from the each and evry logfile  and put in another file with Respect to
SerialNumber of the Product.
If it doesnt find any Mac then it should display MAC NOT PROGRAMMED for
that SerialNumber.

for Ex output in the file:
Serial NumberMac Programmed

AG-0117-10-1740 00:05:95:37:17:8b
AG-0117-10-1741 00:05:95:37:17:8c
AG-0117-10-1742 00:05:95:37:17:8d
AG-0117-10-1743 MAC NOT PROGRAMMED
AG-0117-10-1744 00:05:95:37:17:8e

I Have written the code Please help me correcting the Errors which I have
made in my code.



#!/usr/bin/perl
use strict;
use warnings;
use Cwd;

print "\tEnter the User Name:";
my $user = ;
chomp($user);
print "\tEnter the Directory name where Logs are Stored:";
my $Directory = ;
chomp($Directory);
system("mkdir -p /mnt/ONT");
my $userPath="/mnt/backup/$Directory";
chomp($userPath);

my $scriptfile = "/mnt/ONT/MAC-REPORT-FILE.txt";
system("rm -f $scriptfile");

open(SCRIPT , ">>$scriptfile");

print "\n Results are stored in /mnt/ONT/MAC-REPORT-FILE.txt\n";

`rm /mnt/ONT/MAC-REPORT-FILE.txt`;

sub ScanDirectory {
my ($workdir) = shift;

   my($startdir) = &cwd;

chdir($workdir) or die "Unable to enter dir $workdir:$!\n";

opendir(DIR, "$workdir") or die "Unable to open $workdir:$!\n";
my @names = readdir(DIR);
closedir(DIR);

foreach my $name (@names){
next if ($name eq ".");
next if ($name eq "..");

if (-d $name){
my $pwd=`pwd`;
chomp($pwd);
my $path=$pwd."/".$name;
&ScanDirectory($path);
next;
}
unless (&CheckFile($name)){

}
}

close(SCRIPT);
chdir($startdir) or die "Unable to change to dir $startdir:$!\n";
}

my $date =`date`;
my $data_file2='/mnt/ONT/MAC-REPORT-FILE.txt';
open DATAOUT, ">>$data_file2" or die "can't open $data_file2 $!";
print DATAOUT "\n\t\t\tMAC-ID GENERATED REPORT\n";
print DATAOUT "\nGeneteated By:$user\n";
print DATAOUT "\nDATE: $date \n";
print DATAOUT "NOTE: THIS REPORT IS GENERATED BASED ON THE TEST LOGS
AVAILABLE IN THE SERVER\n";
print DATAOUT "\n";
print DATAOUT " SERIAL NUMBER\t\tMACADDRESS\n";
print DATAOUT "-\n";
close(DATA);

sub CheckFile{
my($name) = shift;

my $datafile=$name;
#print "$datafile\n";
my $data_file2='/mnt/ONT/MAC-REPORT-FILE.txt';

open DATA, "$datafile" or die" can't open $datafile $!";
my @array_of_data=;

#print @array_of_data;

foreach my $i ($datafile)
{

my $Result = `grep "Base MAC Address" \/mnt\/backup\/$Directory\/$name |
tail -n 1 `;
my ($str,@mac) = split(":",$Result);
if($mac[1] ne "05")  {

@mac="   MAC NOT PROGRAMMED\n";
#print "\n";
print DATAOUT " $name\t\t@mac\n" ;
}
else{
print DATAOUT " $name\t\t
$mac[0]:$mac[1]:$mac[2]:$mac[3]:$mac[4]:$mac[5]\n" ;
}
}
}

&ScanDirectory($userPath);

close(DATAOUT);





-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: Parsing Logfiles and fetching Macs programmed and putting in another file.

2017-01-31 Thread Uday Vernekar
Thanks shlomi ,working on your inputs...Thanks:)

On Tue, Jan 31, 2017 at 4:34 PM, Shlomi Fish  wrote:

> Hi Uday,
>
> see my reply interim with your code.
>
> On Tue, 31 Jan 2017 15:31:59 +0530
> Uday Vernekar  wrote:
>
> > Requirement:
> >
> > I have Test log files with filename as SerialNumber of tested Product and
> > the log file consist of
> >  below data and other Text.the IP addresses can be repeated need to fetch
> > only mac starting with 00:05:95:XX:XX:XX
> >
> > 
> > Board IP address  : 192.168.1.1:ff00
> > Host IP address   : 192.168.1.100
> > Gateway IP address:
> > Run from flash/host/tftp (f/h/c)  : f
> > Default host run file name: vmlinux
> > Default host flash file name  : bcm963xx_fs_kernel
> > Boot delay (0-9 seconds)  : 1
> > Default host ramdisk file name:
> > Default ramdisk store address :
> > Board Id (0-5): 968500CHERRY
> > Number of MAC Addresses (1-32): 10
> > Base MAC Address  : 00:05:95:37:17:8b
> > PSI Size (1-64) KBytes: 24
> > Enable Backup PSI [0|1]   : 0
> > System Log Size (0-256) KBytes: 0
> > Auxillary File System Size Percent: 0
> > Main Thread Number [0|1]  : 0
> > MC memory allocation (MB) : 0
> > TM memory allocation (MB) : 0
> > 
> >
> > The data in the Test logs get appended everytime it is tested.
> >
> > I need to fetch "Base MAC Address  : 00:05:95:37:17:8b"
> > from the each and evry logfile  and put in another file with Respect to
> > SerialNumber of the Product.
> > If it doesnt find any Mac then it should display MAC NOT PROGRAMMED for
> > that SerialNumber.
> >
> > for Ex output in the file:
> > Serial NumberMac Programmed
> >
> > AG-0117-10-1740 00:05:95:37:17:8b
> > AG-0117-10-1741 00:05:95:37:17:8c
> > AG-0117-10-1742 00:05:95:37:17:8d
> > AG-0117-10-1743 MAC NOT PROGRAMMED
> > AG-0117-10-1744 00:05:95:37:17:8e
> >
> > I Have written the code Please help me correcting the Errors which I have
> > made in my code.
> >
> > 
> >
> > #!/usr/bin/perl
> > use strict;
> > use warnings;
>
> It's good that you are using those.
>
> > use Cwd;
>
> Perhaps import getcwd/etc. explicitly or do «use Cwd ();».
>
> >
> > print "\tEnter the User Name:";
> > my $user = ;
> > chomp($user);
> > print "\tEnter the Directory name where Logs are Stored:";
> > my $Directory = ;
> > chomp($Directory);
>
> You have some duplicate code here.
>
> > system("mkdir -p /mnt/ONT");
>
> You should use https://metacpan.org/pod/File::Path or whatever instead of
> shelling to system which is less portable and may be slower. See:
>
> http://perl-begin.org/tutorials/bad-elements/#calling-the-shell-too-much
>
> (Note : I maintain that page).
>
> > my $userPath="/mnt/backup/$Directory";
> > chomp($userPath);
> >
>
> No need for chomp here.
>
> > my $scriptfile = "/mnt/ONT/MAC-REPORT-FILE.txt";
> > system("rm -f $scriptfile");
>
> again - you should use unlink.
>
> >
> > open(SCRIPT , ">>$scriptfile");
> >
>
> See http://perl-begin.org/tutorials/bad-elements/#open-function-style -
> you can
> also try using https://metacpan.org/pod/autodie .
>
> > print "\n Results are stored in /mnt/ONT/MAC-REPORT-FILE.txt\n";
> >
> > `rm /mnt/ONT/MAC-REPORT-FILE.txt`;
> >
>
> 1. Use unlink().
>
> 2. Don't use backticks instead of system -
> http://perl-begin.org/tutorials/bad-elements/#qx_for_command_execution
>
> > sub ScanDirectory {
> > my ($workdir) = shift;
> >
>
> You should do either:
>
> my ($work_dir) = @_;
>
> or:
>
> my $work_dir = shift;
>
> See scalar vs. list context.
>
> Also see http://perl-begin.org/tutorials/bad-elements/#
> calling-variables-file
>
> >my($startdir) = &cwd;
> >
>
> Don't call subroutines using ampersands :
>
> * http://perl-begin.org/tutorials/bad-elements/#
> ampersand-in-subroutine-calls
>
> * https://perlhacks.com/2015/04/subroutines-and-ampersands/
>
> > chdir($workdir) or die "Unable to enter dir $workdir:$!\n";
>
> I find that using chdir is usually a bad idea.
>
> >
> > opendir(DIR, "$workdir") or die &qu

Installing Net::SFTP

2017-03-14 Thread Uday Vernekar
Hello,

Need some help on installing Net::SFTP perl module on RHEL.

please guide.

With Regards
Uday V G

-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


Re: Installing Net::SFTP

2017-03-15 Thread Uday Vernekar
I tried installing through CPAN.but getting following Errors

Test Summary Report
---
t/01-load.t(Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 1 tests but ran 0.
t/06-circular.t (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
Files=2, Tests=0,  0 wallclock secs ( 0.02 usr  0.01 sys +  0.01 cusr  0.00
csys =  0.04 CPU)
Result: FAIL
Failed 2/2 test programs. 0/0 subtests failed.
make: *** [test_dynamic] Error 2
  DBROBINS/Net-SFTP-0.10.tar.gz
  /usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports DBROBINS/Net-SFTP-0.10.tar.gz
Running make install
  make test had returned bad status, won't install without force
Failed during this command:
 DBROBINS/Net-SFTP-0.10.tar.gz: make_test NO
 SCHWIGON/Net-SSH-Perl-2.09.01.tar.gz : make_test NO one dependency
not OK (Math::GMP)



On Wed, Mar 15, 2017 at 1:11 PM, community tech 
wrote:

> before that you may want to install SSLeay etc.
>
> cpanm Net::SSLeay
> cpanm Crypt::SSLeay
>
>
> 2017-03-15 14:22 GMT+08:00 Uday Vernekar :
>
>> Hello,
>>
>> Need some help on installing Net::SFTP perl module on RHEL.
>>
>> please guide.
>>
>> With Regards
>> Uday V G
>>
>> --
>> *
>> Don't ask them WHY they hurt you,
>> because all they'll tell you is lies and excuses.
>>  Just know they were wrong, and try to move on.
>> **
>>
>
>


-- 
*
Don't ask them WHY they hurt you,
because all they'll tell you is lies and excuses.
 Just know they were wrong, and try to move on.
**


covert perl code to binary

2019-01-11 Thread Uday Vernekar
Hi all,

I have a perl code which I need to covert to binary so that nobody can see
the code.

we used pp package to make the perl code binary but here the user can see
the code which gets created in tmp.

Need help if anybody knows kindly reply

With regards
Uday V G


Re: covert perl code to binary

2019-01-13 Thread Uday Vernekar
Nobody is very smart :) so only we want him not to see the code..we tried
bleach as well..one can see the code by replacing end of  first line of
bleached code with print and after executing we can see the code.
On 11-Jan-2019 6:29 pm, "David Mertens"  wrote:

> How dumb is your "nobody"? Would Acme::Bleach do the trick? Or something
> similar?
>
> :)
>
> On Fri, Jan 11, 2019, 5:01 AM Uday Vernekar 
>> Hi all,
>>
>> I have a perl code which I need to covert to binary so that nobody can
>> see the code.
>>
>> we used pp package to make the perl code binary but here the user can see
>> the code which gets created in tmp.
>>
>> Need help if anybody knows kindly reply
>>
>> With regards
>> Uday V G
>>
>


Re: covert perl code to binary

2019-01-17 Thread Uday Vernekar
perlcc has been removed from Perl.
https://www.perlmonks.org/index.pl?node_id=654568
On 11-Jan-2019 6:27 pm, "Andrew Solomon"  wrote:

> Just a warning - I'm no expert on this topic, but it was such an
> interesting question I decided to find out for myself :-)
>
> I installed B::C and ran https://metacpan.org/pod/distribution/B-C/script/
> perlcc.PL
>
> It actually does the compilation - as opposed to pp which is just
> packaging it - so you don't see the perl code of the source file.
>
> Does that resolve your question?
>
> Andrew
>
>
>
> On Fri, Jan 11, 2019 at 9:59 AM Uday Vernekar 
> wrote:
>
>> Hi all,
>>
>> I have a perl code which I need to covert to binary so that nobody can
>> see the code.
>>
>> we used pp package to make the perl code binary but here the user can see
>> the code which gets created in tmp.
>>
>> Need help if anybody knows kindly reply
>>
>> With regards
>> Uday V G
>>
>
>
> --
> Andrew Solomon
>
> Perl Trainer, Geekuni http://geekuni.com/
> and...@geekuni.com // +44 7931 946 062
>