[11546] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5146 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 16 10:10:24 1999

Date: Tue, 16 Mar 99 07:00:28 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 16 Mar 1999     Volume: 8 Number: 5146

Today's topics:
        401 and mod_perl <jacek@finn.pl>
    Re: Can I carry a variable form 1 page to another? (Tad McClellan)
    Re: Complex Structure Question <droby@copyright.com>
    Re: Datastream API Problem Help! <dimensions@dialaccess.com>
    Re: Fast DNS lookups? (Michael Fuhr)
        Filehandle question <jmfernandez@gredos.cnb.uam.es>
        Forking server on Solaris 2.6 <rowland@cis.ohio-state.edu>
        How  to receive string from cgi to HTML ? <galina.wasama@tieto.com>
        How Do You Insert This imgsize Code in a CGI Script? tatabu@my-dejanews.com
    Re: How Do You Insert This imgsize Code in a CGI Script (Matthew Bafford)
        Incrementing several values in a hash <Philip.Newton@datenrevision.de>
        Interrupting "print FH" prl2@lehigh.edu
        Modules, how to build in local directory? (Charles Packer)
    Re: NewbieQ: if ($dbhost && $dbname !~ m%[/@]%); (Tad McClellan)
    Re: Please can we stop this PIII thread RIGHT HERE? As  <edward_hill@gec.nospam.com>
        Problem passing parameters through MSDOS/Windows batch  piet@cs.uu.nl
    Re: Problems with files that a script creates, new Perl <alf@orion.it>
        Ranish <s.gontier@dl.ac.uk>
        Reading a file <s.filipowicz@orades.nl>
    Re: Reading a file <eedalf@eed.ericsson.se>
    Re: Reading a file (Tad McClellan)
        Regular Expression is perl <ykakui@netvigator.com>
    Re: Regular Expression is perl <All@n.due.net>
        script that will exclude lines with shebang from text f <seugenio@man.amis.com>
    Re: script that will exclude lines with shebang from te (Tad McClellan)
    Re: Somebody help me with this script please! <Philip.Newton@datenrevision.de>
    Re: The truth about the Pentium III chip and ID --- **b (Greg Gershowitz)
        traversing a directory tree <andrewf@beausys.demon.co.uk>
        Which is better for Windows use: perl or python (Franz Kaufmann)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 16 Mar 1999 10:09:08 GMT
From: "Jacek" <jacek@finn.pl>
Subject: 401 and mod_perl
Message-Id: <85qH2.1250$J52.267033@news.tpnet.pl>

I want to show something user's private data from database (MySQL). Hier is
example in PHP3. How can I this make with Perl/mod_perl?

Jacek

