Because I am not a very good perl programmer (but working on it) an unable
to answer most of the questions from the group, I thought I could at least
contribute what I have learned so I can help others that are in my position.
Today I learned something about XML::Writer where I was using single
When generating a file with XML::Writer the script certainly builds the file
but when I go to test for it, it fails. Does anyone have a reason why? How
do I create a file that I can use in the rest of my script?
use XML::Writer;
use IO::File;
my $output = new IO::File(test.xml);
my $writer =
My script is having problems reading and XML file with only one record in
it. When I add two or more records, there are no problems. The error is
Not and ARRAY reference..
Here is the PROBLEM xml file (test.xml):
?xml version=1.0 encoding=ISO-8859-1 ?
DATA
RECORD
COLLNAMEFBIS2004/COLLNAME
print Hash Values Output: \n;
foreach my $value_values (values %starrecords) {
print $value_values\n;
}
On 3/26/07, Rob Dixon [EMAIL PROTECTED] wrote:
Dave Adams wrote:
What are the general steps to building a hash from and xml document?
Here are my steps:
1. Read in xml document using
What are the general steps to building a hash from and xml document?
Here are my steps:
1. Read in xml document using XML::Simple
2. Create and empty hash
3. Loop through $VAR1 (the anonymous datastructure) and populate hash
Is this the general idea or is there a simplier way?
Thanks to all,
How do I print the value of 'Time Magazine'?
Here is my file (ejournlist.xml):
?xml version='1.0'?
EJOURNLIST
EJOURN
TIAfrica Confidential/TI
ISSUEVol. 1, no.1/ISSUE
FILEFORMATPDFformat/FILEFORMAT
/EJOURN
EJOURN
TITime Magazine/TI
ISSUEVol. 1, no.1/ISSUE
FILEFORMATTXTformat/FILEFORMAT
I am trying to get the number of children of the root element and my script
gives me the number of children of the children instead.
Here is my XML document (ejournlist.xml):
?xml version='1.0'?
EJOURNLIST
EJOURN
TIAfrica Confidential/TI
ISSUEVol. 1, no.1/ISSUE
If I have a xml file like the following:
?xml version='1.0'?
employee
nameJohn Doe/name
age43/age
sexM/sex
departmentRecieving/department
/employee
employee
nameBob Gordon/name
age50/age
sexM/sex
departmentShipping/department
*My Code:*
my $logfile = logfile_with_content;
if (-w $logfile) {
print (True - file exists but empty);
}
if (-s $logfile) {
print (True - file exist and has content);
}
*My Output:*
True - file exists but empty True - file exist and has content
*My Question:*
Why do both test
', 'RecordNumber' = '23617', 'Id' = 'test'
};
*Question:* How do I get the value of RecordNumber?
Thanks in advance.
Dave Adams
++) {
push(@body, $textfile_contents[$i]);
}
Thanks again for all the contributors on the list.
Dave Adams
Question: How do you find a paragraph break in perl?
Synopsis: In a string I need to find the paragraph breaks and replace
it with a ^P. Here is my code.
#!/usr/bin/perl -w
use strict;
use Text::Wrap;
$my text = 'This is the FIRST paragraph.
This is the SECOND paragraph.';
print
break.
My desired output is: This is the FIRST paragraph^PThis is the SECOND paragraph
Thank you for your interest and your efforts to help me out. Very
much appreciated.
DA
On 10/14/05, Xavier Noria [EMAIL PROTECTED] wrote:
On Oct 14, 2005, at 16:13, Dave Adams wrote:
Question: How do you find
My Code:
--
#!/usr/bin/perl -w
use strict;
my $text= 'hello';
my $text2 = 'bye';
my $text3 =~ s/$text/$text2/g;
print $text3;
My Error:
---
F:\perlex\findpara.pl line 5.
Use of uninitialized value in print at F:\perlex\findpara.pl line 6.
My Questions:
When I do this:
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
my $grades = {tom= 50, sally= 60, harry = 70};
print Dumper($grades) ;
And perl gives me this:
$VAR1 = {
'harry' = 70,
'sally' = 60,
'tom' = 50
};
QUESTION: Does this mean that $grades is
QUESTION: What is the purpose of the line my $msg = shift;? I am
guessing it is for the @_ array but what list element is there to be
shifted off? It seems that the shift function is in a lot of
subroutines and I am confused as to their purpose.
#!/bin/perl -w
(my $PROGNAME = $0) =~ s/^.*\///;
Being a junior perl programmer, I read a lot of docs and I came across
a really good site that is well written and structured. If you are
just starting out, I would highly recommend it.
http://www.wdvl.com/Authoring/Languages/Perl/PerlfortheWeb/toc.html
My compliments to Aaron Weiss, the
Sometimes I get perl scripts that were developed on windows and then
brought over to UNIX and the scripts contain all the pesky
metacharacters of ^M and excessive blank lines.
Does anyone have a simple script to clean these files up or suggestions?
My appreciation in advance,
DA
--
To
I have a hash that I need to use later and display some values in a
particular order. Perl comes up with its own way of ordering it but I
am wondering if I can instruct perl to have it listed in the way that
I want.
Here is the code
#!/usr/bin/perl -w
use strict;
my $page = {
AUTHOR=John
I am trying to write a simple SOAP client written in perl and to talk to a
webservice written in .NET. I am unsuccessful. I believe the web service is
expecting document/literal SOAP messages but I think the SOAP::Lite module
sends stuff in RPC/encoded messages.
Is there any way of telling?
In the code below, I thought $array[2] and $array-[2] were different
but they give me the same result.
Any explaination for this?
my @array = (1,2,3);
my $array [EMAIL PROTECTED];
print ref($array);
print $array[2];
print $array-[2];
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional
and very clear.
On Fri, 2005-08-19 at 10:31 -0400, Dave Adams wrote:
In the code below, I thought $array[2] and $array-[2] were different
but they give me the same result.
Any explaination for this?
Try this: untested - and i don't usually use refs.
my @array = (1,2,3);
my $array_ref
I am trying to get the date stamps of multiple files on a win32
machine using the strftime function in a foreach loop.
For testing purpose, I take a single file and get the modification
time of it. This works.
I then recycle my code and place it in a foreach loop. This fails.
Error message
Robert,
Thanks very much. It works great. Your code was nice and simple.
Much appreciated.
DA
On 7/28/05, Robert [EMAIL PROTECTED] wrote:
I found this maybe it will help:
use strict;
use File::stat;
use POSIX qw(strftime);
my $file = 'test.txt';
my $s =
On a Win32 system, how do you get a date stamp of a file?
I used:
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use File::stat;
my $filename = test.txt;
my $stat = stat($filename);
print Dumper($stat);
my $modified_time = stat($filename)-mtime;
print (The modified time of $filename is:
I got this error that reads something like: Can't call method print
on unblessed reference at {script name} , STDIN chunk 1.
In general terms, can anyone tell the what this is about so I can comb
through my script and fix this problem.
Thanks in advance,
Dave Adams
--
To unsubscribe, e-mail
Does perl allow you to conditionally include a module?
For example:
#!/usr/bin/perl -w
use strict;
my $DEBUG = 0;
if (DEBUG) {
use diagnostics;
}
my $filename = test$$.txt;
open (FH , $filename) || die error: $!;
print (FH hi);
close (FH);
Although this is a simple and silly example, it
The following code looks too rigid, how can I achieve the same result
using one of the control structure (foreach, for, etc)?
#!/usr/bin/perl -w
use strict;
use Date::Calc qw(:all);
my @today = Today();
my $year_now = $today[0];
my $month_now = $today[1];
my $day_now = $today[2];
print
I want to create a variable, to be used for other stuff, using today's date.
Can anyone help me with the second last line?
use Time::localtime;
my $tm = localtime;
printf(The current date is
%04d%02d%02d\n,$tm-year+1900,($tm-mon)+1, $tm-mday);
my $currentdate = ??
print ($currentdate);
Can you use some sort of 'tail' command to get the last lines?
DA
On 7/16/05, Wiggins d'Anconia [EMAIL PROTECTED] wrote:
Octavian Rasnita wrote:
Hi,
I need to create a program which reads a file from the LAN, and that file is
continuously updated (kind of log).
The file increases
I can get date but not time.
use Time::localtime;
$tm = localtime;
printf(Current date: %04d-%02d-%02d\n,$tm-year+1900,($tm-mon)+1, $tm-mday);
printf(Current time: %02d:%02d:%02d\n,$tm-hours,$tm-min,$tm-sec);
Any help would be appreciated.
DA
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For
.
This is very frustrating for a beginner when the text book is wrong.
Thank you very much for the help.
DA
On 7/19/05, Wiggins d'Anconia [EMAIL PROTECTED] wrote:
Dave Adams wrote:
I can get date but not time.
use Time::localtime;
$tm = localtime;
printf(Current date: %04d-%02d-%02d\n,$tm-year
I am behind a firewall and I cannot get out to the internet and I want
to integrate a local copy of perl documentation in the the IDE of
Komodo, but the default is for it to go out to the internet to get it.
Does anyone know how to configure this?
Thanks in advance,
Dave Adams
--
To unsubscribe
%vegetable_costs = (Beans = 300
Carrots = 200,
Apple = 250 );
To get the value of the key called Beans you use $vegetable_costs{Beans} .
How do you do the reverse and get the value of the key?
Anyone?
--
To unsubscribe,
This code should work but it does not, any suggestions?
All I need is to create a temporary file to store some data so I can
stuff it into
another application and then trash it. I thought it would be easy.
use utf8;
use IO::Handle;
#use File::Copy;
use File::Temp qw /tempdir tempfile /;
$dir
I am new to PERL but how would I write a script that would read in a
file and output the last 10 lines?
I guess it is sort of like the UNIX command of Tail.
Any ideas, much appreciated.
DA
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
I have a 2 gig log file and I need to read only the last 10 lines.
I was also thinking something like:
1. Read in File
2. Get number of lines
3. Print last ten lines
or something like that.
DA
On 4/19/05, Wagner, David --- Senior Programmer Analyst --- WGO
[EMAIL PROTECTED] wrote:
Dave Adams
Hi there,
I have a problem which I would like to use perl to resolve, however I'm not
sure if it is possible to do.
I need to scan a file and check some conditions, first if field 9 is
duplicated on 1 or more rows, then I need to check field 10 to see which is
the greater value and then only
38 matches
Mail list logo