<?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: grep function in perl in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571505#M228249</link>
    <description>For geeks like you that's ok.&lt;BR /&gt;But for me it would take longer to fumble up the oneliner than running "perl -de0", and doing two line assignments.&lt;BR /&gt;Who cares, our boxes have plenty of RAM.</description>
    <pubDate>Mon, 27 Jun 2005 12:49:15 GMT</pubDate>
    <dc:creator>Ralph Grothe</dc:creator>
    <dc:date>2005-06-27T12:49:15Z</dc:date>
    <item>
      <title>grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571494#M228238</link>
      <description>How to incorporate "grep -w $variable" in perl grep? eg:&lt;BR /&gt;@ps = grep(/$variable*/, @ps);  &lt;BR /&gt;Thanks</description>
      <pubDate>Mon, 27 Jun 2005 10:20:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571494#M228238</guid>
      <dc:creator>Mike_Ca Li</dc:creator>
      <dc:date>2005-06-27T10:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571495#M228239</link>
      <description>Use the \b anchor which denote word boundaries in Perl regexps.&lt;BR /&gt;Place your match (i.e. $variable) within these.&lt;BR /&gt;See also "perldoc perlre"</description>
      <pubDate>Mon, 27 Jun 2005 10:30:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571495#M228239</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2005-06-27T10:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571496#M228240</link>
      <description>@ps = grep /\b$variable\b/ =&amp;gt; @ps;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn [ a more detailed question could have caused a more verbose answer ]</description>
      <pubDate>Mon, 27 Jun 2005 10:30:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571496#M228240</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-06-27T10:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571497#M228241</link>
      <description>An image says more than thousand words it says.&lt;BR /&gt;So procura has given you the image of my clumsy description.&lt;BR /&gt;However, don't let yourself get confused by his style.&lt;BR /&gt;The =&amp;gt; is, as they say, syntactic sugar the professinals use to discern themselves from us mortal Perl foot folk.&lt;BR /&gt;grep really takes a list as argument.&lt;BR /&gt;see "perldoc -f grep"</description>
      <pubDate>Mon, 27 Jun 2005 10:55:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571497#M228241</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2005-06-27T10:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571498#M228242</link>
      <description>Ah something else I realized.&lt;BR /&gt;You are reading and assigning to the array @ps at the same time.&lt;BR /&gt;Beware the this will only substitute the leading array elements that produced a match.&lt;BR /&gt;The tail holds still the old array elements.&lt;BR /&gt;So this may not exactly be what you expect,&lt;BR /&gt;especially if you rely on the array's dimension (e.g. in scalar context)</description>
      <pubDate>Mon, 27 Jun 2005 10:59:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571498#M228242</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2005-06-27T10:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571499#M228243</link>
      <description>Ah something else I realized.&lt;BR /&gt;You are reading and assigning to the array @ps at the same time.&lt;BR /&gt;Beware that this will only substitute the leading array elements that produced a match.&lt;BR /&gt;The tail holds still the old array elements.&lt;BR /&gt;So this may not exactly be what you expect,&lt;BR /&gt;especially if you rely on the array's dimension (e.g. in scalar context)</description>
      <pubDate>Mon, 27 Jun 2005 10:59:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571499#M228243</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2005-06-27T10:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571500#M228244</link>
      <description>Thanks for replies.&lt;BR /&gt;where to find detailed documentation of \b$variable\b. &lt;BR /&gt;&lt;BR /&gt;perldoc -f grep is very short.</description>
      <pubDate>Mon, 27 Jun 2005 11:23:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571500#M228244</guid>
      <dc:creator>Mike_Ca Li</dc:creator>
      <dc:date>2005-06-27T11:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571501#M228245</link>
      <description>I told you already, read "perldoc perlre"</description>
      <pubDate>Mon, 27 Jun 2005 11:56:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571501#M228245</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2005-06-27T11:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571502#M228246</link>
      <description>Ralph, no!&lt;BR /&gt;&lt;BR /&gt;@ps = .... @ps&lt;BR /&gt;&lt;BR /&gt;grep / map / function / whatever&lt;BR /&gt;&lt;BR /&gt;*REPLACES*&lt;BR /&gt;&lt;BR /&gt;@ps completely. No tail or head will remain.&lt;BR /&gt;&lt;BR /&gt;BTW If @ps refers to a process list (e.g. from `ps`), I'd suggest having a look at Proc::ProcessTable&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Mon, 27 Jun 2005 12:28:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571502#M228246</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-06-27T12:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571503#M228247</link>
      <description>Sorry for spreading lies.&lt;BR /&gt;  &lt;BR /&gt;I just verified in the debugger,&lt;BR /&gt;procura's right.&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 27 Jun 2005 12:34:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571503#M228247</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2005-06-27T12:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571504#M228248</link>
      <description>No debugger needed. An image again :)&lt;BR /&gt;&lt;BR /&gt;lt09:/home/merijn 104 &amp;gt; perl -le'$,=" ";@a=(1..20);print@a;@a=grep/7/,@a;print@a'&lt;BR /&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20&lt;BR /&gt;7 17&lt;BR /&gt;lt09:/home/merijn 105 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Mon, 27 Jun 2005 12:38:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571504#M228248</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-06-27T12:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571505#M228249</link>
      <description>For geeks like you that's ok.&lt;BR /&gt;But for me it would take longer to fumble up the oneliner than running "perl -de0", and doing two line assignments.&lt;BR /&gt;Who cares, our boxes have plenty of RAM.</description>
      <pubDate>Mon, 27 Jun 2005 12:49:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571505#M228249</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2005-06-27T12:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571506#M228250</link>
      <description>variable=/ABC/SVR; ps -ef | grep $variable&lt;BR /&gt;returns &lt;BR /&gt;/ABC/SVR1&lt;BR /&gt;/ABC/SVR&lt;BR /&gt;/ABC/SVR3&lt;BR /&gt;/ABC/SVR4&lt;BR /&gt;etc&lt;BR /&gt;&lt;BR /&gt;variable=/ABC/SVR; ps -ef | grep -w $variable&lt;BR /&gt;returns nothing, but I wanted /ABC/SVR&lt;BR /&gt;&lt;BR /&gt;I also want to get /ABC/SVR from:&lt;BR /&gt;&lt;BR /&gt;variable=/ABC/SVR; perl -e 'print grep(/\b$variable\b/, `ps -ef`)' &lt;BR /&gt;does not return anything and I wanted /ABC/SVR&lt;BR /&gt;&lt;BR /&gt;Please advise.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 27 Jun 2005 12:58:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571506#M228250</guid>
      <dc:creator>Mike_Ca Li</dc:creator>
      <dc:date>2005-06-27T12:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571507#M228251</link>
      <description>However, &lt;BR /&gt; perl -e 'print grep(/\bSVR\b/, `ps -ef`)' &lt;BR /&gt;does print only /ABC/SVR&lt;BR /&gt;&lt;BR /&gt;but &lt;BR /&gt;&lt;BR /&gt;perl -e 'print grep(/\b\/ABC\/SVR\b/, `ps -ef`)'&lt;BR /&gt;returns nothing. I'm confused and what am I doing wrong. &lt;BR /&gt;</description>
      <pubDate>Mon, 27 Jun 2005 13:23:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571507#M228251</guid>
      <dc:creator>Mike_Ca Li</dc:creator>
      <dc:date>2005-06-27T13:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571508#M228252</link>
      <description>Hah! HAH!&lt;BR /&gt;&lt;BR /&gt;You were not specific enough in the first quest. You were refering to an EXTERNAL or ENVIRONMENT (shell) variable, not to a perl variable&lt;BR /&gt;&lt;BR /&gt;variable=/ABC/SVR; perl -e 'print grep(/\b$ENV{variable}\b/, `ps -ef`)'&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Mon, 27 Jun 2005 13:31:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571508#M228252</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-06-27T13:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571509#M228253</link>
      <description>HI:&lt;BR /&gt;variable=/ABC/SVR; perl -e 'print grep(/\b$ENV{variable}\b/,`ps -ef`)'&lt;BR /&gt;is returning all the systems processes :(&lt;BR /&gt;Any ideas? Thanks</description>
      <pubDate>Mon, 27 Jun 2005 13:40:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571509#M228253</guid>
      <dc:creator>Mike_Ca Li</dc:creator>
      <dc:date>2005-06-27T13:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571510#M228254</link>
      <description>yes I have, but I do not know if that is applicable in your shell&lt;BR /&gt;&lt;BR /&gt;$ variable=blah;echo $variable; perl -le'print$ENV{variable}'&lt;BR /&gt;blah&lt;BR /&gt;&lt;BR /&gt;$ export variable=blah;echo $variable; perl -le'print$ENV{variable}'&lt;BR /&gt;blah&lt;BR /&gt;blah&lt;BR /&gt;$ env variable=blah perl -le'print$ENV{variable}'&lt;BR /&gt;blah&lt;BR /&gt;$&lt;BR /&gt;&lt;BR /&gt;you are setting a 'shell' variable, not an environment variable. Variables set the way you do, are not available to other processes than the shell itself&lt;BR /&gt;You will need either export or env&lt;BR /&gt;&lt;BR /&gt;Now you grep using a $ENV that's empty, so you grep on /\b\b/, which is probably not what you tought to do.&lt;BR /&gt;&lt;BR /&gt;I'm using a tcsh, which would need setenv instead of export. 'env' works in all shells&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn [ think about your points please ]&lt;BR /&gt;</description>
      <pubDate>Mon, 27 Jun 2005 13:48:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571510#M228254</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-06-27T13:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571511#M228255</link>
      <description>export variable=/NSG/SVR; perl -le 'print grep(/$ENV{variable}/,`ps -ef`)'&lt;BR /&gt;returns:&lt;BR /&gt;/NSG/SVR3&lt;BR /&gt;/NSG/SVR&lt;BR /&gt;/NSG/SVR2&lt;BR /&gt;/NSG/SVR1&lt;BR /&gt;etc&lt;BR /&gt;&lt;BR /&gt;but:&lt;BR /&gt;export variable=/NSG/SVR; perl -le 'print grep(/\b$ENV{variable}\b/,`ps -ef`)'&lt;BR /&gt;returns nothing&lt;BR /&gt;&lt;BR /&gt;More points issued if able to find a solution. Thanks</description>
      <pubDate>Mon, 27 Jun 2005 14:36:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571511#M228255</guid>
      <dc:creator>Mike_Ca Li</dc:creator>
      <dc:date>2005-06-27T14:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571512#M228256</link>
      <description>variable=/ABC/SVR; perl -le 'print grep(/$ENV{variable}\b/,`ps -ef`)'&lt;BR /&gt; returns /ABC/SVR&lt;BR /&gt;&lt;BR /&gt;Thanks all for replies&lt;BR /&gt;</description>
      <pubDate>Mon, 27 Jun 2005 14:44:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571512#M228256</guid>
      <dc:creator>Mike_Ca Li</dc:creator>
      <dc:date>2005-06-27T14:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: grep function in perl</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571513#M228257</link>
      <description>What if you drop the first \b?&lt;BR /&gt;I'm still baffled though. This should work!&lt;BR /&gt;&lt;BR /&gt;Totally besides the point: the paren's are not needed with grep.&lt;BR /&gt;&lt;BR /&gt;# export variable=/NSG/SVR; perl -le 'print grep(/\b$ENV{variable}\b/,`ps -ef`)'&lt;BR /&gt;&lt;BR /&gt;Just to easy my curiousity: what does env do?&lt;BR /&gt;&lt;BR /&gt;# env variable=/NSG/SVR perl -le 'print grep /\b$ENV{variable}\b/, `ps -ef`'&lt;BR /&gt;&lt;BR /&gt;And what perl version do you use&lt;BR /&gt;&lt;BR /&gt;# perl -v&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn [ please point *all* answers. 0 is better than unassigned ]</description>
      <pubDate>Mon, 27 Jun 2005 14:48:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-function-in-perl/m-p/3571513#M228257</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-06-27T14:48:28Z</dc:date>
    </item>
  </channel>
</rss>

