<?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 Programming question . in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-programming-question/m-p/3484130#M213770</link>
    <description>Yes, just as in awk the function is called split. Man perlfunc for details.&lt;BR /&gt;&lt;BR /&gt;Here's a snippet that will do what you are trying to do with your awk:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl -w&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;&lt;BR /&gt;my @list = `ls -la /dev/vg00`;&lt;BR /&gt;chomp(@list);&lt;BR /&gt;my $i = 0;&lt;BR /&gt;while ($i &amp;lt;= $#list)&lt;BR /&gt;  {&lt;BR /&gt;    my @array = split /\s+/,$list[$i];&lt;BR /&gt;    if ($#array &amp;gt; 5)&lt;BR /&gt;      {&lt;BR /&gt;        printf("%s %s\n",$array[5],$array[$#array]);&lt;BR /&gt;      }&lt;BR /&gt;    ++$i;&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;This could have been written far more tersely but I intentionally do it step by step for clarity. Note the use of $#array to yield the maximum allowed subscript of @array. \s+ says grab all the white space.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 11 Feb 2005 17:35:35 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2005-02-11T17:35:35Z</dc:date>
    <item>
      <title>PERL Programming question .</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-programming-question/m-p/3484129#M213769</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I am new to PERL . Trying to script something .&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;@list=`ls -al /dev/vg00'&lt;BR /&gt;&lt;BR /&gt;now my array element is &lt;BR /&gt;crw-r-----   1 root       sys         64 0x000000 Aug 15  2004 /dev/vg00/group &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I do not want to store all the info, what I need is minor number and VG name .&lt;BR /&gt;&lt;BR /&gt;I tried to include awk , like this&lt;BR /&gt;&lt;BR /&gt;@list=`ls -ld /dev/vg00|awk '{print $6,$NF}'`;&lt;BR /&gt;&lt;BR /&gt;But Perl is giving compilation error , &lt;BR /&gt;&lt;BR /&gt;I there any function to split the array element (similar we achive with awk )&lt;BR /&gt;&lt;BR /&gt;substr function will not work for me , since all array elements do not have same size ...&lt;BR /&gt;&lt;BR /&gt;Please reply ,&lt;BR /&gt;Thanks in advance,&lt;BR /&gt;BL.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 11 Feb 2005 17:06:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-programming-question/m-p/3484129#M213769</guid>
      <dc:creator>baiju_3</dc:creator>
      <dc:date>2005-02-11T17:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: PERL Programming question .</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-programming-question/m-p/3484130#M213770</link>
      <description>Yes, just as in awk the function is called split. Man perlfunc for details.&lt;BR /&gt;&lt;BR /&gt;Here's a snippet that will do what you are trying to do with your awk:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl -w&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;&lt;BR /&gt;my @list = `ls -la /dev/vg00`;&lt;BR /&gt;chomp(@list);&lt;BR /&gt;my $i = 0;&lt;BR /&gt;while ($i &amp;lt;= $#list)&lt;BR /&gt;  {&lt;BR /&gt;    my @array = split /\s+/,$list[$i];&lt;BR /&gt;    if ($#array &amp;gt; 5)&lt;BR /&gt;      {&lt;BR /&gt;        printf("%s %s\n",$array[5],$array[$#array]);&lt;BR /&gt;      }&lt;BR /&gt;    ++$i;&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;This could have been written far more tersely but I intentionally do it step by step for clarity. Note the use of $#array to yield the maximum allowed subscript of @array. \s+ says grab all the white space.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 11 Feb 2005 17:35:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-programming-question/m-p/3484130#M213770</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-02-11T17:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: PERL Programming question .</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-programming-question/m-p/3484131#M213771</link>
      <description>One thing that I should add is that Perl arrays are zero-based rather than awk's which are 1-based.</description>
      <pubDate>Fri, 11 Feb 2005 17:37:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-programming-question/m-p/3484131#M213771</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-02-11T17:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: PERL Programming question .</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-programming-question/m-p/3484132#M213772</link>
      <description>Try something like:&lt;BR /&gt;&lt;BR /&gt;(undef, undef, undef, undef, undef, $minornum, undef, undef, undef, $vgname) = qw(`ls -al /dev/vg00`);&lt;BR /&gt;&lt;BR /&gt;I think you will need the 'qw' to break out each element.&lt;BR /&gt;&lt;BR /&gt;Also, I believe there are perl built-in functions that can do this for you. I don't have my docs in front of me, but take a look at functions related to stat. I have  used stat to get time stamps  on files;&lt;BR /&gt;&lt;BR /&gt;$time = (stat($file))[8]; &lt;BR /&gt;&lt;BR /&gt;so it would be something like;&lt;BR /&gt;&lt;BR /&gt;($minornum, $vgname) = (stat(/dev/vg00/group))[7,9];&lt;BR /&gt;&lt;BR /&gt;or even;&lt;BR /&gt;&lt;BR /&gt;(undef, undef, undef, undef, undef, $minornum, undef, undef, undef, $vgname) = stat(/dev/vg00/group);&lt;BR /&gt;&lt;BR /&gt;The elements of stat are  not isn the same order  as 'ls  -l' so you will need to look at that.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;David</description>
      <pubDate>Fri, 11 Feb 2005 17:38:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-programming-question/m-p/3484132#M213772</guid>
      <dc:creator>David Child_1</dc:creator>
      <dc:date>2005-02-11T17:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: PERL Programming question .</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-programming-question/m-p/3484133#M213773</link>
      <description>While I'm at it, I'll go ahead and show you what was wrong with your awk approach:&lt;BR /&gt;&lt;BR /&gt;@list=`ls -la /dev/vg00|awk '{print \$6,\$NF}'`;&lt;BR /&gt;&lt;BR /&gt;You just needed to escape the $6 and $NF so that Perl would leave them alone.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 11 Feb 2005 17:50:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-programming-question/m-p/3484133#M213773</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-02-11T17:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: PERL Programming question .</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-programming-question/m-p/3484134#M213774</link>
      <description>still using 'awk' in perl is pretty pointless, you might just as well write a shell script in that case...</description>
      <pubDate>Mon, 14 Feb 2005 02:31:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-programming-question/m-p/3484134#M213774</guid>
      <dc:creator>dirk dierickx</dc:creator>
      <dc:date>2005-02-14T02:31:10Z</dc:date>
    </item>
  </channel>
</rss>

