<?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 conditions HELP in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/perl-conditions-help/m-p/3670815#M102744</link>
    <description>&lt;BR /&gt;From a perl perspective, the biggest thing that is wrong with your script is that is that is really is a shell script more than a perl program. You can do it al in perl, as written earlier.&lt;BR /&gt;&lt;BR /&gt;Does the input to be tested for look like:&lt;BR /&gt;DIFFLOTID  123.455 &lt;BR /&gt;followed by a ] or not?&lt;BR /&gt;&lt;BR /&gt;I think the single regexpr for that, testing that word followed by the value is readably written as:&lt;BR /&gt;&lt;BR /&gt;/DIFFLOTID\s+\d+\.\d+]?&lt;BR /&gt;&lt;BR /&gt;that is:&lt;BR /&gt;- word&lt;BR /&gt;- one or more whitespace chars&lt;BR /&gt;- one or more decimal&lt;BR /&gt;- a period&lt;BR /&gt;- one or more decimal&lt;BR /&gt;- zero or one ]&lt;BR /&gt;&lt;BR /&gt;If you prefer to do the action in the shell then you could do something like:&lt;BR /&gt;&lt;BR /&gt;perl -ne '$x=1 if (/DIFFLOTID\s+\d+\.\d+]?/); print $x if eof' $FILE&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 14 Nov 2005 07:29:53 GMT</pubDate>
    <dc:creator>Hein van den Heuvel</dc:creator>
    <dc:date>2005-11-14T07:29:53Z</dc:date>
    <item>
      <title>Perl conditions HELP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-conditions-help/m-p/3670809#M102738</link>
      <description>Dear Gurus,&lt;BR /&gt;&lt;BR /&gt;Below is line part of my script:&lt;BR /&gt;&lt;BR /&gt;export Var=$(awk -F "," '/DIFFLOTID/ {print $2}' $FILE)&lt;BR /&gt;  $perl/perl -e '$PerlVar=$ENV{Var};&lt;BR /&gt;  $PerlVar=~ m/^[0-9][0-9]*[\.[0-9][0-9]*]{0,1}$/g;&lt;BR /&gt;  if (pos($PerlVar)) {system("'$scrptpath'/parset2xml -t '$FILE'");system("'$ExePath'/rm '$FILE'");else {system("'$ExePath'/mv -f '$FILE' '$temp'");'&lt;BR /&gt;&lt;BR /&gt;The Var variable will get the DIFFLOTID, then it will be check if it is purely numeric. If it is numeric, then it will call parset2xml program and then remove the file to the system. If the DIFFLOTID is not purely numeric, it will  move the file to a temp directory.&lt;BR /&gt;&lt;BR /&gt;I dont know what is wrong with the script lines above.&lt;BR /&gt;&lt;BR /&gt;Maximum points for all correct answers.</description>
      <pubDate>Mon, 14 Nov 2005 04:15:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-conditions-help/m-p/3670809#M102738</guid>
      <dc:creator>Pando</dc:creator>
      <dc:date>2005-11-14T04:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: Perl conditions HELP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-conditions-help/m-p/3670810#M102739</link>
      <description>No perl here, but I check if variable is number or not as follows.&lt;BR /&gt;&lt;BR /&gt;if [ "$(echo $MYVAR | tr -d '[:digit:]')" = "" ]&lt;BR /&gt;then&lt;BR /&gt;echo "All digits"&lt;BR /&gt;else&lt;BR /&gt;echo "$MYVAR has non-digits"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;typeset newvar=$(var) 2&amp;gt;/dev/null&lt;BR /&gt;if [[ $? â  eq 0 ]];then&lt;BR /&gt;echo â  variable-${var} is intergetâ  &lt;BR /&gt;else&lt;BR /&gt;echo â  not itegerâ  &lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Nov 2005 04:20:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-conditions-help/m-p/3670810#M102739</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-11-14T04:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Perl conditions HELP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-conditions-help/m-p/3670811#M102740</link>
      <description>Hello RAC,&lt;BR /&gt;&lt;BR /&gt;Thanks for your quick reply. May i ask what is wrong with the line:&lt;BR /&gt;&lt;BR /&gt; if (pos($PerlVar)) {system("'$scrptpath'/parset2xml -t '$FILE'");system("'$ExePath'/rm '$FILE'");else {system("'$ExePath'/mv -f '$FILE' '$temp'");'&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Nov 2005 04:23:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-conditions-help/m-p/3670811#M102740</guid>
      <dc:creator>Pando</dc:creator>
      <dc:date>2005-11-14T04:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: Perl conditions HELP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-conditions-help/m-p/3670812#M102741</link>
      <description>Can you share  DIFFLOTID format here. You are combining awk, shell and perl scripting. You can do it with awk or shell or perl with this.&lt;BR /&gt;&lt;BR /&gt;Post that information to give script to that.&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Mon, 14 Nov 2005 04:24:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-conditions-help/m-p/3670812#M102741</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-11-14T04:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Perl conditions HELP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-conditions-help/m-p/3670813#M102742</link>
      <description>May be your requirement is like this:&lt;BR /&gt;&lt;BR /&gt;# cat filename&lt;BR /&gt;DIFFLOTID,12[12]&lt;BR /&gt;# cat test.pl&lt;BR /&gt;#!/usr/contrib/bin/perl&lt;BR /&gt;open FD, "filename" || die "Can not open file: $!";&lt;BR /&gt;&lt;BR /&gt;while (&lt;FD&gt;)&lt;BR /&gt;{&lt;BR /&gt;  $Var=(split (/,/))[1] if /DIFFLOTID/;&lt;BR /&gt;  print "$Var\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;print $var . "\n";&lt;BR /&gt;if ( $Var =~ m/^[0-9][0-9]*[\.[0-9][0-9]*]{0,1}$/g )&lt;BR /&gt;{&lt;BR /&gt;  print "ok done" . "\n";&lt;BR /&gt;}&lt;BR /&gt;else {&lt;BR /&gt;  print "sorry\n";&lt;BR /&gt;}&lt;BR /&gt;# perl test.pl&lt;BR /&gt;12[12]&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ok done&lt;BR /&gt;&lt;BR /&gt;# Just change your content as,&lt;BR /&gt;&lt;BR /&gt;#!/usr/contrib/bin/perl&lt;BR /&gt;open FD, "filename" || die "Can not open file: $!";&lt;BR /&gt;&lt;BR /&gt;while (&lt;FD&gt;)&lt;BR /&gt;{&lt;BR /&gt;  $Var=(split (/,/))[1] if /DIFFLOTID/;&lt;BR /&gt;  print "$Var\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;print $var . "\n";&lt;BR /&gt;if ( $Var =~ m/^[0-9][0-9]*[\.[0-9][0-9]*]{0,1}$/g )&lt;BR /&gt;{&lt;BR /&gt;  system("'$scrptpath'/parset2xml -t '$FILE'");system("'$ExePath'/rm '$FILE'");&lt;BR /&gt;}&lt;BR /&gt;else {system("'$ExePath'/mv -f '$FILE' '$temp'");'&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;##&lt;BR /&gt;&lt;BR /&gt;That is it.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/FD&gt;&lt;/FD&gt;</description>
      <pubDate>Mon, 14 Nov 2005 04:31:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-conditions-help/m-p/3670813#M102742</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-11-14T04:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: Perl conditions HELP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-conditions-help/m-p/3670814#M102743</link>
      <description>Use this script:&lt;BR /&gt;&lt;BR /&gt;#!/usr/contrib/bin/perl&lt;BR /&gt;$FILE="filename"&lt;BR /&gt;open FD, $FILE || die "Can not open file: $!";&lt;BR /&gt;&lt;BR /&gt;while (&lt;FD&gt;)&lt;BR /&gt;{&lt;BR /&gt;$Var=(split (/,/))[1] if /DIFFLOTID/;&lt;BR /&gt;print "$Var\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;print $var . "\n";&lt;BR /&gt;if ( $Var =~ m/^[0-9][0-9]*[\.[0-9][0-9]*]{0,1}$/g )&lt;BR /&gt;{&lt;BR /&gt;system("'$scrptpath'/parset2xml -t '$FILE'");&lt;BR /&gt;system("'$ExePath'/rm '$FILE'");&lt;BR /&gt;}&lt;BR /&gt;else {system("'$ExePath'/mv -f '$FILE' '$temp'");'&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;##&lt;BR /&gt;&lt;BR /&gt;Took more attempts to get this ;(&lt;/FD&gt;</description>
      <pubDate>Mon, 14 Nov 2005 04:35:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-conditions-help/m-p/3670814#M102743</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-11-14T04:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: Perl conditions HELP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-conditions-help/m-p/3670815#M102744</link>
      <description>&lt;BR /&gt;From a perl perspective, the biggest thing that is wrong with your script is that is that is really is a shell script more than a perl program. You can do it al in perl, as written earlier.&lt;BR /&gt;&lt;BR /&gt;Does the input to be tested for look like:&lt;BR /&gt;DIFFLOTID  123.455 &lt;BR /&gt;followed by a ] or not?&lt;BR /&gt;&lt;BR /&gt;I think the single regexpr for that, testing that word followed by the value is readably written as:&lt;BR /&gt;&lt;BR /&gt;/DIFFLOTID\s+\d+\.\d+]?&lt;BR /&gt;&lt;BR /&gt;that is:&lt;BR /&gt;- word&lt;BR /&gt;- one or more whitespace chars&lt;BR /&gt;- one or more decimal&lt;BR /&gt;- a period&lt;BR /&gt;- one or more decimal&lt;BR /&gt;- zero or one ]&lt;BR /&gt;&lt;BR /&gt;If you prefer to do the action in the shell then you could do something like:&lt;BR /&gt;&lt;BR /&gt;perl -ne '$x=1 if (/DIFFLOTID\s+\d+\.\d+]?/); print $x if eof' $FILE&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Nov 2005 07:29:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-conditions-help/m-p/3670815#M102744</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-11-14T07:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: Perl conditions HELP</title>
      <link>https://community.hpe.com/t5/operating-system-linux/perl-conditions-help/m-p/3670816#M102745</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;In a shell script one way to do this appears below.  For example, to test whether or not ${X} is numeric (0..9):&lt;BR /&gt;&lt;BR /&gt;# X=123&lt;BR /&gt;# if [ `expr ${X} : '[0-9]*'` -eq `expr ${X} : '.*'` ]; then&lt;BR /&gt;&amp;gt; echo "is_numeric"&lt;BR /&gt;&amp;gt; else&lt;BR /&gt;&amp;gt; echo "is_NOT_numeric"&lt;BR /&gt;&amp;gt; fi&lt;BR /&gt;&lt;BR /&gt;This works by returning and comparing the number of characters in each 'expr'ession. If the number of *numeric* characters in the first expression is equal to the total number of characters in the second expresssion, then the first expression must consist only of (decimal) digits and therefore be "numeric".&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Nov 2005 07:54:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/perl-conditions-help/m-p/3670816#M102745</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-11-14T07:54:56Z</dc:date>
    </item>
  </channel>
</rss>

