[28647] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 10011 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 27 18:06:07 2006

Date: Mon, 27 Nov 2006 15:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 27 Nov 2006     Volume: 10 Number: 10011

Today's topics:
    Re: Errors in Perl Function <someone@example.com>
    Re: Errors in Perl Function <thepoet_nospam@arcor.de>
    Re: Errors in Perl Function <glennj@ncf.ca>
    Re: Errors in Perl Function (hymie!)
        Expression problem <Holleran.Kevin@gmail.com>
    Re: Expression problem <antispam@randometry.com>
    Re: Expression problem <thepoet_nospam@arcor.de>
    Re: Expression problem xhoster@gmail.com
    Re: Expression problem <Holleran.Kevin@gmail.com>
    Re: handling hanging database connections: timeout in p <tadmc@augustmail.com>
        Help improving IO::Socket script response <dragnet\_@_/internalysis.com>
        How to find utf8.enc? <newsdog@quercus.org>
    Re: How to find utf8.enc? <john@castleamber.com>
    Re: How to find utf8.enc? <newsgroups@free.fr>
    Re: How to find utf8.enc? <newsdog@quercus.org>
        How to get the DOM from a XML page <novostik@googlemail.com>
    Re: How to get the DOM from a XML page <john@castleamber.com>
        Interactive programs & Teeing conrado.blasco@gmail.com
    Re: modPerl, Apache, and REMOTE_USER <no@email.com>
    Re: pretty print to postscript (or pdf or tex) for both <glennj@ncf.ca>
    Re: print_r() <tzz@lifelogs.com>
    Re: test message - please ignore <tadmc@augustmail.com>
        Using perl to parse verilog wolfpack307@yahoo.com
    Re: Using perl to parse verilog wolfpack307@yahoo.com
    Re: Using perl to parse verilog <glex_no-spam@qwest-spam-no.invalid>
        Windows CE, Windows Mobile sgbailey@iee.org
    Re: Windows CE, Windows Mobile <john@castleamber.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 27 Nov 2006 08:19:01 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Errors in Perl Function
Message-Id: <Vbxah.19829$1U5.153@edtnps90>

abhi147@gmail.com wrote:
> 
>  I have a shell script which has a small function to find previous
> day's date , which is a perl function.
> When I run this script on the command line , the script runs
> successfully . Whereas when I run it as a cron job , it gives errors .
> 
> The perl function in the shell script is :
> 
> ### To get yesterday's date ###
> function get_yesterday {
>     perl << "EOF"
>     my ($mday, $mon, $year) = (localtime(time()-86400))[3,4,5];
>     $mon++;
>     $year += 1900;
>     printf("%04d-%02d-%02d\n", $year, $mon, $mday);
> EOF
> }
> yesterday=$(get_yesterday)
> 
> The errors encountered were :
> 
> $ ./test.sh
> ./test.sh: function: not found
> 2006-11-23
> ./test.sh: syntax error at line 15: `}' unexpected
> 
> Can anyone please tell me .. that do I need to do something extra to
> run this script through crontab ?

Since this is a shell script why not use date?

$ date "+%Y%m%d"; date -d yesterday "+%Y%m%d"
20061127
20061126


But if you really must use Perl:

$ perl -MPOSIX -le'
print for strftime( "%Y%m%d", localtime ),
          strftime( "%Y%m%d", localtime time() - 86400 )
'
20061127
20061126



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


------------------------------

Date: Mon, 27 Nov 2006 09:27:41 +0100
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: Errors in Perl Function
Message-Id: <456aa17d$0$18836$9b4e6d93@newsspool4.arcor-online.net>

abhi147@gmail.com wrote:
> 
>  I have a shell script which has a small function to find previous
> day's date , which is a perl function.
> When I run this script on the command line , the script runs
> successfully . Whereas when I run it as a cron job , it gives errors .
> 
> The perl function in the shell script is :
> 
> ### To get yesterday's date ###
> function get_yesterday {
>     perl << "EOF"
>     my ($mday, $mon, $year) = (localtime(time()-86400))[3,4,5];
>     $mon++;
>     $year += 1900;
>     printf("%04d-%02d-%02d\n", $year, $mon, $mday);
> EOF
> }
> yesterday=$(get_yesterday)
> 
> The errors encountered were :
> 
> $ ./test.sh
> ./test.sh: function: not found
> 2006-11-23
> ./test.sh: syntax error at line 15: `}' unexpected
> 
> Can anyone please tell me .. that do I need to do something extra to
> run this script through crontab ?

