[8899] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2516 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 6 14:07:49 1998

Date: Wed, 6 May 98 11:01:09 -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, 6 May 1998     Volume: 8 Number: 2516

Today's topics:
    Re: 256 char limitation? (Mike Wescott)
    Re: Another Odd Regexp Question - Buggy Behaviour? <danboo@negia.net>
    Re: Another Odd Regexp Question - Buggy Behaviour? (Mark Schmick)
    Re: autoflush or $| (Mark Schmick)
    Re: autoflush or $| <rar@rentrak.com>
        Bad free() ignored -- latest Perl not an option <andy@wonderworks.co.uk>
    Re: Bad free() ignored -- latest Perl not an option <andy@wonderworks.co.uk>
        Bizarre problem with scalar .. operator? <boys@aspentech.com>
    Re: Bizarre problem with scalar .. operator? <dcameron@bcs.org.uk>
    Re: Bizarre problem with scalar .. operator? <jdf@pobox.com>
    Re: Bizarre problem with scalar .. operator? (Hakan Hjelmstrom)
        case sensitive of a search engine <info@atig.fr>
    Re: COUNTING DAYS UNTIL 2000 <pas@unh.edu>
    Re: COUNTING DAYS UNTIL 2000 (Michael J Gebis)
    Re: Ever Wonder Why Not Everyone Uses Modules? <andy@wonderworks.co.uk>
    Re: File Renaming <aqumsieh@matrox.com>
    Re: File Renaming (brian d foy)
        Help - File manipulation - deleting lines (Lonnie Clardy)
    Re: Help - File manipulation - deleting lines <jdf@pobox.com>
        Help : Generating a Unicode file <kdsull@softmagic.co.kr>
        help needed with regular expression (Mischa van Rijswijk)
        how do you do to extract the title of a .html document? <info@atig.fr>
    Re: how do you do to extract the title of a .html docum <br@ndon.com>
    Re: how do you do to extract the title of a .html docum (Philosopher King)
    Re: how do you do to extract the title of a .html docum (Craig Berry)
    Re: how do you do to extract the title of a .html docum (Craig Berry)
    Re: how do you do to extract the title of a .html docum <lr@hpl.hp.com>
        http+sockets <ksiero@sgh.waw.pl>
    Re: http+sockets (brian d foy)
    Re: http+sockets <ksiero@sgh.waw.pl>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 06 May 1998 12:44:44 -0400
From: wescott@cygnus.ColumbiaSC.NCR.COM (Mike Wescott)
To: pittdno@spamexecpc.com
Subject: Re: 256 char limitation?
Message-Id: <x4ra27ic1v.fsf@cygnus.ColumbiaSC.NCR.COM>

In article <6inbnn$rnh@newsops.execpc.com> N/A <pittdno@spamexecpc.com> writes:
>   1) The problem is that if I try to send more than 256 chars from the
>   client to the server, the first 256 get lost and only the chars after
>   that show up at the other clients! In other words, if I type a paragraph
>   of text 280 chars long in the client terminal window, and hit return,
>   what the other clients see is chars 257-280! If I type less than 256,
>   they get it all![...] Is this a Solaris limitation, socket limitation?

Solaris limitation/bug/feature (take your pick), also present in other
SysVr4-derived OS's. It is, I believe, a limitation in the pseudo-tty
code which provides a standard tty-like interface between your xterm
and your shell (and its children).

One way to avoid this, is to change the tty modes so that characters
can be read by the script as they are typed. See perlfaq5:

	How can I read a single character from a file? From the keyboard?

-- 
	-Mike Wescott
	 mike.wescott@ColumbiaSC.NCR.COM


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

Date: Wed, 06 May 1998 10:40:42 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Another Odd Regexp Question - Buggy Behaviour?
Message-Id: <3550766A.4D70BAED@negia.net>

Derek Balling wrote:
> 
> OK, I am using a regexp to parse an automated request for
> provisioning of a cable modem.
> 
> I'm using the regexp:
> 
> $foo = $1 if $request =~ /modem (\d{5,6})/gs;
> 
> Which should find the either five or six digit modem UUID
> following the word "modem" in the request string. (Where the
> message has been parsed to just be line1\nline2\nline3)
> 
> This WORKS in the following example:
[SNIP]

