<?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: scripting questions in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092174#M806683</link>
    <description>my $path = "/oracle/datafile/arclogs";&lt;BR /&gt;my @p = ($path =~ m{(/[^/]*)}g);&lt;BR /&gt; &lt;BR /&gt;lt09:/home/merijn 101 &amp;gt; perl -le'$path=shift;@p=($path=~m{(/[^/]*)}g);print for@p' /oracle/datafile/arclogs:&lt;BR /&gt;/oracle&lt;BR /&gt;/datafile&lt;BR /&gt;/arclogs:&lt;BR /&gt;lt09:/home/merijn 102 &amp;gt;&lt;BR /&gt; &lt;BR /&gt;Enjoy, have FUN! H.Merijn</description>
    <pubDate>Tue, 14 Oct 2003 12:12:20 GMT</pubDate>
    <dc:creator>H.Merijn Brand (procura</dc:creator>
    <dc:date>2003-10-14T12:12:20Z</dc:date>
    <item>
      <title>scripting questions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092166#M806675</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;How do I write the below lines in PERL script.&lt;BR /&gt;&lt;BR /&gt;line="/oracle/datafile/arclogs:"    &lt;BR /&gt;HDR=`echo $line | cut -c 1-1`        &lt;BR /&gt;HDR1=`echo $line | cut -f3 -d'/'` &lt;BR /&gt;HDR2=`echo $line | cut -f1 -d':'`  &lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Mon, 13 Oct 2003 18:49:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092166#M806675</guid>
      <dc:creator>Ridzuan Zakaria</dc:creator>
      <dc:date>2003-10-13T18:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: scripting questions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092167#M806676</link>
      <description>Use this way,&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;$line = "/oracle/datafiles/arclogs";&lt;BR /&gt;@HDR = split(/\//, $line);&lt;BR /&gt;print("$HDR[1]\n");&lt;BR /&gt;print("$HDR[2]\n");&lt;BR /&gt;print("$HDR[3]\n");&lt;BR /&gt;&lt;BR /&gt;This will have 3 variables with name $HDR[1], $HDR[2], $HDR[3], where @HDR is the array.&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;Rajeev</description>
      <pubDate>Mon, 13 Oct 2003 19:46:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092167#M806676</guid>
      <dc:creator>Rajeev  Shukla</dc:creator>
      <dc:date>2003-10-13T19:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: scripting questions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092168#M806677</link>
      <description>&lt;BR /&gt;or alternatively&lt;BR /&gt;&lt;BR /&gt;$line="/oracle/datafile/arclogs:";&lt;BR /&gt;($HDR,$HDR1)=$line=~m#(.).+/(.+)/.+#;&lt;BR /&gt;($HDR2)=$line=~/(.+):/;&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Oct 2003 00:37:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092168#M806677</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-10-14T00:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: scripting questions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092169#M806678</link>
      <description>A slight modification on Marks. "?" need to be added to quantative matches. (.+) will match the maximum number of times. "?" will match a minimum. For example if your path were /oracle/datafile/arclogs/bleem, then Marks pattern match will return "arclogs" for $HDR1 rather than the 3rd field "datafile".&lt;BR /&gt; &lt;BR /&gt;Try this-&lt;BR /&gt; &lt;BR /&gt;$line="/oracle/datafile/arclogs:";&lt;BR /&gt;($HDR2,$HDR,$HDR1)=$line=~m#^((.).+?/(.+?)/.+):#;&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Oct 2003 09:37:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092169#M806678</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-10-14T09:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: scripting questions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092170#M806679</link>
      <description>The first solution by Rajeev which uses split() is to be preferred since regex matching is more expensive  (and error prone ;-).&lt;BR /&gt; &lt;BR /&gt;Maybe overkill for your example, but you can also import the File::Basename module which is part of a core Perl installation.&lt;BR /&gt;This exports for you among others the functions dirname() and basename() which should be familiar to you from shell scripting&lt;BR /&gt;(though uncalled for exporting isn't considered polite as CPAN standards go ;-)&lt;BR /&gt; &lt;BR /&gt;You can read the docs by issuing&lt;BR /&gt; &lt;BR /&gt;perldoc File::Basename&lt;BR /&gt; &lt;BR /&gt;and if your interested in the implementation use the -m switch&lt;BR /&gt; &lt;BR /&gt;perldoc -m File::Basename&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Oct 2003 10:00:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092170#M806679</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2003-10-14T10:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: scripting questions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092171#M806680</link>
      <description>Actually Ralph, Rajeevs solution doesn't solve the problem.  It looks at first sight that the questioner is asking for the directory names extracted out of the path but look carefully at the suppied script and you'll see that it isn't the case. HDR should end up as "/", HDR1 should have "datafile" and HDR2 has the whole path without the trailing ":".  I don't know if this is what the poster actually wanted but it is what he asked for.</description>
      <pubDate>Tue, 14 Oct 2003 10:04:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092171#M806680</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-10-14T10:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: scripting questions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092172#M806681</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;Mark is correct, HDR should return '/' ,HDR2 should return 'datafile' and HDR2 should return everything before ':'.&lt;BR /&gt;&lt;BR /&gt;I have written the script in kornshell but it tooks very time to complete. Perhap perl will give better performance. &lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Tue, 14 Oct 2003 11:33:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092172#M806681</guid>
      <dc:creator>Ridzuan Zakaria</dc:creator>
      <dc:date>2003-10-14T11:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: scripting questions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092173#M806682</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;Mark is correct, HDR should return '/' ,HDR1 should return 'datafile' and HDR2 should return everything before ':'.&lt;BR /&gt;&lt;BR /&gt;I have written the script in kornshell but it tooks very time to complete. Perhap perl will give better performance. &lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Tue, 14 Oct 2003 11:34:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092173#M806682</guid>
      <dc:creator>Ridzuan Zakaria</dc:creator>
      <dc:date>2003-10-14T11:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: scripting questions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092174#M806683</link>
      <description>my $path = "/oracle/datafile/arclogs";&lt;BR /&gt;my @p = ($path =~ m{(/[^/]*)}g);&lt;BR /&gt; &lt;BR /&gt;lt09:/home/merijn 101 &amp;gt; perl -le'$path=shift;@p=($path=~m{(/[^/]*)}g);print for@p' /oracle/datafile/arclogs:&lt;BR /&gt;/oracle&lt;BR /&gt;/datafile&lt;BR /&gt;/arclogs:&lt;BR /&gt;lt09:/home/merijn 102 &amp;gt;&lt;BR /&gt; &lt;BR /&gt;Enjoy, have FUN! H.Merijn</description>
      <pubDate>Tue, 14 Oct 2003 12:12:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092174#M806683</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-10-14T12:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: scripting questions</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092175#M806684</link>
      <description>Mark,&lt;BR /&gt; &lt;BR /&gt;I admit I was too sloppy, not reading carefully enough the wanted result.&lt;BR /&gt; &lt;BR /&gt;The only thing I wanted to stress is that whenever you can avoid Regexs, use functions like split(), or substr().&lt;BR /&gt;And if you can't or don't want to avoid them when you have a constant pattern, use the "o" modifier.&lt;BR /&gt; &lt;BR /&gt;However, with the given result wanted you can avoid a regex, though admittedly by loss of elegance.&lt;BR /&gt; &lt;BR /&gt;e.g.&lt;BR /&gt; &lt;BR /&gt;$line  = '/oracle/datafile/arclogs:';&lt;BR /&gt;($HDR, $HDR1, $HDR2) = (substr($line,0,1),(split(/\//,$line))[2],substr($line,0,&lt;BR /&gt;-1));&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Oct 2003 10:03:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-questions/m-p/3092175#M806684</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2003-10-15T10:03:52Z</dc:date>
    </item>
  </channel>
</rss>