<?
    cfunction authenticate() {
        Header("WWW-authenticate: basic realm=\"Photo Album\"");
        Header("HTTP/1.0 401 Unauthorized");
        $title="Invalid Login";
        include "include/header.inc";?>
        In order to proceed you will need a valid username/password.
        <?include "include/footer.inc";
        exit;
    }

    if(!isset($PHP_AUTH_USER)) {
        authenticate();
    } else {
        mysql_pconnect("localhost","nobody","") or die("Unable to connect to
SQL server");
        mysql_select_db("rasmus") or die("Unable to select database");
        $id=strtolower($PHP_AUTH_USER);
        $query = mysql_query("select * from users where id='$id' and
password='$PHP_AUTH_PW'");
        if(!mysql_num_rows($query)) {
            authenticate();
        }
    }
?>

and something with $id




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

Date: Tue, 16 Mar 1999 03:11:59 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Can I carry a variable form 1 page to another?
Message-Id: <fo3lc7.gp6.ln@magna.metronet.com>

Doc (Doc@goforit.demon.co.uk) wrote:

: I have a database on a server.  I can build a web page from it 'on the
: fly' using a CGI script (+ODBC for win95 etc.).  I want the user to be
: able to press a button to call for the next relevant page.  This
: requires that the script called for by the button press knows the values
: of several variables from the current page.  I presume that my first
: script, which formed the current page is now dead.  How can I do this?


   You have an HTML/CGI question, not a Perl question.

   You can use "hidden" fields to pass info between CGI scripts.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 16 Mar 1999 14:29:48 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: Complex Structure Question
Message-Id: <7clpsf$5mi$1@nnrp1.dejanews.com>

In article <x3ylnh2ensy.fsf@tigre.matrox.com>,
  Ala Qumsieh <aqumsieh@matrox.com> wrote:
>
>
> I was seriously confused about this myself, but I tested it, and it
> seems to work fine, although I don't know why. Look:
>
> % perl -w
> my %hash;
> $hash{'a'} = 'a';
> $hash{'a'}{'b'} = 'b';
> print "$hash{'a'} and $hash{'a'}{'b'}.\n";
> __END__
> a and b.
>
> But, under 'use strict' it complains:
>
> Can't use string ("a") as a HASH ref while "strict refs" in use at - line 4.
>
> IMHO, the behaviour (without use strict) is broken. The result should
> be something like:
>
> HASH(0xb851c) and b.
>
> Is there a good explanation for this?
>

Yes.  A soft reference.

> $hash{'a'} = 'a';
> $hash{'a'}{'b'} = 'b';

These two statements conspire to create a hash named %a.
The first defines $hash{'a'} to be a string, and the second interprets that
string as a soft reference to a hash.

This is perhaps unfortunate, but it's not broken.

It is a good reason for always using strict references.

--
Don Roby

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 16 Mar 1999 08:14:31 -0600
From: "Dimensions" <dimensions@dialaccess.com>
Subject: Re: Datastream API Problem Help!
Message-Id: <SJtH2.12$xd4.632@newsfeed.slurp.net>

Got it solved. Thanks Randal and everyone else for the feedbacks!







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

Date: 16 Mar 1999 03:56:50 -0700
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Fast DNS lookups?
Message-Id: <7clddi$ise@flatland.dimensional.com>

Bjorn Borud <borud@lucifer.fast.no> writes:

> now for the exciting part;  instead of crawling forward looking up one
> name at a time you use Net::DNS to fire off a bunch of packets in
> batches of 50-100 at a time.  then you use IO::Select to listen for
> replies and for timing out.  there is an example in the Net::DNS
> package that does this.  check the demo/mresolv program.

I've been working on mresolv2, an improved version of mresolv.  Here's
the current version:

#!/usr/local/bin/perl -w
#------------------------------------------------------------------------------
# Usage:  mresolv2 [ -t timeout ] [ file... ]
#
# Reads IP addresses and issues non-blocking DNS queries.  Answers are
# sent to standard output in RR format:
#
# 1.1.168.192.in-addr.arpa.   86400  IN  PTR    host1.example.com.
#
# 1.2.168.192.in-addr.arpa.  86400  IN  CNAME  1.0-16.2.168.192.in-addr.arpa.
# 1.0-16.2.168.192.in-addr.arpa. 86400  IN  PTR  host2.example.com.
#
# Michael Fuhr
# mike@fuhr.org
#
# Copyright (c) 1999 Michael Fuhr.  All rights reserved.  This program is
# free software; you can redistribute it and/or modify it under the same
# terms as Perl itself. 
#
# $Id: mresolv2,v 1.1 1999/03/16 10:52:55 mfuhr Exp mfuhr $
#------------------------------------------------------------------------------

use IO::Socket;
use IO::Select;
use Net::DNS;
use Getopt::Std;
use strict;

my $default_timeout = 30;

# Fallback to this if no nameservers are configured.
my $default_nameserver = "127.0.0.1";

#------------------------------------------------------------------------------
# Get the timeout or use a reasonable default.
#------------------------------------------------------------------------------

my $progname = $0;
$progname =~ s!.*/!!;

my %opt;
getopts("t:", \%opt);

my $timeout = defined($opt{"t"}) ? $opt{"t"} : $default_timeout;
die "$progname: invalid timeout: $timeout\n" if $timeout < 0;

#------------------------------------------------------------------------------
# Create a socket pointing at the default nameserver.
#------------------------------------------------------------------------------

my $res = Net::DNS::Resolver->new;
my $ns = $res->nameservers ? ($res->nameservers)[0] : $default_nameserver;
my $sock = IO::Socket::INET->new(PeerAddr => $ns,
                                 PeerPort => "dns(53)",
			         Proto    => "udp");
die "couldn't create socket: $!" unless $sock;

my $sel = IO::Select->new;
$sel->add($sock);

#------------------------------------------------------------------------------
# Read IP addresses and send queries.
#------------------------------------------------------------------------------

my $pending = 0;

while (<>) {
    chomp;
    next unless /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/;

    my $ip = "$4.$3.$2.$1.in-addr.arpa";

    my $packet = Net::DNS::Packet->new($ip, "PTR");
    $sock->send($packet->data) or die "send: $ip: $!";
    ++$pending;

    while ($sel->can_read(0)) {
	--$pending;
        my $buf = "";
        $sock->recv($buf, 512) or die "recv: $!";
        next unless $buf;

        my $ans = Net::DNS::Packet->new(\$buf);
        next unless $ans;

        foreach my $rr ($ans->answer) {
	    $rr->print;

	    if ($rr->type eq "CNAME") {
		my $cname = $rr->cname;
		my $packet = Net::DNS::Packet->new($cname, "PTR");
                $sock->send($packet->data) or die "send: $cname: $!";
                ++$pending;
	    }
	}
    }
}

#------------------------------------------------------------------------------
# Wait for outstanding requests until all are complete or we've timed out.
#------------------------------------------------------------------------------

while ($pending > 0 && $sel->can_read($timeout)) {
    --$pending;
    my $buf = "";
    $sock->recv($buf, 512) or die "recv: $!";
    next unless $buf;

    my $ans = Net::DNS::Packet->new(\$buf);
    next unless $ans;

    foreach my $rr ($ans->answer) {
        $rr->print;

        if ($rr->type eq "CNAME") {
	    my $cname = $rr->cname;
            my $packet = Net::DNS::Packet->new($cname, "PTR");
            $sock->send($packet->data) or die "send: $cname: $!";
            ++$pending;
        }
    }
}
__END__

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/


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

Date: Tue, 16 Mar 1999 11:13:42 +0100
From: =?iso-8859-1?Q?Jos=E9=20Mar=EDa=20Fern=E1ndez=20Gonz=E1lez?=  <jmfernandez@gredos.cnb.uam.es>
Subject: Filehandle question
Message-Id: <36EE2ED6.AD1F64AE@gredos.cnb.uam.es>


Hi group!

	Do you know how to change the predefined STDIN, STDOUT & STDERR filehandles, in
the same style as the "dup2" system call?
			All your answers will be apreciated,
							Josi Marma


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

Date: 16 Mar 1999 03:25:43 -0500
From: Shaun Rowland <rowland@cis.ohio-state.edu>
Subject: Forking server on Solaris 2.6
Message-Id: <87u2vlj0xk.fsf@darkstar.cis.ohio-state.edu>

I am trying to write a print quota server on Solaris 2.6.  The server
will be hit often, so I decided to use a forking server where the
parent will fork off a child to handle the request and go back to
listening on the socket it is bound to.  I am using perl version
5.004_04.

The problem that I am having is the parent process forks the child,
the child handles the request and then the whole server dies.  This
doesn't happen on my FreeBSD workstation or on Solaris 2.5.1.  The
code that I am using is almost exactly the same as the examples in the
Programming Perl and Advanced Perl Programming books.  I also tried
this using Socket and binding to the port I want, but it still
behaves in the same manner.  I apologize if this has been answered
before.  I did a quick search and didn't find anything.  Any pointers
would be greatly appreciated.

I currently have a working model hacked with a goto (shudder)
statement, but even this is a little borked (as noted after the code).
This is a simple segment of code that I am using:

==========================
$SIG{CHLD} = sub {wait()};

$main_sock = new IO::Socket::INET (LocalHost => "$pquota_server",
				   LocalPort => 1200,
				   Listen    => 100,
				   Proto     => 'tcp',
				   Reuse     => 1,
				   );
die "Socket could not be created. Reason: $!\n" unless ($main_sock);

ACCEPT: while($new_sock = $main_sock->accept()) {
  goto CLOSE if(!defined($new_sock));

  $pid = fork();
  print LOG "Cannot fork: $!\n" unless defined($pid);
  
  if($pid == 0) {
    # Child process.      
    $date = scalar(localtime);
    print LOG "Connection at $date\n";

    #####
    #
    # This is the child that handles the print qutoa daemon protocol...
    #
    #####

    exit(0);
  } # else parent process -> goes back to listen for more connections.
  
}

goto ACCEPT;

CLOSE: close($main_sock);
==========================

Without the goto ACCEPT there, the server will die with a single
connection.  As it is above, it works.  I also noticed that the goto
doesn't really go to the ACCEPT label it seems.  I did have a LOG
print statement above the while/accept block that printed when the
server was restarted.  Every query to the server added this restart
message to the log file as if the goto went to the beginning of the
entire script instead of to the label.

This program works on some platforms and not on others (without the
messy gotos which I really hate to use, but can't seem to get out of
using).  Is there something simple that I have missed?

Thanks in advance...

-- 
Shaun Rowland   rowland@cis.ohio-state.edu
IICF System Administrator  	DL798
http://www.cis.ohio-state.edu/~rowland


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

Date: Tue, 16 Mar 1999 14:05:22 +0200
From: Galina Wasama <galina.wasama@tieto.com>
Subject: How  to receive string from cgi to HTML ?
Message-Id: <36EE4902.F0091D33@tieto.com>

This is a multi-part message in MIME format.
--------------5C9A5CAAB30D49D576CFA5F6
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I have to call same PERL script from HTML.
Is it possible to receive same date ( string ) from called script to
HTML.

Thanks!


--------------5C9A5CAAB30D49D576CFA5F6
Content-Type: text/x-vcard; charset=us-ascii;
 name="galina.wasama.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Galina Wasama
Content-Disposition: attachment;
 filename="galina.wasama.vcf"

begin:vcard 
n:Wasama;Galina
tel;work:+358 9 862 65 762
x-mozilla-html:FALSE
org:Tieto Corporation Oyj;Telecom
version:2.1
email;internet:galina.wasama@tieto.com
title:System Analyst
adr;quoted-printable:;;Kumpulantie 11, =0D=0AP.O.Box 156=0D=0A;00521 Helsinki;;;Finland
x-mozilla-cpt:;0
fn:Galina Wasama
end:vcard

--------------5C9A5CAAB30D49D576CFA5F6--



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

Date: Tue, 16 Mar 1999 08:09:46 GMT
From: tatabu@my-dejanews.com
Subject: How Do You Insert This imgsize Code in a CGI Script?
Message-Id: <7cl3k6$ijh$1@nnrp1.dejanews.com>

Opera and Netscape will understand the code

($width,$height) = imgsize("friend.jpg");

in a Java script inside an HTML module (both in
a CGI script file) as follows:

sub do_preview
{
$fields{'the_message'} =~s/\"/\'/g;
print <<__STOP_OF_PREVIEW__;
Content-type: text/html

<HTML> <HEAD> <meta name="robots" content="noindex,nofollow"> </HEAD> <SCRIPT
LANGUAGE="JavaScript"> <!-- $sizes = imgsize("friend.jpg");
document.writeln('$sizes = imgsize("$PICTUREURL/$fields{'pic_select'}")'); if
(navigator.userAgent.indexOf("MSIE") != -1) document.writeln (''); else
document.writeln ('<EMBED SRC="$MIDIURL/$fields{'midifile'}" AUTOSTART="true"
HIDDEN="true" VOLUME="80%">'); //--> </SCRIPT> <BGSOUND
SRC="$MIDIURL/$fields{'midifile'}">

$BODYTAG
<CENTER>
<P>

etc., etc.

MSIE does not understand this piece of code?
Is there something missing?

Thanks!

@@-->>> Soulis
friends@soulis.com

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 16 Mar 1999 13:34:59 GMT
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: How Do You Insert This imgsize Code in a CGI Script?
Message-Id: <slrn7esmjt.p0c.dragons@localhost.localdomain>

Tue, 16 Mar 1999 08:09:46 GMT -- tatabu@my-dejanews.com <tatabu@my-dejanews.com>:
-> Opera and Netscape will understand the code

[snip]

-> MSIE does not understand this piece of code?

Hmm, you tell me.

-> Is there something missing?

If you are having no problems with the actual code, then this is no longer a Perl
Question.  Since your code is working fine with O and NS, then there are two
possibilities:

1) Your HTML output it wrong,
2) MSIE is misinterpreting your proper HTML output.

Either way, this belongs in one of the comp.infosystems.www.* groups.

-> Thanks!

HTH!

-> @@-->>> Soulis

--Matthew


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

Date: Tue, 16 Mar 1999 14:20:06 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Incrementing several values in a hash
Message-Id: <36EE5A86.8BD89F75@datenrevision.de>

Hi there,

I tried to increase several values in a hash using a slice and ++.

Here's what I was trying to do:

     my %hash = (one => 1, two => 2, three => 3);
     my @keys = qw(one two three);
     #here's the crunch
     @hash{@keys}++;

Afterwards, I expect %hash to be (one => 2, two => 3, three => 4), but
instead it is (one => 1, two => 2, three => 4). Does this have something
to do with the following bit out of `perldoc perldata`, meaning that the
hash slice only returns the last element of the slice ("three") for the
++ to see?

<perldata>
If you evaluate a named array in a scalar context, it returns the length
of the array.  (Note that this is not true of lists, which return the
last value, like the C comma operator, nor of built-in functions, which
return whatever they feel like returning.)
</perldata>

How can I increment all the values in a slice? Must I do something like

     foreach my $key (@keys) { $hash{$key}++; }

, or is there a better way?

Cheers,
Philip


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

Date: Tue, 16 Mar 1999 14:24:24 GMT
From: prl2@lehigh.edu
Subject: Interrupting "print FH"
Message-Id: <7clpic$593$1@nnrp1.dejanews.com>

In the following test, if I strike ENTER everything goes fine.	However, if I
ctrl-C when it's waiting for input, the test.log has nothing in it when I
check it.

open FH, ">test.log" or die "!";
print FH "test";
my $z = <STDIN>;

Questions: - Why? - What can I do to protect the log from ctrl-C's?  In my
real program I'm using a typeglobbed FH that's stored in an object's hash,
ala:

sub printlog {
    my $self = shift;
    my $log_fh = $self->{private_Report_info}{logref};
    print $log_fh @_;
}

Thanks,
Phil R Lawrence
prlawrence@lehigh.edu

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 16 Mar 1999 12:45:12 GMT
From: packer@shell.clark.net (Charles Packer)
Subject: Modules, how to build in local directory?
Message-Id: <slrn7eskio.svo.packer@shell.clark.net>

I would like to know how to build a module in my own 
directory when it depends on other modules that I also
have to build locally, rather than install at the root level.
 
By executing  "perl Makefile.PL PREFIX=mypath" I understand
that I can create a makefile that will build the module in the
directory specified by mypath. But I've discovered that if module
A assumes the existence of module B, it doesn't do any good to
build module B in mypath first, because when I then build module A
I still get a warning that module B can't be found.
 
I have looked at the O'Reilly Perl book and...oh man (not the Unix 
command)...when you get beyond basic Perl, you have to put on hip
waders...I'm deep in the muck at page 211, about ExtUtils::MakeMaker.
Could somebody pull me out?



-- 
packer@clark.net
http://www.clark.net/pub/whatnews/whatnews.html


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

Date: Tue, 16 Mar 1999 03:08:09 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: NewbieQ: if ($dbhost && $dbname !~ m%[/@]%);
Message-Id: <9h3lc7.gp6.ln@magna.metronet.com>

Steven T. Hatton (hattons@cpkwebser5.ncr.disa.mil) wrote:

: The 'm' for multi-line
: matching goes at the end of the line.  e.g.,  $string_name !~ m&[/@]&m .  What
: exactly that does for me is not clear but I don't care right now.


   m//m affects only anchors (^ and $).

   It should only be used if your pattern _has_ anchors, otherwise
   it has no effect and is misleading.

   Without m//m, the anchors match only the begin/end of the
   _entire string_, ignoring "interior" newlines.

   With m//m, anchors will match the begin/end of "interior" lines.



   Similarly, m//s affects only the dot character.

   It should only be used if your pattern _has_ a dot, otherwise
   it has no effect and is misleading.

   Without m//s, the dot matches any character except a newline.

   With m//s, the dot matches any character.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 16 Mar 1999 08:39:58 -0800
From: Edward Hill <edward_hill@gec.nospam.com>
Subject: Re: Please can we stop this PIII thread RIGHT HERE? As it's off-topic for everybody!
Message-Id: <36EE895E.2E2F@gec.nospam.com>

James@DX2.home (James Stevenson) was too tempted to not write:
> Hi
> 
> just to add to the point
> it would be impossible to do
> eg would it know what os you are running???
> talk the the correct cp stack etc......
> 
> And of course it has a serial number so there
> can work out who steals them if ppl do that sort of thing :)

