Help needed in perl; moving or copying the variables


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help needed in perl; moving or copying the variables
# 1  
Old 06-29-2011
Help needed in perl; moving or copying the variables

Hi All,

I have a perl script blc.pl; i have five variables a,b,c,d and e in this script.
Now I want to copy the values of these variables into a data file,say abc.dat.. Can anybody please tell me how to do this?

Any help is appreciated..

Thanks in advance
# 2  
Old 06-29-2011
why dont you search in google ? ( if it is urgent )

"file operation in perl"
# 3  
Old 06-29-2011
Hi,

Something like this??
Code:
$ cat script.pl
use warnings;
use strict;

my ($a, $b, $c, $d, $e) = ( "aa", "bb", "cc", "dd", "ee" );

open my $fh, ">", "abc.dat" or die "Cannot open file: $!\n";

print $fh "Variable a: ", $a, "\n";
print $fh "Variable b: ", $b, "\n";
# and so on....

close $fh;
$ perl script.pl
$ cat abc.dat
Variable a: aa
Variable b: bb

Regards,
Birei
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

What's the best way to check file permissions before moving files if needed?

Hello, I would like to know if it's a good practice to check the file permissions of the contents of a directory before moving them. For example: mv -- "$directory"/* "$directory"/.* "$directory"/..?* "$destination"The variables $directory and $destination contain the path to an existing... (6 Replies)
Discussion started by: Cacializ
6 Replies

2. OS X (Apple)

using variables when copying files

smaller sample from a larger script: i'm simply trying to copy files from one desktop directory on a mac to another using variables. when i first test the logic of the script without variables, everything works and the copy is effective. but i'm unable to call the same copy by passing a... (3 Replies)
Discussion started by: hungryd
3 Replies

3. UNIX for Dummies Questions & Answers

moving/copying files in a numerical order

Hi I am newbie to unix scripting, but i have enough knowledge to understand. I have a specific questions like, I use to collect like 3500 files per experiment, each one named like data_001.img.. data_002.img data_003.img .... data_3500.img I would like to move every 12 files in the 3500... (3 Replies)
Discussion started by: wpat
3 Replies

4. Shell Programming and Scripting

Moving Content from one file to another with variables

Greetings All, Need some help, your input is appreciated. Scenario: I have five files, each has one line with comletely different content. I execute the command to combine all the five lines of content into a single file. Goal: I would like to take that single file that has the... (3 Replies)
Discussion started by: royarellano
3 Replies

5. Shell Programming and Scripting

Help needed with searching files and moving them to a different directory

I am new to shell scripting. Can someone help me out with this one please? I need to write a script fot the following scenario: I am currently in /parent directory. I have a set of files in /parent/error_files directory My script has to search for a file in /parent/erratic_files... (1 Reply)
Discussion started by: ss3944
1 Replies

6. Shell Programming and Scripting

moving variables to another variable as a new avriable

Somehow I can't get it for this basic bash problem. maybe someone can help. What I try to do is: a="world" b="hello" how can I move this into $c so that I can replace "helloworld" with "world hello" in sed like: sed "s/\helloworld/ ${c}... I tried several combinations but all with... (4 Replies)
Discussion started by: lowmaster
4 Replies

7. UNIX for Dummies Questions & Answers

Cygwin help needed! for copying shellscripts

Hello, this is not exactly a unix specific question however i am sure someone out there may answer my question. The problem is that i write shellscripts and now i want to convert all these shellscripts to .txt. Is it possible? or if someone knows how to copy the content of shellscript then also... (3 Replies)
Discussion started by: salman4u
3 Replies

8. Shell Programming and Scripting

FTP files are not moving/copying

Hi I want to FTP some file from one server to another server, those file should copy from one server to another and then move the same files to another folder in the same server. I have written the code but the text files are moving and coping but the remaing file are not moving or coping to... (4 Replies)
Discussion started by: mahantysk
4 Replies

9. UNIX for Dummies Questions & Answers

Copying & moving en masse

I'm new to UNIX and have got some of the basics down, but I've got a puzzle I'm having difficulty working out. :confused: Scenario: Have FILE_A.JPG in DIR_A Need to copy FILE_A 200 times and rename it 200 different names. List of 200 names in NAME_FILE.TXT After renaming 200 files,... (4 Replies)
Discussion started by: anekab
4 Replies

10. Solaris

copying/moving partition

I have a slice on a 72GB hard drive like this (example): /dev/dsk/c0t1d0s0 51424287 51009 50859036 1% /usr/stuff that I need to copy or move to a slice on a MUCH larger slice like this: /dev/dsk/c0t2d0s6 70592505 570236 69316344 1% /usr/newstuff What is the... (4 Replies)
Discussion started by: antalexi
4 Replies
Login or Register to Ask a Question