[24645] in Perl-Users-Digest
Perl-Users Digest, Issue: 6809 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 3 13:16:27 2004
Date: Tue, 3 Aug 2004 10:15:58 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 3 Aug 2004 Volume: 10 Number: 6809
Today's topics:
How to use Mozilla within Perl (to replace IE) <invalid@invalid.invalid>
Re: How to use Mozilla within Perl (to replace IE) <dwall@fastmail.fm>
Re: How to use Mozilla within Perl (to replace IE) <invalid@invalid.invalid>
Re: How to use Mozilla within Perl (to replace IE) <noreply@nowhere.com>
Re: How to use Mozilla within Perl (to replace IE) <Joe.Smith@inwap.com>
How to use perl to get all of a domains' nameservers. <artgh@hotmail.com>
Re: How to use perl to get all of a domains' nameserver (David Efflandt)
Re: How to use perl to get all of a domains' nameserver <gnari@simnet.is>
How to use perl to get lots of domans's IP address? <artgh@hotmail.com>
Re: How to use perl to get lots of domans's IP address? <kkeller-usenet@wombat.san-francisco.ca.us>
Re: How to use perl to get lots of domans's IP address? <someone@example.com>
Re: How to use perl to get lots of domans's IP address? <artgh@hotmail.com>
Re: How to use perl to get lots of domans's IP address? (Anno Siegel)
How to zip stderr message to a core file! <luke@program.com.tw>
Re: How to zip stderr message to a core file! <usenet@vyznev.invalid>
Hrs of work on regex: please help (Robert)
Re: Hrs of work on regex: please help <noreply@gunnar.cc>
Re: Hrs of work on regex: please help (Robert)
Re: Hrs of work on regex: please help <jgibson@mail.arc.nasa.gov>
Re: Hrs of work on regex: please help <noreply@gunnar.cc>
Re: Hrs of work on regex: please help <noreply@gunnar.cc>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 29 Jul 2004 18:44:09 GMT
From: "DG" <invalid@invalid.invalid>
Subject: How to use Mozilla within Perl (to replace IE)
Message-Id: <ZzbOc.179684$%_6.81508@attbi_s01>
Hello and thanks for the help,
I've used IE within Perl to access web sites. Given the recent IE security
problems, I'd like to replace it with Mozilla 1.71.
Unfortunately, I don't know how.
Below is an example of how I have used IE within Perl. How would I change
this code to access Mozilla?
thanks for the help,
DG
use Win32::OLE;
$BROWSER = Win32::OLE->new('InternetExplorer.Application'); #open the
browser
$BROWSER->with(Visible => 1, Top => 1, Left => 1, Height => 50, Width =>
500); #shrink the browser window, and place it in the upper left corner
$BROWSER->Navigate("http://wwws.yahoo.com"); #get the
cookies
do #wait until the first page finishes loading (to get the cookies) before
logging in
{
select(undef,undef,undef,0.1); #sleep 0.1 seconds (finer time resolution
than "sleep" command)
$stat=$BROWSER->{Busy}; #get the status of the browser load
}
while ($stat); #continue looping if the browser is NOT yet
done loading
# get the HTML data
$body=$BROWSER->Document->{body}; #get the hash string
returned by the browser
$mystring= $body->{innerHTML}; #get the HTML data from
browser
#$mystring= $body->{innerTEXT}; #removes all HTML commands
leaving only the text
------------------------------
Date: Thu, 29 Jul 2004 19:09:13 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: How to use Mozilla within Perl (to replace IE)
Message-Id: <Xns95359A268C7ACdkwwashere@216.168.3.30>
DG <invalid@invalid.invalid> wrote in message
<news:ZzbOc.179684$%_6.81508@attbi_s01>:
> I've used IE within Perl to access web sites. Given the recent IE
> security problems, I'd like to replace it with Mozilla 1.71.
Just use LWP::UserAgent and HTTP::Request. See lwpcook for examples and
lwptut for a tutorial on using the LWP libraries.
LWP (short for ``Library for WWW in Perl'') is a very popular
group of Perl modules for accessing data on the Web.
------------------------------
Date: Thu, 29 Jul 2004 19:52:03 GMT
From: "DG" <invalid@invalid.invalid>
Subject: Re: How to use Mozilla within Perl (to replace IE)
Message-Id: <CzcOc.210381$XM6.126778@attbi_s53>
"David K. Wall" <dwall@fastmail.fm> wrote in message
news:Xns95359A268C7ACdkwwashere@216.168.3.30...
> DG <invalid@invalid.invalid> wrote in message
> <news:ZzbOc.179684$%_6.81508@attbi_s01>:
>
> > I've used IE within Perl to access web sites. Given the recent IE
> > security problems, I'd like to replace it with Mozilla 1.71.
>
> Just use LWP::UserAgent and HTTP::Request. See lwpcook for examples and
> lwptut for a tutorial on using the LWP libraries.
>
> LWP (short for ``Library for WWW in Perl'') is a very popular
> group of Perl modules for accessing data on the Web.
>
Thanks for the reply.
I've used these libraries in the past (prior to switching to IE), and found
they didn't meet my needs. For example: sometimes I need a browser window
to open for the user to view, and these libraries don't do that. Also, I've
had problems with secure sites (https://) not liking the way these libraries
handle cookies (usually because these sites use JavaScript to modify
cookies). I worked around these problems for a while, but finally decided
that it was just easier to just use a full blown browser. That's when I
switched to using IE within Perl (I also found a side benefit that I didn't
need to upgrade the code when new developments in web pages occurred,
because handlers for these upgrades were built into the browser updates).
So, based on this past experience, I'd like to use a full browser within
Perl. That's why I'm asking how to use Mozilla within Perl.
But thanks for taking the time to suggest a solution,
DG
------------------------------
Date: Thu, 29 Jul 2004 22:04:08 GMT
From: Shailesh Humbad <noreply@nowhere.com>
Subject: Re: How to use Mozilla within Perl (to replace IE)
Message-Id: <sveOc.44$sl6.35@fe2.columbus.rr.com>
DG wrote:
> "David K. Wall" <dwall@fastmail.fm> wrote in message
> news:Xns95359A268C7ACdkwwashere@216.168.3.30...
>
>>DG <invalid@invalid.invalid> wrote in message
>><news:ZzbOc.179684$%_6.81508@attbi_s01>:
>>
>>
>>>I've used IE within Perl to access web sites. Given the recent IE
>>>security problems, I'd like to replace it with Mozilla 1.71.
>>
>>Just use LWP::UserAgent and HTTP::Request. See lwpcook for examples and
>>lwptut for a tutorial on using the LWP libraries.
>>
>> LWP (short for ``Library for WWW in Perl'') is a very popular
>> group of Perl modules for accessing data on the Web.
>>
>
>
> Thanks for the reply.
>
> I've used these libraries in the past (prior to switching to IE), and found
> they didn't meet my needs. For example: sometimes I need a browser window
> to open for the user to view, and these libraries don't do that. Also, I've
> had problems with secure sites (https://) not liking the way these libraries
> handle cookies (usually because these sites use JavaScript to modify
> cookies). I worked around these problems for a while, but finally decided
> that it was just easier to just use a full blown browser. That's when I
> switched to using IE within Perl (I also found a side benefit that I didn't
> need to upgrade the code when new developments in web pages occurred,
> because handlers for these upgrades were built into the browser updates).
> So, based on this past experience, I'd like to use a full browser within
> Perl. That's why I'm asking how to use Mozilla within Perl.
>
> But thanks for taking the time to suggest a solution,
> DG
>
>
Mozilla can't be automated as an OLE/ActiveX object the way Internet
Explorer can. I did find this:
http://www.iol.ie/~locka/mozilla/control.htm
Mozilla ActiveX control, but I know nothing about it. It might work
for you.
In general, to retrieve/post HTTP, use the LWP libraries. You can
always launch Mozilla easily by writing a temporary HTML file that
does anything special you need it to, and then using a
system("c:\program files\...\mozilla.exe") to open it. Look here for
Mozilla command line options:
http://www.mozilla.org/docs/command-line-args.html
------------------------------
Date: Fri, 30 Jul 2004 12:37:30 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: How to use Mozilla within Perl (to replace IE)
Message-Id: <eirOc.185394$IQ4.94922@attbi_s02>
Shailesh Humbad wrote:
> In general, to retrieve/post HTTP, use the LWP libraries.
Yes, but if you know ahead of time that the HTML will be containing
JavaScript, then you'll want to use a browser instead of just LWP.
-Joe
------------------------------
Date: Mon, 02 Aug 2004 11:35:50 +0800
From: Facco Eloelo <artgh@hotmail.com>
Subject: How to use perl to get all of a domains' nameservers.
Message-Id: <410ea088.6613890@news.individual.net>
usually,I use "www.internic" to get a domain's a nameservers or use the command
"nslookup--->set q=mx"
How to use perl to achive the same goal or are there any perl moudle can be
used?Thanks in advance.
------------------------------
Date: Mon, 2 Aug 2004 04:35:05 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: How to use perl to get all of a domains' nameservers.
Message-Id: <slrncgrh3p.1e3.efflandt@typhoon.xnet.com>
On Mon, 02 Aug 2004 11:35:50 +0800, Facco Eloelo <artgh@hotmail.com> wrote:
> usually,I use "www.internic" to get a domain's a nameservers or use the command
> "nslookup--->set q=mx"
>
> How to use perl to achive the same goal or are there any perl moudle can be
> used?Thanks in advance.
Search a CPAN mirror near you. Or try the CPAN mirror link at
www.perl.com. Should be easy enough to find Net::DNS (Latest Release:
Net-DNS-0.47_01).
--
David Efflandt - All spam ignored http://www.de-srv.com/
------------------------------
Date: Mon, 2 Aug 2004 11:33:18 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: How to use perl to get all of a domains' nameservers.
Message-Id: <cel8m3$ku7$1@news.simnet.is>
"Facco Eloelo" <artgh@hotmail.com> wrote in message
news:410ea088.6613890@news.individual.net...
> usually,I use "www.internic" to get a domain's a nameservers or use the
command
> "nslookup--->set q=mx"
>
> How to use perl to achive the same goal or are there any perl moudle can
be
> used?Thanks in advance.
why a new thread ?
if all else fails, there is allways LWP
gnari
------------------------------
Date: Thu, 29 Jul 2004 12:44:41 +0800
From: Facco Eloelo <artgh@hotmail.com>
Subject: How to use perl to get lots of domans's IP address?
Message-Id: <41087edb.8402912@news.individual.net>
I have lots of domains' name in a text file which called "in.txt".It looks like
that:
in.txt
www.yahoo.com
www.msn.com
www.aol.com
...
Now,I want to get their IP addresses,and put the results into a new text file
called "out.txt".It looks like:
out.txt
www.yahoo.com,66.94.230.51
www.baidu.com,202.108.250.249
www.sina.com.cn,61.135.152.77
www.sohu.com,61.135.150.75
How can I do that using Perl?Thanks in advance.
------------------------------
Date: Wed, 28 Jul 2004 22:20:21 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: How to use perl to get lots of domans's IP address?
Message-Id: <l1emt1xm5q.ln2@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
On 2004-07-29, Facco Eloelo <artgh@hotmail.com> wrote:
> I have lots of domains' name in a text file which called "in.txt".It looks like
> that:
>
> in.txt
> www.yahoo.com
> www.msn.com
> www.aol.com
> ...
>
>
> Now,I want to get their IP addresses,and put the results into a new text file
> called "out.txt".It looks like:
>
> out.txt
> www.yahoo.com,66.94.230.51
> www.baidu.com,202.108.250.249
> www.sina.com.cn,61.135.152.77
> www.sohu.com,61.135.150.75
>
> How can I do that using Perl?Thanks in advance.
You can use Net::DNS, open the input file for reading, output
file for writing, loop over each line in the input, do the DNS
DNS query, and print to the output filehandle. If you have code
that's giving you trouble, you might consider posting it.
- --keith
- --
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFBCIkThVcNCxZ5ID8RAgHpAJ4ryti+wNOf00pXaB1bqbc+NJMJcACeMWwy
AEGTrkmwPfmbeOsoWEThwYg=
=/Npn
-----END PGP SIGNATURE-----
------------------------------
Date: Thu, 29 Jul 2004 06:06:51 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: How to use perl to get lots of domans's IP address?
Message-Id: <%t0Oc.75090$iw3.3829@clgrps13>
Facco Eloelo wrote:
> I have lots of domains' name in a text file which called "in.txt".It looks like
> that:
>
> in.txt
> www.yahoo.com
> www.msn.com
> www.aol.com
> ...
>
> Now,I want to get their IP addresses,and put the results into a new text file
> called "out.txt".It looks like:
>
> out.txt
> www.yahoo.com,66.94.230.51
> www.baidu.com,202.108.250.249
> www.sina.com.cn,61.135.152.77
> www.sohu.com,61.135.150.75
>
> How can I do that using Perl?Thanks in advance.
This should do what you want:
#!/usr/bin/perl
use warnings;
use strict;
use Socket;
my $in_file = 'in.txt';
my $out_file = 'out.txt';
open my $in, '<', $in_file or die "Cannot open $in_file: $!";
open my $out, '>', $out_file or die "Cannot open $out_file: $!";
while ( <$in> ) {
chomp;
my $ip = gethostbyname $_;
print $out "$_,", inet_ntoa( $ip ), "\n" if defined $ip;
}
__END__
John
--
use Perl;
program
fulfillment
------------------------------
Date: Thu, 29 Jul 2004 14:39:15 +0800
From: Facco Eloelo <artgh@hotmail.com>
Subject: Re: How to use perl to get lots of domans's IP address?
Message-Id: <410b98c4.15036040@news.individual.net>
Thank you very muc, John!
The script that you wrote is wonderful.
But there is a problem:
in fact,my "in.txt" contains nearly 1000 domains' names,
so,the time of the process is too long to wait.
Is there a good method to show the processing percent or the remaining time when
the script is runing?
thanks again!
--
------------------------------
Date: 29 Jul 2004 10:10:51 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to use perl to get lots of domans's IP address?
Message-Id: <ceaifb$kd0$2@mamenchi.zrz.TU-Berlin.DE>
Facco Eloelo <artgh@hotmail.com> wrote in comp.lang.perl.misc:
> Thank you very muc, John!
> The script that you wrote is wonderful.
>
> But there is a problem:
> in fact,my "in.txt" contains nearly 1000 domains' names,
> so,the time of the process is too long to wait.
>
> Is there a good method to show the processing percent or the remaining time when
> the script is runing?
What have you tried to add that feature to John's solution?
Anno
------------------------------
Date: Fri, 23 Jul 2004 19:33:05 +0800
From: "news.hinet.net" <luke@program.com.tw>
Subject: How to zip stderr message to a core file!
Message-Id: <cdqt2j$ii2$1@netnews.hinet.net>
open STDERR, "../tmp/core" or die " Can't write to ../tmp/core : $! \";
1.How to zip stderr and insert the message to a zip file(core)?
2.Could i add some string to stderr?? Ex: date info
------------------------------
Date: Fri, 23 Jul 2004 23:02:23 +0300
From: Ilmari Karonen <usenet@vyznev.invalid>
Subject: Re: How to zip stderr message to a core file!
Message-Id: <slrncg2rmf.vf.usenet@yhteiskone.vyznev.net>
On 2004-07-23, news.hinet.net <luke@program.com.tw> wrote:
>
> 1.How to zip stderr and insert the message to a zip file(core)?
"Zip"? Like this?
open STDERR, '|gzip >>../tmp/core' or die "Can't redirect stderr: $!\n";
If you want to put stderr later the way it was, you need to dup it
first:
open TMPERR, '>&', \*STDERR or die "Can't dup stderr: $!\n";
open STDERR, '|gzip >>../tmp/core' or die "Can't redirect stderr: $!\n";
# ... do stuff ...
open STDERR, '>&', \*TMPERR or die "can't restore stderr: $!\n";
> 2.Could i add some string to stderr?? Ex: date info
You can do this by opening a pipe to (a fork of) yourself:
defined(my $pid = open STDERR, '|-') or die "Can't fork: $!\n";
if (!$pid) {
while (<STDIN>) {
print STDERR "[".gmtime()." GMT] $_";
}
exit;
}
Combining the two solutions is left as an exercise.
--
Ilmari Karonen
If replying by e-mail, please replace ".invalid" with ".net" in address.
------------------------------
Date: 26 Jul 2004 17:51:02 -0700
From: robert_bondi@intuit.com (Robert)
Subject: Hrs of work on regex: please help
Message-Id: <f46a37bb.0407261651.417c7469@posting.google.com>
After this message text is a pasted xml file I've been working
(wrestling) with.
The goal is to remove text from the file that begins with:
"<ns0:ErrorDetails>" and ends with "</ns0:ErrorDetails>".
I have done several other s/// type operations to this file to remove
other text parts, and it was no problem. I've heard the 'devil is in
the details' and I believe it now, hehe.
I have copy 'n pasted the text surrounding the target before and
after, and made a string of it in a simple Perl script. I had to use
single quotes, due to the numerous double quotes in the text. I used
the same s/// operation and it printed as I want! Wonderful, I
thought, now to do it on the file contents. But, it just will not do a
replace. It is getting beyond the point where I can think on this
problem without my brain feeling a spinning motion. I humbly submit my
problem for discussion.
My code follows:
#!/usr/bin/perl
my $results_dir = $ARGV[0];
my $expected_results_dir = "$results_dir/expectedresults";
my $cleaned_results_dir = "$results_dir/cleanedresults";
my $cleaned_expected_results_dir =
"$results_dir/expectedresults/cleanedexpectedresults";
my $cleaned_xml = "";
my $clean_file = "";
my $Line = "";
opendir(BIN, $results_dir) or die "Can't open directory: $dir: $!";
FILE_CLEAN: while( defined ($file = readdir BIN) )
{
next FILE_CLEAN if $file =~ /^\.\.?$/; # skip . and ..
next FILE_CLEAN if (-d "$results_dir/$file");# skip if it is
directory
open(To_Clean, "$results_dir/$file") or die "Can't open $To_Clean:
$!\n";
my @data = <To_Clean>; #read file contents
close(To_Clean); #close file
$clean_file = "$cleaned_results_dir/$file";
for (my $i = 0; $i < scalar(@data); ++$i) {
$Line = $data[$i];
#replace whitespaces at beginning and end with nothing
chomp $Line;
$Line =~ tr/\t/ /;
$Line =~ s/\t//g;
$Line =~ s/\<ns0:ErrorDetails\>.*?\<\/ns0:ErrorDetails\>//g;
$cleaned_xml = $cleaned_xml . $Line;
$Line = "";
};#END FOR
open(CLEANFILE, ">$clean_file") or die "Can't open $clean_file:
$!\n";
print CLEANFILE $cleaned_xml;
close(CLEANFILE);
$cleaned_xml = "";
};#END WHILE
print "...DONE\n";
closedir(BIN);
################################################################################
<?xml version="1.0" encoding="UTF-8"?>
<ns0:BOBEntitlementRoot xmlns:ns0="http://www.noco.com/BOBEntitlement"
version="NA"><ns0:ApplicationArea><ns0:CreationDateTime>2004-07-26T14:07:02.248-07:00</ns0:CreationDateTime><ns0:SourceSystem>HANDSHAKE</ns0:SourceSystem><ns0:Operation><ns0:Name>UnknownOperation</ns0:Name><ns0:Version>NA</ns0:Version></ns0:Operation></ns0:ApplicationArea><ns0:DataArea><ns0:Status><ns0:StatusCode>Failure</ns0:StatusCode><ns0:Error><ns0:ErrorCode>2101</ns0:ErrorCode><ns0:ErrorSever
ty>Error</ns0:ErrorSeverity><ns0:ErrorCategory>InputFormatError</ns0:ErrorCategory><ns0:ErrorDescription>Invalid
XML request. </ns0:ErrorDescription><ns0:ErrorDetails>Job-4296 Error
in [Processes/Integration_Interfaces/getEntitlement/getBHAPIJMSRequest_1.process/Group
(1)/Group/Parse XML]
Output data invalid
at com.tibco.pe.core.TaskImpl.a(TaskImpl.java:501)
at com.tibco.pe.core.TaskImpl.eval(TaskImpl.java:428)
at com.tibco.pe.core.Job.a(Job.java:591)
at com.tibco.pe.core.Job.if(Job.java:443)
at com.tibco.pe.core.JobDispatcher$a.a(JobDispatcher.java:270)
at com.tibco.pe.core.JobDispatcher$a.run(JobDispatcher.java:218)
caused by: org.xml.sax.SAXException: validation error: unexpected
content "{http://www.noco.com/BOBEntitlement}Sku"; expected
"{http://www.noco.com/BOBEntitlement}Name" or
"{http://www.noco.com/BOBEntitlement}Description" or
"{http://www.noco.com/BOBEntitlement}DomainType" or
"{http://www.noco.com/BOBEntitlement}PropertyTypeStatus" or
"{http://www.noco.com/BOBEntitlement}ChangeDate" or
"{http://www.noco.com/BOBEntitlement}DefaultValue" or
"{http://www.noco.com/BOBEntitlement}UsageType"
({com.tibco.xml.validation}COMPLEX_E_UNEXPECTED_CONTENT) at
/BOBEntitlementRoot[1]/DataArea[1]/BOBEntitlement[1]/OfferingProperty[1]/OfferingPropertyType[1]/Sku[1]
java.lang.Exception: unexpected content
"{http://www.noco.com/BOBEntitlement}Sku"; expected
"{http://www.noco.com/BOBEntitlement}Name" or
"{http://www.noco.com/BOBEntitlement}Description" or
"{http://www.noco.com/BOBEntitlement}DomainType" or
"{http://www.noco.com/BOBEntitlement}PropertyTypeStatus" or
"{http://www.noco.com/BOBEntitlement}ChangeDate" or
"{http://www.noco.com/BOBEntitlement}DefaultValue" or
"{http://www.noco.com/BOBEntitlement}UsageType"
at com.tibco.xml.validation.helpers.d.a(XmlContentValidatorElementContext.java:348)
at com.tibco.xml.validation.helpers.h.if(XmlContentValidator.java:753)
at com.tibco.xml.validation.helpers.h.text(XmlContentValidator.java:1601)
at com.tibco.xml.datamodel.nodes.Text.content(Text.java:327)
at com.tibco.xml.datamodel.nodes.Element.content(Element.java:1101)
at com.tibco.xml.datamodel.nodes.Element.content(Element.java:1101)
at com.tibco.xml.datamodel.nodes.Element.content(Element.java:1101)
at com.tibco.xml.datamodel.nodes.Element.content(Element.java:1101)
at com.tibco.xml.datamodel.nodes.Element.content(Element.java:1101)
at com.tibco.xml.datamodel.nodes.Element.content(Element.java:1101)
at com.tibco.xml.datamodel.nodes.Document.content(Document.java:226)
at com.tibco.xml.datamodel.nodes.Document.serialize(Document.java:242)
at com.tibco.xml.xdata.bind.BindingRunner.validate(BindingRunner.java:302)
at com.tibco.xml.xdata.bind.OutputBindingRunner.validate(OutputBindingRunner.java:47)
at com.tibco.pe.core.TaskImpl.a(TaskImpl.java:489)
at com.tibco.pe.core.TaskImpl.eval(TaskImpl.java:428)
at com.tibco.pe.core.Job.a(Job.java:591)
at com.tibco.pe.core.Job.if(Job.java:443)
at com.tibco.pe.core.JobDispatcher$a.a(JobDispatcher.java:270)
at com.tibco.pe.core.JobDispatcher$a.run(JobDispatcher.java:218)
validation error: no declaration for element
"{http://www.noco.com/BOBEntitlement}Sku"
({com.tibco.xml.validation}COMPLEX_E_MISSING_ELEMENT_DECLARATION) at
/BOBEntitlementRoot[1]/DataArea[1]/BOBEntitlement[1]/OfferingProperty[1]/OfferingPropertyType[1]/Sku[1]
java.lang.Exception: no declaration for element
"{http://www.noco.com/BOBEntitlement}Sku"
at com.tibco.xml.validation.helpers.d.if(XmlContentValidatorElementContext.java:615)
at com.tibco.xml.validation.helpers.d.a(XmlContentValidatorElementContext.java:180)
at com.tibco.xml.validation.helpers.h.if(XmlContentValidator.java:818)
at com.tibco.xml.validation.helpers.h.text(XmlContentValidator.java:1601)
at com.tibco.xml.datamodel.nodes.Text.content(Text.java:327)
at com.tibco.xml.datamodel.nodes.Element.content(Element.java:1101)
at com.tibco.xml.datamodel.nodes.Element.content(Element.java:1101)
at com.tibco.xml.datamodel.nodes.Element.content(Element.java:1101)
at com.tibco.xml.datamodel.nodes.Element.content(Element.java:1101)
at com.tibco.xml.datamodel.nodes.Element.content(Element.java:1101)
at com.tibco.xml.datamodel.nodes.Element.content(Element.java:1101)
at com.tibco.xml.datamodel.nodes.Document.content(Document.java:226)
at com.tibco.xml.datamodel.nodes.Document.serialize(Document.java:242)
at com.tibco.xml.xdata.bind.BindingRunner.validate(BindingRunner.java:302)
at com.tibco.xml.xdata.bind.OutputBindingRunner.validate(OutputBindingRunner.java:47)
at com.tibco.pe.core.TaskImpl.a(TaskImpl.java:489)
at com.tibco.pe.core.TaskImpl.eval(TaskImpl.java:428)
at com.tibco.pe.core.Job.a(Job.java:591)
at com.tibco.pe.core.Job.if(Job.java:443)
at com.tibco.pe.core.JobDispatcher$a.a(JobDispatcher.java:270)
at com.tibco.pe.core.JobDispatcher$a.run(JobDispatcher.java:218)
validation error: unexpected end of content
({com.tibco.xml.validation}COMPLEX_E_UNEXPECTED_END_OF_CONTENT) at
/BOBEntitlementRoot[1]/DataArea[1]/BOBEntitlement[1]/OfferingProperty[1]/OfferingPropertyType[1]
java.lang.Exception: unexpected end of content
at com.tibco.xml.validation.helpers.d.case(XmlContentValidatorElementContext.java:414)
at com.tibco.xml.validation.helpers.h.a(XmlContentValidator.java:1182)
at com.tibco.xml.validation.helpers.h.endElement(XmlContentValidator.java:1034)
at com.tibco.xml.datamodel.nodes.Element.content(Element.java:1108)
at com.tibco.xml.datamodel.nodes.Element.content(Element.java:1101)
at com.tibco.xml.datamodel.nodes.Element.content(Element.java:1101)
at com.tibco.xml.datamodel.nodes.Element.content(Element.java:1101)
at com.tibco.xml.datamodel.nodes.Element.content(Element.java:1101)
at com.tibco.xml.datamodel.nodes.Document.content(Document.java:226)
at com.tibco.xml.datamodel.nodes.Document.serialize(Document.java:242)
at com.tibco.xml.xdata.bind.BindingRunner.validate(BindingRunner.java:302)
at com.tibco.xml.xdata.bind.OutputBindingRunner.validate(OutputBindingRunner.java:47)
at com.tibco.pe.core.TaskImpl.a(TaskImpl.java:489)
at com.tibco.pe.core.TaskImpl.eval(TaskImpl.java:428)
at com.tibco.pe.core.Job.a(Job.java:591)
at com.tibco.pe.core.Job.if(Job.java:443)
at com.tibco.pe.core.JobDispatcher$a.a(JobDispatcher.java:270)
at com.tibco.pe.core.JobDispatcher$a.run(JobDispatcher.java:218)
at com.tibco.xml.xdata.bind.BindingRemarkHandler.assertNoErrors(BindingRemarkHandler.java:43)
at com.tibco.xml.xdata.bind.BindingRunner.validate(BindingRunner.java:319)
at com.tibco.xml.xdata.bind.OutputBindingRunner.validate(OutputBindingRunner.java:47)
at com.tibco.pe.core.TaskImpl.a(TaskImpl.java:489)
at com.tibco.pe.core.TaskImpl.eval(TaskImpl.java:428)
at com.tibco.pe.core.Job.a(Job.java:591)
at com.tibco.pe.core.Job.if(Job.java:443)
at com.tibco.pe.core.JobDispatcher$a.a(JobDispatcher.java:270)
at com.tibco.pe.core.JobDispatcher$a.run(JobDispatcher.java:218)
</ns0:ErrorDetails></ns0:Error></ns0:Status></ns0:DataArea></ns0:BOBEntitlementRoot>
------------------------------
Date: Tue, 27 Jul 2004 03:15:17 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Hrs of work on regex: please help
Message-Id: <2mlootFonsi8U1@uni-berlin.de>
Robert wrote:
> The goal is to remove text from the file that begins with:
> "<ns0:ErrorDetails>" and ends with "</ns0:ErrorDetails>".
Hmm.. Far too much code for my taste. ;-)
<snip>
> my @data = <To_Clean>; #read file contents
Here you slurp the file into an array, where each line is a separate
element.
<snip>
> for (my $i = 0; $i < scalar(@data); ++$i) {
Here you start various operations for each line.
<snip>
> $Line =~ s/\<ns0:ErrorDetails\>.*?\<\/ns0:ErrorDetails\>//g;
Since the start and end tags appear on different lines, that pattern
will never match.
Try slurping the file into a scalar variable instead, and add the /s
modifier to the s/// operator.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 27 Jul 2004 13:09:49 -0700
From: robert_bondi@intuit.com (Robert)
Subject: Re: Hrs of work on regex: please help
Message-Id: <f46a37bb.0407271209.73b4860f@posting.google.com>
Thanks for the reply. Just to close the loop, what I ended up doing
was using the join function on the @data variable. I then used the
tr/// function to replace tabs and newlines with a space char. Now,
everything is set for the substituion, and the resulting files are
still able to be viewed as xml!
The main thing I have learned is when I spend more than an hour on a
problem, look at it from a different direction.
Thanks, again.
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<2mlootFonsi8U1@uni-berlin.de>...
> Robert wrote:
> > The goal is to remove text from the file that begins with:
> > "<ns0:ErrorDetails>" and ends with "</ns0:ErrorDetails>".
>
> Hmm.. Far too much code for my taste. ;-)
>
> <snip>
>
> > my @data = <To_Clean>; #read file contents
>
> Here you slurp the file into an array, where each line is a separate
> element.
>
> <snip>
>
> > for (my $i = 0; $i < scalar(@data); ++$i) {
>
> Here you start various operations for each line.
>
> <snip>
>
> > $Line =~ s/\<ns0:ErrorDetails\>.*?\<\/ns0:ErrorDetails\>//g;
>
> Since the start and end tags appear on different lines, that pattern
> will never match.
>
> Try slurping the file into a scalar variable instead, and add the /s
> modifier to the s/// operator.
------------------------------
Date: Tue, 27 Jul 2004 14:58:06 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Hrs of work on regex: please help
Message-Id: <270720041458064786%jgibson@mail.arc.nasa.gov>
In article <f46a37bb.0407261651.417c7469@posting.google.com>, Robert
<robert_bondi@intuit.com> wrote:
[problem description snipped]
>
> My code follows:
> #!/usr/bin/perl
You should have 'use strict;' here. You are declaring variables with
'my', so why not ask Perl for help.
> my $results_dir = $ARGV[0];
> my $expected_results_dir = "$results_dir/expectedresults";
> my $cleaned_results_dir = "$results_dir/cleanedresults";
> my $cleaned_expected_results_dir =
> "$results_dir/expectedresults/cleanedexpectedresults";
The above three lines are irrelevant to your problem, and should be
eliminated from your posted code. Please try to always post the
shortest possible program that illustrates the problem you are having.
> my $cleaned_xml = "";
> my $clean_file = "";
> my $Line = "";
Unneeded initialization of variables.
> opendir(BIN, $results_dir) or die "Can't open directory: $dir: $!";
You probably want $results_dir instead of $dir in your error message.
> FILE_CLEAN: while( defined ($file = readdir BIN) )
You don't need to name this loop because you are not using any loop
control in any inner loop.
> {
> next FILE_CLEAN if $file =~ /^\.\.?$/; # skip . and ..
> next FILE_CLEAN if (-d "$results_dir/$file");# skip if it is
You can just use 'next if ...' here.
> directory
> open(To_Clean, "$results_dir/$file") or die "Can't open $To_Clean:
> $!\n";
The variable $To_Clean contains nothing. Had you put 'use strict;' at
the beginning of your program, perl would have shown you this error.
> my @data = <To_Clean>; #read file contents
As Gunnar pointed out, you probably want to replace this with 'my $data
= <To_Clean>;'
> close(To_Clean); #close file
> $clean_file = "$cleaned_results_dir/$file";
> for (my $i = 0; $i < scalar(@data); ++$i) {
You can more simply say 'for my $Line ( @data ) {', although if you
follows Gunnar's advice you won't be using @data.
> $Line = $data[$i];
> #replace whitespaces at beginning and end with nothing
> chomp $Line;
> $Line =~ tr/\t/ /;
> $Line =~ s/\t//g;
You just changed all of the tab characters to spaces. Why are you now
trying to change them to nothings.
> $Line =~ s/\<ns0:ErrorDetails\>.*?\<\/ns0:ErrorDetails\>//g;
You don't need to escape < and > as they are not special in a
double-quotish context. If you don't use forward slashes to delimit
your substitution strings, you won't have to escape the forward slashes
in your strings, either.
If you have slurped your file into a single variable, you can use
something like (untested):
$data =~ s|<ns0:ErrorDetails>.*?</ns0:ErrorDetails>||g;
[rest of program and way too much test data snipped]
Good luck!
------------------------------
Date: Thu, 29 Jul 2004 21:31:13 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Hrs of work on regex: please help
Message-Id: <2mt1mvFqldc2U1@uni-berlin.de>
Jim Gibson wrote:
> Robert wrote:
>>
>> my @data = <To_Clean>; #read file contents
>
> As Gunnar pointed out, you probably want to replace this with 'my
> $data = <To_Clean>;'
That must be combined with enabling "slurp" mode:
local $/;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 29 Jul 2004 21:31:16 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Hrs of work on regex: please help
Message-Id: <2mt1n2Fqldc2U2@uni-berlin.de>
Robert wrote:
> Gunnar Hjalmarsson wrote:
>> Robert wrote:
>>> The goal is to remove text from the file that begins with:
>>> "<ns0:ErrorDetails>" and ends with "</ns0:ErrorDetails>".
>>
>> Try slurping the file into a scalar variable instead, and add the
>> /s modifier to the s/// operator.
>
> Thanks for the reply. Just to close the loop, what I ended up doing
> was using the join function on the @data variable.
You could have skipped the @data array by just doing:
my $data = do { local $/; <To_Clean> };
> I then used the tr/// function to replace tabs and newlines with a
> space char.
Why? I suspect that the reason is that you are unfamiliar with the /s
modifier. Read about it in "perldoc perlre".
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6809
***************************************