It's amazing how a post entitled along the lines of 
'don't reply to this thread' is just too tempting for james.

Is this the same as having a big red button with 'do not push
me on?' 

Ed
-followups means adjusted


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

Date: 16 Mar 1999 14:36:32 +0100
From: piet@cs.uu.nl
Subject: Problem passing parameters through MSDOS/Windows batch file
Message-Id: <un21dy2sf.fsf@cs.uu.nl>

Is there a way to reliably pass parameters to a perl script through a batch
file?

E.g the following batch file (mybat.bat):
perl myscript %1 %2 %3 etc.

The problem is that = signs are replaced by spaces (why this imbecile
behaviour?) 

The = signs can be protected by quoting the parameters, e.g.
mybat "a=b" "c=d"
works

But then it doesn't work with quotes inside.
I want parameters of the form:
"src=\"/images/"
It can work with one of these, but I cannot get it working with 2:

mybat "src=\"/images/" "dst=\"/images2/"
where arg1 should come out as src="/images/ and
arg2 as dst="/images2/
As these are used as regexps, the quotes could be escaped in the internal
perl variables.
-- 
Piet van Oostrum <piet@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: Piet.van.Oostrum@gironet.nl


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

Date: Tue, 16 Mar 1999 09:03:46 +0100
From: Alessandro Forghieri <alf@orion.it>
Subject: Re: Problems with files that a script creates, new Perl user
Message-Id: <36EE1062.EA08A547@orion.it>

