Syntax error in perl program.


 
Thread Tools Search this Thread
Top Forums Programming Syntax error in perl program.
# 1  
Old 10-21-2011
Syntax error in perl program.

Hi,
i am running this code but i am getting syntax error
Code:
#!/usr/bin/perl
use warnings;
use strict;
 use XML::LibXML;
 use XML::LibXML::Reader;
use Data::Dumper;

my $file;
open( $file, 'DTC_Specification_transformed.xml');
	my $reader = XML::LibXML::Reader->new( IO => $file ) or die ("unable to open file");
    
	 my %nums;
	 my $number;
	 my $infohash;
while ($reader->nextElement( 'Number' )) {
    my $number = $reader->copyCurrentNode(1)->textContent;

    $reader->nextElement( 'Address' ); 
    my $node = $reader->copyCurrentNode(1); 
    my $infohash = {
        house => $node->getElementsByTagName(  'housenumber' )[0]->textContent,
       street => $node->getElementsByTagName(  'streetname')[0]->textContent,
                     };
    $nums{$number} = $infohash;
 }

i am getting syntax error at near ")[" at 21line and at the end "}" at 25 line. how can rectify.
# 2  
Old 10-21-2011
Code:
#
# should the comma's at the end of the lines be there or are they supposed to be semi colons ..
# 
...
house => $node->getElementsByTagName(  'housenumber' )[0]->textContent,
       street => $node->getElementsByTagName(  'streetname')[0]->textContent,
...

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl program get a response before the program quits

I created a program, so a kid can practice there math on it. It dispenses varies math problems and the kid must input an answer. I also want it to grade the work they have done, but I can't find the best place for it to print out the grade. I have: if ( $response =~ m/^/ ) { $user_wants_to_quit... (1 Reply)
Discussion started by: germany1517
1 Replies

2. Shell Programming and Scripting

A Perl Syntax Question.

Greetings! Here's what I believe is a "simple one" for the community tonight ;) What I'm trying to do is assign a "true/false" value to a variable depending upon whether a named process (some-process) exists; and then test for this value in the succeeding logic. I banged my head against the... (2 Replies)
Discussion started by: LinQ
2 Replies

3. UNIX for Dummies Questions & Answers

Perl syntax

Query with perl syntax Aim: is to change a perl script to use a new file I was required to replace - entries \"$entries\" with -lib <full_path_to_filename> So in the code detector.pm sub rundetector { my $class = shift; mkdir($resultDirectory); my... (3 Replies)
Discussion started by: sa@@
3 Replies

4. Shell Programming and Scripting

Perl syntax

I'm a newbie to perl scripting. Can someone please explain the syntax below. Specifically what does -> and => do? $tz->site( => $site); (10 Replies)
Discussion started by: scj2012
10 Replies

5. Programming

Perl syntax question

Hallo everybody, I have a following problem - I'm doing a map funciont to fill in a HTML table and I want to use some radiobutton groups. Unfortunatelly, they are grouped by names, so I have to add some "counter" that will divide one row from another, and I'm using CGI.pm for generating the... (3 Replies)
Discussion started by: duskos
3 Replies

6. Homework & Coursework Questions

Calling compiled C program with Perl program

Long story short: I'm working inside of a Unix SSH under a bash shell. I have to code a C program that generates a random number. Then I have to call the compiled C program with a Perl program to run the C program 20 times and put all the generated random #s into a text file, then print that text... (1 Reply)
Discussion started by: jdkirby
1 Replies

7. Shell Programming and Scripting

perl syntax help

Im new at scripting and im trying to write a script using perl that will make sure there are 2 command line integer arguments and then check if the 2nd argument is greater than the first. i believe im close but still receive my error message even when i have 2 arguments and the second part gives me... (6 Replies)
Discussion started by: livewire06
6 Replies

8. Shell Programming and Scripting

Perl Grep Error - Possible Syntax?

Alrighty, I'm trying to get a perl script going to search through a bunch of files for me and compile it to a single location. I am currently having troubles on just getting the grep to work. Here is what I currently have: #!/usr/bin/perl open (LOG, "errors.txt") or die ("Unable to open... (2 Replies)
Discussion started by: adelsin
2 Replies

9. Linux

an error in perl program

Hi I am having a file with 243 lines.. The file format s given below eg P25787 hsa03050 1 P20618 hsa03050 1 P25786 hsa03050 1 P49721 hsa03050 1 P54132 hsa03440 1 Q13472 hsa03470 1 Q05513 hsa04530 hsa04910 hsa04930 3 Q04759 ... (0 Replies)
Discussion started by: binnybio
0 Replies

10. Shell Programming and Scripting

Perl Script Syntax error in version 4

Hi , I use the following simple perl script to find the yesterday time perl -e ' use POSIX(strftime); print POSIX::strftime("%a %b %e %H:%M:%S %Y", localtime(time-86400*$ARGV))' 1 However in the perl version 4 , it gives me the following error : Do the perl version 4 does not support... (4 Replies)
Discussion started by: youareapkman
4 Replies
Login or Register to Ask a Question