<?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 command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445495#M852045</link>
    <description>\w = matches alphanumeric character plus "_"&lt;BR /&gt;\d = matches a digit character&lt;BR /&gt;&lt;BR /&gt;if ($var =~ /^\d+$/) {&lt;BR /&gt;        print "$var is numeric\n";&lt;BR /&gt;} elsif ($var =~ /^\w+$/) {&lt;BR /&gt;        print "$var is alphanumeric\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Check perlre(1) for more details.</description>
    <pubDate>Thu, 16 Dec 2004 21:15:10 GMT</pubDate>
    <dc:creator>Ermin Borovac</dc:creator>
    <dc:date>2004-12-16T21:15:10Z</dc:date>
    <item>
      <title>perl command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445494#M852044</link>
      <description>Is there a perl command to distinguish a data between a numeric or alphanumeric?&lt;BR /&gt;&lt;BR /&gt;I need the syntax for it.&lt;BR /&gt;&lt;BR /&gt;maximum points for all correct replies.</description>
      <pubDate>Thu, 16 Dec 2004 20:33:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445494#M852044</guid>
      <dc:creator>Pando</dc:creator>
      <dc:date>2004-12-16T20:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: perl command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445495#M852045</link>
      <description>\w = matches alphanumeric character plus "_"&lt;BR /&gt;\d = matches a digit character&lt;BR /&gt;&lt;BR /&gt;if ($var =~ /^\d+$/) {&lt;BR /&gt;        print "$var is numeric\n";&lt;BR /&gt;} elsif ($var =~ /^\w+$/) {&lt;BR /&gt;        print "$var is alphanumeric\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Check perlre(1) for more details.</description>
      <pubDate>Thu, 16 Dec 2004 21:15:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445495#M852045</guid>
      <dc:creator>Ermin Borovac</dc:creator>
      <dc:date>2004-12-16T21:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: perl command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445496#M852046</link>
      <description># man perlre:&lt;BR /&gt;&lt;BR /&gt;       Because patterns are processed as double quoted strings,&lt;BR /&gt;       the following also work:&lt;BR /&gt;&lt;BR /&gt;           \t          tab                   (HT, TAB)&lt;BR /&gt;           \n          newline               (LF, NL)&lt;BR /&gt;           \r          return                (CR)&lt;BR /&gt;           \f          form feed             (FF)&lt;BR /&gt;           \a          alarm (bell)          (BEL)&lt;BR /&gt;           \e          escape (think troff)  (ESC)&lt;BR /&gt;           \033        octal char (think of a PDP-11)&lt;BR /&gt;           \x1B        hex char&lt;BR /&gt;           \x{263a}    wide hex char         (Unicode SMILEY)&lt;BR /&gt;           \c[         control char&lt;BR /&gt;           \N{name}    named char&lt;BR /&gt;           \l          lowercase next char (think vi)&lt;BR /&gt;           \u          uppercase next char (think vi)&lt;BR /&gt;           \L          lowercase till \E (think vi)&lt;BR /&gt;           \U          uppercase till \E (think vi)&lt;BR /&gt;           \E          end case modification (think vi)&lt;BR /&gt;           \Q          quote (disable) pattern metacharacters till \E&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;       In addition, Perl defines the following:&lt;BR /&gt;&lt;BR /&gt;           \w  Match a "word" character (alphanumeric plus "_")&lt;BR /&gt;           \W  Match a non-"word" character&lt;BR /&gt;           \s  Match a whitespace character&lt;BR /&gt;           \S  Match a non-whitespace character&lt;BR /&gt;           \d  Match a digit character&lt;BR /&gt;           \D  Match a non-digit character&lt;BR /&gt;           \pP Match P, named property.  Use \p{Prop} for longer names.&lt;BR /&gt;           \PP Match non-P&lt;BR /&gt;           \X  Match eXtended Unicode "combining character sequence",&lt;BR /&gt;               equivalent to (?:\PM\pM*)&lt;BR /&gt;           \C  Match a single C char (octet) even under Unicode.&lt;BR /&gt;               NOTE: breaks up characters into their UTF-8 bytes,&lt;BR /&gt;               so you may end up with malformed pieces of UTF-8.&lt;BR /&gt;               Unsupported in lookbehind.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn [ suggesting to also read 'man perlretut' ]</description>
      <pubDate>Fri, 17 Dec 2004 02:01:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445496#M852046</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-12-17T02:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: perl command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445497#M852047</link>
      <description>Hi procura,&lt;BR /&gt;&lt;BR /&gt;I am very new to perl. Am currently creating a script to test the value of a $Var (please see below). I have used the awk like this in my script&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;Var=$(awk -F "," '/DIFFLOTID/ {print $2}' $FILE)&lt;BR /&gt;&lt;BR /&gt;Is it possible for a perl to distinguish the value of $Var if it is numeric or alphanumeric? I need the way to test it.&lt;BR /&gt;Many thanks.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Dec 2004 03:51:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445497#M852047</guid>
      <dc:creator>Pando</dc:creator>
      <dc:date>2004-12-17T03:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: perl command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445498#M852048</link>
      <description>Consider a numeric as some numerics followed by a dot and some more numerics. regexp is as follow :&lt;BR /&gt;^[0-9][0-9]*[\.[0-9][0-9]*]{0,1}$&lt;BR /&gt;&lt;BR /&gt;so if your var is $Var following perl code whould be OK :&lt;BR /&gt;$Var=~ m/^[0-9][0-9]*[\.[0-9][0-9]*]{0,1}$/g;&lt;BR /&gt;if (pos($Var)) {&lt;BR /&gt;  print "$Var Is a numeric.";&lt;BR /&gt;} else {&lt;BR /&gt;  print "$Var Is NOT a numeric.";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Dec 2004 04:05:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445498#M852048</guid>
      <dc:creator>Fred Ruffet</dc:creator>
      <dc:date>2004-12-17T04:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: perl command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445499#M852049</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;Attached is a portion of the script am making.&lt;BR /&gt;I have also attached 2 files for testing.&lt;BR /&gt;I need your expertise to test the value of the variable if it is numeric or alphanumeric.&lt;BR /&gt;Many thanks to all.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Dec 2004 04:22:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445499#M852049</guid>
      <dc:creator>Pando</dc:creator>
      <dc:date>2004-12-17T04:22:24Z</dc:date>
    </item>
    <item>
      <title>Re: perl command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445500#M852050</link>
      <description># man perlfaq4&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;# perldoc -q number/whole&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;       How do I determine whether a scalar is a number/whole/integer/float?&lt;BR /&gt;&lt;BR /&gt;       Assuming that you don't care about IEEE notations like&lt;BR /&gt;       "NaN" or "Infinity", you probably just want to use a regular expression.&lt;BR /&gt;&lt;BR /&gt;          if (/\D/)            { print "has nondigits\n" }&lt;BR /&gt;          if (/^\d+$/)         { print "is a whole number\n" }&lt;BR /&gt;          if (/^-?\d+$/)       { print "is an integer\n" }&lt;BR /&gt;          if (/^[+-]?\d+$/)    { print "is a +/- integer\n" }&lt;BR /&gt;          if (/^-?\d+\.?\d*$/) { print "is a real number\n" }&lt;BR /&gt;          if (/^-?(?:\d+(?:\.\d*)?|\.\d+)$/) { print "is a decimal number\n" }&lt;BR /&gt;          if (/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/)&lt;BR /&gt;                               { print "a C float\n" }&lt;BR /&gt;&lt;BR /&gt;       There are also some commonly used modules for the task.&lt;BR /&gt;       Scalar::Util (distributed with 5.8) provides access to&lt;BR /&gt;       perl's internal function "looks_like_number" for determinï¿½&lt;BR /&gt;       ing whether a variable looks like a number.  Data::Types&lt;BR /&gt;       exports functions that validate data types using both the&lt;BR /&gt;       above and other regular expressions. Thirdly, there is&lt;BR /&gt;       "Regexp::Common" which has regular expressions to match&lt;BR /&gt;       various types of numbers. Those three modules are availï¿½&lt;BR /&gt;       able from the CPAN.&lt;BR /&gt;&lt;BR /&gt;       If you're on a POSIX system, Perl supports the&lt;BR /&gt;       "POSIX::strtod" function.  Its semantics are somewhat cumï¿½&lt;BR /&gt;       bersome, so here's a "getnum" wrapper function for more&lt;BR /&gt;       convenient access.  This function takes a string and&lt;BR /&gt;       returns the number it found, or "undef" for input that&lt;BR /&gt;       isn't a C float.  The "is_numeric" function is a front end&lt;BR /&gt;       to "getnum" if you just want to say, ``Is this a float?''&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;           sub getnum {&lt;BR /&gt;               use POSIX qw(strtod);&lt;BR /&gt;               my $str = shift;&lt;BR /&gt;               $str =~ s/^\s+//;&lt;BR /&gt;               $str =~ s/\s+$//;&lt;BR /&gt;               $! = 0;&lt;BR /&gt;               my($num, $unparsed) = strtod($str);&lt;BR /&gt;               if (($str eq '') || ($unparsed != 0) || $!) {&lt;BR /&gt;                   return undef;&lt;BR /&gt;               } else {&lt;BR /&gt;                   return $num;&lt;BR /&gt;               }&lt;BR /&gt;           }&lt;BR /&gt;&lt;BR /&gt;           sub is_numeric { defined getnum($_[0]) }&lt;BR /&gt;&lt;BR /&gt;       Or you could check out the String::Scanf module on the&lt;BR /&gt;       CPAN instead. The POSIX module (part of the standard Perl&lt;BR /&gt;       distribution) provides the "strtod" and "strtol" for conï¿½&lt;BR /&gt;       verting strings to double and longs, respectively.&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have F</description>
      <pubDate>Fri, 17 Dec 2004 05:02:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445500#M852050</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-12-17T05:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: perl command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445501#M852051</link>
      <description>I modified your program this way :&lt;BR /&gt;ls -l *.TDF |awk '{print $9}' |while read FILE&lt;BR /&gt;do&lt;BR /&gt;  export Var=$(awk -F "," '/DIFFLOTID/ {print $2}' $FILE)&lt;BR /&gt;  perl -e '$PerlVar=$ENV{Var};$PerlVar=~ m/^[0-9][0-9]*[\.[0-9][0-9]*]{0,1}$/g;if (pos($PerlVar)) {print "$PerlVar Is a numeric.\n"} else {print&lt;BR /&gt; "$PerlVar Is NOT a numeric.\n"}'&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;This integrates my precedent post.&lt;BR /&gt;Output is like this :&lt;BR /&gt;./test&lt;BR /&gt;8964 Is a numeric.&lt;BR /&gt;8963ver Is NOT a numeric.&lt;BR /&gt;&lt;BR /&gt;isn't it what you want ?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Dec 2004 05:09:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445501#M852051</guid>
      <dc:creator>Fred Ruffet</dc:creator>
      <dc:date>2004-12-17T05:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: perl command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445502#M852052</link>
      <description>If it's integers only, there is a very dirty way to do it:&lt;BR /&gt;&lt;BR /&gt;# perl -le'$x = $ENV{VAR}; $x += 0; print $x eq $ENV{VAR} ? "OK" : "Not OK"'&lt;BR /&gt;&lt;BR /&gt;This uses automatic conversions from string to numeric, and if the numeric to string conversion equals the original string all conversions are OK&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.merijn</description>
      <pubDate>Fri, 17 Dec 2004 05:13:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445502#M852052</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-12-17T05:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: perl command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445503#M852053</link>
      <description>Unlike "compiling programming languages" perl isn't typed.&lt;BR /&gt;(this may however change with the advent of Perl 6 and the Parrot engine, but I'm not into this to tell)&lt;BR /&gt;Therefore Perl "decides" on the context, as&lt;BR /&gt;procura demonstrated in his last code example.&lt;BR /&gt;Although he said that's a dirty hack, this is, I would say, the usual way Perl programmers do it;&lt;BR /&gt;i.e. forcing a variable into a explicit context to make Perl treat it as either numeric or string.&lt;BR /&gt;If you're interested in the Perl innards and data types in Perl have a look at&lt;BR /&gt;perldoc perlguts&lt;BR /&gt;though I would assume that's a bit heavy reading for now (advanced stuff).&lt;BR /&gt;I would suggest as most others replied to simply stick to regexps and use \d or \w to decide.&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Dec 2004 05:53:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445503#M852053</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2004-12-17T05:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: perl command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445504#M852054</link>
      <description>Hello Fred Ruffet!,&lt;BR /&gt;It works! Many thanks to you.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Dec 2004 21:48:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-command/m-p/3445504#M852054</guid>
      <dc:creator>Pando</dc:creator>
      <dc:date>2004-12-20T21:48:19Z</dc:date>
    </item>
  </channel>
</rss>