Greetings.

Ronald J Kimball wrote:
[...]
> `chown` and `chgrp` the Perl script to the desired owner and group, and
> then make it a setuid script with `chmod`.

AFAIK, that won't quite work on redhat, because '...setuid scripts
aren't 
disabled in your kernel...'. At least that was true last time I looked.

Cheers,
	Alessandro


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

Date: Tue, 16 Mar 1999 14:25:50 +0000
From: s gontier <s.gontier@dl.ac.uk>
Subject: Ranish
Message-Id: <36EE69EE.5F62C94@dl.ac.uk>

Hi,

I would like to know whether some of you has used Ranish partition
manager to install Linux or others on their Pc, please.

Thanks to let me know.
Cheers.



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

Date: Tue, 16 Mar 1999 14:16:04 +0100
From: Steven Filipowicz <s.filipowicz@orades.nl>
Subject: Reading a file
Message-Id: <36EE5994.1B3BAA8C@orades.nl>

Hi Everyone,

I've tried to make a small program that displays a file.
This is what the program looks like :

-----------------------------------------------------------
#!/usr/local/bin/perl

$target = '/usr/local/etc/httpd/logs/www.orades.nl.log';

open FILE, "$target";
while ($line = <FILE> {
	$line = split / / , $line ;
	print $line if $line[1] ne "-";
	}
	close FILE;
	
print "DONE\n";
-----------------------------------------------------------

Only it doesn't work! :(
It just has to read the file in line by line and print the line to the
webbrowser.

Any ideas??

Thanks!


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

Date: Tue, 16 Mar 1999 14:37:34 +0100
From: Alex Farber <eedalf@eed.ericsson.se>
To: s.filipowicz@orades.nl
Subject: Re: Reading a file
Message-Id: <36EE5E9E.67D0A737@eed.ericsson.se>

Hi,

Steven Filipowicz wrote:
> #!/usr/local/bin/perl
> 
> $target = '/usr/local/etc/httpd/logs/www.orades.nl.log';
> 
> open FILE, "$target";

open FILE, $target or die;
                  ^^^^^^^

> while ($line = <FILE> {

while ($line = <FILE>) {
                     ^

>         $line = split / / , $line ;

          @line = split / /, $line;
          ^

>         print $line if $line[1] ne "-";
>         }
>         close FILE;
> 
> print "DONE\n";

Regards
/Alex


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

Date: Tue, 16 Mar 1999 03:20:35 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Reading a file
Message-Id: <j84lc7.gp6.ln@magna.metronet.com>

Steven Filipowicz (s.filipowicz@orades.nl) wrote:

: I've tried to make a small program that displays a file.
: This is what the program looks like :

: -----------------------------------------------------------
: #!/usr/local/bin/perl

: $target = '/usr/local/etc/httpd/logs/www.orades.nl.log';

: open FILE, "$target";
: while ($line = <FILE> {
: 	$line = split / / , $line ;
: 	print $line if $line[1] ne "-";
: 	}
: 	close FILE;
: 	
: print "DONE\n";
: -----------------------------------------------------------

: Only it doesn't work! :(
: It just has to read the file in line by line and print the line to the
: webbrowser.

: Any ideas??


   1) *Always* enable warnings with the -w switch

         #!/usr/local/bin/perl -w


   2) *Always* check the return value from open() calls

         open FILE, $target or die "could not open '$target'  $!";
                 ^^^^^^^
      The quotes are misleading and not needed.


   3) split() returns a list which you are assigning to a _scalar_.
      you are losing all but one of the split out parts...

        @lines = split / / , $line ;


   4) $line[1] accesses the second element of the @line array, but
      you have never put anything into the @line array.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 16 Mar 1999 16:46:49 +0800
