<?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 syntax question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-syntax-question/m-p/5278902#M640677</link>
    <description>Even shorter&lt;BR /&gt;&lt;BR /&gt; $ perl -pi -e'1..1 and print "New line 1\n"' textfile&lt;BR /&gt;&lt;BR /&gt;The default for the .. operator is the line number(s).&lt;BR /&gt;&lt;BR /&gt;JRF's suggestions for $ENV{} or shift are both fine.&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
    <pubDate>Thu, 07 Apr 2011 14:17:34 GMT</pubDate>
    <dc:creator>H.Merijn Brand (procura</dc:creator>
    <dc:date>2011-04-07T14:17:34Z</dc:date>
    <item>
      <title>Perl syntax question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-syntax-question/m-p/5278899#M640674</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;to insert a line in position 1 in a text file the command would be:&lt;BR /&gt;&lt;BR /&gt;perl -p -i -e 'if ($. == 1) { print "Random text \n"}' $textfile&lt;BR /&gt;&lt;BR /&gt;What would the correct syntax be if I wanted to pass a script variable to it to produce something like..&lt;BR /&gt;&lt;BR /&gt;perl -p -i -e 'if ($. == 1) { print "Number of cars is $CARNUM \n"}' $textfile&lt;BR /&gt;&lt;BR /&gt;($CARNUM being the var calculated in the script)&lt;BR /&gt;&lt;BR /&gt;Many thks!&lt;BR /&gt;&lt;BR /&gt;Jon</description>
      <pubDate>Thu, 07 Apr 2011 13:19:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-syntax-question/m-p/5278899#M640674</guid>
      <dc:creator>hpuxrocks</dc:creator>
      <dc:date>2011-04-07T13:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Perl syntax question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-syntax-question/m-p/5278900#M640675</link>
      <description>Hi Jon:&lt;BR /&gt;&lt;BR /&gt;There are a number of ways and as always, the best choice is "it depends".&lt;BR /&gt;&lt;BR /&gt;You could do:&lt;BR /&gt;&lt;BR /&gt;# perl -p -i -e 'BEGIN{$CARNUM=shift};if ($. == 1) { print "Number of cars is $CARNUM \n"}' &lt;VALUE&gt; $textfile&lt;BR /&gt;&lt;BR /&gt;...where you pass the variable &lt;VALUE&gt; as the first argument.&lt;BR /&gt;&lt;BR /&gt;You could do:&lt;BR /&gt;&lt;BR /&gt;# export CARNUM=3;perl -p -i -e 'if ($. == 1) { print "Number of cars is $ENV{CARNUM} \n"}'  $textfile&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;&lt;/VALUE&gt;&lt;/VALUE&gt;</description>
      <pubDate>Thu, 07 Apr 2011 13:45:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-syntax-question/m-p/5278900#M640675</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-04-07T13:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: Perl syntax question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-syntax-question/m-p/5278901#M640676</link>
      <description>Hi (again) Jon:&lt;BR /&gt;&lt;BR /&gt;I should point out that for simple one-liners you can also use alternate quoting within the Perl snippet and let the shell fill-in the interpolated variable.&lt;BR /&gt;&lt;BR /&gt;Consider this example:&lt;BR /&gt;&lt;BR /&gt;# X=Jon;perl -nle "print join qq( ),$X,\$_" /etc/hosts&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 07 Apr 2011 13:59:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-syntax-question/m-p/5278901#M640676</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-04-07T13:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: Perl syntax question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-syntax-question/m-p/5278902#M640677</link>
      <description>Even shorter&lt;BR /&gt;&lt;BR /&gt; $ perl -pi -e'1..1 and print "New line 1\n"' textfile&lt;BR /&gt;&lt;BR /&gt;The default for the .. operator is the line number(s).&lt;BR /&gt;&lt;BR /&gt;JRF's suggestions for $ENV{} or shift are both fine.&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 07 Apr 2011 14:17:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-syntax-question/m-p/5278902#M640677</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2011-04-07T14:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: Perl syntax question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-syntax-question/m-p/5278903#M640678</link>
      <description>thks guys</description>
      <pubDate>Thu, 07 Apr 2011 14:29:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-syntax-question/m-p/5278903#M640678</guid>
      <dc:creator>hpuxrocks</dc:creator>
      <dc:date>2011-04-07T14:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: Perl syntax question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-syntax-question/m-p/5278904#M640679</link>
      <description>.</description>
      <pubDate>Fri, 08 Apr 2011 01:46:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-syntax-question/m-p/5278904#M640679</guid>
      <dc:creator>hpuxrocks</dc:creator>
      <dc:date>2011-04-08T01:46:19Z</dc:date>
    </item>
  </channel>
</rss>

