[25724] in Perl-Users-Digest
Perl-Users Digest, Issue: 7964 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 12 00:05:30 2005
Date: Mon, 11 Apr 2005 21:05:17 -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 Mon, 11 Apr 2005 Volume: 10 Number: 7964
Today's topics:
Re: C# regular expressions, HTML & removal of text betw <tadmc@augustmail.com>
Re: C# regular expressions, HTML & removal of text betw <jgibson@mail.arc.nasa.gov>
Re: C# regular expressions, HTML & removal of text betw <jurgenex@hotmail.com>
Multiple lines in output! please some help! <monte_b1@yahoo.com>
Re: Multiple lines in output! please some help! <1usa@llenroc.ude.invalid>
Re: Multiple lines in output! please some help! <tadmc@augustmail.com>
Re: Multiple lines in output! please some help! <tadmc@augustmail.com>
Re: New Perl installation can't find module <tadmc@augustmail.com>
Re: Perl function for negative integers using the 2's c <liam@nedernet.net>
Re: Perl function for negative integers using the 2's c <tadmc@augustmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 11 Apr 2005 15:55:25 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: C# regular expressions, HTML & removal of text between <script> tags
Message-Id: <slrnd5lp1t.21n.tadmc@magna.augustmail.com>
john.w.blair@gmail.com <john.w.blair@gmail.com> wrote:
> using C# regular
> expressions?
You have found the wrong newsgroup.
We do Perl in the Perl newsgroup.
(and regular expressions do not change text anyway, they "match"
or "don't match" strings. Perl has an operator that changes
text and makes use of regular expressions though. What operators
are available to you in C# is a mystery to me. Find a C# newsgroup.
)
(also, using regular expressions on a context-free language such
as HTML is impossible in the general case. You need a Real Parser.
Have you seen the Perl FAQ about removing HTML from a string?
)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 11 Apr 2005 17:15:29 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: C# regular expressions, HTML & removal of text between <script> tags
Message-Id: <110420051715291287%jgibson@mail.arc.nasa.gov>
In article <RO2dnTxGVotTfcffRVn-vA@comcast.com>, Chris Mattern
<matternc@comcast.net> wrote:
> john.w.blair@gmail.com wrote:
>
> > Can someone help me out this this please? How does one remove content
> > between script tags and the script tags themselves using C# regular
> > expressions?
> >
[one, two snipped]
> Three: Er, what's the difference between "script tags" and "the script
> tags themselves"?
I believe that sentence should be parsed: "content between script tags"
vs. "script tags themselves".
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
------------------------------
Date: Tue, 12 Apr 2005 01:07:56 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: C# regular expressions, HTML & removal of text between <script> tags
Message-Id: <MbF6e.11012$H_5.5773@trnddc01>
john.w.blair@gmail.com wrote:
> Can someone help me out this this please? How does one remove content
> between script tags and the script tags themselves
Please let us know which problems you have with the answer in the FAQ such
that we can improve it.
> using C#
Are you sure you are in the right NG?
> regular expressions?
As has been pointed out many, many times (did you check google, this NG, or
the FAQ) no sane person would try to parse HTML using regular expressions.
jue
------------------------------
Date: 11 Apr 2005 17:38:48 -0700
From: "monte" <monte_b1@yahoo.com>
Subject: Multiple lines in output! please some help!
Message-Id: <1113266328.138163.213320@g14g2000cwa.googlegroups.com>
I am a new user and I am parsing and file that contains a heirarchy. i
would like to get the cell name once and the libraries that that the
cell was found. my code is repeating he output everytime it goes into
and produces multiple listing of the cell when I only like to have this
done once. Can anyone help me figure this out?
1)suppose the input file is formatted like this
1. libA cellB
2. libC cellD
...
8. libF cellG
9. libX cellB
2) desire output:
CELL:cellB LIB:libA libX
CELL:cellD LIB: libC
CELL:cellG LIB: libF
4) my code:
while(<>)
{
chomp;
$show_file=$_;
next if ( $show_file=~ /\#/ );
#print $show_file;
$show_file=~/^\s+\d\.\s+(\S+)\s+(\S+)/;
$lib=$1;
$cell=$2;
#checking if the same cell exist in the same heirarchy
($rec{$2}= "Cell:$2 Lib:") if (! exists($rec{$2}));
$rec{$2}.="$1\t";
foreach $entry(keys %rec)
{
print" $rec{$entry}\n";
}}#last braket for 1st foreach loop
5) My output list the cells and libs everytime it goes into the loop
and I only like to have the cell listed once with the libraries
associated with it.
------------------------------
Date: Tue, 12 Apr 2005 02:43:13 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Multiple lines in output! please some help!
Message-Id: <Xns9635E70DE3B55asu1cornelledu@127.0.0.1>
"monte" <monte_b1@yahoo.com> wrote in
news:1113266328.138163.213320@g14g2000cwa.googlegroups.com:
> I am a new user and I am parsing and file that contains a heirarchy. i
> would like to get the cell name once and the libraries that that the
> cell was found. my code is repeating he output everytime it goes into
> and produces multiple listing of the cell when I only like to have
> this done once. Can anyone help me figure this out?
> 1)suppose the input file is formatted like this
> 1. libA cellB
> 2. libC cellD
> ...
> 8. libF cellG
> 9. libX cellB
Please do read the posting guidelines to find out how you can post an
accurate depiction of the data your script is using in a ready-to-run
format.
If I wanted to edit/rewrite your script, I have to do extra work just
getting the data formatted so that I can run it.
The guidelines provide information on how you can help others help you.
> 2) desire output:
> CELL:cellB LIB:libA libX
> CELL:cellD LIB: libC
> CELL:cellG LIB: libF
>
> 4) my code:
Please post code that is ready to be run, and indent it properly.
use strict;
use warnings;
> while(<>)
> {
> chomp;
> $show_file=$_;
> next if ( $show_file=~ /\#/ );
> #print $show_file;
> $show_file=~/^\s+\d\.\s+(\S+)\s+(\S+)/;
> $lib=$1;
> $cell=$2;
You should always check if the match actually succeeded before using $1
and $2 here.
> #checking if the same cell exist in the same heirarchy
> ($rec{$2}= "Cell:$2 Lib:") if (! exists($rec{$2}));
> $rec{$2}.="$1\t";
> foreach $entry(keys %rec)
> {
> print" $rec{$entry}\n";
> }}#last braket for 1st foreach loop
Such comments would not be needed if you indented your code properly.
Here is one way to do it:
use strict;
use warnings;
my %cells;
while(<DATA>) {
chomp and length or last;
if(/^\d+\.\s+(\w+)\s+(\w+)/) {
push @{ $cells{$2} }, $1;
}
}
for my $cell (keys %cells) {
print "CELL: $cell LIB: @{ $cells{$cell} }\n";
}
__END__
1. libA cellB
2. libC cellD
...
8. libF cellG
9. libX cellB
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Mon, 11 Apr 2005 22:44:44 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Multiple lines in output! please some help!
Message-Id: <slrnd5mh1c.1ms.tadmc@magna.augustmail.com>
monte <monte_b1@yahoo.com> wrote:
> 4) my code:
> while(<>)
> {
> chomp;
> $show_file=$_;
> next if ( $show_file=~ /\#/ );
> #print $show_file;
> $show_file=~/^\s+\d\.\s+(\S+)\s+(\S+)/;
> $lib=$1;
> $cell=$2;
>
> #checking if the same cell exist in the same heirarchy
> ($rec{$2}= "Cell:$2 Lib:") if (! exists($rec{$2}));
> $rec{$2}.="$1\t";
> foreach $entry(keys %rec)
> {
> print" $rec{$entry}\n";
> }}#last braket for 1st foreach loop
Something horrid has happened to the formatting of your code.
You'd better figure out how to fix that if you expect volunteers
to read it.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 11 Apr 2005 22:51:13 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Multiple lines in output! please some help!
Message-Id: <slrnd5mhdh.1ms.tadmc@magna.augustmail.com>
monte <monte_b1@yahoo.com> wrote:
> while(<>)
> {
> chomp;
> $show_file=$_;
You can replace all of that with just:
while ( $show_file = <> )
{
chomp $show_file;
Whitespace is not a scarce resource, feel free to use as much of
it as you like to make your code easier to read.
> next if ( $show_file=~ /\#/ );
You do not neet to backslash the #, it is not special.
> $show_file=~/^\s+\d\.\s+(\S+)\s+(\S+)/;
> $lib=$1;
> $cell=$2;
You should never use the dollar-digit variables unless you have
first ensured that the pattern match *succeeded*:
if ( $show_file =~ /^\s+\d\.\s+(\S+)\s+(\S+)/ ) {
$lib=$1;
...
> }}#last braket for 1st foreach loop
If you indented properly, then you wouldn't have to make
those little notes to yourself.
> 5) My output list the cells and libs everytime it goes into the loop
> and I only like to have the cell listed once with the libraries
> associated with it.
I am not going to try and analyse your code, in an effort to help
you with your problem.
It is too ugly to look upon.
Fix it and post again.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 11 Apr 2005 16:00:45 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: New Perl installation can't find module
Message-Id: <slrnd5lpbt.21n.tadmc@magna.augustmail.com>
JONL <jon.m.landenburger@verizon.com> wrote:
> program which has the statement use Term/ReadKey
^^^
Do you mean a program which has the statement use Term::ReadKey?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 11 Apr 2005 16:27:55 -0700
From: "stylechief" <liam@nedernet.net>
Subject: Re: Perl function for negative integers using the 2's complement in hex?
Message-Id: <1113262075.455239.161760@g14g2000cwa.googlegroups.com>
That works like a charm when one can explicitly pass a hex number like
the above example. However, for whatever reason, when one attempts to
read from a binary file and use unpack() to deliver the hex numbers,
one gets:
Argument "ffbe8e" isn't numeric in pack at E:\Test\bif.plx line 5.
code:
open (BINARYFILE, "<000332") || die "Cant open: $!\n";
while(read(BINARYFILE, $data, 3)){
$data= unpack 'H*',$data;
print unpack 'i',pack 'i',$data;
print "\n";
}
close (BINARYFILE) || die"Cant close: $!\n";
It *is* unpacking to a 24 bit hex number, but fails to see this number
as numeric. It gets "stringified" somehow.
------------------------------
Date: Mon, 11 Apr 2005 22:52:45 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl function for negative integers using the 2's complement in hex?
Message-Id: <slrnd5mhgd.1ms.tadmc@magna.augustmail.com>
stylechief <liam@nedernet.net> wrote:
> That works like a charm
What does?
> when one can explicitly pass a hex number like
> the above example.
What example above?
Please compose followups the normal way and quote some context.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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 7964
***************************************