<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
  <title>Linux Format forums</title>
  <link>http://www.linuxformat.com/forums/index.php</link>
  <description>Help, discussion, magazine feedback and more</description>
  <language>english</language>
  <copyright>(c) Copyright Thu May 23, 2013 5:07 pm by Linux Format forums</copyright>
  <managingEditor>webmaster@linuxformat.com</managingEditor>
  <webMaster>webmaster@linuxformat.com</webMaster>
  <pubDate>Thu May 23, 2013 5:07 pm</pubDate>
  <lastBuildDate>Thu May 23, 2013 5:07 pm</lastBuildDate>
  <docs>http://backend.userland.com/rss</docs>
  <generator>phpBB2 RSS Syndication Mod by Lucas</generator>
  <ttl>1</ttl>

  <image>
    <title>Linux Format forums</title>
    <url></url>
    <link>http://www.linuxformat.com/forums/</link>
    <description>Help, discussion, magazine feedback and more</description>
  </image>

                                      <item>
                                        <title>Re: Piping to perl script</title>
                                        <link>http://www.linuxformat.com/forums/viewtopic.php?p=98088#98088</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://www.linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=67333'&gt;geek73666&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Wed Mar 30, 2011 7:59 am&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      You could always do something like cat file | complicated.pl file, and use $ARGV[0] as the file name.  &lt;img src=&quot;images/smiles/icon_smile.gif&quot; alt=&quot;Smile&quot; border=&quot;0&quot; /&gt;</description>
                                        <comments>http://www.linuxformat.com/forums/viewtopic.php?p=98088#98088</comments>
                                        <author>geek73666</author>
                                        <pubDate>Wed Mar 30, 2011 7:59 am</pubDate>
                                        <guid isPermaLink="true">http://www.linuxformat.com/forums/viewtopic.php?p=98088#98088</guid>
                                      </item>
                                      <item>
                                        <title>Re: Piping to perl script</title>
                                        <link>http://www.linuxformat.com/forums/viewtopic.php?p=90284#90284</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://www.linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=8402'&gt;tweetiepooh&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Tue Jun 22, 2010 12:54 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      It's not that hard to change your script.&lt;br /&gt;
&lt;br /&gt;
Simply put an open() call in.  I've put the file name in a variable as later you can pass the file name in and just change how you set &lt;span style=&quot;font-style: italic&quot;&gt;$filename&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;my $filename = &amp;quot;myfile&amp;quot;;&lt;br /&gt;
open my $filehandle, '&amp;lt;', $filename or die &amp;quot;Can't open $filename\n&amp;quot;;&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
Then change &amp;lt;STDIN&amp;gt; to use file handle&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;while &amp;#40;my $line = &amp;lt;$filehandle&amp;gt;&amp;#41; &amp;#123;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;# do something with $line&lt;br /&gt;
&amp;#125;&lt;br /&gt;
close $filehandle;&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;</description>
                                        <comments>http://www.linuxformat.com/forums/viewtopic.php?p=90284#90284</comments>
                                        <author>tweetiepooh</author>
                                        <pubDate>Tue Jun 22, 2010 12:54 pm</pubDate>
                                        <guid isPermaLink="true">http://www.linuxformat.com/forums/viewtopic.php?p=90284#90284</guid>
                                      </item>
                                      <item>
                                        <title>Re: Piping to perl script</title>
                                        <link>http://www.linuxformat.com/forums/viewtopic.php?p=89456#89456</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://www.linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=5'&gt;nelz&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Fri May 21, 2010 10:58 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      You can't do this reliably because your script is not getting the data from the file, it is getting it from standard input. It doesn't even know of the existence of the file.&lt;br /&gt;
&lt;br /&gt;
As for the log rotation, why reinvent the wheel? Call the standard logrotate program to do this job.</description>
                                        <comments>http://www.linuxformat.com/forums/viewtopic.php?p=89456#89456</comments>
                                        <author>nelz</author>
                                        <pubDate>Fri May 21, 2010 10:58 pm</pubDate>
                                        <guid isPermaLink="true">http://www.linuxformat.com/forums/viewtopic.php?p=89456#89456</guid>
                                      </item>
                                      <item>
                                        <title>Piping to perl script</title>
                                        <link>http://www.linuxformat.com/forums/viewtopic.php?p=89442#89442</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://www.linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=4636'&gt;drax&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Fri May 21, 2010 2:23 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Hi,&lt;br /&gt;
I'm a perl newbie but it seems like it's now part of my job...&lt;br /&gt;
How can I capture the name of a file being piped to a perl script ?&lt;br /&gt;
&lt;br /&gt;
I have this;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold&quot;&gt;&lt;br /&gt;
cat myfile | complicated.pl&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
It's a logfile analyser that's built around  a &lt;span style=&quot;font-weight: bold&quot;&gt;while(&amp;lt;STDIN&amp;gt;)&lt;/span&gt; loop and outputs a digest. I need to be able to tell what &lt;span style=&quot;font-weight: bold&quot;&gt;myfile&lt;/span&gt; is within the script. I've tried variations on ARGV but I think they'd only work if the script was called like this;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold&quot;&gt;complicated.pl myfile&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Which I can't do, basically coz I'd have to rewrite the script and my level of perl knowledge is self evident from this post &lt;img src=&quot;images/smiles/icon_smile.gif&quot; alt=&quot;Smile&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
It's also got to handle logrotation, I was thinking it might be easier to amend the logrotate script or is there a way I can capture a HUP within complicated.pl get it to close its currently open files and start crunching the new log file ?</description>
                                        <comments>http://www.linuxformat.com/forums/viewtopic.php?p=89442#89442</comments>
                                        <author>drax</author>
                                        <pubDate>Fri May 21, 2010 2:23 pm</pubDate>
                                        <guid isPermaLink="true">http://www.linuxformat.com/forums/viewtopic.php?p=89442#89442</guid>
                                      </item></channel></rss>