<?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: Simple perl question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311854#M185740</link>
    <description>man perlsyn&lt;BR /&gt;&lt;BR /&gt;next some boolean operation;&lt;BR /&gt;or&lt;BR /&gt;next;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
    <pubDate>Tue, 22 Jun 2004 08:29:51 GMT</pubDate>
    <dc:creator>harry d brown jr</dc:creator>
    <dc:date>2004-06-22T08:29:51Z</dc:date>
    <item>
      <title>Simple perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311853#M185739</link>
      <description>Hello&lt;BR /&gt;&lt;BR /&gt;When using the "next if" loop in perl, what is the correct syntax for :-&lt;BR /&gt;&lt;BR /&gt;next if ($x ne "some string")&lt;BR /&gt;&lt;BR /&gt;Jeff</description>
      <pubDate>Tue, 22 Jun 2004 08:25:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311853#M185739</guid>
      <dc:creator>Jeff Picton</dc:creator>
      <dc:date>2004-06-22T08:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: Simple perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311854#M185740</link>
      <description>man perlsyn&lt;BR /&gt;&lt;BR /&gt;next some boolean operation;&lt;BR /&gt;or&lt;BR /&gt;next;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Tue, 22 Jun 2004 08:29:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311854#M185740</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2004-06-22T08:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Simple perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311855#M185741</link>
      <description>that is OK, though I myself prefer&lt;BR /&gt;&lt;BR /&gt;$x eq "some string" or next;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Tue, 22 Jun 2004 08:30:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311855#M185741</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-06-22T08:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: Simple perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311856#M185742</link>
      <description>"if" in this case is using the modifier syntax which is availabe on all expressions. Example-&lt;BR /&gt; &lt;BR /&gt;print "hello" if $x &amp;gt; 5;&lt;BR /&gt; &lt;BR /&gt;"unless" is also a modifier-&lt;BR /&gt; &lt;BR /&gt;print "hello" unless $x &amp;lt;= 5;&lt;BR /&gt; &lt;BR /&gt;In your example, the parenthesis aren't required, and using the "unless" modifier you get-&lt;BR /&gt; &lt;BR /&gt;next unless $x eq "some string";&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 22 Jun 2004 08:37:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311856#M185742</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2004-06-22T08:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Simple perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311857#M185743</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Thanks for the replies. This is the full problem (I wish to print all the values of $last_field except the ones containing the string).&lt;BR /&gt;&lt;BR /&gt;$last_field=pop(@array);&lt;BR /&gt;next unless ($last_field eq "some_string");&lt;BR /&gt;&lt;BR /&gt;Jeff</description>
      <pubDate>Tue, 22 Jun 2004 08:45:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311857#M185743</guid>
      <dc:creator>Jeff Picton</dc:creator>
      <dc:date>2004-06-22T08:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Simple perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311858#M185744</link>
      <description>printf("%s",$last_field) unless ($last_field eq "some_string");&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Tue, 22 Jun 2004 08:50:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311858#M185744</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2004-06-22T08:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: Simple perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311859#M185745</link>
      <description>I meant to mention that I was printing to file not screen</description>
      <pubDate>Tue, 22 Jun 2004 08:55:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311859#M185745</guid>
      <dc:creator>Jeff Picton</dc:creator>
      <dc:date>2004-06-22T08:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Simple perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311860#M185746</link>
      <description>open(OUTPUTFILEPTR,"&amp;gt; /tmp/somefilename");&lt;BR /&gt;&lt;BR /&gt;some loop:&lt;BR /&gt;&lt;BR /&gt;printf(OUTPUTFILEPTR "%s",$last_field) unless ($last_field eq "some_string");&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Tue, 22 Jun 2004 08:58:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311860#M185746</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2004-06-22T08:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: Simple perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311861#M185747</link>
      <description>This should work, however it does not strip out the unwanted list of strings.&lt;BR /&gt;&lt;BR /&gt;I think it may be the fact I used the pop function on an array.</description>
      <pubDate>Tue, 22 Jun 2004 09:02:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311861#M185747</guid>
      <dc:creator>Jeff Picton</dc:creator>
      <dc:date>2004-06-22T09:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Simple perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311862#M185748</link>
      <description>something like this?&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;#&lt;BR /&gt;@arrSTUFF="";&lt;BR /&gt;while (&lt;STDIN&gt;) {&lt;BR /&gt;push @arrSTUFF,$_;&lt;BR /&gt;}&lt;BR /&gt;foreach $last_field (@arrSTUFF) {&lt;BR /&gt;printf("%s\n",$last_field) unless ($last_field =~ "crazyman");&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;You can use "chomp" to remove "CR's" after the foreach line above:&lt;BR /&gt;chomp($last_field);&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry&lt;/STDIN&gt;</description>
      <pubDate>Tue, 22 Jun 2004 09:29:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311862#M185748</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2004-06-22T09:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: Simple perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311863#M185749</link>
      <description>Almost right. Running that with (the recommended) -w switch would yield a warning, because an array is not initialized with a string, but with a list.&lt;BR /&gt;&lt;BR /&gt;Knowing that, the initialization isn't needed at all, and the chomp can be done in one go&lt;BR /&gt;&lt;BR /&gt;=~ operator doesn't take " as delimiter without the m prefix&lt;BR /&gt;&lt;BR /&gt;For automatically aliasses $_, and printf isn't needed for a single string. The added \n (newline can be shorthanded to the -l command line opting, reducing Harry's snippet to the syntacticcally valid:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl -wl&lt;BR /&gt;chomp (my @arr = &lt;STDIN&gt;);&lt;BR /&gt;for (@arr) {&lt;BR /&gt;print unless /crazyman/;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn&lt;/STDIN&gt;</description>
      <pubDate>Tue, 22 Jun 2004 09:56:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311863#M185749</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-06-22T09:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Simple perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311864#M185750</link>
      <description>Perl's "grep" function might do what you&lt;BR /&gt;want in one step:&lt;BR /&gt;&lt;BR /&gt;@array2 = grep(/^some_string$/, @array);&lt;BR /&gt;&lt;BR /&gt;The array @array2 will be the subset of&lt;BR /&gt;items from @array that are not "some_string".&lt;BR /&gt;The ^ and $ anchor the pattern so that you&lt;BR /&gt;match "some_string" exactly and do not match&lt;BR /&gt;"also_some_string" or "some_string_or_other".&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Jun 2004 12:02:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311864#M185750</guid>
      <dc:creator>Gregory Fruth</dc:creator>
      <dc:date>2004-06-22T12:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Simple perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311865#M185751</link>
      <description>Following example from PERL Black Book by Steven Holzner page 213 published by Coriolis&lt;BR /&gt;&lt;BR /&gt;To trap for division by zero:&lt;BR /&gt;&lt;BR /&gt;@a(0 .. 20)&lt;BR /&gt;@b(-10 .. 10)&lt;BR /&gt;&lt;BR /&gt;DIVISION: while(@a){&lt;BR /&gt;  $a=pop @a;&lt;BR /&gt;  $b=pop @b;&lt;BR /&gt;&lt;BR /&gt;  next DIVISION if ($b == 0);&lt;BR /&gt;  print "$a / $b = ".$a/$b."\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;when $b==0, it skips to the end of the loop.</description>
      <pubDate>Wed, 23 Jun 2004 14:47:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-perl-question/m-p/3311865#M185751</guid>
      <dc:creator>R. Allan Hicks</dc:creator>
      <dc:date>2004-06-23T14:47:08Z</dc:date>
    </item>
  </channel>
</rss>