> So I would say "OK, that works!"  ***EXCEPT*** if a string
> elsewhere in the text is changed, as in THIS example
[SNIP]

it works fine for me (as expected). perhaps you could boil it down
to a small working example and post it. on an unrelated note, i'm
not convinced you need the 'g'. it seems you would only expect one
match, and if there were multiples, they'd probably be the same.
and since your not using '.', '^', or '$', no need for the 's'
modifier either.

hope this helps,

-- 
Dan Boorstein   home: danboo@negia.net  work: danboo@y-dna.com

 "THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
                         - Cosmic AC


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

Date: Wed, 06 May 1998 17:24:43 GMT
From: mark@webz.com (Mark Schmick)
Subject: Re: Another Odd Regexp Question - Buggy Behaviour?
Message-Id: <35509bce.174398383@news.flash.net>

Derek,

Your question in incomplete. Based on the information provided,
nothing should go wrong. For instance, I cut-n-pasted to create
the following script:

--------------------------------------
$foo = q{
A request has been made to provision modem 99999, a CCM201
modem, with 10 usable IP addresses for Cablemaster ID
123456-01.
REQUESTOR: derek


Downstream:     PHOENIX DOWN4
Upstream Modem: 602-555-1212
Call Waiting? : NO
Customer Name : Test USer
Address1:       77777 Do Not Create
Address2:       Phoenix AZ 88888
Address3:
Phone Number:   550-555-5555
};

$foo2 = q{
A request has been made to provision modem 99999, a CCM201
modem, with 10 usable IP addresses for Cablemaster ID PCTV.
REQUESTOR: derek
RESPONSIBLE: foobar

Downstream:     PHOENIX DOWN4
Upstream Modem: 602-555-1212
Call Waiting? : NO
Customer Name : Test USer
Address1:       77777 Do Not Create
Address2:       Phoenix AZ 88888
Address3:
Phone Number:   550-555-5555
};

print $1,"\n" if $foo =~ /modem (\d{5,6})/gs;
print $1,"\n" if $foo2 =~ /modem (\d{5,6})/gs;
--------------------------------------

And got the following output:
99999
99999

Meaning that both regex's worked just fine. You should probably
post *exactly* the code you're using, and *exactly* the data set
being processed. It could be that "modem 99999" is actually
"modem\n99999" or something(?), so you'd want "\s" in your regex
rather than a space. But that's a wild guess, in lieu of more
information.

Hope that was helpful,
Mark

---------------------------------------------------
Mark Schmick     mark@webz.com      http://webz.com
"Crispy Outside, Light and Crackery Inside"


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

Date: Wed, 06 May 1998 16:26:31 GMT
From: mark@webz.com (Mark Schmick)
Subject: Re: autoflush or $|
Message-Id: <35508def.170846658@news.flash.net>

On Tue, 5 May 1998 15:36:18 -0700, "Richard Robinson"
<rar@rentrak.com> wrote:

