473,473 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Trying to parse a variable name

Basically I'm reading a SQL predicate from an XML file. The predicate
contains a perl variable name.

I have a sub called parseValue that takes a literal string and then
returns the value.

Now, if I pass in a qq{} or ' ' quoted string it works fine, but when
I pass in the value from the XML file it doesn't work.

I should get the following output:

PARSED STRING: ENGINE_ID = 1
PARSED STRING: ENGINE_ID = 1

But I get the following:

PARSED STRING: ENGINE_ID = 1
PARSED STRING: ENGINE_ID = &parseValue($engine_id)

What the heck is going on?

I've included the code and the XML file below.

#!/usr/bin/perl

use XML::Simple;
use Data::Dumper;

$engine_id = 1;

sub parseValue
{
my $value = shift;

$value =~ s/\$(\w+)/${$1}/;

return $value;
}

print "PARSED VALUE: ",&parseValue('$engine_id'),"\n";

sub BySequence
{
$transforms->{Transform}->{$a}->{Sequence} <=>
$transforms->{Transform}->{$b}->{Sequence}
}

$transforms = XMLin("test.xml",forcearray => ["Transform"]);

foreach $transform (sort BySequence keys %{$transforms->{Transform}})
{
%transform = %{$transforms->{Transform}->{$transform}};

$delete_predicate = $transform{DeletePredicate};

print "$delete_predicate\n";
$delete_predicate =~ s/(\$\w+)/&parseValue($1)/g;
print "$delete_predicate\n";

%transform = ();
}

<?xml version="1.0" ?>
<Transforms>
<Transform Sequence="1" name="Planned Order">
<DeletePredicate>ENGINE_ID =
$engine_id</DeletePredicate>
</Transform>
</Transforms>
Jul 19 '05 #1
1 4601
Aaron wrote:
Basically I'm reading ...


This group is defunct. See reply in comp.lang.perl.misc.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Kevin Joseph | last post by:
I have written a Perl script to modify some files over the network. All PCs are Win2k. Most of the files reside on a share in the form of \\server\share_name. Some of the files are on dirves in the...
6
by: nate | last post by:
Hello, Does anyone know where I can find an ASP server side script written in JavaScript to parse text fields from a form method='POST' using enctype='multipart/form-data'? I'd also like it to...
3
by: Ben Hallert | last post by:
Hi there, I haven't done a lot of Javascript programming, so I'm not having great luck debugging something I put together, and I was hoping someone here could give it a quick lookover and maybe...
4
by: Dave | last post by:
I used the following class and .aspx code below to understand how static works on variables and methods taken from...
10
by: Martin Eyles | last post by:
Hi, I am getting a string passed back from a web form in the format name1:variable1;name2:variable2... I would like to split this up into several variable, such that the variable names are...
2
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
I am usign the code below to find the current row and cell. Which works OK. Then hwat I want to do is get the value of each other cell in the row. So below I am trying to get at least one values....
3
by: bb nicole | last post by:
Below is the code i create when i click on the job title hyperlink, it will display the job information where call from database. But the error message is: Parse error: parse error, unexpected $end...
3
by: Bint | last post by:
Hi, I'm trying to parse an xml file into an array tree. From the PHP site in the comments, I got this code. But it doesn't work for me. It's saying that the passed variable is not an array or...
3
by: Leighya | last post by:
Im currently working on this xml file but when i load it to Mozilla, i got an error "Error Loading Stylesheet: Xpath parse failure: invalid variable name" It loads on IE properly. Only with the...
0
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
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,...
1
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: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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...

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.