473,466 Members | 1,331 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Perl Script Problem

5 New Member
I am writing one perl script which will take value from an external file and then append the value to another file.
The external file will be in the format like
$name=value;
$name1=value1;
and so on.
The file may contain several variables like this.
My problem is how to get these variable values and append those values to another file using a perl script.
Can anybody help me? I am stuck.
Sep 21 '07 #1
4 1231
pbmods
5,821 Recognized Expert Expert
Heya, Itzaps. Welcome to TSDN!

I'm going to go ahead and move this thread to the Perl forum, where our resident Experts will be better able to help you out.
Sep 21 '07 #2
KevinADC
4,059 Recognized Expert Specialist
I am writing one perl script which will take value from an external file and then append the value to another file.
The external file will be in the format like
$name=value;
$name1=value1;
and so on.
The file may contain several variables like this.
My problem is how to get these variable values and append those values to another file using a perl script.
Can anybody help me? I am stuck.
What have you tried so far?
Sep 21 '07 #3
itzaps
5 New Member
What have you tried so far?
I tried printing the 1st character like

Expand|Select|Wrap|Line Numbers
  1. $fname = "C:\shared\IQA\appli.env";
  2. open(FILE,$fname) || die "cannot open File: $!";
  3. $answer=<FILE>;
  4. chomp($answer);
  5. print $answer;
  6. close(FILE);
  7.  
But it is giving output as $name=value where i want the value only
Sep 26 '07 #4
numberwhun
3,509 Recognized Expert Moderator Specialist
I tried printing the 1st character like
name=value where i want the value only
I am assuming that your env file has that format for each line ( ie: name=value). If that is the case, your script (above) is doing exactly what it is supposed to do. You told it to print each line of input from the file and do nothing else. What you want to do is split each line into its parts and then print the value, like so:

Expand|Select|Wrap|Line Numbers
  1. my $fname = "C:\shared\IQA\appli.env";
  2. open(FILE, $fname) || die "cannot open File: $!";
  3.  
  4. while(<FILE>)
  5. {
  6.     my $answer="$_";
  7.     chomp($answer);
  8.  
  9.     my ($name, $value) = split(/\=/, $answer);
  10.  
  11.     print $value;
  12. }
  13.  
  14. close(FILE);
  15.  
Regards,

Jeff
Sep 26 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Sandman | last post by:
The subject says it all. I am doing a: I have a perl script in which I am using a ReadParse routine that parses the $ENV{'QUERY_STRING'} or $ENV{'CONTENT_LENGTH'} which are two variables passed...
1
by: sam | last post by:
I have a function writen in Perl that takes a name-value list (array) as argument and returns a name-value list (array). My question is: How to call this function from PHP and get the returned...
1
by: Julia Bell | last post by:
I would like to run the same script on two different platforms. The directory in which the script(s) will be stored is common to the two platforms. (I see the same directory contents regardless...
1
by: sm00thcrimnl13 | last post by:
if i have windows 2000 and know how to write perl scripts, how to i actuvate the script through perl?
9
by: Martin Foster | last post by:
Hi. I would like to be able to mimic the unix tool 'uniq' within a Perl script. I have a file with entries that look like this 4 10 21 37 58 83 111 145 184 226...
3
by: PzYon | last post by:
Hey 2gether! I'm trying to execute a PERL script on the web server when the user presses a button in an ASP.NET Web Application using Visual Basic. The most obvious solution for me seemed to be...
3
by: sir.linying | last post by:
My php script is to call perl scipt which makes use of Spreadsheet::ParseExcel module to parse Excel file. I am able to launch php script from command line so that perl script can run and properly...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
3
by: vijayarl | last post by:
Hi all, i have perl script, which is used to send mail. its a command line utility. if we run this perl script in command line by passing all it's required arguments, it works very well.there no...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.