>Hello,
>
>I've got a CGI script that runs an LWP client. I want to log the results of
>the client's success (or not) to a log file and AT the same time (or
>thereabouts in milliseconds) I want to print the results to STDOUT, or my
>browser.
>
>I've done this, basically,
>
>open TEMP "log.file"
>
>select TEMP
>autoflush(1);
>select STDOUT
>autoflush(1);
>
>But the autoflush is not working on the STDOUT (I don't know if it's working
>on TEMP either, but don't really care). What happens is that after a while
>the browser I'M IN, says that it doesn't receive a response from the server,
>and I click on OK (only option). So my connection is closed with server, but
>the autoclient continues to run on the server till it is done (fine).
>
>Question is Why isn't autoflush working on STDOUT?

You need to run your script in non-parsed-header (nph) mode, usually
(this varies by web server) by adding the prefix "nph-" to the script
name. This turns off the standard output buffering that the web server
uses, and complements the suppression of buffering you've already
done inside your script (you need both).

Hope that was helpful,
Mark

---------------------------------------------------
Mark Schmick     mark@webz.com      http://webz.com
"Crispy Outside, Light and Crackery Inside"


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

Date: Wed, 6 May 1998 10:27:09 -0700
From: "Richard Robinson" <rar@rentrak.com>
Subject: Re: autoflush or $|
Message-Id: <6iq68h$650$1@brokaw.wa.com>

Thanks, Mark. nph-scriptname.cgi did the trick beautifully and cleanly.

--Richard

Mark Schmick wrote in message <35508def.170846658@news.flash.net>...
>On Tue, 5 May 1998 15:36:18 -0700, "Richard Robinson"
><rar@rentrak.com> wrote:
>
>>Hello,
>>
>>I've got a CGI script that runs an LWP client. I want to log the results
of
>>the client's success (or not) to a log file and AT the same time (or
>>thereabouts in milliseconds) I want to print the results to STDOUT, or my
>>browser.
>>
>>I've done this, basically,
>>
>>open TEMP "log.file"
>>
>>select TEMP
>>autoflush(1);
>>select STDOUT
>>autoflush(1);
>>
>>But the autoflush is not working on the STDOUT (I don't know if it's
working
>>on TEMP either, but don't really care). What happens is that after a while
>>the browser I'M IN, says that it doesn't receive a response from the
server,
>>and I click on OK (only option). So my connection is closed with server,
but
>>the autoclient continues to run on the server till it is done (fine).
>>
>>Question is Why isn't autoflush working on STDOUT?
>
>You need to run your script in non-parsed-header (nph) mode, usually
>(this varies by web server) by adding the prefix "nph-" to the script
>name. This turns off the standard output buffering that the web server
>uses, and complements the suppression of buffering you've already
>done inside your script (you need both).
>
>Hope that was helpful,
>Mark
>
>---------------------------------------------------
>Mark Schmick     mark@webz.com      http://webz.com
>"Crispy Outside, Light and Crackery Inside"




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

Date: Wed, 6 May 1998 16:48:05 +0100
From: Andy Armstrong <andy@wonderworks.co.uk>
Subject: Bad free() ignored -- latest Perl not an option
Message-Id: <FBbMkGA1YIU1EwMi@wndrwrks.demon.co.uk>

We're currently developing a CGI script which works well locally but
fails with "Bad free() ignored" when installed on our public server
(which is hosted by our ISP).

Unfortunately our ISP is still running 5.001 and there's no prospect of
changing this in the near futyre.

The script uses NDBM, and I'm assuming that the message is caused by
memory being allocated via the raw allocater but freed freed via Perl's

So, is there a known work around for this given that I can't get to any
part of the Perl installation to change it and I can't provide a local
copy of the module.

Ditching NDBM altogether and storing the databases in text files is an
option (they're not huge), but not a terribly attractive one...

-- 
Andy Armstrong, Wonderworks, http://www.wonderworks.co.uk


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

Date: Wed, 6 May 1998 17:31:31 +0100
From: Andy Armstrong <andy@wonderworks.co.uk>
Subject: Re: Bad free() ignored -- latest Perl not an option
Message-Id: <dgea8DAjBJU1Ew9s@wndrwrks.demon.co.uk>

In article <FBbMkGA1YIU1EwMi@wndrwrks.demon.co.uk>, Andy Armstrong
<andy@wonderworks.co.uk> writes

[snip]

>Ditching NDBM altogether and storing the databases in text files is an
>option (they're not huge), but not a terribly attractive one...

Actually I've just tried removing the NDBM dependency and it still
produces the same error so NDBM evidently has nothing to do with it.

The message is always associated with a line like

  sub xxx
  {
     my ($smig, $smeg) = @_;     <-- error reported here
  }

-- 
** Don't CC any follow-ups to me - I *do* read the newsgroups I post to **
Andy Armstrong, Wonderworks, http://www.wonderworks.co.uk


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

Date: Wed, 06 May 1998 17:21:48 +0100
From: Ian Boys <boys@aspentech.com>
Subject: Bizarre problem with scalar .. operator?
Message-Id: <35508E1C.15FB@aspentech.com>

I was trying to use the scalar .. operator to solve a problem, but my
code kept failing to do what I expected it to do.

The problem seems to arise from using a certain expressions on the left
hand side of the .. operator, for example (but I think not limited to) a
literal constant.

I've simplified the problem down to a simple (non-useful) example, to
illustrate.

Example 1 does what I expect:

    for my $i (1..10) {
        my $m = ($i==$i) .. ($i == 7);
        print "$i: $m\n";
    }

% perl -w dotdot.pl
1: 1
2: 2
3: 3
4: 4
5: 5
6: 6
7: 7E0
8: 1
9: 2
10: 3
%

Example 2 I think should produce the same output but doesn't:

    for my $i (1..10) {
        my $m = (1) .. ($i == 7);
        print "$i: $m\n";
    }

% perl -w dotdot.pl
1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
10: 
%

It seems that the .. never evaluates to true.  Can anyone explain what
is going on?

Thanks for any hints,

Ian


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

Date: 6 May 1998 17:36:55 GMT
From: "Duncan Cameron" <dcameron@bcs.org.uk>
Subject: Re: Bizarre problem with scalar .. operator?
Message-Id: <01bd7915$42a62220$d83e63c3@dns.btinternet.com>

No, not too bizarre.  See Camel page 90, for what happens when either
operand of scalar .. is a numeric literal.

HTH

Duncan Cameron

Ian Boys <boys@aspentech.com> wrote in article
<35508E1C.15FB@aspentech.com>...
> I was trying to use the scalar .. operator to solve a problem, but my
> code kept failing to do what I expected it to do.
> 
< code snipped> 

> It seems that the .. never evaluates to true.  Can anyone explain what
> is going on?
> 
> Thanks for any hints,
> 
> Ian
> 


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

Date: 06 May 1998 13:47:54 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: Ian Boys <boys@aspentech.com>
Subject: Re: Bizarre problem with scalar .. operator?
Message-Id: <g1in9qxx.fsf@mailhost.panix.com>

Ian Boys <boys@aspentech.com> writes:

>     for my $i (1..10) {
>         my $m = (1) .. ($i == 7);
>         print "$i: $m\n";
>     }

According to perlop:

   If either operand of scalar ".." is a numeric literal, that operand is
   implicitly compared to the $. variable, the current line
   number. Examples:

   As a scalar operator:

      if (101 .. 200) { print; } # print 2nd hundred lines
      next line if (1 .. /^$/);  # skip header lines

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: Wed, 06 May 1998 17:49:09 GMT
From: hawk@algonet.se (Hakan Hjelmstrom)
Subject: Re: Bizarre problem with scalar .. operator?
Message-Id: <3552a26e.6982109@news.algonet.se>

On Wed, 06 May 1998 17:21:48 +0100, Ian Boys wrote:
> I was trying to use the scalar .. operator to solve a problem, but my
> code kept failing to do what I expected it to do.
> The problem seems to arise from using a certain expressions on the left
> hand side of the .. operator, for example (but I think not limited to) a
> literal constant.

Funny, I never realized there were so many aspects to those two little
dots! I tried some stuff based on your example after reading the
perlop docs. It's my understanding that the left hand side expression
never evaluates to true since, and I quote:

  "If either operand of scalar '..' is a numeric literal, that operand

    is implicitly compared to the $. variable, the current line
    number."

In this example $. is undef since no filehandle has been read from and
the '..' operator will stay false as long as its left operator is
false.

Hmm, I guess this little operator could come in handy sometime!

Hekan Hjelmstrvm
hawk@algonet.se


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

Date: Wed, 6 May 1998 18:04:16 +0200
From: "sg" <info@atig.fr>
Subject: case sensitive of a search engine
Message-Id: <6iq1so$4ud$1@minus.oleane.net>

hi everybody !

I'm making a little search engine, and when i test it :
i put a caracter like ? or * or % in the case of the
form, it is not able to return me the page call not_found.
so, i would wanted to made my form's case not
sensible to these caracters without doing tests like
that :
if ($cle eq (? or % or etc...) {
return &not_found
}

is it possible??

thanks you to answer me
sg
info@atig.fr




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

Date: 6 May 1998 15:52:47 GMT
From: Paul A Sand <pas@unh.edu>
Subject: Re: COUNTING DAYS UNTIL 2000
Message-Id: <6iq10f$lan@mozz.unh.edu>

fl_aggie@thepentagon.com (I R A Aggie) writes:
>In article <01bd7860$50183840$a44a6dc2@earl.esense.nl>, "Mathijs Oosterom"
><thijs@esense.nl> wrote:

>+ Hi there,
>+ 
>+ Does anyone has a Perl-script that counts the days until the year 2000? 

>Yep. It uses some modules, and if you don't have them, it won't work.
[...]

Although I R A's solution (using Julian dates) is probably more robust
for the general case, Date::Manip can do this by itself:

    #!/usr/bin/perl

    use Date::Manip;

    $today = &ParseDate("today");
    $y2k = &ParseDate("1/1/2000");
    $delta = &DateCalc($today, $y2k, \$err);
    print &Delta_Format($delta, 1, "About %dt days until y2k\n");

(We won't quibble about ``year 2000 in which time zone,'' OK? Although
I suppose we could.)

I really, really, like Date::Manip...

-- 
-- Paul A. Sand                 | The FAQ had done its job so well that the
-- University of New Hampshire  | Question was no longer Frequently Asked,
-- pas@unh.edu                  | and thus, its answer is no longer in the FAQ.
-- http://pubpages.unh.edu/~pas |     (Kevin Williams, in rec.arts.books)


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

Date: 6 May 1998 17:31:32 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: COUNTING DAYS UNTIL 2000
Message-Id: <6iq6pk$659@mozo.cc.purdue.edu>

fl_aggie@thepentagon.com (I R A Aggie) writes:

}In article <01bd7860$50183840$a44a6dc2@earl.esense.nl>, "Mathijs Oosterom"
}<thijs@esense.nl> wrote:

}+ Hi there,
}+ 
}+ Does anyone has a Perl-script that counts the days until the year 2000? 

}Yep. It uses some modules, and if you don't have them, it won't work.

