perl - The folder shows 3 files but when run the script in CMD it shows extra ` . ` and ` .. `? -


I have been confused with the situation below, instead of size = 3 5 only got 3 files in my folder as ? . and .. from where?

Code:

  My $ directory = 'c: \ modules \ SFTP \ New'; Opendir (DIR, $ directory); My @ fils = reddir (dir); Closedir (DIR); Foreign (@file) {print $ _, "\ n"; } My $ size = @files; Print "Size - $ Size \ n";   

Play Perl:

This shows 5 records instead of 3

Only 3 files inside my folder were found, but it prints 5 records in CMD. Why is . and .. to show in CMD?

Enter image details here

update :

Thanks minitech and chilemagic then . and .. is the current directory and the original directory.

Additional questions: How can I only show the file, so that I size = 3 If there is no other way, then maybe I should do it manually in a manual way.

. and .. are the current and root directories respectively.

This is a common thing to filter by calling:

  Use strict; Use warnings; Use Autodi; My $ directory = 'c: \ modules \ SFTP \ New'; My @ files = {opendir my $ dh, "$ directory"; Grep {! /^..+$/} reader ($ dh); };   

Or if you are ok with full path information, you can use one, in which will not be included. and .. .

  My @ file = globe ("$ directory \\ *")    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -