<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Perl script help required in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092759#M310556</link>
    <description>@ All,&lt;BR /&gt;&lt;BR /&gt;Thanks for your overwhelming response ,&lt;BR /&gt;&lt;BR /&gt;with your inputs I managed to extract data from the file. I see there are numerous ways to perform a single task in Perl especcially.&lt;BR /&gt;&lt;BR /&gt;I used James script to perform my task. &lt;BR /&gt;&lt;BR /&gt;Heins is also very similar but contains some added  info , Will come in handy in future too. &lt;BR /&gt;&lt;BR /&gt;I am new to perl. Are there any documented material for perl especially for generating &lt;BR /&gt;reports extracting data from file etc&lt;BR /&gt;&lt;BR /&gt;Am sure this will get into my brain by practice and doing more of scripting only.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Akram</description>
    <pubDate>Sat, 27 Oct 2007 03:51:04 GMT</pubDate>
    <dc:creator>Akram Shaik</dc:creator>
    <dc:date>2007-10-27T03:51:04Z</dc:date>
    <item>
      <title>Perl script help required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092746#M310543</link>
      <description>Hi all ,&lt;BR /&gt;&lt;BR /&gt;I am reading some contents from a file &lt;BR /&gt;&lt;BR /&gt;File contains the following data &lt;BR /&gt;lvdata   20000  /ora/data&lt;BR /&gt;lvappl   2048   /ora/appl&lt;BR /&gt;lvcs     1024   /ora/scs&lt;BR /&gt;lvora    2048   /ora&lt;BR /&gt;&lt;BR /&gt;I want to store the lvinfo in an array variable,&lt;BR /&gt;the LV size in another array variable and the FS in another array variable.&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;I am not able to do that using perl. I am beginner in perl . Kindly let me know if this is possible and how .&lt;BR /&gt;&lt;BR /&gt;Thanks for all .&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Akram&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Oct 2007 09:19:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092746#M310543</guid>
      <dc:creator>Akram Shaik</dc:creator>
      <dc:date>2007-10-26T09:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092747#M310544</link>
      <description>#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;my @lv;&lt;BR /&gt;my @lvsize;&lt;BR /&gt;my @fs;&lt;BR /&gt;&lt;BR /&gt;open(MYFILE,"xxxxxxxx") #where xxx is file name.&lt;BR /&gt;my @fh=&lt;MYFILE&gt;;&lt;BR /&gt;foreach(@fh) {&lt;BR /&gt;    my ($lv,$lvsize,$fs)=split(/ /,$_);&lt;BR /&gt;     push(@lv,$lv);&lt;BR /&gt;     push(@lvsize,$lvsize);&lt;BR /&gt;     push(@fs,$fs);&lt;BR /&gt;}&lt;BR /&gt;print "The following is the lvinfo:\n";&lt;BR /&gt;print "@lv\n";&lt;BR /&gt;print "The following is the lvsize:\n";&lt;BR /&gt;print "@lvsize\n";&lt;BR /&gt;print "The following is the fs:\n"&lt;BR /&gt;print "@fs\n";&lt;BR /&gt;&lt;BR /&gt;hope this helps.&lt;/MYFILE&gt;</description>
      <pubDate>Fri, 26 Oct 2007 09:34:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092747#M310544</guid>
      <dc:creator>David Bellamy</dc:creator>
      <dc:date>2007-10-26T09:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092748#M310545</link>
      <description>Akram,&lt;BR /&gt;&lt;BR /&gt;There are MANY ways to do this.&lt;BR /&gt;The best way depends on the actual problem you are trying to solve.&lt;BR /&gt;&lt;BR /&gt;I suspect you do not really want 3 arrays as suggested but possibly just 2 keyed by the third such that you can use a variable like: $size{'lvappl')&lt;BR /&gt;&lt;BR /&gt;Still, here is an example answerring your question:&lt;BR /&gt;&lt;BR /&gt;$ cat &amp;gt; x&lt;BR /&gt;lvdata 20000 /ora/data&lt;BR /&gt;lvappl 2048 /ora/appl&lt;BR /&gt;lvcs 1024 /ora/scs&lt;BR /&gt;lvora 2048 /ora&lt;BR /&gt;$ perl -lne '($lv[$.],$size[$.],$fs[$.]) = split}{ print $size[3]' x&lt;BR /&gt;1024&lt;BR /&gt;&lt;BR /&gt;what this does is use the implied loop with -n.&lt;BR /&gt;Each record is split (on spaces) and the result placed in three (undeclared) array @lv, @size and @fs, using the input file line number as index.&lt;BR /&gt;&lt;BR /&gt;the '}{' (eskimo kiss) closes the implied input loop and opens the end processing which, as an example just prints the size for line 3.&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Oct 2007 09:35:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092748#M310545</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-10-26T09:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092749#M310546</link>
      <description>&lt;!--!*#--&gt;TIMTOWTDI&lt;BR /&gt;&lt;BR /&gt;one possible way:&lt;BR /&gt;&lt;BR /&gt;map {chomp;push @lv,$_-&amp;gt;[0];push @sz,$_-&amp;gt;[1];push @fs,$_-&amp;gt;[2]}&lt;BR /&gt;        map [m|([-\w]+)\s+(\d+)\s+([-\w./]+)|], &lt;DATA&gt;;&lt;BR /&gt; &lt;BR /&gt;__DATA__&lt;BR /&gt;lvdata 20000 /ora/data&lt;BR /&gt;lvappl 2048 /ora/appl&lt;BR /&gt;lvcs 1024 /ora/scs&lt;BR /&gt;lvora 2048 /ora&lt;BR /&gt;&lt;/DATA&gt;</description>
      <pubDate>Fri, 26 Oct 2007 09:42:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092749#M310546</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2007-10-26T09:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092750#M310547</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;For fun, in the spirit of TMTOWTDI, using your data in 'file' as input, the following will print the array of sizes digested:&lt;BR /&gt;&lt;BR /&gt;# perl -nle '@a=split;for ($i=0;$i&amp;lt;=$#a;$i++) {push @{$list{$i}},$a[$i]};END{print "@{$list{1}}"}' file&lt;BR /&gt;&lt;BR /&gt;...returns:&lt;BR /&gt;&lt;BR /&gt;20000 2048 1024 2048&lt;BR /&gt;&lt;BR /&gt;This uses a hash of arrays.  Each hash element is keyed by the field number of the split line read.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Oct 2007 10:29:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092750#M310547</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-10-26T10:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092751#M310548</link>
      <description>@David ,&lt;BR /&gt;&lt;BR /&gt;I tried your &lt;BR /&gt;Global symbol "@fh" requires explicit package name at ./scr4 line 10&lt;BR /&gt;&lt;BR /&gt;@Hein,&lt;BR /&gt;&lt;BR /&gt;as suggested by you I tried the command from command line , well it worked fine.&lt;BR /&gt;&lt;BR /&gt;I guess I need to explain out my requirement a bit more clear,&lt;BR /&gt;&lt;BR /&gt;1. Read the file which contains the data&lt;BR /&gt;2. First field will be stored in one array variable, second in another and so on.&lt;BR /&gt;3. I should be able to call the array variable @LVNAME say I need $LVNAME[1] whenever required,&lt;BR /&gt;&lt;BR /&gt;Hein , is it possible to call the array @lv,&lt;BR /&gt;inside a script.&lt;BR /&gt;I dont want to print it as such &lt;BR /&gt;&lt;BR /&gt;Thanks all for your valuable suggestions&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;Akram&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Oct 2007 11:07:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092751#M310548</guid>
      <dc:creator>Akram Shaik</dc:creator>
      <dc:date>2007-10-26T11:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092752#M310549</link>
      <description>&amp;gt;&amp;gt;&amp;gt; I tried your &lt;BR /&gt;Global symbol "@fh" requires explicit package name at ./scr4 line 10&lt;BR /&gt;&lt;BR /&gt;It's just a minor typo in line 9 (not 10).&lt;BR /&gt;A missing semicolon.&lt;BR /&gt;There is an other missing semi at a print line around line 20.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; 1. Read the file which contains the data&lt;BR /&gt;Done already!&lt;BR /&gt;&amp;gt; 2. First field will be stored in one array variable, second in another and so on.&lt;BR /&gt;Done already!&lt;BR /&gt;&lt;BR /&gt;&amp;gt; 3. I should be able to call the array variable @LVNAME say I need $LVNAME[1] whenever required,&lt;BR /&gt;&lt;BR /&gt;Done already... with a different name.&lt;BR /&gt;@xyz is an array in perl&lt;BR /&gt;@xyz[n] is element n in that array.&lt;BR /&gt;$xyz[n] is the preferred way to refer to that same element n.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; Hein , is it possible to call the array @lv,&lt;BR /&gt;&lt;BR /&gt;Sure... check this...&lt;BR /&gt;&lt;BR /&gt;$ perl -lne '($lv[$i],$size[$i],$fs[$i]) = split; $i++}{ print join qq(\n),@lv' x&lt;BR /&gt;lvdata&lt;BR /&gt;lvappl&lt;BR /&gt;lvcs&lt;BR /&gt;lvora&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;btw.. I replaced $. by a self-maintained $i, in case you need to skip some input lines.&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Oct 2007 12:00:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092752#M310549</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-10-26T12:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092753#M310550</link>
      <description>Hi&lt;BR /&gt;Again all commands work awesome on the command line , and prints the content ,&lt;BR /&gt;&lt;BR /&gt;But I need to add these in script and every field in the file contained an array variable :-( . I am not able to do that with the same options given by all in a script file .&lt;BR /&gt;&lt;BR /&gt;The following does not work &lt;BR /&gt;&lt;BR /&gt;open(DATA,/test3/paramfile)&lt;BR /&gt;map {&lt;BR /&gt;chomp;&lt;BR /&gt;push @lv,$_-&amp;gt;[0];&lt;BR /&gt;push @sz,$_-&amp;gt;[1];&lt;BR /&gt;push @fs,$_-&amp;gt;[2]&lt;BR /&gt;}&lt;BR /&gt;map [m|([-\w]+)\s+(\d+)\s+([-\w./]+)|],&lt;DATA&gt;;&lt;BR /&gt;print @lv;&lt;BR /&gt;print @sz;&lt;BR /&gt;print @fs;&lt;BR /&gt;&lt;BR /&gt;Prints me nothing..&lt;BR /&gt;&lt;BR /&gt;and &lt;BR /&gt;&lt;BR /&gt;open(DATA,/test3/paramfile)&lt;BR /&gt;@a=split &lt;DATA&gt;;&lt;BR /&gt;for($i=0;$i&amp;lt;=$#a;$i++)&lt;BR /&gt;{&lt;BR /&gt;push @{$list{$i}},$a[$i]};END{print "@{$list{1}}"}&lt;BR /&gt;&lt;BR /&gt;Gives me error of course. Please correct if I am doing something bad.&lt;BR /&gt;&lt;BR /&gt;Thanks again&lt;/DATA&gt;&lt;/DATA&gt;</description>
      <pubDate>Fri, 26 Oct 2007 12:13:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092753#M310550</guid>
      <dc:creator>Akram Shaik</dc:creator>
      <dc:date>2007-10-26T12:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092754#M310551</link>
      <description>&lt;!--!*#--&gt;Hi Akram:&lt;BR /&gt;&lt;BR /&gt;Your 'open' statement is incorrect and you are missing semicolons after statements.  Re-working the commandline into a script might look like this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $i;&lt;BR /&gt;my @a;&lt;BR /&gt;my %list;&lt;BR /&gt;my $file = "/test3/paramfile";&lt;BR /&gt;&lt;BR /&gt;open( DATA, "&amp;lt;", $file ) or die "Error: Can't open $file\n";&lt;BR /&gt;&lt;BR /&gt;while (&lt;DATA&gt;) {&lt;BR /&gt;    @a = split;&lt;BR /&gt;    for ( $i = 0 ; $i &amp;lt;= $#a ; $i++ ) {&lt;BR /&gt;        push @{ $list{$i} }, $a[$i];&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;print "sizes = @{$list{1}}\n";&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;You should always use the 'strict' and 'warnings' pragma for other than commandline scripts!  You will save yourself countless hours of chasing stupid mistakes.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/DATA&gt;</description>
      <pubDate>Fri, 26 Oct 2007 12:39:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092754#M310551</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-10-26T12:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092755#M310552</link>
      <description>Hi (again) Akram:&lt;BR /&gt;&lt;BR /&gt;By the way, I would limit the use of a file handle named "DATA" or "END" to the file handle for data stored within a script, like Ralph used:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;while (&lt;DATA&gt;) {&lt;BR /&gt;    print;&lt;BR /&gt;}&lt;BR /&gt;__DATA__&lt;BR /&gt;line-1&lt;BR /&gt;line-2&lt;BR /&gt;line-3&lt;BR /&gt;&lt;BR /&gt;Note the actual datafile delimiter token begins and ends with two underscore ("_") characters whereas the file handle is the simple token DATA.&lt;BR /&gt;&lt;BR /&gt;A common package name for a file handle is FH, so I would have sritten:&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;my $file = "/home/jrf/myfile";&lt;BR /&gt;open( FH, "&amp;lt;", $file ) or die "Error: Can't open $file\n";&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/DATA&gt;</description>
      <pubDate>Fri, 26 Oct 2007 13:10:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092755#M310552</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-10-26T13:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092756#M310553</link>
      <description>&lt;!--!*#--&gt;&amp;gt;&amp;gt; But I need to add these in script and every field in the file contained an array variable :-( . &lt;BR /&gt;&lt;BR /&gt;Array in a shell script calling perl, or just an array in perl?&lt;BR /&gt;&lt;BR /&gt;Of course I agree 100% with FRF that for anything beyond a one-liner, you need to do perl 'properly' making things slear, and obvious and checked.&lt;BR /&gt;&lt;BR /&gt;My simple command line, but now as script might looks like:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my (@lv, @size, @fs);&lt;BR /&gt;my $i=0;&lt;BR /&gt;#&lt;BR /&gt;# Read in all data lines from STDIN or first file mentioned.&lt;BR /&gt;#&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;  ($lv[$i], $size[$i], $fs[$i]) = split;&lt;BR /&gt;  $i++;&lt;BR /&gt;  }&lt;BR /&gt;#&lt;BR /&gt;# Now all data is in the arrays.&lt;BR /&gt;# Let's prove we can use it there with&lt;BR /&gt;# a silly exercise to report object in order of descending size.&lt;BR /&gt;#&lt;BR /&gt;foreach $i (sort { $size[$b] &amp;lt;=&amp;gt; $size[$a] } 0..@size-1) {&lt;BR /&gt;   printf qq(%d, %9d %-10s %-20s\n), $i, $size[$i], $lv[$i], $fs[$i];&lt;BR /&gt;   }&lt;BR /&gt;&lt;BR /&gt;0..@size-1 : this generates a list from 0 to the size of the array minus one, this iterting over all elements.&lt;BR /&gt;&lt;BR /&gt;Yes, I could alsso have written:&lt;BR /&gt;my $max_elements = @size - 1;&lt;BR /&gt;or even exploit the fact tht we counted in $i:&lt;BR /&gt;my $max_elements = --$i;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sort {xxx} : sort using function described with xxx, where $a and $b are available as the things to compare&lt;BR /&gt;foreach $i (sort { $size[$b] &amp;lt;=&amp;gt; $size[$a] } &lt;BR /&gt;&lt;BR /&gt;Here xxx :  $size[$b] &amp;lt;=&amp;gt; $size[$a] &lt;BR /&gt;So it does not compare the element numbers, but the value of the array elements pointed to.&lt;BR /&gt;&lt;BR /&gt;Clear as mud?&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Oct 2007 13:15:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092756#M310553</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-10-26T13:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092757#M310554</link>
      <description>Hi James ,&lt;BR /&gt;&lt;BR /&gt;Your re worked script display the following &lt;BR /&gt;&lt;BR /&gt;sizes = 20000 2048 1024 2048&lt;BR /&gt;&lt;BR /&gt;But what I am looking for is  :&lt;BR /&gt;&lt;BR /&gt;How will I print/call the  value 20000 only or 2048 only ,&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Oct 2007 13:28:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092757#M310554</guid>
      <dc:creator>Akram Shaik</dc:creator>
      <dc:date>2007-10-26T13:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092758#M310555</link>
      <description>&lt;!--!*#--&gt;Hi (again) Akram:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; How will I print/call the value 20000 only or 2048 only?&lt;BR /&gt;&lt;BR /&gt;Searching for something is often best solved with a hash (or an "associative array" if you are accustomed to thinking in 'awk').  Consider:&lt;BR /&gt;&lt;BR /&gt;# cat ./findit&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my ( $i, $size );&lt;BR /&gt;my @a;&lt;BR /&gt;my %list;&lt;BR /&gt;die "Usage: $0 size file\n" unless $#ARGV+1 &amp;gt;= 2;&lt;BR /&gt;$size = shift;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    @a = split;&lt;BR /&gt;    push @{ $list{ $a[1] } }, $a[0] . ":" . $a[2];&lt;BR /&gt;}&lt;BR /&gt;print "size = $size:\n";&lt;BR /&gt;print "\t$_\n" for @{ $list{$size} };&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...Using your original file as data, do:&lt;BR /&gt;&lt;BR /&gt;# ./findit 2048 myfile&lt;BR /&gt;size = 2048:&lt;BR /&gt;        lvappl:/ora/appl&lt;BR /&gt;        lvora:/ora&lt;BR /&gt;&lt;BR /&gt;# ./findit 20000 myfile&lt;BR /&gt;size = 20000:&lt;BR /&gt;        lvdata:/ora/data&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 26 Oct 2007 16:36:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092758#M310555</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-10-26T16:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092759#M310556</link>
      <description>@ All,&lt;BR /&gt;&lt;BR /&gt;Thanks for your overwhelming response ,&lt;BR /&gt;&lt;BR /&gt;with your inputs I managed to extract data from the file. I see there are numerous ways to perform a single task in Perl especcially.&lt;BR /&gt;&lt;BR /&gt;I used James script to perform my task. &lt;BR /&gt;&lt;BR /&gt;Heins is also very similar but contains some added  info , Will come in handy in future too. &lt;BR /&gt;&lt;BR /&gt;I am new to perl. Are there any documented material for perl especially for generating &lt;BR /&gt;reports extracting data from file etc&lt;BR /&gt;&lt;BR /&gt;Am sure this will get into my brain by practice and doing more of scripting only.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Akram</description>
      <pubDate>Sat, 27 Oct 2007 03:51:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-required/m-p/4092759#M310556</guid>
      <dc:creator>Akram Shaik</dc:creator>
      <dc:date>2007-10-27T03:51:04Z</dc:date>
    </item>
  </channel>
</rss>

