Sponsored Content
Top Forums Shell Programming and Scripting Perl file and folder listing -Help Post 302350340 by KevinADC on Thursday 3rd of September 2009 12:40:47 PM
Old 09-03-2009
If you would run your perl scripts with warnings turned on as is always recommended you might have figured it out:

readline() on unopened filehandle at script line 3.

the construct <"$value"> which should really be <$value> is interpreted as a filehandle not a glob. It should be:

Code:
use warnings;
@files = <F:/*.*>; 
foreach my $file (@files) {
   print "Here is the content of the drive $file ";
}

If for some reason you must use a scalar in the glob you can do this:

Code:
use warnings;
$value = 'F:/*.*'; 
@files = <${value}>;
foreach my $file (@files) {
   print "Here is the content of the drive $file ";
}

But you should really be using the glob() function instead of the <> brackets:

Code:
use warnings;
$value = 'F:/*.*'; # Searching under F drive
@files = glob($value); # but if I hardcord as @files = <F:/*.*>; it works well.
foreach my $file (@files) {
   print "Here is the content of the drive $file ";
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parse the .txt file for folder name and FTP to the corrsponding folder.

Oracle procedure create files on UNIX folder on a regular basis. I need to FTP files onto windows server and place the files, based on their name, in the corresponding folders. File name is as follows: ccyymmddfoldernamefile.txt; Folder Name length could be of any size; however, the prefix and... (3 Replies)
Discussion started by: MeganP
3 Replies

2. Shell Programming and Scripting

searching folder in perl

i will tell my problem with example: if i have a folder name called sree1.7.3 i know the starting name say sree and also path say /usr/lib. so i want the folder name. and how can i link this folder in makefile thank u sree (2 Replies)
Discussion started by: phani_sree
2 Replies

3. Shell Programming and Scripting

Move the file from one folder to another folder

Hi, I have a requirement to move a file from one folder(a) to another folder(b) only when folder (b) have a write permission. Folder permission is 755 If the permission is otherthan 755 we need to come out of the loop I will appreciate your help Thanks Soll (1 Reply)
Discussion started by: sollins
1 Replies

4. Shell Programming and Scripting

File Management: How do I move all JPGS in a folder structure to a single folder?

This is the file structure: DESKTOP/Root of Photo Folders/Folder1qweqwasdfsd/*jpg DESKTOP/Root of Photo Folders/Folder2asdasdasd/*jpg DESKTOP/Root of Photo Folders/Folder3asdadfhgasdf/*jpg DESKTOP/Root of Photo Folders/Folder4qwetwdfsdfg/*jpg DESKTOP/Root of Photo... (4 Replies)
Discussion started by: guptaxpn
4 Replies

5. Shell Programming and Scripting

want to move set of file from one folder to another folder

Hi all, let me explain my requirments i am having 5 folder with different name for eg) abc , cdf , efd, rtg, ead each 5 folders contain 15 files i want to move 10 files to some other folder, remain 5 files should be there in the same folder. give me some suggestion on this. (6 Replies)
Discussion started by: natraj005
6 Replies

6. UNIX for Dummies Questions & Answers

[Solved] How to remove listing of current user cmd from ps -ef listing?

Hi All, Could you please help to resolve my following issues: Problem Description: Suppose my user name is "MI90". i.e. $USER = MI90 when i run below command, i get all the processes running on the system containing name MQ. ps -ef | grep MQ But sometimes it lists... (8 Replies)
Discussion started by: KDMishra
8 Replies

7. Shell Programming and Scripting

Need help in finishing a bash script for listing subfolder by size in a large folder

Greetings everyone. I have seen that you do wonders here. I have a large folder on a Ubuntu linux. Organization main folder, inside 20 000 subfolders, and inside those subolders many other like 5-6 folders and files. I am interested to create an output to a txt file under the bash... (2 Replies)
Discussion started by: ultimo
2 Replies

8. Programming

Perl - Moving file based upon filesize in folder

Hi I'm trying to look through a series of directories in A folder, lets just call it A: for example: A/1 A/2 A/3 Etc and I wish to move the files in the folder if they are bigger than a certain size into a structure like below: A/TooBig/1 A/TooSmall/1 A/TooBig/2 A/TooSmall/2... (1 Reply)
Discussion started by: PerlNewbRP
1 Replies

9. Shell Programming and Scripting

[Perl] Module for recursive listing of remote Windows shares

Hi, I'm looking for a Perl module which can recursively list remote Windows shares from within a Linux machine. I've tried Filesys::SmbClient ans Filesys:SmbClientPars but they just list the current directory Thank You for your help (4 Replies)
Discussion started by: Fundix
4 Replies

10. Shell Programming and Scripting

How can i sort this listing in PYTHON by folder creation?

Is there anything i can do about this code? I need to sort it by folder creation, the newest will be first ... thx :) for dirname in postme: dirname = os.path.abspath(dirname) if dirname: ... (2 Replies)
Discussion started by: ZerO13
2 Replies
Sub::Delete(3pm)					User Contributed Perl Documentation					  Sub::Delete(3pm)

NAME
Sub::Delete - Perl module enabling one to delete subroutines VERSION
1.00002 SYNOPSIS
use Sub::Delete; sub foo {} delete_sub 'foo'; eval 'foo();1' or die; # dies DESCRIPTION
This module provides one function, "delete_sub", that deletes the subroutine whose name is passed to it. (To load the module without importing the function, write "use Sub::Delete();".) This does more than simply undefine the subroutine in the manner of "undef &foo", which leaves a stub that can trigger AUTOLOAD (and, consequently, won't work for deleting methods). The subroutine is completely obliterated from the symbol table (though there may be references to it elsewhere, including in compiled code). PREREQUISITES
This module requires perl 5.8.3 or higher. LIMITATIONS
If you take a reference to a glob containing a subroutine, and then delete the subroutine with "delete_sub", you will find that the glob you referenced still has a subroutine in it. This is because "delete_sub" removes a glob, replaces it with another, and then copies the contents of the old glob into the new one, except for the "CODE" slot. (This is nearly impossible to fix without breaking constant::lexical.) BUGS
If you find any bugs, please report them to the author via e-mail. AUTHOR &; COPYRIGHT Copyright (C) 2008-10 Father Chrysostomos (sprout at, um, cpan dot org) This program is free software; you may redistribute or modify it (or both) under the same terms as perl. SEE ALSO
perltodo, which has "delete &sub" listed as a possible future feature Symbol::Glob and Symbol::Util, both of which predate this module (but I only discovered them recently), and which allow one to delete any arbitrary slot from a glob. Neither of them takes perl 5.10 constants into account, however. They also both differ from this module, in that a subroutine referenced in compiled code can no longer be called if deleted from its glob. The entire glob must be replaced (which this module does). perl v5.10.1 2010-11-06 Sub::Delete(3pm)
All times are GMT -4. The time now is 06:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy