[16754] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4166 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 29 18:05:54 2000

Date: Tue, 29 Aug 2000 15:05:26 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967586725-v9-i4166@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 29 Aug 2000     Volume: 9 Number: 4166

Today's topics:
        "Require" weirdness (malgosia askanas)
    Re: "Require" weirdness (Mark-Jason Dominus)
    Re: "Require" weirdness (malgosia askanas)
    Re: ActiveState perl automatic installation on NT ? <jevon@islandtelecom.com>
    Re: another "why doesn't this work?" question. notknown@anonymous.com
    Re: another "why doesn't this work?" question. <lr@hpl.hp.com>
    Re: check and save random number <lr@hpl.hp.com>
    Re: Counting across multiple lines? <lr@hpl.hp.com>
        error happens in part of backticked pipe <brodzik@kryos.colorado.edu>
    Re: error happens in part of backticked pipe (Greg Bacon)
    Re: Executing Shell Commands in Perl <jevon@islandtelecom.com>
    Re: Executing Shell Commands in Perl <stig@palmquist.org>
    Re: Executing Shell Commands in Perl (Tony L. Svanstrom)
        fast http server in perl <zfido88@zr.ru>
    Re: Get own machine's dial-up IP address? <rgparker@west.net>
    Re: get temporary file name? (David H. Adler)
    Re: Getting the greedy RegEx, wanting the Lazy - help? <tim@ipac.caltech.edu>
    Re: Getting the greedy RegEx, wanting the Lazy - help? <elijah@workspot.net>
    Re: Getting the greedy RegEx, wanting the Lazy - help? <mcameron@mirusweb.com>
    Re: how about programming a mud driver in Perl? <maxwelln@purdue.edu>
    Re: How to Unzip a .tar.gz file (BUCK NAKED1)
    Re: How to Unzip a .tar.gz file <bart.lateur@skynet.be>
    Re: Loading a array from a file. r_conner@my-deja.com
    Re: Loading a array from a file. <abe@ztreet.demon.nl>
    Re: making sure input is a certain way i.e. starting an <lr@hpl.hp.com>
    Re: making sure input is a certain way i.e. starting an <star@sonic.net>
    Re: making sure you all have the documentation <star@sonic.net>
    Re: making sure you all have the documentation (Abigail)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 29 Aug 2000 17:00:13 -0400
From: askanas@panix.com (malgosia askanas)
Subject: "Require" weirdness
Message-Id: <8oh88t$pqe$1@panix3.panix.com>

I have two modules that I am including in my script, by means of "use"
statements.  They both have an identical "require" statement in them.
For one of the modules the "require" works just fine, and for the other
I get a runtime error when I try to invoke a subroutine that resides
in the "required" file -- it is as if the "require" just didn't exist.
But when I put a "BEGIN" block around the "require" statement in that
faulting module, it all works just fine.  Does anybody know what the problem
might be?  Many thanks in advance.


-malgosia


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

Date: Tue, 29 Aug 2000 21:04:25 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: "Require" weirdness
Message-Id: <39ac2558.67d7$311@news.op.net>

In article <8oh88t$pqe$1@panix3.panix.com>,
malgosia askanas <askanas@panix.com> wrote:
>For one of the modules the "require" works just fine, and for the
>other I get a runtime error when I try to invoke a subroutine that
>resides in the "required" file -- it is as if the "require" just
>didn't exist.  Does anybody know what the problem might be?  

I wonder if the on-line manual that comes with Perl has anything to
say about that?


require 

        ... demands that a library file be included
         if it hasn't already been included.  

        ...

I guess it does.

Try using `do' instead.



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

Date: 29 Aug 2000 17:50:32 -0400
From: askanas@panix.com (malgosia askanas)
Subject: Re: "Require" weirdness
Message-Id: <8ohb78$1c7$1@panix3.panix.com>

>require 
>
>        ... demands that a library file be included
>         if it hasn't already been included.  
>
>        ...

You mean if it has been included in one "used" module, it doesn't get included
in others?  Don't these modules have independent namespaces?


-malgosia


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

Date: Tue, 29 Aug 2000 18:44:02 GMT
From: "Jevon MacDonald" <jevon@islandtelecom.com>
Subject: Re: ActiveState perl automatic installation on NT ?
Message-Id: <SvTq5.165$uR1.23304@sapphire.mtt.net>

Begin at www.activestate.com .. They have some decent support mailing lists
for both Activeperl and ActivePython..


"Markus Fischer" <mfischer-news@josefine.ben.tuwien.ac.at> wrote in message
news:slrn8qnafi.8cp.mfischer-news@josefine.ben.tuwien.ac.at...
> Hi,
>
> Does someone know if it's possible to install active state perl
> during an MSWindows NT unattended installation ? Since the latest
> version is not an executeable anymore where I could pass any
> switches which hopefully could work but only an MS Windows
> Installer *.msi file, I don't know where to start to search for
> an automatic installation.
>
> thanks for taking time,
> kind regards,
> Markus
>
> --
> Markus Fischer,  http://josefine.ben.tuwien.ac.at/~mfischer/
> EMail:         mfischer@josefine.ben.tuwien.ac.at
> PGP Public  Key: http://josefine.ben.tuwien.ac.at/~mfischer/C2272BD0.asc
> PGP Fingerprint: D3B0 DD4F E12B F911 3CE1  C2B5 D674 B445 C227 2BD0
>                 - Free Software For A Free World -




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

Date: Tue, 29 Aug 2000 15:00:45 -0400
From: notknown@anonymous.com
Subject: Re: another "why doesn't this work?" question.
Message-Id: <39AC085C.ABFCF081@anonymous.com>

I'm new to perl and might be way off here but how about something like this.

@ARGV=~tr/\\t/ /g;

or
$_=@ARGV;
s/\t/ /g;

But i'm not sure it should be \\t or just \t and space could be / / or /' '/




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

Date: Tue, 29 Aug 2000 12:53:54 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: another "why doesn't this work?" question.
Message-Id: <MPG.1415b4b17602fd3b98acf2@nntp.hpl.hp.com>

In article <39AC085C.ABFCF081@anonymous.com> on Tue, 29 Aug 2000 
15:00:45 -0400, notknown@anonymous.com <notknown@anonymous.com> says...
> I'm new to perl and might be way off here but how about something like this.
> 
> @ARGV=~tr/\\t/ /g;
> 
> or
> $_=@ARGV;
> s/\t/ /g;
> 
> But i'm not sure it should be \\t or just \t and space could be / / or /' '/

Dear notknown@anonymous.com,

Despite your good intentions to help, you are indeed too 'new to Perl' 
(see perlfaq1 for the distinction between 'perl' and 'Perl) to post 
purported solutions 'something like this'.

Even the most experienced posters here embarrass themselves sometimes by 
posting inadequately tested code.  You haven't even gotten that far, and 
have posted conjectures.

Please lurk here a while, read the Perl docs, write more Perl programs, 
and *then*, if you feel you can help answer a question, post tested 
code, preferably with references to the documentation that explains your 
answer.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 29 Aug 2000 12:00:16 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: check and save random number
Message-Id: <MPG.1415a818e30ff95798acee@nntp.hpl.hp.com>

In article <20000829000448.10567.00000578@ng-bh1.aol.com> on 29 Aug 2000 
04:04:48 GMT, Todt68 <todt68@aol.com> says...
> I'm try to make a program that will make a random number.
> Then check a file to see if number is in that file. If number is in file then
> remake another random number and check again. If number isn't in file then save
> number in that file. And save number in another file.

Your line lengths are too long.  Set your newsreader to wrap at 72 
characters.

> So far I have

There are lots of issues with your code, starting with lack of 
indentation (which serious impedes readability).

> #!/usr/bin/perl

No '-w', no 'use strict;'.

> my ($found, @values, @match);

But you do declare these variables, which is good.  I prefer to do that 
where they are first needed, which helps restrict their scope.
 
> open (DB, "<random_master.txt") or die "Unable to open.";

Good diagnostics include the name of the file and the variable $!.

> $found = 0;
> LINE: while (<DB>) {
> (/^#/) and next LINE;
> (/^\s*$/) and next LINE;

The label and its uses are all superfluous.  Anyhow, these details 
aren't relevant to your reason for posting, so should be omitted.  Use 
test data that doesn't have comments or blank lines.

> chomp; 
> @values = &split_decode($_);

In Perl 5, it is better to omit the '&'.

> NUMBER:
> $found = 0;
> $b = 0;
> @array=(1..10);
> range 1 to 9 random number

Is that supposed to be a comment?  Please post code that compiles!

> $random = $array[rand @array];
> $b = "$random";

All that maneuvering reduces to:

  $b = 1 + int rand 10;

which yields an integer between 1 and 10.  Turning it into a string 
isn't necessary -- it will become one when you need it to be.

> if ($values[$num] eq $b) {

Do you really want to do a string comparison on numbers?

> push @match,$_; 
> $found++; 
> print "no more numbers available \n";
> goto NUMBER ;
> } # end of if
> 
> } # end of while
> 
> close DB;
> goto NUMBER if $values[$num] eq $b;

 ...

> so far it almost works. However when its suppose to remake random number
> because of a duplicate - it doesn't.
> 
> Any help pointing me in the right direction would be GREATLY appreciated.

I can't follow the logic well enough to see what you are doing.  It 
would help if you reposted just the relevant code.  We don't need to see 
all the stuff I cut out about writing results to various files.

Instead of implying data read from an external file, show data after an 
__END__ marker and read it from filehandle DATA, so anyone can run the 
code to see what it does.

Clarify what you mean by 'random number'.  Is it really an integer 
between 1 and 10, as the code shows?

Use standard looping constructs to avoid labels if possible.

Indent, indent, indent!  (Read `perldoc perlstyle` for one way to do 
it.)

Perhaps in the process of isolating the problem you will understand it 
well enough to solve it yourself.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 29 Aug 2000 12:16:37 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Counting across multiple lines?
Message-Id: <MPG.1415abf2cae19cf098acef@nntp.hpl.hp.com>

In article <7HLq5.3$05.90465@nnrp2.clara.net> on Tue, 29 Aug 2000 
09:49:55 GMT, Colin Keith <newsgroups@ckeith.clara.net> says...
> In article <39A8981B.47000002@uswest.net>, Pedro A Navarro <pnavarro@uswest.net> wrote:

 ...

> >How do I get rid of the newline character, or at the very least, how do
> 
> chomp($_);     # best

  chomp;         # better

> $_ =~ s/\n$//;   # change to \r\n \r\r or the like as needed

What does your comment mean?  There are no "\r" in any line, provided it 
is read and written using the same type of file system.

  $_ =~

is the default, and using it explicitly creates visual clutter, which 
implies mental clutter, fairly or not.

  /\n$/

is unnecessary after the chomp(); in the absence of the chomp, the '$' 
is superfluous, and tr/\n//d; is better.
 
> >I join the multiple lines so I have one single string? I'm fairly sure
> >this is a simple thing to do, but so far I don't know what else to try!
> 
>   my($sum) = 0;
>   $sum += length($_) while(<STDIN>);

Again, defaults help eliminate visual clutter.

>   $sum -= $.;  # cheeky cos it assumes 1 \n per line

There is never more or fewer than one newline per line (if read with the 
default value of $/, "\n"), except for pathological files that don't end 
in "\n".

So you could just write:

    $sum += length() - 1;

Or the Golf winner (and comprehensibility loser :-):

    $sum -= 1 - length;

>   print "Number of characters: $sum\n";
> 
> or
>   my($sum) = 0;
>   while(<STDIN>){
>     chomp;
>     $sum += length($_);
>   }
> 
> er.. or
> 
> $/ = "\n\n";  # (won't match for us)

More ussually done this way:

  {
     local $/;

> $_ = <STDIN>;
> s/\n//g;

 tr/\n//d;

> print length($_);
> 
> You get the idea .. I would suggest length() rather than tr// because tr is 
> replacing the characters it finds, so it takes longer.

When tr() is used for counting, it doesn't do any replacing.  But 
length() is faster because Perl knows the lengths of strings without 
having to examine them (as C has to, for example).

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 29 Aug 2000 13:22:37 -0600
From: "M. J. Brodzik" <brodzik@kryos.colorado.edu>
Subject: error happens in part of backticked pipe
Message-Id: <39AC0D7D.551A2AFF@kryos.colorado.edu>

I have arranged a sequence of calls to some C programs from my perl
script, enclosed them in backticks, and I'm checking $? for the success
of the pipe like this:

`program_a | program_b > outfile.dat`;
if (0 != $?) {
	...do some error processing...
}

However, this fails to catch the following situation:

1) program_a exits with a non-zero exit status, and empty output to the 
pipe, and

2) it's not an error for program_b to get empty information from stdin,
so program_b exits with a "successful" zero exit status, so $? returns
to 
my perl script with a value of zero.

Is there some way to trap the fact that a piece of the pipe failed,
rather than just getting the exit status of the last process in the
pipe?

thanks in advance,
MJ


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

Date: Tue, 29 Aug 2000 20:04:11 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: error happens in part of backticked pipe
Message-Id: <sqo5prtic5d182@corp.supernews.com>

In article <39AC0D7D.551A2AFF@kryos.colorado.edu>,
    M. J. Brodzik <brodzik@kryos.colorado.edu> wrote:

: Is there some way to trap the fact that a piece of the pipe failed,
: rather than just getting the exit status of the last process in the
: pipe?

Borrowing from "csh Programming Considered Harmful"[*]

    #! /usr/bin/perl -w

    use strict;

    my $status =`((perl -e 'exit 42' 2>&1 1>&3 3>&- 4>&-; echo \$? >&4) |
                  perl -e 'exit 3' 1>&2 3>&- 4>&-) 4>&1`;
    chomp $status;

    print "\$status = '$status', \$? = '", $? >> 8, "'\n";

[*] <URL:http://www.perl.com/pub/language/versus/csh.html>

Greg
-- 
To succeed in the other trades, capacity must be shown; in the law,
concealment of it will do.
    -- Mark Twain


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

Date: Tue, 29 Aug 2000 18:42:58 GMT
From: "Jevon MacDonald" <jevon@islandtelecom.com>
Subject: Re: Executing Shell Commands in Perl
Message-Id: <SuTq5.163$uR1.23413@sapphire.mtt.net>

I would advise to exercise extreme caution. passing user input to anything
you do not exercise full control over is the stuff exploits are made of.

"Scott Yanoff" <yanoff@yahoo.com> wrote in message
news:39ABF0C1.B1FDADE6@yahoo.com...
> "Nail Ünlü" wrote:
> > i tried to write some shell commands with "exec" in perl
> > and it didn't work. I  changed the options in apache conf
> > for allowing SSI but it didn't work....
> > i also use STDOUT to read the output but no way....
> >
> > is there another way to execute commands like
> >
> > rup $computername
> >
> > in perl???
>
> Is your Perl script a CGI program?
> One way to try to execute another program in Perl is with the "system"
> command.
> Make sure that you are using the full pathname to the program you are
> trying to execute.  Also make sure that whatever user your server is
> running as also has permission to execute the program you are trying to
> call with the "system" command.
>
> If this is a CGI program, you want to be careful if you are passing the
> system call any user input.
>
> Good luck,
> -Scott




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

Date: 29 Aug 2000 21:29:11 +0200
From: Stig Palmquist <stig@palmquist.org>
Subject: Re: Executing Shell Commands in Perl
Message-Id: <m31yz7zx14.fsf@stig.a.sol.no>

"Nail Ünlü" <nail.uenlue@freesurf.ch> writes:

> Hi folks,
> 
> i tried to write some shell commands with "exec" in perl
> and it didn't work. I  changed the options in apache conf
> for allowing SSI but it didn't work....
> i also use STDOUT to read the output but no way....
> 
> is there another way to execute commands like

system("your_command_here")

-- 
Stig Palmquist <stig@palmquist.org>


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

Date: Tue, 29 Aug 2000 22:50:26 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Executing Shell Commands in Perl
Message-Id: <1eg5dzp.hp5wk3qdh1g6N%tony@svanstrom.com>

Jevon MacDonald <jevon@islandtelecom.com> wrote:

> "Scott Yanoff" <yanoff@yahoo.com> wrote in message
> news:39ABF0C1.B1FDADE6@yahoo.com...

> > If this is a CGI program, you want to be careful if you are passing the
> > system call any user input.

> I would advise to exercise extreme caution. passing user input to anything
> you do not exercise full control over is the stuff exploits are made of.

That's what Scott said... And he did that without replying
Jeopardy-style...


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Wed, 30 Aug 2000 01:24:24 +0400
From: "Roman Chumakov" <zfido88@zr.ru>
Subject: fast http server in perl
Message-Id: <8oh9gd$rbe$1@news.msu.ru>

Is it possible to write little high-performance web server in perl for
serving gif files (10-15Kb each)
I gonna make a counter server.
The server will get request, mark request in database (I think it will be
BerkeleyDB), and then it will send reply to a client.
The reply - is a dinamic generated gif file.

I need to handle about  30-50 requests per second on a machine of class
P133-64
Is it possble to make in perl?
Or I need to use C?

Thank you alot.
Roman



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

Date: Tue, 29 Aug 2000 20:28:14 GMT
From: Randall Parker <rgparker@west.net>
Subject: Re: Get own machine's dial-up IP address?
Message-Id: <MPG.1415bd89286c779d9898f5@news.onlynews.com>

On Tue, 29 Aug 2000 16:34:31 GMT esteemed mexicanmeatballs@my-deja.com 
did'st hold forth thusly:
> After some experimentation the only way I could get the IP address
> from my machine here (Linux/LAN based) without parsing
> ifconfig/ipconfig 

Jon,

In my case parsing that is kinda messy since I have 2 ethernet adapaters 
and a dial-up connection. So I get 3 sets of lines for the 3 addresses. 
I'd have to hardwire in (or pass as a command line arg) what is the name 
of the logical device that is for the dial-up. But I think I may need to 
use that name regardless of what approach I use since essentually my box 
has more than 1 IP address.

I'd really like to make this portable. But likely ipconfig doesn't format 
out the same way on all operarting system.

>was this, not very clean I'm afraid:
> 
> use Socket;
> socket(IN, PF_INET, SOCK_DGRAM, IPPROTO_IP);
> connect(IN, sockaddr_in(0, 0));
> ($port, @addr) = unpack_sockaddr_in(getsockname(IN));
> print inet_ntoa($addr[0]);

Okay, what is IPPROTO_IP? Is it suppose to be your own IP address? When I 
run it on NT with with use strict I get the first error below. Then 
taking away the use strict (actually, just backing it off to use strict 
'vars') gets me the second error:

[j:\prg\perl]perl \tricks\perl\getport.pl
Bareword "IPPROTO_IP" not allowed while "strict subs" in use at 
\tricks\perl\getport.pl line 9.
Execution of \tricks\perl\getport.pl aborted due to compilation errors.

[j:\prg\perl]vs \tricks\perl\getport.pl

[j:\prg\perl]perl \tricks\perl\getport.pl
Argument "IPPROTO_IP" isn't numeric in socket at \tricks\perl\getport.pl 
line 9.
0.0.0.0


> This is pretty grim I only post it because I couldn't find another way.
> (Probably staring me in the face)

Well, no one else seems to know either. So it can't be all that obvious.

> I haven't tried this with the dial up configuration you described,
> but since the @addr array is an array I guess it would hold all the
> addresses relating to the socket.

I tihnk maybe I should go and make a socket connection to something on 
the internet in order to find out which of my addresses is the address I 
present to the internet. But how would I query a socket I create to ask 
it what my own address is on that socket?

> recv(from) returns the remote ip address, so you could do it like that
> but you should be able to get your own address without jumping through
> hoops, I'm sure someone will know how to do it.

I'm hoping so.

 


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

Date: 29 Aug 2000 20:12:23 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: get temporary file name?
Message-Id: <slrn8qo697.4li.dha@panix6.panix.com>

On Sat, 26 Aug 2000 21:05:38 GMT, s. keeling
<keeling@topquark.spots.ab.ca> wrote:

>(0) /home/keeling/_ perl -v
>
>This is perl, version 5.004_04 built for i386-linux
>[snip]

>Usually.  Or am I (yet again) hopelessly out of date from the current
>(bleading edge) configuration?

Well, perldoc -q isn't exactly "bleading edge".  It came in around
5.005, IIRC, and 5.004_04 is going on three years old (we're currently
on 5.6).  Upgrading to 5.005_03 or so might be a good idea.

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
New Songs/New Members/New CD/Same rotten attitude
    - Raving Noah press release


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

Date: Tue, 29 Aug 2000 11:49:27 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Getting the greedy RegEx, wanting the Lazy - help?
Message-Id: <39AC05B7.49E974BB@ipac.caltech.edu>

Some comments interspersed at lines beginning '******'. (I've also re-split your
sample input so it fits on a narrower screen.)

ptomsic@my-deja.com wrote:
> 
> I'm getting the wrong part (actually, getting nothing) of a regEx, and
> I'm wondering if someone could shed some light...
> 
> I've got the following:
> ############################################
> ... snip ...
> $cont =~ s/(\n|\r|\t|\f)+/ /g;
> $cont =~ s/^.*<!-+.*BEGIN.*STUFF.*-+>(.*)<!-+.*STOP.*STUFF.*-+>.*/$1/i;
******                              ^^^ this is matching ...
> ... snip ...
> ------------------------------------------------------------
> <TD><testing="one">FIRST</testing></TD><test ing="two">SECOND </test
> ing></TD>MORE<TD><b>b </b><a href="one.html">This</a>-<!-BEGIN-><a
> href="two.html
> ">that</a> the other<!-END->boing<TD><font>font</font>
> <!---BEGIN STUFF--->HEre
******            ^^^^  not here        
> is a
> little TEST
> <!--END CONTENT HERE--->
******                ^^^^ but here
> <!--STOP STUFFxxx---------->bingo
> bango
> testingonetweetergoods
> 
> ----------------------------------------------------------------------
> I'm actually looking to return the text
> HEre is a little TEST <!--END CONTENT HERE--->

The non-greedy versions of '*' and '+' are '*?' and '+?'. Read all the way
through the perlre doc. You will learn much.

There might be other problems with your regex, but why not start with that?

--

-- Tim Conrow         tim@ipac.caltech.edu       626-395-8435


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

Date: 29 Aug 2000 20:27:15 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: Getting the greedy RegEx, wanting the Lazy - help?
Message-Id: <eli$0008291617@qz.little-neck.ny.us>

In comp.lang.perl.misc,  <ptomsic@my-deja.com> wrote:
> I'm getting the wrong part (actually, getting nothing) of a regEx, and
> I'm wondering if someone could shed some light...

[snip attempt to match a multiline pattern delimited with HTML
comments from a multiline HTML fragment with a single reg-exp]

I could write a reg-exp to do that, but you probably wouldn't
understand it and lots of people here would jump down my throat
about how one should never use REs to parse HTML. 

You would be much better off using an HTML parser like HTML::Parser
from CPAN.

The latest Perl Journal (#17) has an article on fairly painlessly
using HTML::Parser, which can be intimidating to those not used
to OO. <URL:http://www.tpj.com>

Elijah
------
'Seventeen!' squealled the yellow pig with glee.


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

Date: Tue, 29 Aug 2000 21:40:35 GMT
From: Mike Cameron <mcameron@mirusweb.com>
Subject: Re: Getting the greedy RegEx, wanting the Lazy - help?
Message-Id: <39AC3C81.9FFEDA4A@mirusweb.com>

Rookie looking to learn. Just curious..

Why not use RE's to parse html?

Eli the Bearded wrote:

> In comp.lang.perl.misc,  <ptomsic@my-deja.com> wrote:
> > I'm getting the wrong part (actually, getting nothing) of a regEx, and
> > I'm wondering if someone could shed some light...
>
> [snip attempt to match a multiline pattern delimited with HTML
> comments from a multiline HTML fragment with a single reg-exp]
>
> I could write a reg-exp to do that, but you probably wouldn't
> understand it and lots of people here would jump down my throat
> about how one should never use REs to parse HTML.
>
> You would be much better off using an HTML parser like HTML::Parser
> from CPAN.
>
> The latest Perl Journal (#17) has an article on fairly painlessly
> using HTML::Parser, which can be intimidating to those not used
> to OO. <URL:http://www.tpj.com>
>
> Elijah
> ------
> 'Seventeen!' squealled the yellow pig with glee.



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

Date: Tue, 29 Aug 2000 16:54:47 -0500
From: "Nick Maxwell" <maxwelln@purdue.edu>
Subject: Re: how about programming a mud driver in Perl?
Message-Id: <8ohbhc$4d$1@mozo.cc.purdue.edu>

>First, it gives you access to the system, and second,


I would be writing my own language/interpreter in perl with memory hogging
things done in C.

>I'd just stick with DGD....

But what I am trying to do is take a whole new approach to driver
implementation and new base features that are intrinsic to my system but not
to others that are already out there.  I also think this would be a good
exercise in programming in general.  What are your thoughts?

- Nick Maxwell
maxwelln@purdue.edu





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

Date: Tue, 29 Aug 2000 13:10:07 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: How to Unzip a .tar.gz file
Message-Id: <1070-39ABFC7F-78@storefull-245.iap.bryant.webtv.net>

Thanks Bart. Still trying to get something to work. When you say
"headers," do you mean that I need a "Content-type" line? Should that be
the normal 
print "Content-type: text/html\n\n;"  or something different?

PS to Keith: FWIW, whataman is my pc addy and bucknaked is my webtv
addy. It depends on which machine that I am posting from. 


--Regards,
Dennis



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

Date: Tue, 29 Aug 2000 20:46:30 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to Unzip a .tar.gz file
Message-Id: <e78oqs8sre5rk74cmi72n8rhd5e6qln4mp@4ax.com>

BUCK NAKED1 wrote:

>When you say
>"headers," do you mean that I need a "Content-type" line?

I've scanned my previous messages in this thread, but the word "header"
doesn't appear in there.

-- 
	Bart.


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

Date: Tue, 29 Aug 2000 20:34:39 GMT
From: r_conner@my-deja.com
Subject: Re: Loading a array from a file.
Message-Id: <8oh6ot$5hn$1@nnrp1.deja.com>

In article <zHDq5.21184$C5.356406@typhoon.austin.rr.com>,
  mike@stok.co.uk wrote:
> In article <8oetds$fnv$1@nnrp1.deja.com>,  <r_conner@my-deja.com>
wrote:
> >I have been trying to load an array from a text file, but with only
> >kludge results.
>
> There may be things in there which you don't understand, but saving
it in
> a file and using the debugger to examine @array as it's built in the
line
> which looks suspiciously like the one from perllol might be
instructive.
>
-snip!-
> Hope this helps,
>
> Mike
> --
> mike@stok.co.uk                    |           The "`Stok'
disclaimers" apply.
> http://www.stok.co.uk/~mike/       |
> GPG PGP Key 1024D/059913DA         | Fingerprint      0570 71CD 6790
7C28 3D60
> stok@colltech.com (CT - work)      |                  75D2 9EC4 C1C0
0599 13DA
>
Actually it did, it is very much like one of my attempts, except I did
not have the $row++ part folded into the push, so it was much more
annoying. I see how that fits in, I just did not realize I could fold
it in.
Seems like map() would be ideal, but I cannot figure it out.
this will work for now. Thanks again!


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 29 Aug 2000 23:54:49 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Loading a array from a file.
Message-Id: <n3coqs480cesgjn4e1dj24paaquav7lnfq@4ax.com>

