problem with the script in counting
Hi, I have a script which greps for a word in a file contains records. I grabbed a particular column sent the colomn values to a file. I need to find each column value, the times it appeared in the file. My script is: grep sceneority file | cut -f 6 swi I am stuck at how to find the occurance of column values in swi file. Plz help me. Ex: The file has following column values: 123 324 123 123 435 435 The output should be 123 is 3 times 324 is 1 time 435 is 2 times Thanks Regards, Pradeep. Meet people who discuss and share your passions. Go to http://in.promos.yahoo.com/groups/bestofyahoo/
problem with the script in counting
Hi, I have a script which greps for a word in a file contains records.. I grabbed a particular column sent the colomn values to a file. I need to find each column value, the times it appeared in the file. My script is: grep sceneority file | cut -f 6 swi I am stuck at how to find the occurance of column values in swi file. Plz help me. Ex: The file has following column values: 123 324 123 123 435 435 The output should be 123 is 3 times 324 is 1 time 435 is 2 times Thanks Regards, Pradeep. Bollywood, fun, friendship, sports and more. You name it, we have it on http://in.promos.yahoo.com/groups/bestofyahoo/
problem with the script in counting
Hi, I have a script which greps for a word in a file contains records.. I grabbed a particular column sent the colomn values to a file. I need to find each column value, the times it appeared in the file. My script is: grep sceneority file | cut -f 6 swi I am stuck at how to find the occurance of column values in swi file. Plz help me. Ex: The file has following column values: 123 324 123 123 435 435 The output should be 123 is 3 times 324 is 1 time 435 is 2 times Thanks Regards, Pradeep. Share files, take polls, and make new friends - all under one roof. Go to http://in.promos.yahoo.com/groups/
Re: problem with the script in counting
Hi, Thanks for the reply. Can this impletemented in shell script alsso? - Original Message From: Gunnar Hjalmarsson [EMAIL PROTECTED] To: beginners@perl.org Sent: Saturday, 5 April, 2008 3:01:41 PM Subject: Re: problem with the script in counting pradeep reddy wrote: I am stuck at how to find the occurance of column values in swi file. The file has following column values: 123 324 123 123 435 435 The output should be 123 is 3 times 324 is 1 time 435 is 2 times Use a hash. open my $fh, '', 'swi' or die $!; my %cnt; while ($fh) { chomp; $cnt{$_}++; } foreach my $val ( sort keys %cnt ) { print $val is $cnt{$val} times\n; } -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ Explore your hobbies and interests. Go to http://in.promos.yahoo.com/groups/
doubt on time structures
Hello, I used the follwoing code: struct rusage startusage, stopusage; getrusage(RUSAGE_SELF, startusage); getrusage(RUSAGE_SELF, stopusage); cpu_delta_user=((stopusage.ru_utime.tv_sec*100) + stopusage.ru_utime.tv_usec) -(startUsage.ru_utime.tv_sec*100) + startUsage.ru_utime.tv_usec); cpu_delta_sys=((stopusage.ru_stime.tv_sec*100) + stopusage.ru_stime.tv_usec) -((startUsage.ru_stime.tv_sec*100) + startUsage.ru_stime.tv_usec); And the options I used in makefile to compile my code: CFLAGS = -c -Wall -DUNIX -DLINUX -D_GNU_SOURCE -DFLOATING_POINT_SUPPORT=1 - DTHREAD_SAFE -D_REENTRANT -DLINK_AMS -DLINK_DPC -DLINK_DMS -DRW_MUL TI_THREAD -DMMII -include /usr/include/features.h -O2 -I. -I/hap/active/include LFLAGS = -L/hap/active/lib -L/hap/active/goahead/lib/LINUX -L/usr/app/ha/lib -lHapComponent -lGoAhead -llog -lcevm -levl -lha -O0 -lplatformServices But stopusage.ru_utime.tv_sec stopusage.ru_utime.tv_usec...all are giving NULL values. I know this is perl group.But Iam giving my last trial , if I get any help.. -reddy. Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php
Re: perl script execution issue
I did the samewhat you told, this time its says, command not found.The same perl script runs fine on windows environment.But on linux machine its giving this problem.I have few other scripts, which are running fine with this environent both on linux and windows machines. -reddy. - Original Message From: Owen Cook [EMAIL PROTECTED] To: pradeep reddy [EMAIL PROTECTED] Cc: beginners@perl.org Sent: Tuesday, 19 December, 2006 1:29:15 PM Subject: Re: perl script execution issue On Tue, Dec 19, 2006 at 06:18:54AM +, pradeep reddy wrote: Hi, The Perl excutable is located at /usr/bin The script has #!/usr/bin/env perl at the top. I changed the #!/usr/bin/env perl to /usr/bin perl, this time when I run , its giving permission denied.But, I have other scripts, with #!/usr/bin/env perl, these are executing with no issues. You need to make that #!/usr/bin/perl or is that what you had? Owen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php
Re: perl script execution issue
Yes Ruud, I edited it in windows environment, as a text pad format, then I saved it. How can i correct this issue. -reddy. - Original Message From: Dr.Ruud [EMAIL PROTECTED] To: beginners@perl.org Sent: Tuesday, 19 December, 2006 3:32:22 PM Subject: Re: perl script execution issue pradeep reddy schreef: The same perl script runs fine on windows environment. But on linux machine its giving this problem. Did you edit it in a Windows environment? Then a bunch of CRs might have creeped in your script, corrupting your shebang and more. -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php
Re: perl script execution issue
Cook, I run the command what you sent.But still the same problem persists.I cant execute the script in linux machine directly by its name, by i can do it on windows machine.. -reddy. - Original Message From: Owen Cook [EMAIL PROTECTED] To: pradeep reddy [EMAIL PROTECTED] Cc: beginners@perl.org Sent: Tuesday, 19 December, 2006 4:48:39 PM Subject: Re: perl script execution issue On Tue, Dec 19, 2006 at 03:48:49PM +0530, pradeep reddy wrote: Yes Ruud, I edited it in windows environment, as a text pad format, then I saved it. How can i correct this issue. -reddy. At the prompt, type # perl -p -e 's/\r$//' winfile.txt unixfile.txt so if your script is called foo.pl, it is # perl -p -e 's/\r$//' foo.pl newfoo.pl Owen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php
Re: perl script execution issue
Its worked for me now. I run the following command on unix to convert. perl -i -pe 's/\x0d\x0a/\x0a/g' name.pl Thx all for your support. Thx Cook,Krishnan,Ruud. -reddy. - Original Message From: H Krishnan [EMAIL PROTECTED] To: pradeep reddy [EMAIL PROTECTED]; Dr.Ruud [EMAIL PROTECTED] Cc: beginners@perl.org Sent: Tuesday, 19 December, 2006 4:05:09 PM Subject: RE: perl script execution issue hi Reddy, If u open the perl script file using vi editor, r u seeing ^M ? If its the case u can use the dos2unix command and clear that. U may want to check for the permissions for this particular file. - krishnan. -Original Message- From: pradeep reddy [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 19, 2006 3:49 PM To: Dr.Ruud Cc: beginners@perl.org Subject: Re: perl script execution issue Yes Ruud, I edited it in windows environment, as a text pad format, then I saved it. How can i correct this issue. -reddy. - Original Message From: Dr.Ruud [EMAIL PROTECTED] To: beginners@perl.org Sent: Tuesday, 19 December, 2006 3:32:22 PM Subject: Re: perl script execution issue pradeep reddy schreef: The same perl script runs fine on windows environment. But on linux machine its giving this problem. Did you edit it in a Windows environment? Then a bunch of CRs might have creeped in your script, corrupting your shebang and more. -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php
Re: perl script execution issue
Yes, you are right and It works both ways.. -Reddy. - Original Message From: Chad Perrin [EMAIL PROTECTED] To: beginners@perl.org Sent: Wednesday, 20 December, 2006 12:37:00 AM Subject: Re: perl script execution issue On Tue, Dec 19, 2006 at 10:18:39PM +1100, Owen Cook wrote: On Tue, Dec 19, 2006 at 03:48:49PM +0530, pradeep reddy wrote: Yes Ruud, I edited it in windows environment, as a text pad format, then I saved it. How can i correct this issue. -reddy. At the prompt, type # perl -p -e 's/\r$//' winfile.txt unixfile.txt so if your script is called foo.pl, it is # perl -p -e 's/\r$//' foo.pl newfoo.pl I usually just use the dos2unix utility for that. -- CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] It's just incredible that a trillion-synapse computer could actually spend Saturday afternoon watching a football game. - Marvin Minsky -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php
perl script execution issue
Hello all, I have a starnge problem. I have a perl script.Previously I was executing it, by simply giving its name with .pl (pradeep.pl).Recently I made few changes and, from that time, I could not execuite it directly by its name. Now I need to give perl pathname/pradeep.pl to run the script,What would be the issue here.I checked the .cshrc file, but no aliasing was there for this script. Plz let me know, your inputs. -reddy. Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php
Re: perl script execution issue
Hi, Error was: : No such file or directory. I made the changes in the code of script.I did not change any environment variable and any execution path. The script has #!/usr/bin/env perl at the top. -Reddy. - Original Message From: Larry Johnson [EMAIL PROTECTED] To: pradeep reddy [EMAIL PROTECTED] Sent: Tuesday, 19 December, 2006 10:37:21 AM Subject: Re: perl script execution issue We'd need a bit more information to help out here. It would help to have a copy of the script, and a description of the changes you've made. Lacking that, I'd look in two places. First (assuming you're in a Unix environment) is the permissions on the file itself. To run it it needs to be executable. Second would be #! line. If it's damaged, missing, or the location of perl has changed, the script would fail. Could you give a bit more detailed description of your environment, the script, the changes you made, and the error messages? Regards, Larry pradeep reddy [EMAIL PROTECTED] wrote: Hello all, I have a starnge problem. I have a perl script.Previously I was executing it, by simply giving its name with .pl (pradeep.pl).Recently I made few changes and, from that time, I could not execuite it directly by its name. Now I need to give perl Plz let me know, your inputs. -reddy. Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php
Re: perl script execution issue
Hi, The Perl excutable is located at /usr/bin The script has #!/usr/bin/env perl at the top. I changed the #!/usr/bin/env perl to /usr/bin perl, this time when I run , its giving permission denied.But, I have other scripts, with #!/usr/bin/env perl, these are executing with no issues. -reddy. - Original Message From: Owen [EMAIL PROTECTED] To: pradeep reddy [EMAIL PROTECTED] Cc: beginners@perl.org Sent: Tuesday, 19 December, 2006 11:32:17 AM Subject: Re: perl script execution issue On Tue, 19 Dec 2006 10:55:43 +0530 (IST) pradeep reddy [EMAIL PROTECTED] wrote: Hi, Error was: : No such file or directory. I made the changes in the code of script.I did not change any environment variable and any execution path. The script has #!/usr/bin/env perl at the top. Where is the perl executable/binary located. Normally it can be accessed through /usr/bin/perl and I suggest you use that to see if that is the problem Owen Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php
Fw: Reg:need to find the particular pattern in a line and assign to variables.
Hello all, Iam new member to this group and also beginner to PERL. Here is my question,plz let me know your inpus: I have a PERL script which gives error report at the end. Here is the output. cleartool: Error: Unable to create label Pradeep on /vob/rootinclude/paer.c version /main/3. cleartool: Error: Unable to create label Pradeep on /vob/rootinclude/pcme.h version /main/2. I need to grab the two elements between the two quotes. Iam very much beginer to the PERL script. Iam trying this bit of code, not sure how to go on. foreach (@problemLines) { push $outLine,@problemLines; /here Iam trying to get the each line into outLine/ if ($outLine =~ / cleartool: Error: Unable to create label /) {/here Iam trying to match the pattern/ my @values = split(' ',$outline);/Here Iam splitting the outline/ my $pathName = @values[3]; my $Version = @values[5]; cleartool mklabel $RECURSE $REPLACE -version $Version $labelName $pathName; /This is the comand Iam using/ print $_\n; } Here Version should get version of the elements label and pathName should get /vob/root/include/pcme.h If I use foreach, will it automatically go to next error line, otherwsie do I need to use forloop. Plz let me now your answers. Thanks Regards, Pradeep. Find out what India is talking about on - Yahoo! Answers India Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get it NOW __ Yahoo! India Answers: Share what you know. Learn something new http://in.answers.yahoo.com/
Re: Fw: Reg:need to find the particular pattern in a line and assign to variables.
John, Thx for your inputs. 1st i/p: Iam afraid, I cant read each line from array problemLines to outLine. 2nd i/p: =~ /([^]+)/g;--What is the logic in this expression? Can u bit ellaborate. I wanted to read the values in double quotes, from each line. And , Iam using this logic ---if ($outLine =~ / cleartool: Error: Unable to create label /) , to check for the patten in part of line..Is this correct? Thanks Regards, Pradeep. - Original Message From: John W. Krahn [EMAIL PROTECTED] To: Perl Beginners beginners@perl.org Sent: Wednesday, 25 October, 2006 12:11:02 PM Subject: Re: Fw: Reg:need to find the particular pattern in a line and assign to variables. pradeep reddy wrote: Hello all, Hello, Iam new member to this group and also beginner to PERL. Here is my question,plz let me know your inpus: I have a PERL script which gives error report at the end. Here is the output. cleartool: Error: Unable to create label Pradeep on /vob/rootinclude/paer.c version /main/3. cleartool: Error: Unable to create label Pradeep on /vob/rootinclude/pcme.h version /main/2. I need to grab the two elements between the two quotes. Iam very much beginer to the PERL script. Iam trying this bit of code, not sure how to go on. foreach (@problemLines) { push $outLine,@problemLines; /here Iam trying to get the each line into outLine/ The first argument to push() must be an array so that will not work. if ($outLine =~ / cleartool: Error: Unable to create label /) {/here Iam trying to match the pattern/ my @values = split(' ',$outline);/Here Iam splitting the outline/ my $pathName = @values[3]; my $Version = @values[5]; cleartool mklabel $RECURSE $REPLACE -version $Version $labelName $pathName; /This is the comand Iam using/ print $_\n; } You probably want something like this: my ( $labelName, $pathName, $Version ) = $outline =~ /([^]+)/g; John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response __ Yahoo! India Answers: Share what you know. Learn something new http://in.answers.yahoo.com/
Re: Fw: Reg:need to find the particular pattern in a line and assign to variables.
Hello, This is code I used and it executed in a wanted way. foreach $outLine(@problemLines) { if ($outLine =~ cleartool: Error: Unable to create label ) { my @values = split('',$outline); my @label = @values[1]; my $pathName = @values[3]; my $Version = @values[5]; cleartool mklabel $RECURSE $REPLACE -version $Version $label $pathName; } Anyways, as per Bolliger's i/p I with try to use $_ instead of with outLine varible. Thx PERL team. -Pradeep. - Original Message From: D. Bolliger [EMAIL PROTECTED] To: beginners@perl.org Sent: Wednesday, 25 October, 2006 4:36:10 PM Subject: Re: Fw: Reg:need to find the particular pattern in a line and assign to variables. pradeep reddy am Mittwoch, 25. Oktober 2006 09:02: John, Thx for your inputs. 1st i/p: Hello please don't top post so the discussion can be followed easily. Iam afraid, I cant read each line from array problemLines to outLine. You don't show how you modified your code after John's advice. foreach (@problemLines) { # for all lines do: # handle the current line in $_ # [no need for the $outLine variable] } 2nd i/p: =~ /([^]+)/g;--What is the logic in this expression? Can u bit ellaborate. I wanted to read the values in double quotes, from each line. It does what you want: Extract (by capturing with ()) all (/g) strings ([^]+) between two double quotes (/snip/). Look at the documentation (from command line): perldoc perlre And , Iam using this logic ---if ($outLine =~ / cleartool: Error: Unable to create label /) , to check for the patten in part of line..Is this correct? Spaces are relevant. According to your output below, there is no space before cleartool. To check if it's correct, simply try it and look at the result. Hope this helps! Dani [Original question JWK's 1st answer:] - Original Message From: John W. Krahn [EMAIL PROTECTED] To: Perl Beginners beginners@perl.org Sent: Wednesday, 25 October, 2006 12:11:02 PM Subject: Re: Fw: Reg:need to find the particular pattern in a line and assign to variables. pradeep reddy wrote: Hello all, Hello, Iam new member to this group and also beginner to PERL. Here is my question,plz let me know your inpus: I have a PERL script which gives error report at the end. Here is the output. cleartool: Error: Unable to create label Pradeep on /vob/rootinclude/paer.c version /main/3. cleartool: Error: Unable to create label Pradeep on /vob/rootinclude/pcme.h version /main/2. I need to grab the two elements between the two quotes. Iam very much beginer to the PERL script. Iam trying this bit of code, not sure how to go on. foreach (@problemLines) { push $outLine,@problemLines; /here Iam trying to get the each line into outLine/ The first argument to push() must be an array so that will not work. if ($outLine =~ / cleartool: Error: Unable to create label /) { /here Iam trying to match the pattern/ my @values = split(' ',$outline);/Here Iam splitting the outline/ my $pathName = @values[3]; my $Version = @values[5]; cleartool mklabel $RECURSE $REPLACE -version $Version $labelName $pathName; /This is the comand Iam using/ print $_\n; } You probably want something like this: my ( $labelName, $pathName, $Version ) = $outline =~ /([^]+)/g; John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response __ Yahoo! India Answers: Share what you know. Learn something new http://in.answers.yahoo.com/
Re: Multi dimension arrays
hi, You can simulate multi-dimensional arrays using references. For information about references see 'perlreftut' and 'perlref' manpages. eg. @array = ( [ hello,world]; [ quick,brown]; ); is a two dimentional array. if you want to access hello $array[0]-[0] of course threre are other ways. 'There's more than one way to do it.' --Programming Perl pradeep. On Mon, 3 Sep 2001, Gordon Barr wrote: Is there a way of handling these in perl? (I am converting some programs from UNIX awk that make extensive use of this feature). Any advice would be much appreciated. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: References? (fwd)
hi Bert de Jong, Basically references are like pointers in C (of course there are subtle differences). eg .In perl. |In C (int var , *ptr); $variable = hello world;|var = 12345; $reference = \$variable|ptr = var $reference is a pointer to $variable. To access hello world 1. $variable ( the way you are familiar ); 2. $$reference (pointer notation for scalars); I think this will give you a basic idea. If you want to learn more on references. you can see perlreftut manpage. pradeep. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Where are the printf function formatting options / rules? (fwd)
Hi Nathan, Your message delivered to right box. You can access manpages just by typing man perl on the command line. Then you will see some 80 odd man pages. Now you can go to whatever manpage you want. eg. for printf function you can go to perlfunctions man page. man perlfunc now search for printf.(type /printf) Thanks, pradeep. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]