GoldenNewby
GoldenNewby

Reputation: 4452

Determine if file is a socket reference in Linux with Perl

In linux, I can do a stat on a file in the proc directory and determine if it is a socket.

root@dev:/proc/2221/fd# stat 100
  File: `100' -> `socket:[125598]'

How can I get this same result with perl?

Upvotes: 1

Views: 159

Answers (1)

sirgeorge
sirgeorge

Reputation: 6531

If you only want to know if it is a socket, then:

if(-S $file_name) { /* do something */ }

Upvotes: 3

Related Questions