Maybe you need to set the correct PATH environment variable or
put the full path to perl into your shell script.
Most cron version run with a limited environment for safety
reasons, excluding directories like /usr/local/bin from $PATH.

HTH
-Chris


------------------------------

Date: 27 Nov 2006 14:06:31 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: Errors in Perl Function
Message-Id: <slrnemls77.e3i.glennj@smeagol.ncf.ca>

At 2006-11-27 12:17AM, "abhi147@gmail.com" wrote:
>  When I run this script on the command line , the script runs
>  successfully . Whereas when I run it as a cron job , it gives errors .
[...]
>  $ ./test.sh
>  ./test.sh: function: not found
>  2006-11-23
>  ./test.sh: syntax error at line 15: `}' unexpected

What's the difference between your shell and cron's shell?

-- 
Glenn Jackman
Ulterior Designer


------------------------------

Date: Mon, 27 Nov 2006 09:38:37 -0600
From: hymie_@_lactose.homelinux.net (hymie!)
Subject: Re: Errors in Perl Function
Message-Id: <ZNGdnaPjiOHgm_bYnZ2dnUVZ_rydnZ2d@comcast.com>

In our last episode, the evil Dr. Lacto had captured our hero,
  "John W. Krahn" <krahnj@telus.net>, who said:
 
>Since this is a shell script why not use date?
>
>$ date "+%Y%m%d"; date -d yesterday "+%Y%m%d"
>20061127
>20061126

date -d is a gnu-specific extension that is not necessarily portable
across all systems.

>Perl isn't a toolbox, but a small machine shop where you can special-order
>certain sorts of tools at low cost and in short order.       -- Larry Wall

An old co-worker had a similar quote, which I don't know where he found:
Unix is all of the tools you need to build the machine you thought you bought.

hymie!        http://www.smart.net/~hymowitz        hymie@lactose.homelinux.net
===============================================================================


------------------------------

Date: 27 Nov 2006 13:40:31 -0800
From: "K.J. 44" <Holleran.Kevin@gmail.com>
Subject: Expression problem
Message-Id: <1164663631.228421.209640@45g2000cws.googlegroups.com>

I have the two following regular expressions.  I am not very good at
writing these yet.  I am parsing some logs looking for some key words,
then taking the text after them.

if ($details[$i] =~ /\bworkstation\b\bname:\b\s\b[0-9A-Za-z_\-]+\b/i) {
		($nothing, $hostName[$i]) = split(/:/, $&);
}
if ($details[$i] =~ /\buser\b\bname:\b\w+/i) {
		print("The username is: $&");
		($nothing, $username[$i]) = split(/:/, $&);
}

The $details array is read in from a text file and this works fine.
What I want to do is search the $details text for certain key words,
then take the text right after.  The first if statement

Find the word Workstation followed by a space followed by name:
followed by a space followed by a string of characters including word
characters and hyphens.  if the match is found, take only the text
after the : as the workstation name.

The second part is along the same lines for username.

Find the word user followed a space followed by the word name: followed
by a space followed by a string of word characters.  Split at the : as
the username found.

These do not seem to be finding matches when I can see them in the log
file.  Where am I messing up?  

Thanks.



------------------------------

Date: Mon, 27 Nov 2006 22:50:27 +0100
From: Ric <antispam@randometry.com>
Subject: Re: Expression problem
Message-Id: <ekfmpj$gga$1@online.de>

You need to post at least one of the lines you read from your text file.
You should name the values you would like to have extracted.

example line: 		yesterday 12:30 hans:went:home

var1 should contain: 	12:20
var2 should contain: 	went

this is much faster and precise than explaining something in a huge
block of text


K.J. 44 schrieb:
> I have the two following regular expressions.  I am not very good at
> writing these yet.  I am parsing some logs looking for some key words,
> then taking the text after them.
> 
> if ($details[$i] =~ /\bworkstation\b\bname:\b\s\b[0-9A-Za-z_\-]+\b/i) {
> 		($nothing, $hostName[$i]) = split(/:/, $&);
> }
> if ($details[$i] =~ /\buser\b\bname:\b\w+/i) {
> 		print("The username is: $&");
> 		($nothing, $username[$i]) = split(/:/, $&);
> }
> 
> The $details array is read in from a text file and this works fine.
> What I want to do is search the $details text for certain key words,
> then take the text right after.  The first if statement
> 
> Find the word Workstation followed by a space followed by name:
> followed by a space followed by a string of characters including word
> characters and hyphens.  if the match is found, take only the text
> after the : as the workstation name.
> 
> The second part is along the same lines for username.
> 
> Find the word user followed a space followed by the word name: followed
> by a space followed by a string of word characters.  Split at the : as
> the username found.
> 
> These do not seem to be finding matches when I can see them in the log
> file.  Where am I messing up?  
> 
> Thanks.
> 


------------------------------

Date: Mon, 27 Nov 2006 22:57:00 +0100
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: Expression problem
Message-Id: <456b5fa5$0$27624$9b4e6d93@newsspool2.arcor-online.net>

K.J. 44 wrote:
> I have the two following regular expressions.  I am not very good at
> writing these yet.  I am parsing some logs looking for some key words,
> then taking the text after them.
> 
> if ($details[$i] =~ /\bworkstation\b\bname:\b\s\b[0-9A-Za-z_\-]+\b/i) {
> 		($nothing, $hostName[$i]) = split(/:/, $&);
> }
> if ($details[$i] =~ /\buser\b\bname:\b\w+/i) {
> 		print("The username is: $&");
> 		($nothing, $username[$i]) = split(/:/, $&);
> }
> 
> The $details array is read in from a text file and this works fine.
> What I want to do is search the $details text for certain key words,
> then take the text right after.  The first if statement
> 
> Find the word Workstation followed by a space followed by name:
> followed by a space followed by a string of characters including word
> characters and hyphens.  if the match is found, take only the text
> after the : as the workstation name.
> 
> The second part is along the same lines for username.
> 
> Find the word user followed a space followed by the word name: followed
> by a space followed by a string of word characters.  Split at the : as
> the username found.
> 
> These do not seem to be finding matches when I can see them in the log
> file.  Where am I messing up?  

In that \b is a _zero width_ assertion, so the part
workstation\b\bname
can never match, as to match there would need to be a non-word
character between the "\b"s. In your case, they are completely
redundant, as workstation\sname implies the word boundary and
is virtually the same as workstation\b\s\bname.

In fact, you can get rid of (at least) all but the first \b
in your expressions.

If you use capturing parentheses, you can also avoid the use
of $&, which might slow you script down, and get rid of the split()
which fetches the whitespace.

So the first piece of code could be cut down to
if( $details[$i] =~ /\bworkstation\sname:\s([0-9A-Za-z_\-]+)/i )
{
	$hostName[$i] = $1;
}

There's still room for improvement, like e.g. removing A-Z from
the character class, as you are giving the /i modifier anyway,
so both upper and lowercase characters will be matched.

HTH
-Chris


------------------------------

Date: 27 Nov 2006 21:58:14 GMT
From: xhoster@gmail.com
Subject: Re: Expression problem
Message-Id: <20061127165939.362$80@newsreader.com>

"K.J. 44" <Holleran.Kevin@gmail.com> wrote:
> I have the two following regular expressions.  I am not very good at
> writing these yet.  I am parsing some logs looking for some key words,
> then taking the text after them.
>
> if ($details[$i] =~ /\bworkstation\b\bname:\b\s\b[0-9A-Za-z_\-]+\b/i) {

About the only places that \b should be used are the beginning or end
of the regex or before or after something like ".*".  Also, I don't see how
you can ever productively have more than one in a row, doing so is probably
exactly the same as having just one.

\b is a zero-width condition.  So "tion\b\bname" can never match because
you are demanding that there is a n before the \b zero-width placeholder,
and an n after the \b zero-width placeholder, and if that is the case then
the conditions which define \b are not met.  Similarly the \b in ":\b\s" is
impossible to ever match, as it has to have a non-word character on each
side which is what \b does not do.  The \b in "\s\b[0-9A-Za-z_\-]" is
almost redundant--it just forbid the "-" from the character class from
being used, which I doubt is what you want.

 ...

>
> Find the word Workstation followed by a space followed by name:
> followed by a space followed by a string of characters including word
> characters and hyphens.  if the match is found, take only the text
> after the : as the workstation name.

 ... /\bworkstation name: ([-\w]+)/i ...

If you "space" you meant "white space", then turn my spaces into "\s"
(not "\b").


Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: 27 Nov 2006 14:07:40 -0800
From: "K.J. 44" <Holleran.Kevin@gmail.com>
Subject: Re: Expression problem
Message-Id: <1164665260.285211.30040@j72g2000cwa.googlegroups.com>

Thank you very much for your help and suggestions.  I will try these
out.

Thanks!
xhoster@gmail.com wrote:
> "K.J. 44" <Holleran.Kevin@gmail.com> wrote:
> > I have the two following regular expressions.  I am not very good at
> > writing these yet.  I am parsing some logs looking for some key words,
> > then taking the text after them.
> >
> > if ($details[$i] =~ /\bworkstation\b\bname:\b\s\b[0-9A-Za-z_\-]+\b/i) {
>
> About the only places that \b should be used are the beginning or end
> of the regex or before or after something like ".*".  Also, I don't see how
> you can ever productively have more than one in a row, doing so is probably
> exactly the same as having just one.
>
> \b is a zero-width condition.  So "tion\b\bname" can never match because
> you are demanding that there is a n before the \b zero-width placeholder,
> and an n after the \b zero-width placeholder, and if that is the case then
> the conditions which define \b are not met.  Similarly the \b in ":\b\s" is
> impossible to ever match, as it has to have a non-word character on each
> side which is what \b does not do.  The \b in "\s\b[0-9A-Za-z_\-]" is
> almost redundant--it just forbid the "-" from the character class from
> being used, which I doubt is what you want.
>
> ...
>
> >
> > Find the word Workstation followed by a space followed by name:
> > followed by a space followed by a string of characters including word
> > characters and hyphens.  if the match is found, take only the text
> > after the : as the workstation name.
>
> ... /\bworkstation name: ([-\w]+)/i ...
>
> If you "space" you meant "white space", then turn my spaces into "\s"
> (not "\b").
>
>
> Xho
>
> --
> -------------------- http://NewsReader.Com/ --------------------
> Usenet Newsgroup Service                        $9.95/Month 30GB



------------------------------

Date: Sun, 26 Nov 2006 19:46:58 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: handling hanging database connections: timeout in perl
Message-Id: <slrnemkgsi.qfd.tadmc@tadmc30.august.net>

daniel.crosby@gmx.de <daniel.crosby@gmx.de> wrote:

>         &Logging (0, $A, "timeout", $l_msg);
          ^
          ^

Why do you choose to circumvent prototypes?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Mon, 27 Nov 2006 17:00:36 -0600
From: Marc Bissonnette <dragnet\_@_/internalysis.com>
Subject: Help improving IO::Socket script response
Message-Id: <Xns9888B728BA1A0dragnetinternalysisc@216.196.97.131>

Hi all;

I'm not sure where/what I've gone wrong here; The purpose of the code 
below is to get the server type (Apache/IIS/etc) from a list of URLs.
In the SQL query (whose results are used in the IO::Socket call), the 
data from 'cname' will be a string, like "Foo Internet", the data from 
'mainurl' will be a url like "www.foo.com"

The problem lies in massive time-outs (I don't know what the longest 
is/can be: I've killed the process after ten minutes, however); The only 
sanity-saving option so far is to run it in batches of ten URLs, but I've 
got a list of ~400 to go through.

I've googled for somehow using a timeout with IO::Socket, but all the 
responses seem to be that timeout is deprecated and only applies to the 
handshake, not the listen/read. I'd be *really* happy if I could simply 
get this to work with giving each url 5 seconds to respond with the first 
8 lines to get the Server: header. 

I've trimmed my code to get rid of all the HTML output for legibility's 
sake; The reason for this little script is merely curiosity; A thread in 
can.internet.highspeed was asking what OS the majority of ISPs in Canada 
are running, so I thought I'd take a crack at it. 

Many thanks for any provided insights or suggested reading! (I've gone 
over the CPAN entries for IO::Socket and IO::Socket::INET several times, 
but don't seem to be absorbing what it is that's causeing the timeouts)

#!/usr/bin/perl
use CGI;
use IO::Socket;
use URI::Escape;
use CGI::Carp qw(fatalsToBrowser);
use DBI;
use strict;

my $row;
my $keys;
my $key;
my $sock;
my %hosts;
my $hosts;
my $host;
my $dbname;
my $dbuser;
my $dbpass;
my @row;
my $foo;
my $line;
my $count;
my $found;
Define();

my $query="SELECT `cname`,`mainurl` FROM `ispdata` WHERE `mainurl` IS NOT 
NULL  AND `mainurl` != \"http://\" AND `approved` = 1 ORDER BY `cname`";
my $dbh;
my $sth;
$dbh = DBI->connect("DBI:mysql:$dbname", $dbuser, $dbpass,{PrintError => 
1, RaiseError => 1});
$sth=$dbh->prepare($query);
$sth->execute();
while (@row=$sth->fetchrow()) {
	$row[0]=uri_unescape($row[0]);
	$row[1]=uri_unescape($row[1]);
	$foo='http://';
	$row[1]=~ s/$foo//g;
	my @url;
	if ($row[1] =~ /\//) {
		@url=split /\//,$row[1];
		$row[1]=$url[0];
	}
	$row[1]=~ s/ //g;
	$hosts{$row[0]}=$row[1];
}
$sth->finish;
$dbh->disconnect;


LOOP: foreach $key (sort keys %hosts) {
	next if ($hosts{$key} =~ /zeuter/);
	print "\t$key\t$hosts{$key}\t";
	
	my @Header;
	$host = $hosts{$key};
	$sock = IO::Socket::INET->new(PeerAddr => "$host",
                           PeerPort => 'http(80)',
                           Timeout => "5",
                           Reuse => "1",
                           Proto    => 'tcp');
	
	print $sock "GET / HTTP/1.0\n\n";
	$found=0;
	$count=0;
	while(<$sock>) {
		$line = $_;
		++$count;
		if ($line =~ /^Server/) {
			print "$line\t\n";
			$found=1;
			last;
		}
		if ($count >10) {
			print "NO RESPONSE\t\n";
			next LOOP;
		}
	}
	if ($found==0) {
		print "\t\n";
		next LOOP;
	}
}
exit;

sub Define {
	$dbname='xxx';
	$dbuser='xxx';
	$dbpass='xxx';
}
exit;

-- 
Marc Bissonnette
Looking for a new ISP? http://www.canadianisp.com
Largest ISP comparison site across Canada.


------------------------------

Date: Mon, 27 Nov 2006 17:34:16 GMT
From: newsdog <newsdog@quercus.org>
Subject: How to find utf8.enc?
Message-Id: <skFah.296341$1i1.269996@attbi_s72>

I'm running perl 5.8.8-5 under Fedora 5.  My program
uses XML::Simple, which produces an error when I try to compile:

 ./frontend
Couldn't open encmap utf8.enc:
No such file or directory
  at 
/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/XML/Parser.pm 
line 187

I cannot find the utf8.end file anywhere on my system, nor can I find
any mention of it online except in packages intended for working with
Czech or Chinese.  The various Unicode help files I have looked at make
no mention of this file either.

What do I need to do to activate, download, or create the needed file?
Any help much appreciated...


------------------------------

Date: 27 Nov 2006 18:32:35 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: How to find utf8.enc?
Message-Id: <Xns98887F997DA64castleamber@130.133.1.4>

newsdog <newsdog@quercus.org> wrote:

> I'm running perl 5.8.8-5 under Fedora 5.  My program
> uses XML::Simple, which produces an error when I try to compile:
> 
> ./frontend
> Couldn't open encmap utf8.enc:
> No such file or directory
>   at 
> /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/XML/Parser.pm 
> line 187

We might be more able to help you (I guess) if you post line 187 (probably 
with some lines before it as well) so we can see the actual code that 
caused this (not all errors are clearly written, sadly).

-- 
John                Experienced Perl programmer: http://castleamber.com/

          Perl help, tutorials, and examples: http://johnbokma.com/perl/


------------------------------

Date: Mon, 27 Nov 2006 19:42:36 +0100
From: Newsgroups <newsgroups@free.fr>
Subject: Re: How to find utf8.enc?
Message-Id: <1164652956.5320.27.camel@localhost>

Le lundi 27 novembre 2006 =E0 17:34 +0000, newsdog a =E9crit :
> I'm running perl 5.8.8-5 under Fedora 5.  My program
> uses XML::Simple, which produces an error when I try to compile:
>=20
> ./frontend
> Couldn't open encmap utf8.enc:
> No such file or directory
>   at=20
> /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/XML/Parser.pm=20
> line 187

I've a similar problem since yesterday. sudentdly, my script crashed
with the same error, but not "utf8.enc". It couldn't opened
"iso-8859-15.enc"


> I cannot find the utf8.end file anywhere on my system, nor can I find
> any mention of it online except in packages intended for working with
> Czech or Chinese.  The various Unicode help files I have looked at make
> no mention of this file either.
I cannot locate "iso-8859-15.enc" too.

>=20
> What do I need to do to activate, download, or create the needed file?
I probably have updated some libraries, so I think it could be a bug in
one of them...


> Any help much appreciated...
I don't have already tested, but somebody give me an answer to my post,
in fr.comp.lang.perl, (subject is "Couldn't open encmap" : Mon, 27 Nov
2006 09:53:58 +0100)



------------------------------

Date: Mon, 27 Nov 2006 21:17:50 GMT
From: newsdog <newsdog@quercus.org>
Subject: Re: How to find utf8.enc?
Message-Id: <2CIah.296498$1i1.227992@attbi_s72>

John Bokma wrote:
> newsdog <newsdog@quercus.org> wrote:
> 
>> I'm running perl 5.8.8-5 under Fedora 5.  My program
>> uses XML::Simple, which produces an error when I try to compile:
>>
>> ./frontend
>> Couldn't open encmap utf8.enc:
>> No such file or directory
>>   at 
>> /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/XML/Parser.pm 
>> line 187
> 
> We might be more able to help you (I guess) if you post line 187 (probably 
> with some lines before it as well) so we can see the actual code that 
> caused this (not all errors are clearly written, sadly).
> 
Here is the block of code from Parser.pm that produces the error, with
line 187 indicated:

  my $expat = new XML::Parser::Expat(@expat_options, @_);
   my %handlers = %{$self->{Handlers}};
   my $init = delete $handlers{Init};
   my $final = delete $handlers{Final};

   $expat->setHandlers(%handlers);

   if ($self->{Base}) {
     $expat->base($self->{Base});
   }

   &$init($expat)
     if defined($init);

   my @result = ();
   my $result;
   eval {
     $result = $expat->parse($arg);   <== LINE 187
   };
   my $err = $@;
   if ($err) {
     $expat->release;
     die $err;
   }

[end of code block]

The Expat package is installed; the problem appears to be that utf8
is the default character encoding, but there is no .enc object for
the default.  But I am baffled as to what to do about it...


------------------------------

Date: 27 Nov 2006 03:54:02 -0800
From: "novostik@googlemail.com" <novostik@googlemail.com>
Subject: How to get the DOM from a XML page
Message-Id: <1164628442.128403.46090@14g2000cws.googlegroups.com>

Hello guys,
                I want to get the DOM of an XML page.for eg:an XML
page, being converted from HTML using Tidy,is:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Windows (vers 14 February 2006), see www.w3.org">
<title></title>
</head>
<body>
</body>
</html>

should print out  html---head---meta ----title.

I have used the following code in perL....
-------------------------------------------------------------------------------------------------------------------------------------
use XML::DOM;
 my $parser = new XML::DOM::Parser;
 my $doc = $parser->parsefile ("ig.xml");
my $nodes=$doc->getDocumentElement();
print "\n";
print $nodes->getNodeName();
print "--";
@x=$nodes->getChildNodes();

&find(@x);

sub find
{
my (@z)=@_;
foreach $z(@z)
{
@y=$z->getChildNodes();
if($z->getNodeType == ELEMENT_NODE)
{

print $z->getNodeName();
print"--";
}
&find(@y);
}
}

 # Avoid memory leaks - cleanup circular references for garbage
collection
 $doc->dispose;
---------------------------------------------------------------------------------------------------------------------------------------------


The problem is that it gives an output for some files but gives some
error message for other like the google and yahoo hompages.
could you please help me out on this as I was not able to rectify
it.Why does it work for some page and why not for others?
Could you please provide me a solution for this....



------------------------------

Date: 27 Nov 2006 16:56:13 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: How to get the DOM from a XML page
Message-Id: <Xns98886F42DA558castleamber@130.133.1.4>

"novostik@googlemail.com" <novostik@googlemail.com> wrote:
 
> The problem is that it gives an output for some files but gives some
> error message for other like the google and yahoo hompages.
> could you please help me out on this as I was not able to rectify
> it.Why does it work for some page and why not for others?
> Could you please provide me a solution for this....

I am guessing here, but XHTML is widely used, but wrong. Most people using 
it have no clue what XHTML means, and hence use it like HTML and end up 
with documents that are not well-formed. If you want to parse stuff that's 
out on the web, use something like HTML::TreeBuilder.

If you make your own XHTML pages, you might want to think again, twice 
even.

-- 
John                Experienced Perl programmer: http://castleamber.com/

          Perl help, tutorials, and examples: http://johnbokma.com/perl/


------------------------------

Date: 27 Nov 2006 14:09:53 -0800
From: conrado.blasco@gmail.com
Subject: Interactive programs & Teeing
Message-Id: <1164665393.691544.228200@l39g2000cwd.googlegroups.com>

I'm trying to write an interactive script that gets commands from
STDIN, prints the results to STDOUT, *and* tees the results to a log
file.

My problem is that when I add the teeing line to the program (see
below), the script doesn't print anything to STDOUT anymore (not even
the prompt). When I comment out that line, everything works fine
(except that I don't get the log file).

(Well, it actually still prints something, but only when the session is
over.)

It seems to me that I'm missing something very obvious, but I can't
figure out... Any help appreciated.

Relevant excerpt below:

#!/usr/bin/env perl
use warnings; # Needed since '-w' won't work on the shebang line
use strict;
use File::Basename;

my $my_name = fileparse($0);

# STDOUT prints on the screen as well as on to log file
open (STDOUT, "| tee ./" . $my_name . ".log")
  or die "Teeing error: $!\n";

my $prompt = "$my_name > ";

# Main loop, read and parse standard input
print $prompt;
while (<STDIN>) {
  parse_cmdline($_);
  print $prompt;
}



------------------------------

Date: Mon, 27 Nov 2006 18:40:08 +0000
From: Brian Wakem <no@email.com>
Subject: Re: modPerl, Apache, and REMOTE_USER
Message-Id: <4t0pn0F11l2qvU1@mid.individual.net>

Todd W wrote:

> 
> "Brian Wakem" <no@email.com> wrote in message
> news:4srnc3F10valiU1@mid.individual.net...
>> snakedjip@yahoo.com wrote:
>>
>>> Hi,
>>>
>>> I use Xampp for my apache-mysql-modperl setup.
>>>
>>> I'm running a perl script from a directory that is protected with a
>>> .htaccess file.
>>>
>>> I've setup apache to run as normal cgi if I access the file through
>>> /cgi-bin/..., and to run as mod-perl if accessed from /perl/...
>>>
>>> If I run the script as normal cgi, I have access to $ENV{REMOTE_USER}
>>> to identify my user.
>>>
>>> If I run the script as modPerl, that environment variable is not set.
>>>
>>> Is that due to some Xampp configuration in httpd.conf or elsewhere, or
>>> is it just me that should know that $ENV{REMOTE_USER} is not set in
>>> modPerl ?
>>>
>>> My question would then be : how do I know, in modPerl, what user is
>>> accessing my script ?
>>>
>>> Thanks.
>>
>>
>> $ENV{REMOTE_USER} *is* set in mod_perl.
> 
> Well, not by default, because mod_perl provides an API to the environment.
> Search at http://perl.apache.org/ for PerlPassEnv or something like that.


I think it must be set by default, as I've never heard of PerlPassEnv let
alone changed it, and $ENV{REMOTE_USER} has worked on every mod_perl
install I've done.


-- 
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png


------------------------------

Date: 27 Nov 2006 14:04:42 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: pretty print to postscript (or pdf or tex) for both code and pod
Message-Id: <slrnemls3q.e3i.glennj@smeagol.ncf.ca>

At 2006-11-26 06:55PM, "ivowel@gmail.com" wrote:
>  
>  dear perl experts:  yes, I have read the perlfaq, part 3.  alas, I
>  would like something that prints nicely like the enscript perl mode,
>  but with the pod comments formatted nicely.  when I use enscript
>  -Eperl, the pod comments are just text, not nicely formatted.  does a
>  combined pretty-printer exist?

Check CPAN -> Pod::Pdf

-- 
Glenn Jackman
Ulterior Designer


------------------------------

Date: Mon, 27 Nov 2006 19:16:49 +0000
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: print_r()
Message-Id: <g6964d0n1i6.fsf@lifelogs.com>

On 26 Nov 2006, john@castleamber.com wrote:

Tad McClellan <tadmc@augustmail.com> wrote: > Mark
<Mark.Fenbers@noaa.gov> wrote: >
>>> Is there anything in Perl that does the equivalent of what print_r()
>>> does in PHP?
>>
>>
>> What does print_r() do in PHP?
>
> print_r -- Prints human-readable information about a variable. (Which the
> OP should have provided)
>
> OP: see if Data::Dumper does what you want.

ref $variable

may also be useful.  There's a bunch of Devel:: modules that deal with
variable meta-information too.

Ted


------------------------------

Date: Sun, 26 Nov 2006 19:51:47 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: test message - please ignore
Message-Id: <slrnemkh5j.qfd.tadmc@tadmc30.august.net>

John Smith <user@example.net> wrote:

> test message - please ignore


I am going to fart at your dinner table.

Please ignore.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 27 Nov 2006 03:34:21 -0800
From: wolfpack307@yahoo.com
Subject: Using perl to parse verilog
Message-Id: <1164627261.830792.40190@45g2000cws.googlegroups.com>

Hi all,

I am trying to use perl to parse a verilog file.

In trying to parse block comments, I am using am doing

while ($verilog=~s/(.*)\/\*.*(.*)/$1$2/) {}

This code does work for code that looks like this

/* comments
   comments
   comments */

However, if an codes look like the following (which is syntactically
correct in verilog), the script just hangs.

/* comments
/* comments
   comments */

Would appreciate some advice. 
Thanks in advance.

shuteng



------------------------------

Date: 27 Nov 2006 04:14:50 -0800
From: wolfpack307@yahoo.com
Subject: Re: Using perl to parse verilog
Message-Id: <1164629690.791823.116800@14g2000cws.googlegroups.com>

typo error
while ($verilog=~s/(.*)\/\*.*\*\/(.*)/$1$2/s) {}

wolfpack307@yahoo.com wrote:
> Hi all,
>
> I am trying to use perl to parse a verilog file.
>
> In trying to parse block comments, I am using am doing
>
> while ($verilog=~s/(.*)\/\*.*(.*)/$1$2/) {}
>
> This code does work for code that looks like this
>
> /* comments
>    comments
>    comments */
>
> However, if an codes look like the following (which is syntactically
> correct in verilog), the script just hangs.
>
> /* comments
> /* comments
>    comments */
> 
> Would appreciate some advice. 
> Thanks in advance.
> 
> shuteng



------------------------------

Date: Mon, 27 Nov 2006 11:04:51 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Using perl to parse verilog
Message-Id: <456b1b03$0$502$815e3792@news.qwest.net>

wolfpack307@yahoo.com wrote:

>> I am trying to use perl to parse a verilog file.
>>
>> In trying to parse block comments, I am using am doing
[...]
>> Would appreciate some advice. 

Check the FAQ.

perldoc -q "How do I use a regular expression to strip C style comments 
from a file"


------------------------------

Date: 27 Nov 2006 13:08:07 -0800
From: sgbailey@iee.org
Subject: Windows CE, Windows Mobile
Message-Id: <1164661687.296990.107440@f16g2000cwb.googlegroups.com>

Is there a working version of Perl that can be installed on a handheld
PDA or smartphone (eg Ipaq Hw6915).

I am planning to get a new device and would like to install perl on it
- if I can't I'll probably end up installing Basic!

===
sgb



------------------------------

Date: 27 Nov 2006 22:51:22 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Windows CE, Windows Mobile
Message-Id: <Xns9888AB78B1CF7castleamber@130.133.1.4>

sgbailey@iee.org wrote:

> Is there a working version of Perl that can be installed on a handheld
> PDA or smartphone (eg Ipaq Hw6915).
> 
> I am planning to get a new device and would like to install perl on it
> - if I can't I'll probably end up installing Basic!

I am curious as well :-)

From the top of my head, there is a Python for it.
For C#, see: 
<http://johnbokma.com/mexit/2006/11/23/net-cf-without-visual-studio.html>

Perl with Tk would be nice though.

-- 
John                Experienced Perl programmer: http://castleamber.com/

          Perl help, tutorials, and examples: http://johnbokma.com/perl/


------------------------------

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 10011
****************************************


home help back first fref pref prev next nref lref last post