From: "Riddler" <ykakui@netvigator.com>
Subject: Regular Expression is perl
Message-Id: <7cl5kh$leb$1@imsp009a.netvigator.com>

Hi All,
I use a perl CGI script to Extract some data based on
the Regex from a HTML file (first.html). However there are some changes in
the HTML, therefore I have to change the Regex, so that this perl CGI can
work as same as previously. (5 Marks)
Before Changes of the HTML
 ......
<A HREF=001.htm target=bottom>ONE TWO THREE</A><BR>
<A HREF=002.htm target=bottom>ABCABCABC</A><BR>
<BR>
<A HREF=101.htm target=bottom>HELLO WORLD</A><BR>
<BR>
<A HREF=201.htm target=bottom>999-999-5858-6321</A><BR>
<A HREF=202.htm target=bottom>abcdef</A><BR>
<BR>
 .....

The Regex I used was <A HREF=(.*?)target=bottom>(.*?)</A><BR>\n
The OUTPUT was
001.htm  ONE TWO THREE
002.htm  ABCABCABC
101.htm  HELLO WORLD
201.htm  999-999-5858-6321
202.htm  abcdef

AFTER Changes
 .....
<A HREF=001.htm target=bottom><font size=+1><b>ONE TWO
THREE</b></font></A><BR>
<A HREF=002.htm target=bottom>ABCABCABC</A><BR>
<BR>
<A HREF=101.htm target=bottom><font size=+1><b>HELLO
WORLD</b></font></A><BR>
<BR>
<A HREF=201.htm target=bottom><font
size=+1><b>999-999-5858-6321</b></font></A><BR>
<A HREF=202.htm target=bottom>abcdef</A><BR>
<BR>
 .....