On Mon, 28 Aug 2000 23:42:56 GMT, r_conner@my-deja.com wrote:

> I have been trying to load an array from a text file, but with only
> kludge results.
> 
> the file is a simple tab delimited file, and I want to load it in way
> that rows become columns.
> so that
> 1,2,3,3
> 4,5,6,1

That's comma delimited, but ok.
> 
> becomes
> 1,4
> 2,5
> 3,6
> 3,1
> 

#!/usr/bin/perl -w
use strict;

my @data;
while ( <DATA> ) {
	chomp;
	my @cols = split /,/;
	push @{ $data[$_] }, $cols[$_] for 0..$#cols;
};

print join(',', @$_), "\n" for @data;
	
__DATA__
1,2,3,3
4,5,6,1

-- 
Good luck,
Abe


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

Date: Tue, 29 Aug 2000 12:19:47 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: making sure input is a certain way i.e. starting and  endingwith  double quotes
Message-Id: <MPG.1415acb17aa59c4e98acf0@nntp.hpl.hp.com>

In article <B5CFFCA6.7698%star@sonic.net> on Tue, 29 Aug 2000 18:25:08 
GMT, arthur <star@sonic.net> says...
> 
> > Let's take a walk down RTFM lane, shall we?
> 
> I am afraid to ask but what does RTFM stand for?

