<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Perl attributes explained Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/perl-attributes-explained/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/perl-attributes-explained/</link>
	<description>A Platform for Software Engineers</description>
	<lastBuildDate>Sat, 27 Feb 2021 09:52:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>
	<item>
		<title>How to Check  File Attributes in Perl ? Perl File Attributes explained</title>
		<link>https://www.scmgalaxy.com/tutorials/checking-file-attributes-in-perl/</link>
					<comments>https://www.scmgalaxy.com/tutorials/checking-file-attributes-in-perl/#respond</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Tue, 22 Nov 2011 14:14:25 +0000</pubDate>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Attributes]]></category>
		<category><![CDATA[Check]]></category>
		<category><![CDATA[File]]></category>
		<category><![CDATA[File Attributes]]></category>
		<category><![CDATA[File Attributes in Perl]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[Perl attributes]]></category>
		<category><![CDATA[Perl attributes explained]]></category>
		<category><![CDATA[Perl attributes tutorial]]></category>
		<category><![CDATA[Perl File Attributes explained]]></category>
		<category><![CDATA[Perl File Attributes Guide]]></category>
		<category><![CDATA[Perl File Attributes Reference]]></category>
		<category><![CDATA[Perl Tutorial]]></category>
		<category><![CDATA[Tutorial]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2011/11/22/checking-file-attributes-in-perl/</guid>

					<description><![CDATA[<p>Checking File Attributes in Perl I have been using perl for quite some time now. I have also been using the [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/checking-file-attributes-in-perl/">How to Check  File Attributes in Perl ? Perl File Attributes explained</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-3879 aligncenter" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2011/11/file-attributes-in-perl.png" alt="perl-file-attributes" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2011/11/file-attributes-in-perl.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2011/11/file-attributes-in-perl-300x200.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></h2>
<h2>Checking File Attributes in Perl</h2>
<p>I have been using perl for quite some time now. I have also been using the file handling logic in my scripts. However, what I did not know till now is that you can quickly check for certain file properties in perl. Here is an example:<br />
#!/usr/bin/perl<br />
my (@description,$size);<br />
if (-e $file)<br />
{<br />
push @description, ‘binary’ if (-B _);<br />
push @description, ‘a socket’ if (-S _);<br />
push @description, ‘a text file’ if (-T _);<br />
push @description, ‘a block special file’ if (-b _);<br />
push @description, ‘a character special file’ if (-c _);<br />
push @description, ‘a directory’ if (-d _);<br />
push @description, ‘executable’ if (-x _);<br />
push @description, (($size = -s _)) ? “$size bytes” : ‘empty’;<br />
print “$file is “, join(‘, ‘,@description),”\n”;<br />
}<br />
Nice, isn’t it?<br />
Here is the complete list of features that you can check:</p>
<table border="1" width="445" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="155"><strong>Operator </strong></td>
<td valign="top" width="435"><strong>Description</strong></td>
</tr>
<tr>
<td valign="top" width="155">-A</td>
<td valign="top" width="435">Age of file (at script startup) in days since modification.</td>
</tr>
<tr>
<td valign="top" width="155">-B</td>
<td valign="top" width="435">Is it a binary file?</td>
</tr>
<tr>
<td valign="top" width="155">-C</td>
<td valign="top" width="435">Age of file (at script startup) in days since modification.</td>
</tr>
<tr>
<td valign="top" width="155">-M</td>
<td valign="top" width="435">Age of file (at script startup) in days since modification.</td>
</tr>
<tr>
<td valign="top" width="155">-O</td>
<td valign="top" width="435">Is the file owned by the real user ID?</td>
</tr>
<tr>
<td valign="top" width="155">-R</td>
<td valign="top" width="435">Is the file readable by the real user ID or real group?</td>
</tr>
<tr>
<td valign="top" width="155">-S</td>
<td valign="top" width="435">Is the file a socket?</td>
</tr>
<tr>
<td valign="top" width="155">-T</td>
<td valign="top" width="435">Is it a text file?</td>
</tr>
<tr>
<td valign="top" width="155">-W</td>
<td valign="top" width="435">Is the file writable by the real user ID or real group?</td>
</tr>
<tr>
<td valign="top" width="155">-X</td>
<td valign="top" width="435">Is the file executable by the real user ID or real group?</td>
</tr>
<tr>
<td valign="top" width="155">-b</td>
<td valign="top" width="435">Is it a block special file?</td>
</tr>
<tr>
<td valign="top" width="155">-c</td>
<td valign="top" width="435">Is it a character special file?</td>
</tr>
<tr>
<td valign="top" width="155">-d</td>
<td valign="top" width="435">Is the file a directory?</td>
</tr>
<tr>
<td valign="top" width="155">-e</td>
<td valign="top" width="435">Does the file exist?</td>
</tr>
<tr>
<td valign="top" width="155">-f</td>
<td valign="top" width="435">Is it a plain file?</td>
</tr>
<tr>
<td valign="top" width="155">-g</td>
<td valign="top" width="435">Does the file have the setgid bit set?</td>
</tr>
<tr>
<td valign="top" width="155">-k</td>
<td valign="top" width="435">Does the file have the sticky bit set?</td>
</tr>
<tr>
<td valign="top" width="155">-l</td>
<td valign="top" width="435">Is the file a symbolic link?</td>
</tr>
<tr>
<td valign="top" width="155">-o</td>
<td valign="top" width="435">Is the file owned by the effective user ID?</td>
</tr>
<tr>
<td valign="top" width="155">-p</td>
<td valign="top" width="435">Is the file a named pipe?</td>
</tr>
<tr>
<td valign="top" width="155">-r</td>
<td valign="top" width="435">Is the file readable by the effective user or group ID?</td>
</tr>
<tr>
<td valign="top" width="155">-s</td>
<td valign="top" width="435">Returns the size of the file, zero size = empty file.</td>
</tr>
<tr>
<td valign="top" width="155">-t</td>
<td valign="top" width="435">Is the filehandle opened by a TTY (terminal)?</td>
</tr>
<tr>
<td valign="top" width="155">-u</td>
<td valign="top" width="435">Does the file have the setuid bit set?</td>
</tr>
<tr>
<td valign="top" width="155">-w</td>
<td valign="top" width="435">Is the file writable by the effective user or group ID?</td>
</tr>
<tr>
<td valign="top" width="155">-x</td>
<td valign="top" width="435">Is the file executable by the effective user or group ID?</td>
</tr>
<tr>
<td valign="top" width="155">-z</td>
<td valign="top" width="435">Is the file size zero?</td>
</tr>
</tbody>
</table>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/checking-file-attributes-in-perl/">How to Check  File Attributes in Perl ? Perl File Attributes explained</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/checking-file-attributes-in-perl/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
