- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: optimization required for this perl script(tak...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-10-2005 06:25 PM
тАО08-10-2005 06:25 PM
while ($x=
chomp($x);
@y=split(/\|/,$x);
$value=@y[12];
$x=@y[5];
$y=@y[11];
$z=@y[10];
if ($value !=0)
{
@A=(@A,$x*$value*100);
}
if ($value==0)
{
@A=(@A,$y*$z*100);
}
}
close INP;
$i=0;
while ($i <@A)
{
print $A[$i], "\n";
$i++;
if ($A[$i]< 0){$a++}
if (($A[$i] >=0)&& ($A[$i] <10)) {$b++}
elsif (($A[$i] >=10)&&($A[$i] < 20)) {$c++}
elsif (($A[$i]>= 20)&&($A[$i]< 30)) {$d++}
elsif (($A[$i] >= 30)&&($A[$i]< 40)) {$e++}
elsif (($A[$i]>= 40)&&($A[$i]< 50)) {$f++}
elsif ($A[$i]>= 50) {$g++}
}
printf("Transaction amount frequency Less Than 0 = %d\n",$a);
printf("Transaction amount frequency between [0-9] = %d\n",$b);
printf("Transaction amount frequency between [10-19] = %d\n",$c);
printf("Transaction amount frequency between [20-29] = %d\n",$d);
printf("Transaction amount frequency between [30-39] = %d\n",$e);
printf("Transaction amount frequency between [40-49] = %d\n",$f);
printf("Transaction amount frequency between 50 and above = %d\n",$g);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-10-2005 07:51 PM
тАО08-10-2005 07:51 PM
Re: optimization required for this perl script(taking long time to execute) for huge data file.
I am suggesting few ways as,
a) Don't use elif. Use if directly to that.
b) $value=@y[12];
$x=@y[5];
$y=@y[11];
$z=@y[10];
instead use,
($value,$x,$y,$z)=@y[12,5,11,10];
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-10-2005 07:52 PM
тАО08-10-2005 07:52 PM
Re: optimization required for this perl script(taking long time to execute) for huge data file.
> if ($value !=0)
> {
> @A=(@A,$x*$value*100);
> }
> if ($value==0)
> {
> @A=(@A,$y*$z*100);
> }
with
push @A, (($value==0)?$y*$z*100:$x*$value*100);
also
use
@y=split(/\|/,$x,13); # don't split it into more than 13 parts, if you're only interested up to the 12th element
Again some details about the file would be useful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-10-2005 08:26 PM
тАО08-10-2005 08:26 PM
Solution==============
#
open INP, "testupc.txt " or die "testcpnnew.txt: $!";
while (chomp(
($x,$z,$y,$value)=(split (/\|/))[5,10,11,12];
push @A, (($value==0)?$y*$z*100:$x*$value*100);
}
close INP;
my $i=0;
while ($i < @A)
{
$var=$A[$i];
if ($var< 0){$a++}
if (($var >=0)&& ($var <10)) {$b++}
if (($var >=10)&&($var < 20)) {$c++}
if (($var>= 20)&&($var< 30)) {$d++}
if (($var >= 30)&&($var< 40)) {$e++}
if (($var>= 40)&&($var< 50)) {$f++}
if ($var>= 50) {$g++}
print $A[$i++], "\n";
}
printf("Transaction amount frequency Less Than 0 = %d\n",$a);
printf("Transaction amount frequency between [0-9] = %d\n",$b);
printf("Transaction amount frequency between [10-19] = %d\n",$c);
printf("Transaction amount frequency between [20-29] = %d\n",$d);
printf("Transaction amount frequency between [30-39] = %d\n",$e);
printf("Transaction amount frequency between [40-49] = %d\n",$f);
printf("Transaction amount frequency between 50 and above = %d\n",$g);
#
PS: Post your input and required output to give suitable script more.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-16-2005 05:55 PM
тАО08-16-2005 05:55 PM
Re: optimization required for this perl script(taking long time to execute) for huge data file.
Great Thanks in Advance,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2005 03:00 AM
тАО08-17-2005 03:00 AM
Re: optimization required for this perl script(taking long time to execute) for huge data file.
HTH
Rod Hills
open INP, "testupc.txt " or die "testcpnnew.txt: $!";
while (chomp(
($x,$z,$y,$value)=(split (/\|/))[5,10,11,12];
$var=($value==0)?$y*$z*100:$x*$value*100);
print $var,"\n";
if ($var < 0) { $cnt[0]++; }
else {
$inx=($var>=0)+($var>=10)+($var>=20)+($var>=30)+($var>=40)+($var>=50);
$cnt[$inx]++;
}
}
close INP;
for $rng (0..6) {
if ($rng < 0) { $msg="Less Than 0";}
elsif ($rng == 6) { $msg="between 50 and above"; }
else { $msg=sprintf("between [%2.2d-%2.2d]",10*$rng-10,10*$rng-1); }
printf("Transaction amount frequency %20s = %d\n",$cnt[$i]);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2005 03:05 AM
тАО08-17-2005 03:05 AM
Re: optimization required for this perl script(taking long time to execute) for huge data file.
if ($rng < 0) { $msg="Less Than 0";}
should be
if ($rng == 0) { $msg="Less Than 0";}
Rod Hills