You should be afraid to ask in a Perl newsgroup, when you have the 
resources of the Internet and wonderful search engines available.

    http://www.google.com/

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 29 Aug 2000 18:25:08 GMT
From: arthur <star@sonic.net>
Subject: Re: making sure input is a certain way i.e. starting and endingwith  double quotes
Message-Id: <B5CFFCA6.7698%star@sonic.net>


> Let's take a walk down RTFM lane, shall we?

I am afraid to ask but what does RTFM stand for?

~arthur



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

Date: Tue, 29 Aug 2000 19:45:26 GMT
From: arthur <star@sonic.net>
Subject: Re: making sure you all have the documentation
Message-Id: <B5D00F78.76B6%star@sonic.net>


>> 
>>> Let's take a walk down RTFM lane, shall we?
>> 
>> I am afraid to ask but what does RTFM stand for?
> 
> You should be afraid to ask in a Perl newsgroup, when you have the
> resources of the Internet and wonderful search engines available.
> 
> http://www.google.com/

Yes it is as I thought! SHOCKING!  I can only say I beg all of you Perlers
forgiveness. It has taken me a while to learn where the documentation is on
the net (its kind of a catch 22, you have to understand the language enough
to be able to use the resources to understand the language) so if anyone
needs the basics and more, here it is:
http://www.perl.com/pub/doc/manual/html/pod/perl.html

~arthur



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

Date: 29 Aug 2000 21:30:52 GMT
From: abigail@foad.org (Abigail)
Subject: Re: making sure you all have the documentation
Message-Id: <slrn8qoaqr.bbg.abigail@alexandra.foad.org>

arthur (star@sonic.net) wrote on MMDLV September MCMXCIII in
<URL:news:B5D00F78.76B6%star@sonic.net>:
== 
== Yes it is as I thought! SHOCKING!  I can only say I beg all of you Perlers
== forgiveness. It has taken me a while to learn where the documentation is on
== the net (its kind of a catch 22, you have to understand the language enough
== to be able to use the resources to understand the language) so if anyone
== needs the basics and more, here it is:
== http://www.perl.com/pub/doc/manual/html/pod/perl.html


There's no need to go on the net to read the documentation. All the
documentation you need comes with Perl. After installation, I've
6.6 Mb of man pages. No web wowser needed.



Abigail
-- 
perl -wleprint -eqq-@{[ -eqw+ -eJust -eanother -ePerl -eHacker -e+]}-


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4166
**************************************


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