Problem:
What is the new Regex? In order to have the same OUTPUT:
001.htm  ONE TWO THREE
002.htm  ABCABCABC
101.htm  HELLO WORLD
201.htm  999-999-5858-6321
202.htm  abcdef

I have tried
<A HREF=(.*?)target=bottom><font size=+1><b>(.*?)</b></font></A><BR>\n
But the result seems incorrect, because the output was
001.htm  HELLO WORLD
101.htm  999-999-5858-6321

It seems to skip a serveral line!

How to overcome it? How to force the regex to match the whole regex in
single line? (e.g.is \s can force to match only single line by single line?)

  Thanks!! sorry I am new in Perl and Regex

Ridder








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

Date: Tue, 16 Mar 1999 11:08:26 GMT
From: "Allan M. Due" <All@n.due.net>
Subject: Re: Regular Expression is perl
Message-Id: <KYqH2.2336$DM5.1058@news.rdc1.ct.home.com>

Riddler wrote in message <7cl5kh$leb$1@imsp009a.netvigator.com>...
>Hi All,
>I use a perl CGI script to Extract some data based on
>the Regex from a HTML file (first.html). However there are some changes in
>the HTML, therefore I have to change the Regex, so that this perl CGI can
>work as same as previously. (5 Marks)
>Before Changes of the HTML