I made some small changes to your script for conciseness, here it is:

#!/usr/bin/perl -w
use Time::JulianDay;
($mday,$mon,$year)=(localtime())[3..5];
$d=julian_day(1900,1,1)-julian_day(1900+$year,++$mon,$mday);

print "Only $d days till the Year 2000 bug hits!\n";
# ;-)

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Wed, 6 May 1998 16:59:00 +0100
From: Andy Armstrong <andy@wonderworks.co.uk>
Subject: Re: Ever Wonder Why Not Everyone Uses Modules?
Message-Id: <8RHCgNAEjIU1Ewqi@wndrwrks.demon.co.uk>

In article <slrn6kudhr.p5r.bet@ritz.mordor.net>, Bennett Todd
<bet@network.rahul.net> writes
>1998-05-05-12:54:11 Andy Armstrong:
>>One of the inherent problems with encouraging reuse is that you're also
>>encouraging people's ability to engineer solutions from first principles to
>>atrophy.
>
>That's certainly true; I doubt you can find very many programmers graduating
>today who could engineer a good robust application for e.g. text editing
>if given only a bucket of sand and an outcropping to mine and refine for
>impurities. Worse, if you made them go back and start with a loose gas cloud
>of remnants of previous supernova almost everyone would give up. And even that
>is indulging in reuse; pushing elements up the packing curve past iron is
>_hard_.

