<?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 - best practises in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-best-practises/m-p/3103972#M717461</link>
    <description>Being pedantic about not using shell commands keeps things pure but in my view, the best tool for the job is what to use.&lt;BR /&gt; &lt;BR /&gt;I love perl but it doesn't have a "lvdisplay -v vg00" command so I would quite happily use the shell to do that and so why not use the shell for more simple things too if it is actually easier.  Having said that, extracting the date is very easy in perl and gives you individual variables that can be manipulated.&lt;BR /&gt; &lt;BR /&gt;($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);&lt;BR /&gt; &lt;BR /&gt;I remember when I started using perl that the temptation to just jump out to a shell for a quick "grep" was immense but it's not as flexible. &lt;BR /&gt; &lt;BR /&gt;I would suggest, as a rule of thumb, do it with perl but if you know how to do it in shell and it has already taken half an hour to get it working in perl, use the shell.</description>
    <pubDate>Tue, 28 Oct 2003 06:31:09 GMT</pubDate>
    <dc:creator>Mark Grant</dc:creator>
    <dc:date>2003-10-28T06:31:09Z</dc:date>
    <item>
      <title>Perl - best practises</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-best-practises/m-p/3103971#M717460</link>
      <description>Hi Guys,&lt;BR /&gt;&lt;BR /&gt;After intending to get into Perl for a while a problem at work demanded its use and so I have begun to use it. At present I'm only writing some basic stuff so have a few basic questions..&lt;BR /&gt;&lt;BR /&gt;In the shell version of my script I would have a line such as &lt;BR /&gt;&lt;BR /&gt;echo "$(date): $(hostname) has a problem" &amp;gt;&amp;gt; outfile&lt;BR /&gt;&lt;BR /&gt;I want to do the same thing in perl.. I have seen people doing this by making a system call or using `date`. However, I was hoping to keep to JUST perl. Is it acceptable to still use 'shell' commands within your perl script or is there a better way?&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Tony</description>
      <pubDate>Tue, 28 Oct 2003 06:22:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-best-practises/m-p/3103971#M717460</guid>
      <dc:creator>Tony Walker</dc:creator>
      <dc:date>2003-10-28T06:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: Perl - best practises</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-best-practises/m-p/3103972#M717461</link>
      <description>Being pedantic about not using shell commands keeps things pure but in my view, the best tool for the job is what to use.&lt;BR /&gt; &lt;BR /&gt;I love perl but it doesn't have a "lvdisplay -v vg00" command so I would quite happily use the shell to do that and so why not use the shell for more simple things too if it is actually easier.  Having said that, extracting the date is very easy in perl and gives you individual variables that can be manipulated.&lt;BR /&gt; &lt;BR /&gt;($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);&lt;BR /&gt; &lt;BR /&gt;I remember when I started using perl that the temptation to just jump out to a shell for a quick "grep" was immense but it's not as flexible. &lt;BR /&gt; &lt;BR /&gt;I would suggest, as a rule of thumb, do it with perl but if you know how to do it in shell and it has already taken half an hour to get it working in perl, use the shell.</description>
      <pubDate>Tue, 28 Oct 2003 06:31:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-best-practises/m-p/3103972#M717461</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-10-28T06:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: Perl - best practises</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-best-practises/m-p/3103973#M717462</link>
      <description>For the date command, I like to use strftime. U should add 'use POSIX qw(strftime)' in the header of the perl script, and then can do something like this:&lt;BR /&gt;printf "%s: %s has a problem\n",strftime('%d-%m-%Y %H:%M',gmtime(time)),ENV['HOSTNAME']);&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Oct 2003 06:56:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-best-practises/m-p/3103973#M717462</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2003-10-28T06:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: Perl - best practises</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-best-practises/m-p/3103974#M717463</link>
      <description>1. Do in perl where Perl has builtins, like&lt;BR /&gt; &lt;BR /&gt; my $now = locatime time;&lt;BR /&gt; &lt;BR /&gt;2. Use modules for more advanced stuff (these are still pure perl (most of them), but offer a perl-style interface, and are mostly portable)&lt;BR /&gt; &lt;BR /&gt; use Sys::Hostname;&lt;BR /&gt; use Time::gmtime;&lt;BR /&gt; use Time::HiRes;&lt;BR /&gt; use Time::Local;&lt;BR /&gt; use Time::localtime;&lt;BR /&gt; use Time::tm;&lt;BR /&gt; &lt;BR /&gt;Using POSIX' strftime is easy, but slow.&lt;BR /&gt; &lt;BR /&gt;There are modules for HP-UX specific environment, ALSO FOR LVM :)&lt;BR /&gt;&lt;BR /&gt;&lt;A href="ftp://download.xs4all.nl/pub/mirror/CPAN/modules/by-module/HPUX/HPUX-LVM_0.06.tar.gz" target="_blank"&gt;ftp://download.xs4all.nl/pub/mirror/CPAN/modules/by-module/HPUX/HPUX-LVM_0.06.tar.gz&lt;/A&gt;&lt;BR /&gt; &lt;BR /&gt;Enjoy, Have FUN! H.Merijn&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Oct 2003 07:25:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-best-practises/m-p/3103974#M717463</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-10-28T07:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Perl - best practises</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-best-practises/m-p/3103975#M717464</link>
      <description>Already people have answered your question.&lt;BR /&gt;Just to show some flexibility.&lt;BR /&gt;--------------------------&lt;BR /&gt;$time_text = localtime(time);&lt;BR /&gt;print $time_text, "\n";  # outputs whatever date/time it is&lt;BR /&gt;&lt;BR /&gt;---------------------&lt;BR /&gt;time() will give "seconds since the epoch"&lt;BR /&gt;$today = time();&lt;BR /&gt;$tomorrow_at_this_time = time() + (24 * 60 * 60);&lt;BR /&gt;in case of date calculations&lt;BR /&gt;---------------------&lt;BR /&gt;&lt;BR /&gt;Finally the statement&lt;BR /&gt;echo "$(date): $(hostname) has a problem" &amp;gt;&amp;gt; outfile&lt;BR /&gt;&lt;BR /&gt;transaltes in perl as &lt;BR /&gt;&lt;BR /&gt;open OUTFILE,"filename";&lt;BR /&gt;print OUTFILE "$time_text:$(hostname) has a problem"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Oct 2003 09:21:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-best-practises/m-p/3103975#M717464</guid>
      <dc:creator>Paddy_1</dc:creator>
      <dc:date>2003-10-28T09:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Perl - best practises</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-best-practises/m-p/3103976#M717465</link>
      <description>Sorry Paddy. that's plain wrong. You open the file for *reading*&lt;BR /&gt; &lt;BR /&gt;use Sys::Hostname&lt;BR /&gt;open OUTFILE, "&amp;gt;&amp;gt; outfile" or die "outfile: $!";&lt;BR /&gt;print OUTFILE scalar localtime, ": ", hostname, " has a problem\n";&lt;BR /&gt;close OUTFILE;&lt;BR /&gt; &lt;BR /&gt;Enjoy, have FUN! H.Merijn</description>
      <pubDate>Tue, 28 Oct 2003 09:48:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-best-practises/m-p/3103976#M717465</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-10-28T09:48:19Z</dc:date>
    </item>
  </channel>
</rss>