Hey Riddler,
    I don't mean to sound like a nag but when you made the same post in
another venue you characterized it as needing help with an assignment.  As I
noted there, giving people the answer to their homework assignments is often
frowned upon.  As I recall you received two excellent bits of advice in that
other venue in which it was suggested that you try to break down your
problem into parts and identify patterns that have a consistent relationship
with the material you wish to match.  Good luck.

AmD




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

Date: 16 Mar 1999 08:04:44 GMT
From: "Sheila  Eugenio" <seugenio@man.amis.com>
Subject: script that will exclude lines with shebang from text file
Message-Id: <01be6f81$231efbd0$2bbe10ac@amipnet>

I have a text file which I open for reading. How can I manipulate it such
that the output in the browser will eliminate the lines with shebang? 
Thanks!

#!! *** Terminal log file ***
#! Opened 15-MAR-1999 21:46 by BATCH_20011
#!
# Equipment
#Equipment:= loc
#    Location Equipment Display
#Enter location to be viewed:= s-sort
EQP ID   DESCRIPTION                    LOCATION   TYPE    STATUS   CHAR
S120-05C Sentry 21-05 120 pins LV Stat3 S-SORTTEST S-21120  S-AVAIL man
S120-06C Sentry 21-06 120 EELM LV Stat3 S-SORTTEST S-21120  S-AVAIL man
S120-08C Sentry 21-08 120 EELM LV Stat3 S-SORTTEST S-21120  AVAIL   man



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

Date: Tue, 16 Mar 1999 03:13:37 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: script that will exclude lines with shebang from text file
Message-Id: <hr3lc7.gp6.ln@magna.metronet.com>

Sheila Eugenio (seugenio@man.amis.com) wrote:
: I have a text file which I open for reading. How can I manipulate it such
: that the output in the browser will eliminate the lines with shebang? 


while (<FILE>) {
   print unless /^#!/;
}


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 16 Mar 1999 10:34:38 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Re: Somebody help me with this script please!
Message-Id: <36EE25AE.150F418A@datenrevision.de>

Rollo Lawson wrote:
> 
> I have seen some scripts that send back an image to the page and it is
> displayed instead of the broken image.