:-)

I can see how you might have formed the opinion that I'm a
fundamentalist wheelright -- I'm not. I like a good dose of reuse as
much as the next sloth, but it does concern me that as professionals in
our industry get further and further away from the nuts and bolts their
ability to look inside the encapsulation and criticise, debug, accept or
reject it the implementation *when necessary* is being lost.

Incidentally you've half-way hijacked one of my favourite desert island
fantasies -- the one where I'm stuck with a solar powered PC with no
boot disks and (for some unspecified and highly contrived reason) have
to write a new OS for it from scratch.

Also I spent quite a lot of time as a small child worrying about how
they made the first lathe...

-- 
** Don't CC any follow-ups to me - I *do* read the newsgroups I post to **
Andy Armstrong, Wonderworks, http://www.wonderworks.co.uk


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

Date: Wed, 06 May 1998 12:00:27 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: File Renaming
Message-Id: <3550891A.98F008D0@matrox.com>

> In comp.lang.perl.misc, Zsolt Fazekas <zsolt@idigital.net> wrote :
> # I'm trying to write a script that renames files in a logical numeric
> # order in a directory. The only problem is that it won't rename >:-).
> # Here is my script. I'm getting the error at the rename line and it says:
> # "
> #
> # #!/usr/bin/perl
> #
> # $i='0001';
> # open (DIR, "+<file.txt") || die $!;
> # while (defined ($_=<DIR>)) {
> #     $oldname= (chomp $_);
>

