Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

perl::critic::policy::inputoutput::prohibitbarewordfilehandles(3) [centos man page]

Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHUsereContributed Perl DocPerl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles(3)

NAME
Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles - Write "open my $fh, q{<}, $filename;" instead of "open FH, q{<}, $filename;". AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
Using bareword symbols to refer to file handles is particularly evil because they are global, and you have no idea if that symbol already points to some other file handle. You can mitigate some of that risk by "local"izing the symbol first, but that's pretty ugly. Since Perl 5.6, you can use an undefined scalar variable as a lexical reference to an anonymous filehandle. Alternatively, see the IO::Handle or IO::File or FileHandle modules for an object-oriented approach. open FH, '<', $some_file; #not ok open my $fh, '<', $some_file; #ok my $fh = IO::File->new($some_file); #ok There are three exceptions: STDIN, STDOUT and STDERR. These three standard filehandles are always package variables. CONFIGURATION
This Policy is not configurable except for the standard options. SEE ALSO
IO::Handle IO::File AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.3 2014-06-09 Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles(3)

Check Out this Related Man Page

Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHUsereContributed Perl DPerl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles(3pm)

NAME
Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles - Write "open my $fh, q{<}, $filename;" instead of "open FH, q{<}, $filename;". AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
Using bareword symbols to refer to file handles is particularly evil because they are global, and you have no idea if that symbol already points to some other file handle. You can mitigate some of that risk by "local"izing the symbol first, but that's pretty ugly. Since Perl 5.6, you can use an undefined scalar variable as a lexical reference to an anonymous filehandle. Alternatively, see the IO::Handle or IO::File or FileHandle modules for an object-oriented approach. open FH, '<', $some_file; #not ok open my $fh, '<', $some_file; #ok my $fh = IO::File->new($some_file); #ok There are three exceptions: STDIN, STDOUT and STDERR. These three standard filehandles are always package variables. CONFIGURATION
This Policy is not configurable except for the standard options. SEE ALSO
IO::Handle IO::File AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-06-07 Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles(3pm)
Man Page

5 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

File ?

Very new user with a dumb question. While performing ls command I found some files in my directory that look like this: #filename# What does this mean. I cannot open with vi, cat, head, nor can I delete it with rm. Can someone educate me please, and how to fix? THX Dereck (8 Replies)
Discussion started by: dereckbc
8 Replies

2. Shell Programming and Scripting

Write in a file with pipe also in same line

hi, i want to write in a file the output of one command and pile also the same output like ls -lrt > some_file | wc -l (9 Replies)
Discussion started by: narang.mohit
9 Replies

3. Shell Programming and Scripting

Perl-opening a file then copying files

Good morning guys!! Im still practicing with Perl and now Im trying to open a file, and copy its contents to another file. Them I want to remeove the information out of the orginal file after it is copied over. The flow should be messages-->messages1-->messages2. Kind of like a log... (1 Reply)
Discussion started by: bigben1220
1 Replies

4. Shell Programming and Scripting

Perl, open multiple files with wildcards

I have a question regarding Perl scripting. If I want to say open files that all look like this and assign them to a filehandle and then assign the filehandle to a variable, how do I do this? The file names are strand1.fa.gz.tmp strand2.fa.gz.tmp strand3.fa.gz.tmp strand4.fa.gz.tmp ...... (6 Replies)
Discussion started by: japaneseguitars
6 Replies

5. UNIX for Beginners Questions & Answers

Bash script - Remove the 3 top level of a full path filename

Hello. Source file are in : /a/b/c/d/e/f/g/some_file Destination is : /d/e where sub-directories "f" and "g" may missing or not. After copying I want /a/b/c/d/e/f/g/file1 in /d/e/f/g/file1 On source /a is top-level directory On destination /d is top-level directory I would like... (2 Replies)
Discussion started by: jcdole
2 Replies