Hmm yes, you have to send back an image if you're called from an <img>
tag.

> <center><img src="http://rollo/cgi-bin/count.pl" ></center>

Does this work? Is your machine called "rollo"?

> Perl code
> 
> !/perl/bin/perl

I think you mean #!/perl/bin/perl -w

> open(Count,"<remote.txt");
> $total = <Count>;
> close(Count);
> $total++;
> open(Count,">remote.txt");
> print Count $total;
> close(Count);

Ah, the eternal page counter. Problems with locking and concurrent
access -- if several copies of this script run at once, you can't be
sure that someone else doesn't fiddle with the file between closing it
and writing in the new number. Look up perlfaq5 ("perldoc -q increment"
will show your the right place) for how to increment a number in a file
with correct locking.

> print "Content-Type: image/gif\n\n";
> print "<img src=\"http://rollo/mirv.gif\">";

Oops -- first you tell the browser you're going to send it data of type
image/gif, and then you send it "< i m g   s r c " etc.; this is not a
valid GIF stream! GIFs start with "GIF87a" or "GIF89a" and continue
with binary data. You could either open the GIF file yourself:

$/ = undef;
# adjust filename as appropriate
open(GIF, "/rollo/mirv.gif") or die "Cannot open image!";
$gif = <GIF>;
close GIF or die "Cannot close image!";
print "Content-Type: image/gif\n\n";
print $gif;    #print the picture data

Or you can redirect the browser to the picture after fiddling with the
counter:

print "Location: http://rollo/mirv.gif\n\n";

Or you can use the GD.pm module to construct a little blank (or
transparent) GIF on-the-fly and send that back. GD.pm is available from
CPAN.

Either way, though, this is not a Perl question, but rather a CGI
question. Hope this helps anyway.

Cheers,
Philip


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

Date: Tue, 16 Mar 1999 14:26:57 GMT
From: root@aol.com (Greg Gershowitz)
Subject: Re: The truth about the Pentium III chip and ID --- **boycott info**
Message-Id: <36ee69a8.992557692@news.vnet.net>


Someone tell my why this is such a big deal?  Every unix box in
existance has a unique ID.  It's the hostid.  What's it for?
Licensing, mostly.  Of course unix licensing is far more mature than
for windows.  Heck, even a 486 can be made to cough up a hostid.  Of
course, I don't know of any cases where that hostid get transmitted to
a vendor, but what's to stop it from happening?

-Greg G

--
-Greg "TORCHA" Gershowitz
-DG3X's own Extreme Icon
To Reply: See the organization line
Spam sucks.  Fuck you spammers.  Have a Nice Day.
http://www.geocities.com/Area51/5207


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

Date: Tue, 16 Mar 1999 11:33:06 +0000
From: Andrew Fry <andrewf@beausys.demon.co.uk>
Subject: traversing a directory tree
Message-Id: <oiIVtCAyFk72EwfN@beausys.demon.co.uk>

I have been trying to write a little utility which
goes down a directory tree and renames all directories
and files which contain upper-case characters (...to
lower case characters) ... eg FRED.TXT -> fred.txt
I wrote the following, but it doesnt go right down
the tree, only so far. Why is this ?

#!/usr/bin/perl

use strict;

use File::Find;



my $newname;

my $fullname;

my @DIRLIST;


@ARGV = '.' unless @ARGV;

@DIRLIST = @ARGV;

find(\&renamedf,@DIRLIST);



sub renamedf {

  $fullname = $File::Find::name;
  
  # does name contain any uppercase character ?
  
  if ($_ =~ /[A-Z]/)
  
  {
    
    $newname = $_;
    
    $newname =~ tr/A-Z/a-z/;
    
    if (-f $_)
    
    {
      
    print "File $fullname: renaming as $newname\n";
    rename($_,$newname);
    
    }
    
    if (-d $_)
    
    {
      
      print "Directory $fullname: renaming as $newname\n";
      rename($_,$newname);
    
    }
  
  }

}


---
Andrew Fry
"Time flies like an arrow. Fruit flies like a banana". (Groucho Marx).


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

Date: Tue, 16 Mar 99 12:59:57 gmt
From: ws97-868@wsrz1.wiso.uni-erlangen.de (Franz Kaufmann)
Subject: Which is better for Windows use: perl or python
Message-Id: <7clh3l$nro$1@rznews.rrze.uni-erlangen.de>

Hello.

I wonder what language is better suited for windows specific stuff (COM 
a.s.o) :Perl or Python

Can anyone help me with this?

Thank you in advance,
Bye.



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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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