Hmmm ... I hope you know that $oldname contains "0" or undefined. The reason
is that chomp returns the number of characters chopped!! Since $_ would not
contain a "\n" (or more precisely the character defined in $/), chomp will
return 0 which is false!

> #     if ($_=~ /jpg/ || /gif/) {  #leave other files alone
> #         $_=~ s/\w*/$i/;        #chop up to . and discard
> #         $newname=$_;
> #         rename ($oldname,$newname) || die $!";  #here's where the error
> # is: "no such                  file  or directory at progname.pl line 16,
>

BINGO!

> # <DIR> chunk 1.
> #         $i++;
> #     }
> # }
> # close (DIR) || die $!";
>

 Solution:
Just use
$old_name = $_;

Or .. use $_ directly and save some memory!


Enjoy

--
Ala Qumsieh             | "How much wood would a woodchuck
ASIC Design Engineer    |  chuck if a woodchuck could
Matrox Graphics Inc.    |  chuck wood?"
Montreal, Quebec        |             - Trivial ... 5!





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

Date: Wed, 06 May 1998 13:50:15 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: File Renaming
Message-Id: <comdog-ya02408000R0605981350160001@news.panix.com>
Keywords: from just another new york perl hacker

In article <3550891A.98F008D0@matrox.com>, Ala Qumsieh <aqumsieh@matrox.com> posted:

>> In comp.lang.perl.misc, Zsolt Fazekas <zsolt@idigital.net> wrote :

>> # while (defined ($_=<DIR>)) {
>> #     $oldname= (chomp $_);
>>
>
>Hmmm ... I hope you know that $oldname contains "0" or undefined. The reason
>is that chomp returns the number of characters chopped!! Since $_ would not
>contain a "\n" (or more precisely the character defined in $/), chomp will
>return 0 which is false!

hmmm... perhaps the following snippet does something different on
your version of perl :)

   #!/usr/bin/perl
   
   $\ = "\n";
   while( defined ($line = <DATA>) )
      {
      $oldname = (chomp $line);
      print $oldname;
      }
      
   __DATA__
   line 1
   line 2
   line 3

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: Wed, 6 May 1998 09:53:56 -0700
From: lonniec@ntgi.com (Lonnie Clardy)
Subject: Help - File manipulation - deleting lines
Message-Id: <MPG.fba358094f22a51989680@news.lsil.com>

Can someone tell me what the easiest way is to delete certain lines out 
of a text file?  Let me see if I can ask the question better.
What I have is a file that contains user information and I have a script 
that allows someone to add a user to the file via a web page. I now want 
to write a script that would allow for deleting a user from this text 
file.  I can search through the file and find the user name once I do 
this I would like to delete that line and the following 4 lines after it. 
So what would be the easiest way to delete the current line and the 4 
lines after it. 
The final outcome that I am looking for is to have a file with the same 
filename that I started with and same information minus the 5 lines I 
want deleted.

I would appreciate any help that you might be able to provide.

Thanks,
Lonnie
lonniec@ntgi.com


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

Date: 06 May 1998 13:52:20 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: lonniec@ntgi.com (Lonnie Clardy)
Subject: Re: Help - File manipulation - deleting lines
Message-Id: <d8dr9qqj.fsf@mailhost.panix.com>

lonniec@ntgi.com (Lonnie Clardy) writes:

> Can someone tell me what the easiest way is to delete certain lines out 
> of a text file?

Someone already has, in the documentation that accompanies perl.

   C:\> perldoc perlfaq5

Look for "How do I change one line in a file/delete a line in a
file/insert a line in the middle of a file/append to the beginning of
a file?"

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: Thu, 07 May 1998 02:55:57 +0900
From: Sull Kidon <kdsull@softmagic.co.kr>
Subject: Help : Generating a Unicode file
Message-Id: <3550A42D.483898B4@softmagic.co.kr>

Hello !

A question from a Novice (almost a week actually,
have chosen Perl as my first programming language !)

I need to generate a Unicode file for CJK Unified
Ideographs (ie some 20K characters, from 4e00 to
9fff) to edit and comment so on after reading the
file from NT's notepad. I simply can't cut and paste
20k times from NT's Unicode characters table,
can I ?

