[6911] in Perl-Users-Digest
Perl-Users Digest, Issue: 536 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 29 00:07:33 1997
Date: Wed, 28 May 97 21:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 28 May 1997 Volume: 8 Number: 536
Today's topics:
Re: [Q]: l.f. suggestions for implementing lookahead <deven@fuse.net>
A humble guestion about $= defaults from a seeker of tr (GCV3)
Re: A humble guestion about $= defaults from a seeker o <billc@tibinc.com>
Another 5.004 migration bug <chris@ixlabs.com>
Re: Another 5.004 migration bug <chris@ixlabs.com>
Re: Any non number but not a dot... (Abigail)
Re: Any non number but not a dot... <david.s.patterson@boeing.com>
Can't locate perldb.pl in @INC dominic@thiru.vetri.com
Re: How old is my file??? <rootbeer@teleport.com>
LEXICAL Scoping Hell! (explain?) (Jason Fish - SunEducation)
Re: nslookup's in perl (JPR)
Re: nslookup's in perl (Michael Fuhr)
Perl Memory Error When using '0' all others work? (Geoffrey Hebert)
Re: PERL Programmer's: What's It Like? (Nathan V. Patwardhan)
Re: regexp problem (Mr Simon Lee)
Re: script optimization of grep -c <sibsib@hotmail.com>
Re: Script wanted (Tung-chiang Yang)
STDIN hang-up <ira@rta.nsw.gov.au>
Re: undef, split: bug? (Charles DeRykus)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 28 May 1997 18:39:22 -0400
From: "Deven T. Corzine" <deven@fuse.net>
To: Luca Passani <lpa@sysdeco.no>
Subject: Re: [Q]: l.f. suggestions for implementing lookahead
Message-Id: <338CB41A.332@fuse.net>
Luca Passani wrote:
>
> Hallo,
>
> I'm parsing a file and it would be useful to have some kind of lookahead
> which allows me to take actions before I start the loop again.
>
> open(FILE, "file.txt") || die;
> while(<FILE>)
>
> if (/regexp/) {
> if (NEXTLINE matches /regexp2/) {
> action1;
> } else {
> action2;
> }
> }
> }
>
> Of course I could save some status information and decide which action
> to take afterwards, but the lookahead would let me have a much more
> elegant solution. One solution I've been thinking of is slurping
> the whole file into an array in advance in order to do things like:
>
> if ($arraywithfile[$currentline+1] =~ /regexp2/)
>
> but maybe someone has a good reason not to.
It's wasteful of memory. If all you really need is a one-line
lookahead, try shuffling variables a bit:
open FILE,"<file.txt" or die "file.txt: $!\n";
$_ = <FILE>;
$next = <FILE>;
while ($_) {
if (/regexp/) {
if ($next =~ /regexp2/) {
action1;
} else {
action2;
}
}
} continue {
last unless defined($next);
$_ = $next;
$next = <FILE>;
}
close FILE;
This will let you act like you're scanning as usual, with the ability to
look at the next line. And it won't buffer undefined quantities of data
just to get a one-line lookahead.
Deven
------------------------------
Date: 29 May 1997 00:59:52 GMT
From: gcv3@aol.com (GCV3)
Subject: A humble guestion about $= defaults from a seeker of truth.
Message-Id: <19970529005901.UAA08035@ladder02.news.aol.com>
Oh great ones please answer this humble guestion if you will.
I would like to know if anyone can tell me what gives with this script,
run on Windows95. The version of Perl I am using is 5.001.
My question is with how to reset the default FORMAT_LINE_PER_PAGE or $=
to a value other than 60 lines. About 12 lines from the bottom you can
see I've set the lines per page as follows:
$= = 40;
All I get is the default 60 lines per page.
Any help or
suggestions (other than avoiding
wasting your precious
band width) are welcome. :-)
Tim Vander Veer
gcv3@aol.com
My input file has the following format:
a12345678,05/25/97,10:23,t8417tv,9321,Room 59
The program follows:
#!/usr/bin/perl -w
format DUPRPT_TOP =
MET TRACK RF BARCODE SCANNER LOCATION TRACKING page @<
$%
ASSET DATE TIME USER DEPT LOCATION
----- ---- ---- ---- ---- --------
.
format DUPRPT =
@<<<<<<<<<< @>>>>>>>> @>>:@>> @<<<<<<< @|||| @<<<<<<<<
$assetp, $datep, $hrp, $mnp, $usrp, $deptp, $locp
.
open (FILE, $ARGV[0]) or die "Can't read $ARGV[0]: $! ";
@lines = <FILE>; # read all the lines from FILE
foreach $lines (@lines){
$_ = $lines;
s/\s+/_/g;
s/\,/ /g;
($asset, $date, $hr, $mn, $usr, $dept, $loc) =
/^(\w+)\s(\d\d\/\d\d\/\d\d)\s(\d\d)\:(\d\d)\s(\w+)\s(\w+)\s(\w+)/;
push (@passet,$asset);
push (@pdate,$date);
push (@phr,$hr);
push (@pmn,$mn);
push (@pdept,$dept);
push (@pusr,$usr);
push (@ploc,$loc);
}
open (DUPRPT, ">duprpt.out") or die "Can't write duprpt.out: $!\n";
$= = 40;
foreach $i (0..$#passet) {
$assetp = $passet[$i];
$datep = $pdate[$i];
$hrp = $phr[$i];
$mnp = $pmn[$i];
$deptp = $pdept[$i];
$usrp = $pusr[$i];
$locp = $ploc[$i];
write DUPRPT;
}
------------------------------
Date: Wed, 28 May 1997 21:46:12 -0400
From: Bill Cowan <billc@tibinc.com>
To: GCV3 <gcv3@aol.com>
Subject: Re: A humble guestion about $= defaults from a seeker of truth.
Message-Id: <338CDFE4.61FB@tibinc.com>
GCV3 wrote:
>
> Oh great ones please answer this humble guestion if you will.
>
> I would like to know if anyone can tell me what gives with this script,
> run on Windows95. The version of Perl I am using is 5.001.
>
> My question is with how to reset the default FORMAT_LINE_PER_PAGE or $=
> to a value other than 60 lines. About 12 lines from the bottom you can
> see I've set the lines per page as follows:
> $= = 40;
>
> All I get is the default 60 lines per page.
[SNIP]
>
Here is my suggestion...
Before changing special variable (like $=) associated with a specific
file handle, you should first do a "select()" for that filehandle such
as (un-tested):
my $OldHandle = select(REPORTHANDLE); # change default handle
$= = 40; # change special variable for REPORTFILE
write REPORTHANDLE; # write report/format at 40 lines per page
select($OldHandle); # restore default handle
-- Bill
-----------------------------------------------------------------------
Bill Cowan <billc@tibinc.com> Voice:919-490-0034 Fax:919-490-0143
Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707
------------------------------
Date: Wed, 28 May 1997 18:23:44 -0700
From: Chris Schoenfeld <chris@ixlabs.com>
Subject: Another 5.004 migration bug
Message-Id: <338CDAA0.3013@ixlabs.com>
We have a new bug in our code by migrating from 5.003 -> 5.004.
This one relates to DB_File (seemingly). Our stuff is dumping core.
We have been working diligently to whittle down the test script - the
result is below. Note the comments towards the end. You will need to
touch the db filename of course to test.
We will continue to try and narrow the problem a little better.
#!/usr/local/bin/perl5.004 -Tw
use strict;
use DB_File;
no strict; #need to modulate for
Perl
my $flags = O_RDWR;
use strict;
package DB;
sub New {
my $class = shift;
my $filenm = shift;
my $self = {}; #hash that gets tied;
bless $self, $class;
my $filespec = "./$filenm";
my $db = tie %$self, 'DB_File', $filespec, $flags,
0660,$DB_File::DB_BTREE;
if ($db) {
return $self;
} else {
print "Could not tie to the DB at filespec=$filespec:
HECK
PERMISSIONS!";
#since no reference is returned, the object will be
destroyed.
return 0;
}
}
sub DESTROY {
#make sure data base has been closed
my $hash_ref = shift;
print "Destroy invoked\n";
$hash_ref->Close();
}
sub Close {
#called with the tied hash (well, a reference to it)
#(if an OO style call, the Perl supplies this)
#EXAMPLE: $DB_ref->Close();
my $hash_ref = shift;
print "Close: about to untie\n";
untie %$hash_ref; #un tie
print "Close: untied\n";
}
sub Some_function {
print "Some function here!\n";
}
#--------------------------------------
# There are four ways to avoid the seg fault
# 1. remove the use of $db->Some_function below
# (even though _run isn't called)
# 2. move the $db->Some_function out of the _run sub
# 3. use Perl 5.003
# 4. Comment out the untie in Close()
#--------------------------------------
package main;
my $db = DB->New('test.db');
#$db->Close();
sub _run {
$db->Some_function();
}
------------------------------
Date: Wed, 28 May 1997 18:55:48 -0700
From: Chris Schoenfeld <chris@ixlabs.com>
Subject: Re: Another 5.004 migration bug
Message-Id: <338CE224.3569@ixlabs.com>
Never mind, I figured it out - it's perltie gotcha related.
In my own defense, the new Perl manpages were not correctly installed,
so I was reading old ones!
------------------------------
Date: Wed, 28 May 1997 23:38:42 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Any non number but not a dot...
Message-Id: <EAx0CJ.MHu@nonexistent.com>
On Thu, 29 May 1997 01:52:07 +0900, christopher
(christopher@wonderlandinorbit.com) wrote in comp.lang.perl.misc
<URL: news:338C62B7.64C@wonderlandinorbit.com>:
++
++ - what could I use to check if a string has any non digit in it, as long
++ as that / those non digit is/aren't a dot. Don't care where anything
++ appears, I just need to return true if a string is made entirely of
++ numbers and dots.
$str =~ /^[\d.]*$/;
Abigail
--
perl5.004 -wMMath::BigInt -e'$=new Math::BigInt+qq;$$783$[$%9889$47$|88768$596577669$%$5$3364$[$$$|838747$[8889739$%$|$673$%$98$76777$=56;;$=$]*(q.25..($=@))=>do{print+chr$%$;$/=$}while$!=$'
------------------------------
Date: Wed, 28 May 1997 22:27:43 GMT
From: "David S. Patterson" <david.s.patterson@boeing.com>
Subject: Re: Any non number but not a dot...
Message-Id: <338CB15F.63DE@boeing.com>
How about:
if (/^[\d.]+\Z/) {print "TRUE!";}
christopher wrote:
>
> Hello again..
>
> Wandering through regular expression world guided by the usual sources
> but need a hand with this:
>
> - what could I use to check if a string has any non digit in it, as long
> as that / those non digit is/aren't a dot. Don't care where anything
> appears, I just need to return true if a string is made entirely of
> numbers and dots.
>
> As always, help is a delightful addition to my day.
>
> Regards from wonderland
>
> Christopher
> Tokyo,May97
> http://www.wonderlandinorbit.com
--
"Does anyone have any questions? Any answers? Anyone care for a
mint?..."
David S. Patterson, Sr. Software Engineer
Production Illustration Systems (206) 865-3176
david.s.patterson@boeing.com Mail Stop: 7J80
------------------------------
Date: Wed, 28 May 1997 22:35:17 -0600
From: dominic@thiru.vetri.com
Subject: Can't locate perldb.pl in @INC
Message-Id: <864875597.26820@dejanews.com>
Hello,
I have compiled and installed perl 5.003 in my Solaris. I don;t have the
root permission and I installed Perl in my folder.
All my scripts are working fine and the only problem is I am not able to
debug the script. This is because my @INC points to /opt/gnu/perl/lib and
"." and whenever I give perl -d then it will say "Can't locate perldb.pl
in @INC".
I would like to change the @INC permanently. (I dont want to use
unshift(@INC, /bla) each time. Can any one help me out to achieve this.
Thanks and Regards
Dominic
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Wed, 28 May 1997 16:59:44 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Buzz <shommel@gnu.uvm.edu>
Subject: Re: How old is my file???
Message-Id: <Pine.GSO.3.96.970528165827.3306I-100000@kelly.teleport.com>
On 28 May 1997, Buzz wrote:
> Hello, can anyone tell me the easiest way to
> have perl inform me of the creation date of a file?
print "I remember, we created it on Tuesday.\n"; # :-)
Unix-type systems don't store a creation date for files. So there's no way
for Perl to determine one. Oh, well!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 29 May 1997 00:04:30 GMT
From: jason@Sun.COM (Jason Fish - SunEducation)
Subject: LEXICAL Scoping Hell! (explain?)
Message-Id: <5mih6e$pgh@newsworthy.West.Sun.COM>
Keywords: lexical
I'm playing with STATEMENT BLOCKS and what I thought was the creation
of new lexical (textual) areas regarding my() vs local() scoping.
I don't understand why the following happens. if anyone can help,
I'd sure appreciate it. I know what is going on, but it seems
to 'break' what is said about the lexical-ness of my() variables.
Test code below states the "problem". Output from the run of the
code follows that. If you wade through it all and help, you are a
true 'pearl' or a being.
thanks,
jason.
======================test code===============================
#! /usr/bin/perl
#
# testing out lexical scoping using STATEMENT BLOCKS
# (opposed to subroutine calls).
#
# Problem: "my" variables seems to behave as "locals" when a 'child'
# block executes its code. That is, my variables are visible
# within 'child' blocks. I'm confused by this. my variables
# are lexically scoped, available only to the block they are
# created in, or so say the manuals, etc.
#
# What's going on here?
#
# If the "BLOCKS" are replaced by subroutines, and called,
# the scoping of my works.
#
MAIN: {
print "\n\n...In main part of program...\n\n";
$main_var=george;
local $main_local_var=xxyyzz;
my $main_my_var=33333;
print '$main_var = ', $main_var,"\n";
print '$main_local_var = ', $main_local_var,"\n";
print '$main_my_var =', $main_my_var,"\n";
FIRST: {
print "\n\n...Inside the first STATEMENT BLOCK...\n\n";
$first_var=567;
local $first_local_var=linda;
my $first_my_var=fred;
print '$first_var = ',$first_var, "\n";
print '$first_local_var = ',$first_local_var,"\n";
print '$first_my_var = ',$first_my_var,"\n";
print '$main_var = ', $main_var,"\n";
print '$main_local_var = ', $main_local_var,"\n";
print '$main_my_var =', $main_my_var,"\n";
SECOND: {
print "\n\n...Inside the second STATEMENT BLOCK...\n\n";
$second_var=222;
local $second_local_var=mary;
my $second_my_var=henry;
print '$second_var = ',$second_var, "\n";
print '$second_local_var = ',$second_local_var,"\n";
print '$second_my_var = ',$second_my_var,"\n";
print '$first_var = ',$first_var, "\n";
print '$first_local_var = ',$first_local_var,"\n";
print '$first_my_var = ',$first_my_var,"\n";
print '$main_var = ', $main_var,"\n";
print '$main_local_var = ', $main_local_var,"\n";
print '$main_my_var =', $main_my_var,"\n";
} # end of the SECOND BLOCK
print "\n\n...Back inside the first STATEMENT BLOCK...\n\n";
print '$second_var = ',$second_var, "\n";
print '$second_local_var = ',$second_local_var,"\n";
print '$second_my_var = ',$second_my_var,"\n";
print '$first_var = ',$first_var, "\n";
print '$first_local_var = ',$first_local_var,"\n";
print '$first_my_var = ',$first_my_var,"\n";
print '$main_var = ', $main_var,"\n";
print '$main_local_var = ', $main_local_var,"\n";
print '$main_my_var =', $main_my_var,"\n";
} # end of the FIRST BLOCK
print "\n\n...Back in main part of program...\n\n";
print '$second_var = ',$second_var, "\n";
print '$second_local_var = ',$second_local_var,"\n";
print '$second_my_var = ',$second_my_var,"\n";
print '$first_var = ',$first_var, "\n";
print '$first_local_var = ',$first_local_var,"\n";
print '$first_my_var = ',$first_my_var,"\n";
print '$main_var = ', $main_var,"\n";
print '$main_local_var = ', $main_local_var,"\n";
print '$main_my_var =', $main_my_var,"\n";
print "\n";
} # end of the MAIN block
*****************************OUTPUT*************************
...In main part of program...
$main_var = george
$main_local_var = xxyyzz
$main_my_var =33333
...Inside the first STATEMENT BLOCK...
$first_var = 567
$first_local_var = linda
$first_my_var = fred
$main_var = george
$main_local_var = xxyyzz
$main_my_var =33333
...Inside the second STATEMENT BLOCK...
$second_var = 222
$second_local_var = mary
$second_my_var = henry
$first_var = 567
$first_local_var = linda
$first_my_var = fred
$main_var = george
$main_local_var = xxyyzz
$main_my_var =33333
...Back inside the first STATEMENT BLOCK...
$second_var = 222
$second_local_var =
$second_my_var =
$first_var = 567
$first_local_var = linda
$first_my_var = fred
$main_var = george
$main_local_var = xxyyzz
$main_my_var =33333
...Back in main part of program...
$second_var = 222
$second_local_var =
$second_my_var =
$first_var = 567
$first_local_var =
$first_my_var =
$main_var = george
$main_local_var = xxyyzz
$main_my_var =33333
------------------------------
Date: Wed, 28 May 1997 09:14:12 -0700
From: jon@vcnet.TAKE-OUT-TO-REPLY.com (JPR)
Subject: Re: nslookup's in perl
Message-Id: <jon-ya023480002805970914120001@news.vcnet.com>
Uh, thanks. I know how to use nslookup. I was asking how to do it in perl.
Anyway, thanks to all who responded. Back to scripting....
Jon
In article <338BEC06.921E6E83@alf.impaq.com.pl>, Andrew Filip
<news@alf.impaq.com.pl> wrote:
> JPR wrote:
>
> > After spending hours trying to get gethostbyaddr to return a hostname
> > from an IP address, I surrender. I've looked through the 2nd edition
> > camel,
> > the perl.org pages, CPAN, etc. Can somebody give me an example of how
> > to
> > take
> > 192.68.68.1
> > and get
> > whatever.domain.com
>
> to get PTR record (ip addr->name)
> nslookup 192.68.68.1
>
> to get A record (name->ip addr)
> nslookup whatever.domain.com
>
> to get MX record
> nslookup -type=mx whatever.domain.com
>
> --
> common sense is uncommon
------------------------------
Date: 28 May 1997 21:49:16 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: nslookup's in perl
Message-Id: <5miubs$9dl@flatland.dimensional.com>
jon@vcnet.TAKE-OUT-TO-REPLY.com (JPR) writes:
> Uh, thanks. I know how to use nslookup. I was asking how to do it in perl.
>
> Anyway, thanks to all who responded. Back to scripting....
BTW, if you want to query for record types other than A (gethostbyname)
and PTR (gethostbyaddr), you can use Net::DNS.
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: Thu, 29 May 1997 02:19:08 GMT
From: soccer@microserve.net (Geoffrey Hebert)
Subject: Perl Memory Error When using '0' all others work?
Message-Id: <5mintb$s9b$1@news3.microserve.net>
When I have a value of 0 I get the memory error message below.
libc base conversion file _times_power.c line 74: binary exponent 4 :
Insufficient or invalid memory
zsh: abort new.cgi
I am merging two files on a field that contains numbers and alpha.
When I get all numbers I add 1000000 to it so that 3 comes before
1000. The code causing the problem seems to be:
print "get next line is $alpha_line\n";
@aline=split(/:/,$alpha_line);
$sort_key=shift(@aline); Sort_key now is 0
if ($sort_key=~m/^[0-9]+$/) {
$sort_key=$sort_key+1000000; ****** next reference to this
# causes the memory error
}
$word=shift(@aline);
if ($#aline>0) {$page_title=shift(@aline)}
print "page title $page_title\n";
------- signature ----------
Check out the Perl site! (in development)
http://www.microserve.net/~soccer/
(yeh, who would have guessed perl)
use password perlmisc
Will be GREAT tool for Developers (when complete)
------------------------------
Date: 29 May 1997 01:22:14 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: PERL Programmer's: What's It Like?
Message-Id: <5milo6$nj3@fridge-nf0.shore.net>
Jerome Bradenbaugh (bradenb@ibm.net) wrote:
: I'm considering working as a PERL programmer. Please explain what that
: involves. For example, what types of programs would an employer want? In
: what fields of employment do you find PERL programmers?
Our employers want what every software development-related employer wants -
that jobs can be completed effectively, efficiently, and intelligently.
The web-related jobs are where a lot of "Perl programmers" are found, but
there are many non-specific "Perl programming" jobs where Perl knowledge
is expected, like system administration.
You might read some back postings from this newsgroup by Randal Schwartz
who addressed some of the underlying issues you mentioned.
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: 28 May 1997 05:50:24 GMT
From: silee@news.hk.super.net (Mr Simon Lee)
Subject: Re: regexp problem
Message-Id: <5mgh30$q6l$1@tst.hk.super.net>
Tad McClellan (tadmc@flash.net) wrote:
: Mr Simon Lee (silee@news.hk.super.net) wrote:
: : I recently need to match the df output of the SunOS 4.1.x and
: : SunOS 5.x. Their outputs are:
: : SunOS 4.1.3:
: : /dev/sda0 31199 13477 16111 46% /
: : SunOS 5.x:
: : /dev/dsk/c0t0d0s0 31199 13477 16111 46% /
: : so I rsh to each machine, and get their df outputs, and do:
: : (match all the chars and digits in the line, optionally
: : match /\w+ e.g. /c0t0d0s0)
: : if (m|(/dev/\w+(/\w+)?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(.*)|) {
: : print "$1,$2,$3,$4,$5,$6\n";
: : }
: : I expect the outputs would be either:
: : /dev/sda0,31199,13477,16111,46,/
: : or
: : /dev/dsk/c0t0d0s0,31199,13477,16111,46,/
: I get no match at all with that data and that code.
: Because there are no spaces between the '46' and the '%'...
: [ snip output that is not produced by the script above... ]
: : Does anyone know the correct answer ?
: ^^^^^^^^^^^^^^^^^^
: split()
Hi,
I now use the following codes instead:
print "$1,$2,$3,$4,$5,$6\n"
if /(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/;
Thanks anyway,
Simon
: -------------------
: #! /usr/bin/perl -w
: while (<DATA>) {
: @parts = split /%?\s+/;
: foreach (@parts) {print "'$_' "}
: print "\n";
: }
: __DATA__
: /dev/sda0 31199 13477 16111 46% /
: /dev/dsk/c0t0d0s0 31199 13477 16111 46% /
: -------------------
: : Thanks,
: You're welcome.
: --
: Tad McClellan SGML Consulting
: Tag And Document Consulting Perl programming
: tadmc@flash.net
------------------------------
Date: Wed, 28 May 1997 21:28:48 -0400
From: Scott Blanksteen <sibsib@hotmail.com>
Subject: Re: script optimization of grep -c
Message-Id: <338CDBD0.60A1BE75@hotmail.com>
Eric Finley wrote:
> After some advice on my regex my code looks like:
> ...
> and it is slightly slower than grep -c :(
You may want to try 'agrep' - it's faster than most grep's by a
good margin. You can find it (and some docs) at
<ftp.cs.arizona.edu/agrep/>.
Scott
--
Scott I. Blanksteen
sib (at) worldnet (dot) att (dot) net
------------------------------
Date: Mon, 26 May 1997 09:10:14 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: Script wanted
Message-Id: <tcyangEAs6t2.9B8@netcom.com>
I always consider a problem more complicated than it can be, but some
HTML tags could cover more than one line, and the killhtml.pl script
fail. Right now I can think of two cases:
(1) comment. <!-- in one line and --> in another. Javascript codes usually
use this.
(2) terribly long tag, like
<IMG SRC="http://www.playboy.com/97May/covergirl.gif"
ALT="[Image for May, 1997 Cover Girl]"
ALIGH="right">
I guess "lynx -dump" is still a better idea for lazy people like me :)
===============================
Tad McClellan (tadmc@flash.net) wrote:
: : A really dumb program to do this:
: : killhtml.pl:
: : while (<>) {
: : s/<.*>//g;
: : print;
: : }
: A little _too_ dumb ;-)
: s/<.*?>//g;
: ^
: or, better yet:
: s/<[^>]*>//g;
--
Tung-chiang Yang tcyang@netcom.com
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: Thu, 29 May 1997 11:45:56 +1000
From: Ira <ira@rta.nsw.gov.au>
Subject: STDIN hang-up
Message-Id: <338CDFD4.41C6@rta.nsw.gov.au>
while (<STDIN>) {
print ;
}
Okay, but what if the program looks for STDIN and there is none. How can
do I stop it from hanging? I recall reading something about "peaking
into the input stream" in the Camel book...but can't seem to locate that
tidbit.
Ideas?
Ira
------------------------------
Date: Wed, 28 May 1997 20:28:27 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: undef, split: bug?
Message-Id: <EAwrJF.E51@bcstec.ca.boeing.com>
In article <wvlo50ncay.fsf@lovelace.infobiogen.fr>,
Frederic Achard <fred@lovelace.infobiogen.fr> wrote:
>
>
>Dear all,
>
>The following perl code
>" $ perl5.004 -e ' ( undef, undef, $a) = split / /, "1 2 3"; print " $a\n"'
>"
>prints only the new line
>
>The previous perl version returned what I'd expect:
>" $ perl5.003 -e ' ( undef, undef, $a) = split / /, "1 2 3"; print " $a\n"'
>" 3
Frederic,
Correct on mine - maybe the "subversion" is the problem :)
--
Charles DeRykus
ced@carios2.ca.boeing.com
Summary of my perl5 (5.0 patchlevel 3 subversion 93) configuration:
Platform:
osname=aix, osvers=3.2.4, archname=aix
uname='aix carios2 2 3 000005273000 '
hint=recommended, useposix=true, d_sigaction=define
bincompat3=y useperlio= d_sfio=
Compiler:
cc='cc', optimize=' ', gccversion=
cppflags='-DUSE_OP_MASK'
ccflags ='-DUSE_OP_MASK'
stdchar='unsigned char', d_stdstdio=define, usevfork=false
voidflags=15, castflags=1, d_casti32=define, d_castneg=
intsize=4, alignbytes=8, usemymalloc=n, randbits=15
Linker and Libraries:
ld='ld', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
libs=-ldbm -lld -lm -lc -lbsd -lPW
libc=/usr/lib/libc.a, so=so
useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_aix.xs, dlext=so, d_dlsymun=, ccdlflags='-bE:perl.exp'
cccdlflags=' ', lddlflags='-H512 -T512 -bhalt:4 -bM:SRE -bI:$(PERL_INC)/perl.exp -bE:$(BASEEXT).exp -e _nostart -lc -L/usr/local/
lib'
Characteristics of this binary (from libperl):
Built under aix
Compiled at Mar 26 1997 15:12:12
@INC:
/opt/perl5.004/lib
/opt/perl5.004/lib/aix/5.004
/opt/perl5.004/lib
/opt/perl5.004/lib/site_perl/aix
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 536
*************************************