The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
shift not working Nagapandi UNIX for Dummies Questions & Answers 4 06-11-2008 04:28 AM
shift and push question in perl hankooknara Shell Programming and Scripting 5 06-29-2007 06:37 AM
Regarding the shift command??? shrao Shell Programming and Scripting 2 03-31-2007 03:39 AM
shift command Nisha Shell Programming and Scripting 6 07-19-2002 05:54 AM
shift command AkumaTay UNIX for Dummies Questions & Answers 1 05-20-2002 08:26 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #8 (permalink)  
Old 01-09-2009
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,884
Quote:
Originally Posted by ifeatu View Post
nvrmind...I just discovered "printf" :-) :-)
In the hash table, you should still quote the numbers, or remove the leading 0's . Otherwise, perl will interpret these as octal numbers, meaning "08" will end up being "10".
  #9 (permalink)  
Old 01-09-2009
ifeatu ifeatu is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 5
I dont know if I should start a new thread for this as it is contained within the same code that I'm working on in this thread but anyway I have another question

I'm trying to make a series of directories with the newly created names that I have generated...here is the loop that I have, and it doesn't seem to be working:

}
open(FOLDER, "temp.txt");
while ($test = <FOLDER>) {
#print $test;
mkdir('$test',0777) || print $!;
}

For some reason this code keeps generating code with ints instead of the actual chars contained within the file, perhaps its trying to count each line? I'm still very hazy on how to read files into vars line by line. Can anyone enlighten me>?
  #10 (permalink)  
Old 01-10-2009
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,884
Remove the single quotes around $test inside the mkdir call, and it should work fine.
  #11 (permalink)  
Old 01-11-2009
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,078
amend below %hash accordingly should help you some.

Code:
%hash=(Jan,"01",Jul,"07",UC,"Union City");
open FH,"<a.txt";
while(<FH>){
	@arr=split("-",$_);
	$arr[0]= ($hash{$arr[0]})?$hash{$arr[0]}:ucfirst($arr[0]);
	$arr[2]= $hash{substr($arr[2],0,3)};
	print join "-",@arr;
}
Sponsored Links
Closed Thread

Bookmarks

Tags
perl, perl shift, scripting, shift, shift perl

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:09 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0