So I need to generate a file containing 0xfffe and
the following 20K unicode, but can't find any tip how
to generate the binary file from my book (Teach myself
Perl 5 in 3 weeks, tho I find it an excellent guidebook.
That translated in Korean of course).

Shouldn't be more than 10 lines, methinks, so please
can somebody give it a couple of minutes and make
my life a bit easier...

Many thanks in advance.

Kidon Sull






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

Date: Wed, 06 May 1998 15:48:12 GMT
From: mischa@pi.net (Mischa van Rijswijk)
Subject: help needed with regular expression
Message-Id: <355083e6.115753688@news.wxs.nl>

Hello,

I need some help with a regular expression. 

I have the following code to change url's in a webpage:

open (FILE_OUT, ">$ARGV[0]") || die "Cannot creat $ARGV[0]";
        foreach $line (@file) {
                if ($line !~ /\/cgi-bin\//) {
                        $line =~ s/<a href="(.*)">/<a
href="\/cgi-bin\/clickcount\/log.cgi?url=$1?log=$ARGV[1]"
 onMouseOver="window.status='$1';return true"
onMouseOut="window.status=' ';return true">/s;
                        print FILE_OUT $line;
                } else {
                        print FILE_OUT $line;
                }
        }
close (FILE_OUT);
}

The problem is perl does greedy matching so if I have something like
this:

text text text <a href="http://www.bla.com">link</a> text text text
text <a href="http://www.bla2.com">link</a> text text text etc.

It matches $1 from the first <a href till the end of the second url.
What i want is only to match the first url and after this match it
must match the second url.

Anyone got suggestions or knows the sollution to this problem.

Thanx in advance!

Mischa van Rijswijk


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

Date: Wed, 6 May 1998 17:56:26 +0200
From: "sg" <info@atig.fr>
Subject: how do you do to extract the title of a .html document?
Message-Id: <6iq1ca$4c0$1@minus.oleane.net>

hi everybody :)
again a novice's question :)

I would wanted to know how to extract the title of a .html
document (the title is a string between two tags :
<title>title of the page</title>.)
thanks you very much to bring me an answer!

sg
info@atig.fr




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

Date: Wed, 06 May 1998 12:07:58 -0400
From: Brandon Golm <br@ndon.com>
To: sg <info@atig.fr>
Subject: Re: how do you do to extract the title of a .html document?
Message-Id: <35508ADE.5F3BF51C@ndon.com>

sg wrote:
> 
> hi everybody :)
> again a novice's question :)
> 
> I would wanted to know how to extract the title of a .html
> document (the title is a string between two tags :
> <title>title of the page</title>.)
> thanks you very much to bring me an answer!
> 

My Browser prints it right up on the title bar for me.  So that's where
I usually look.

But maybe you're looking for HTML::Parser at CPAN.

http://www.perl.com/CPAN

 .brandon.


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

Date: Wed, 06 May 1998 16:33:20 GMT
From: holcojh5@REMOVEMEwfu.edu (Philosopher King)
Subject: Re: how do you do to extract the title of a .html document?
Message-Id: <3550901b.140891260@enews.newsguy.com>

On Wed, 6 May 1998 17:56:26 +0200, "sg" <info@atig.fr> wrote:

>hi everybody :)
>again a novice's question :)
>
>I would wanted to know how to extract the title of a .html
>document (the title is a string between two tags :
><title>title of the page</title>.)
>thanks you very much to bring me an answer!
>

Just use a simple regular expression like

if (/<title>(.*)<\/title>/i) {
    print $1;
    # or whatever else you want to do with it
}

or something similar when you are parsing the document.

That's probably the easiest way.

Heath

--
Heath Holcomb                  * I want to be more like the ocean
holcojh5@REMOVEMEwfu.edu       * No talking, man...
holcomb@REMOVEMEmthcsc.wfu.edu * All action
http://www.wfu.edu/~holcojh5/  * - Perry Farrell


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

Date: 6 May 1998 17:15:31 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: how do you do to extract the title of a .html document?
Message-Id: <6iq5rj$o71$3@marina.cinenet.net>

A followup to my own previous post -- add the 'i' (case insensitivity) 
qualifier to the large title-matching regex, so you can handle <TITLE> as 
well as <title>.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 6 May 1998 17:14:23 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: how do you do to extract the title of a .html document?
Message-Id: <6iq5pf$o71$2@marina.cinenet.net>

