473,761 Members | 5,839 Online
Bytes | Software Development & Data Engineering Community
+ 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 1242
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
5082
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 to the script under usual SSI (.shtml) containing form data submitted to the page from which the script is executed from. Well, since switching to PHP, I have moved most of my perl scripts to php equivalents, but there are a few perl scripts...
1
19357
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 name-value list in PHP variable? Thanks.
1
4688
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 of which platform I use to access the directory.) Platform 1: perl is installed in /tps/bin/perl. CPAN modules are available Perl is also installed in /usr/bin/perl Platform 1, but the modules are not accessible with this version. Platform...
1
668
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
10197
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 4 12 24 42 64 92 124 162 204 252 4 11 23 44 67 95 134 168 215 271 ..
3
4985
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 to use the 'Shell()'-command . This didn't work: Either I get an "File not found" error, or I get no error at all, but the PERL script isn't executed anyway. The strange thing is that I managed to execute a .bat file for example. Why the hell...
3
4135
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 parse Excel file. However, when I put php script on server side and then launch php through client request, perl program can't run. Anyone has any suggestion re how to fix this problem? Thanks a lot, -Ying
21
34436
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 obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
3
8071
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 issues. my problem is : am just call this perl script by using "system" command inside the another perl script. ie, mail.pl --contains:
1
47481
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 on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
9377
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9925
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8814
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6640
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5266
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3913
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 we have to send another system
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.