sg (info@atig.fr) wrote:
: I would wanted to know how to extract the title of a .html
: document (the title is a string between two tags :
: <title>title of the page</title>.)
: thanks you very much to bring me an answer!

Well, if you want to, you can get and use the HTML::Parser module, which 
makes this relatively easy.

If you want to do it 'by hand', my version would look like this:

  # Assume html file is open for read on handle HTML.
  # Read the entire file text into a single string.

  { local $/; $text = <HTML> }

  # Grab everything between <title> and </title>.

  ($title) = $text =~ m!<\s*title\s*>(.*?)<\s*/title\s*>!s;

  # Trim off leading and trailing whitespace.

  $title =~ s/^\s+//;
  $title =~ s/\s+$//;

This is not especially robust (it can be fooled by titles which have been
commented out, for example), but it should be good enough for most
purposes. 

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Wed, 6 May 1998 10:42:01 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: how do you do to extract the title of a .html document?
Message-Id: <6iq7dg$i8p@hplntx.hpl.hp.com>

[posted and mailed]

Philosopher King wrote in message
<3550901b.140891260@enews.newsguy.com>...
 ...
>if (/<title>(.*)<\/title>/i) {
>    print $1;
>    # or whatever else you want to do with it
>}
 ...

Why assume the title is on one line?  Also, what if there is more than
one title (I know, there shouldn't be!)?

if (/<title>(.*?)<\/title>/is) {
               ^            ^
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com





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

Date: Wed, 6 May 1998 18:19:19 +0200
From: Krzysztof Sierota <ksiero@sgh.waw.pl>
Subject: http+sockets
Message-Id: <Pine.GSO.3.96.980506181121.28575A-100000@akson.sgh.waw.pl>

Hi,
I've got to write an aplication similiar that will:
1) analyze a html form
2) display it like lynx or sth similiar and allow user to type
everything as in normal form
3) submit the form.

1,2 are almost done.
HOwere I have no idea how to submit submit such a form. I tried
telneting to port 80 of my comp and talk to www server I managed
to get the some files typying:
get http://bla.bla.bla/page/ http/1.1
host: bla.bla.bla

It works. But I don't know how to send something to the cgi
script. I am especially interested in GET type forms, ( the
program will have to analyze that kind of forms (mostly :()).

I was thinking of opening a socket and then typing there the same
text I typed when telneting. The problem is I don't know what to
type ;). Another problem is How can I read the response back from
the www server ( analysing html code is almost done )

Please help me.

Thank You in advance 
					Krzysztof Sierota



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

Date: Wed, 06 May 1998 13:16:46 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: http+sockets
Message-Id: <comdog-ya02408000R0605981316460001@news.panix.com>
Keywords: from just another new york perl hacker

In article <Pine.GSO.3.96.980506181121.28575A-100000@akson.sgh.waw.pl>, Krzysztof Sierota <ksiero@sgh.waw.pl> posted:


>It works. But I don't know how to send something to the cgi
>script. I am especially interested in GET type forms, ( the
>program will have to analyze that kind of forms (mostly :()).

use LWP::UserAgent and HTTP::Request.  the docs have plenty
of examples.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: Wed, 6 May 1998 19:41:19 +0200
From: Krzysztof Sierota <ksiero@sgh.waw.pl>
To: brian d foy <comdog@computerdog.com>
Subject: Re: http+sockets
Message-Id: <Pine.GSO.3.96.980506194103.18625A-100000@akson.sgh.waw.pl>

Thank YOu very much, hope I'll manage ;)


On Wed, 6 May 1998, brian d foy wrote:

> In article <Pine.GSO.3.96.980506181121.28575A-100000@akson.sgh.waw.pl>, Krzysztof Sierota <ksiero@sgh.waw.pl> posted:
> 
> 
> >It works. But I don't know how to send something to the cgi
> >script. I am especially interested in GET type forms, ( the
> >program will have to analyze that kind of forms (mostly :()).
> 
> use LWP::UserAgent and HTTP::Request.  the docs have plenty
> of examples.
> 
> good luck :)
> 
> -- 
> brian d foy                                  <comdog@computerdog.com>
> CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
> Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
> Perl Mongers <URL:http://www.pm.org>
> 
> 



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

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

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