[7710] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1336 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 18 07:17:14 1997

Date: Tue, 18 Nov 97 04:00:26 -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, 18 Nov 1997     Volume: 8 Number: 1336

Today's topics:
     Re: Accessing /usr/adm/binary.errlog from Perl <mweber@atlas.de>
     Re: adding to the end of each element in an array (brian d foy)
     compiler-a3: problem with setuid perl program (Yiu Kin Ho)
     Re: Creating a call tree pverdret@sonovision-itep.fr
     Re: DB_File and CGIs...extra load? <dbenhur@egames.com>
     Defining a DSN (ConfigDSN) to MS SQL Server 6.5 from Pe <kika.barokas@caere.com>
     Re: Easily using databases - am I reinventing a wheel? <andrewe@technologyXchange.com>
     File Handling in Perl <andrew2@one.net>
     Re: File Handling in Perl (brian d foy)
     Format and comments (Troian_Pierre)
     Re: Format and comments (Tom Grydeland)
     Re: is h2xs supposed to do this? (Des Herriott)
     JavaScript < -------- > Perl (CGI) <rv33100@ggr.co.uk>
     Re: JavaScript < -------- > Perl (CGI) (Jeremy D. Zawodny)
     Re: Newbie Q: Skipping lines in output <andrewe@technologyXchange.com>
     Re: On the fly GIF and CGI <brandons@uidaho.edu>
     Re: Perl and INETD <qdtcall@esb.ericsson.se>
     Re: perl conversion of curly quotes out of web form (Eric Bohlman)
     Re: Perl Tutotial (Casper K. Clausen)
     Possible?@!?!?!?! <alw421s@cnas.smsu.edu>
     Re: Possible?@!?!?!?! (brian d foy)
     Re: SEGV from perl 5.004_4, solaris 5.5.1 (with example <rjc@liddell.cstr.ed.ac.uk>
     Re: SEGV from perl 5.004_4, solaris 5.5.1 <rjc@liddell.cstr.ed.ac.uk>
     sequence point? <bnelson@netcom.com>
     Re: setenv problem (read the FAQ) <eike.grote@theo.phy.uni-bayreuth.de>
     setenv problem (Beniluz)
     Re: setenv problem (Jeremy D. Zawodny)
     User restriction <chris@cjetech.co.uk>
     Win32::EventLog problems... <maystonr@ihug.co.nz>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 18 Nov 1997 07:56:08 +0100
From: "Mathias-H. Weber" <mweber@atlas.de>
Subject: Re: Accessing /usr/adm/binary.errlog from Perl
Message-Id: <34713C08.13B6AC79@atlas.de>

Hi,
stockman@rdbewss.redstone.army.mil wrote:
> 
> Hello,
> 
>  Using DU 4.0B and Perl5.004_04.

sorry, but for me as an SGI user it took a while to identify DU 
as Digital Unix (am I right?). 

> 
>  I will be posting to the perl newsgroup also.
> 
>  I am trying to learn Perl and am trying to access

                  ^^^^^^^^^^ A good idea!

> a filed called /usr/adm/binary.errlog. The file
> has bootup information that is retrevied via
> uerf -R. What I am wanting to do is write a Perl
> script that will extract information from that
> file and display it in a SGI hinv type of format.
> 

The usually file has only read permissions for user "root" and 
group "adm" (or "system"). Maybe this is your (first?) problem: if 
you run your perls script as a normal (mortal) user you cannot access
the log file for reading.

> 
> #!/usr/local/bin/perl
> $file1 = "/usr/adm/binary.errlog";
> $size = -s $file1;      # remember how big this file is
> 
> print STDERR "$file1 is $size bytes long\n";
> 
> die "\a$file1 does not exist or has no data\n" unless $size;
> open (IN, $file1) || die "Can't open $file1, $!\n";
> while (<IN>) {
>    print "REC $IN \n";

Okay, you print each "line" of the file. But I am not sure, whether
this file is organized in lines at all. I haven't found the 
description of the file format in a quick search. But the man pages
provide a good source to explore further. Also have a look at the man 
pages concerning the perl built-in function "pack". If the data in the
file are some kind of binary nature this could be a help.

> }
> 
> close (IN) || die "Can't close $file1, $!\n";
> 
>  Thanks,
> 
>  Gaylon Stockman
> 
>  stockman@rdbewss.redstone.army.mil
> 


Good luck,
Mathias

-- 
__________________________________________________________________
| Dr. Mathias-H. Weber          ---     mailto:mweber@atlas.de   |
| STN ATLAS ELEKTRONIK GmbH   {~@_@~}                            |
| Brueggeweg 54 / Dept ETS21  _( Y )_   Phone:  +49 421 457 4401 |
| 28305 BREMEN               (:_~*~_:)  Fax  :  +49 421 457 3177 |
| Germany                     (_)-(_)   Telex:  2 457 460        |
___________________________SIGSIG: Signature too long (core dumped)


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

Date: Tue, 18 Nov 1997 01:35:00 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: adding to the end of each element in an array
Message-Id: <comdog-ya02408000R1811970135000001@news.panix.com>

In article <3471ec64.39161497@news.ais.net>, syarbrou@ais.net (Steve) wrote:

>I know chomp can take a character or group of characters off each
>element in an array.  Is there something that can do the opposite?  In
>otherwords if I have an array, and want to add \n to the end of each
>element, is there a single command like chomp to do this?

   @new_array = map { "$_\n" } @old_array;

or if you just want to print them with a newline after each element:

   $" = "\n";
   print "@array\n";

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 18 Nov 1997 07:41:09 GMT
From: khyiu@glink.net.hk (Yiu Kin Ho)
Subject: compiler-a3: problem with setuid perl program
Message-Id: <64rgql$q7h$1@unix2.glink.net.hk>

Hi,
        I have a program orginally written by perl.  Recently, we try to
compile this perl program.  The program need to setuid with the permission
--s--x--x.  The compilation is success.  However, when we chmod the same
permission mode with the compiled program, it appear with the error:

No -e allowed in setuid scripts

We don't have any -e option in my perl program.

Any idea? Thanks....

Yiu


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

Date: Tue, 18 Nov 1997 05:21:30 -0600
From: pverdret@sonovision-itep.fr
Subject: Re: Creating a call tree
Message-Id: <879851183.18321@dejanews.com>

In article <slrn66p3tq.9du.jwilf@darepc.jpl.nasa.gov>,
  jwilf@darepc.jpl.nasa.gov (Joel Wilf) wrote:
>
> Lately I've been examining a system chock full of perl scripts: cgi,
> sysadmin, libraries of subroutines, etc.
>
> Finding all the perl scripts and the subroutines defined in them is easy
> (thanks tp File::Find).  But I haven't found a good way to construct a call
> tree -- a list of all the subroutines called from a main module, the
> subroutines called by those subroutines, and so on.
>
> I've looked at two approaches, so far.  The first is the brute force
> approach: go through every line of the module and try to pick out all the
> calls.  The problem is ensuring that all the calls are found, not just the
> ones prepended with :: or &.
>
> The second approach, which intrigues me, is using the perl debugger.  I've
> played with running the program inside the debugger, using the 'c' command,
> then examining the subroutines with 'S'.  However: I don't know how to do
> this non-interactively (i.e., call the debugger from a script, issue the
> commands, and redirect the DB:OUT output).  Also, I wonder how I can get
> *all* calls, not just the ones found by executing a particular branch of the
> program.
>
> Is anyone out there building call trees for perl scripts?
> And: can you use the perl debugger (in batch mode, somehow) to create one?
>
> Any thoughts would be appreciated.

Install the packages Devel::CallTree.pm and Tree.pm attached below.
And try:

% perl -d:CallTree test.pl

The following test file:

 sub ack {
  my($x, $y, $z) = @_;
  if ($x == 0) {
    $y + $z;
  } else {
    if ($x <= 2 and $z == 0) {
      $x - 1;
    } elsif ($x > 2 and $z == 0) {
      $y;
    } else {
      ack($x - 1, $y, ack($x, $y, $z - 1));
    }
  }
 }

 ack(3, 3, 1);

could produce the following trace:

 TOPLEVEL
 main::ack(3, 3, 1)
  |_ main::ack(3, 3, 0)
  |_ main::ack(2, 3, 3)
     |_ main::ack(2, 3, 2)
     |  |_ main::ack(2, 3, 1)
     |  |  |_ main::ack(2, 3, 0)
     |  |  |_ main::ack(1, 3, 1)
     |  |     |_ main::ack(1, 3, 0)
     |  |     |_ main::ack(0, 3, 0)
     |  |_ main::ack(1, 3, 3)
     |     |_ main::ack(1, 3, 2)
     |     |  |_ main::ack(1, 3, 1)
     |     |  |  |_ main::ack(1, 3, 0)
     |     |  |  |_ main::ack(0, 3, 0)
     |     |  |_ main::ack(0, 3, 3)
     |     |_ main::ack(0, 3, 6)
     |_ main::ack(1, 3, 9)
        |_ main::ack(1, 3, 8)
        |  |_ main::ack(1, 3, 7)
        |  |  |_ main::ack(1, 3, 6)
        |  |  |  |_ main::ack(1, 3, 5)
        |  |  |  |  |_ main::ack(1, 3, 4)
        |  |  |  |  |  |_ main::ack(1, 3, 3)
        |  |  |  |  |  |  |_ main::ack(1, 3, 2)
        |  |  |  |  |  |  |  |_ main::ack(1, 3, 1)
        |  |  |  |  |  |  |  |  |_ main::ack(1, 3, 0)
        |  |  |  |  |  |  |  |  |_ main::ack(0, 3, 0)
        |  |  |  |  |  |  |  |_ main::ack(0, 3, 3)
        |  |  |  |  |  |  |_ main::ack(0, 3, 6)
        |  |  |  |  |  |_ main::ack(0, 3, 9)
        |  |  |  |  |_ main::ack(0, 3, 12)
        |  |  |  |_ main::ack(0, 3, 15)
        |  |  |_ main::ack(0, 3, 18)
        |  |_ main::ack(0, 3, 21)
        |_ main::ack(0, 3, 24)

These packages are provided without any warrantee ;-)
Philippe

--------------------------------------------------------------------
# Author: philippe Verdret, Sonovision-Itep 1997
# pverdret@sonovision-itep.fr
# todo: define a node class
require 5.000;
use strict;
package Tree;
use Carp;

use vars qw($ATTRIBUTES $CHILDREN_HASH $CHILDREN_LIST);
*ATTRIBUTES = \0;		# so it's a constant
*CHILDREN_LIST = \1;
# not used
#*CHILDREN_HASH = \1;

sub new {
  my $receiver = shift;
  my $node = shift;
  my $class = (ref $receiver or $receiver);
  my $self = bless {}, $class;
  if (defined $node) {
    $self->{$node} = [];
    $self->attributes($node, 'father' => @_);
  }
  $self;
}
# Purpose: Node access by name
# Arguments:
# Returns:
sub node {
  my $self = shift;
  my $node = shift;
  $self->{$node};
}
# Pupose: remove a node and all these children
# Arguments: node name
sub deletenode {
  my $self = shift;
  my $node = shift;
  delete $self->{$node};
}
sub addnode {
  my $self = shift;
  my $father = shift;
  my $node = shift;
  if (exists $self->{$node}) {	# insure uniqueness
    my $attribute =  ${$self->{$node}}[$ATTRIBUTES];
    if ($attribute->{'father'} ne $father) {
      croak qq"can't have two nodes with the '$node' name";
    }
  }
  ${$self->{$node}}[$ATTRIBUTES] = { 'father' => $father, @_ }; # Node's
attributes
  push(@{$self->{$father}}, $node); # Node's children
}

# Purpose: access to node's attributes
# Arguments and returns:
# 1. (node) -> a. in a list context returns all attributes
#              b. in a scalar context returns the hash reference
# 2. (node, one_key) -> returns the associated value
# 3. (node, [key, value]+) -> add new attributes to node and returns all
attributes
sub attributes {
  my $self = shift;
  my $node = shift;
  if (exists $self->{$node}) {
    my $attributes = ${$self->{$node}}[$ATTRIBUTES];
    if (@_) {
      if ($#_ >= 1) {
	my %attributes;
	if (defined %{$attributes}) {
	  %attributes = (%{$attributes}, @_);
	} else {
	  %attributes = @_;
	}
	${$self->{$node}}[$ATTRIBUTES] = \%attributes; # Set node's attributes
        %attributes;
      } else {
	$attributes->{$_[0]};	# return the associated value
      }
    } else {
      if (defined %{$attributes}) {
	if (wantarray) {	# in a list context
	  %{$attributes};	# returns all node's attributes
	} else {		# in a scalar context
	  $attributes;		# return the hash reference
	}
      } else {
	();
      }
    }
  } else {
    croak qq^"$node" doesn't exist^;
  }
}
sub father {
  my $self = shift;
  my $node = shift;
  my $attribute =  ${$self->{$node}}[$ATTRIBUTES];
  $attribute->{'father'};
}
sub isleaf {
  my $self = shift;
  my $node = shift;
  defined ${$self->{$node}}[$CHILDREN_LIST] ? 0 : 1;
}
sub children {
  my $self = shift;
  my $nodeName = shift;
  my $node = $self->{$nodeName};
  @{$node}[$CHILDREN_LIST..$#{$node}]
}
sub childof {			# use CHILDREN_HASH instead
  my $self = shift;
  my $child = shift;
  my $father = shift;
  grep /^$child$/, $self->children($father);
}
sub scan {
  my $self = shift;
  my $node = shift;
  if (exists $self->{$node}) {
    local *before = (shift or sub {}); # define a local routine
    local *after = (shift or sub {}); # define a local routine
    $self->subtree($node, 0);	# node name and depth
  } else {
    croak qq^"$node" node doesn't exist^;
  }
}
# Arguments: node name, depth
sub subtree {
  my $self = shift;
  my $node = shift;
  my $depth = shift;
  my $subNode;
  my $attribute;
  my @node = $self->children($node);
  while (@node) {
    $subNode = shift @node;
    $attribute = ${$self->{$subNode}}[$ATTRIBUTES];
    before($self, $depth, $subNode, $attribute, @node);
    next if $subNode eq $node;	# it's the Root
    if (defined ${$self->{$subNode}}[$CHILDREN_LIST]) { #
       $self->subtree($subNode, $depth + 1);
       after($self, $depth, $subNode, $attribute, @node);
    }
  }
}
sub prettyprint {
  my $self = shift;
  my $node = shift;
  my @key = @_;
  my $root = " ";
  my $branch   = "  |";
  my $nobranch = "   ";
  my $child =    "  |_ ";
  my $etc =      "  |_ ...";
  my $maxDepth = 20;
  use vars qw(@edge);
  local @edge = ('');
  $self->scan($node,
	      sub {
		my $self = shift;
		my $level = shift;
		my $node = shift;
		my $attributes = shift;
		if ($level) {
		  if (@_) {	# is there any other branch at this level?
		    $edge[$level] = "$branch";
		  } else {
		    $edge[$level] = "$nobranch";
		  }
		  print @edge[0..$level-1], $child,
		  (map { $attributes->{$_} } @key),  "\n";
		} else {	# zero
		  print $root, (map { defined $attributes->{$_} ?
$attributes->{$_} : '' } @key), "\n";
		}
	      });
}
1;
__END__

----------------------------------------------------------------------------
package Devel::CallTree;

package DB;
sub DB {}
sub sub { &$sub }
use Tree;
my $TRACE = 0;
my $callTree = new Tree;
my $nodeid = -1;
my @stack = ($nodeid);
$callTree->addnode($nodeid, $nodeid,
		   'label' => 'TOPLEVEL', 'args' => undef);

# or redefine this function on the fly # with a require, for a call tree
of a program slice sub sub {  $callTree->addnode($stack[$#stack],
++$nodeid,	       'label' => $sub, 	       'args' => '(' .
(join ', ', @_) . ')'			);  $nodelabel{$sub} =
$stack[$#stack] unless exists $nodelabel{$sub};  print STDERR "$sub args:
@_ [in $sub{$sub} $stack[$#stack] $nodeid ]\n" if $TRACE;  push @stack,
$nodeid;  if (wantarray) {  @return = &$sub;  pop @stack;  @return;  }
else {	$return = &$sub;  pop @stack;  $return;  } }

END {
  local *sub = sub { &$sub };
  select STDERR;
  print "\n";
  $callTree->prettyprint(-1, qw(label args));
}
1;

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Tue, 18 Nov 1997 00:01:51 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: codestorm@mailcity.com
Subject: Re: DB_File and CGIs...extra load?
Message-Id: <34714B6F.2412@egames.com>

[mail&post]
Arup Kanjilal wrote:
> Just wondering... how much of an extra load can be caused by using
> DB_File in my CGIs? Need to use it since it make life a lot simple for
> handling datafiles (I don't want to shift to an rdbms). The CGI in
> question will be facing a lot of high volume traffic - about a million
> hits a day, so is it a major increase in server load if I use the
> library? My httpd is Apache.

Hmmm, a million hits per day where each hit invokes a CGI?
(That's an average of 12 CGI executions/sec, probably peaks more like
50-75/sec)

For this kind of traffic, DB_File isn't the problem, CGI is.
The CGI model is going to load perl and compile your script for every
hit.  You better have a bloody fast server if you think you can handle
this traffic using ordinary CGI.

I suggest you look into FastCGI <http://www.fastcgi.com/> or the
mod_perl Apache extension to solve your performance issues.

HTH
--
Devin Ben-Hur     <dbenhur@egames.com>
eGames.com, Inc.  http://www.egames.com/  The Ultimate Game Store
"Dark is the suede that mows like a harvest" -- Martian Ambassador



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

Date: Mon, 17 Nov 1997 22:45:00 -0800
From: "Barokas, Kika" <kika.barokas@caere.com>
Subject: Defining a DSN (ConfigDSN) to MS SQL Server 6.5 from Perl ?
Message-Id: <70AF97835F4BD11181FF00A0C906B726AB2068@ocrleader2.caere.com>
Keywords: "PERL ODBC DSN ConfigDSN"

I'm trying to set up a perl script which should access the MS SQL Server
ver 6.5.
I can connect to the server and read data once I already have a DSN
defined through the ODBC Manager, but I can't create a new DSN through
the 
I'm using PERL 5.003_07, with WIN32::ODBC 970208.

When I run this code (based on the test program in the ODBC
distribution): 

$DriverType = "SQL Server";
@DSN_Strings = (
	"DSN=$DSN", 
	"Description=$Desc", 
	"DBQ=$DBase", 
	"DEFAULTDIR=$Dir", 
	"UID=$UID", 
	"PWD=$PWD");

if (Win32::ODBC::ConfigDSN(ODBC_ADD_DSN, $DriverType, @DSN_Strings)) 
 ...

the ConfigDSN call works OK with MS Access, but fails with SQL Server.
When I run it with Access I omit the UID and PWD (they work OK for me
when opening a connection with a "new Win32::ODBC($NewString)" call, if
I already have a pre-defined DSN), and for DBQ value Access I put the
path to the directory on the local disk.
I tried to use the server's name there, still the call did not succeed.

Any help, anyone ?

TIA -- Kika



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

Date: Sat, 15 Nov 1997 14:42:06 +0800
From: Andrew Ellerton <andrewe@technologyXchange.com>
Subject: Re: Easily using databases - am I reinventing a wheel?
Message-Id: <346D443E.7F4D8090@technologyXchange.com>

Zenin wrote:
> 
> Peter J. Schoenster <pschon@baste.magibox.net> wrote:
> : I have to make this simple for someone else to administer.  I do not
> : use mSQL or other types although I am looking at them. I find it much
> : easier to write my own dbm or flat-file databases.
> 
>         If multiple people could ever be using this at the same time,
>         I **REALLY** hope you're locking your DBM and flat files.  See
>         the DB_File man page for examples of locking DBM files.  To not
>         lock on update could (will actually, it's just a matter of time)
>         corrupt the file.  Same with flat files.
> 
>         The main advantages with a SQL database (IMHO) is misc column
>         searches.  Right now you've got them all together as a pipe
>         delimited string in a DBM file.  What this meens is that if you
>         want to search on anything but the DBM key, you're reading the
>         *entire* DBM file, and doing a split() on *every* row of data.
>         If you want column substring searches (show me everything that
>         column "name" starts with "rocky") it gets even worse.  You'll
>         end up with a system that doesn't scale at _all_, since it will
>         slow down at an exponential rate to the number of rows you add.
> 

Its definitely a must to lock the files. However, there is an
alternative to using DBM and mSQL. I had to do several sites recently
that didn't have space or privileges for mSQL and I wanted to use flat
files. At first I too did what Peter did - reinvented the wheel. (After
all, "Its not *that* hard to reinvent the wheel"...)  But after a while
I realised that this was just silly.

Checkout Sprite.pm at CPAN. This allows (simplified) select statements
on flat file text "databases". It seems you have to lock the files
yourself, but there's quite a few ways to do that. 

Sprite is small and doesn't require a sql server running like mSQL.
Naturally, it has quite a few drawbacks, one of which is (as Zenin
noted) that its not scalable, and the larger your files grow, the more
ridiculous the time it takes to process.

Still, for us it has worked very well as an intermediate step before
using DBI Oracle or whatever - and there is no point reinventing the
wheel if you're just going to throw it away anyway.

Checkout sprite.pm; definitely worth looking at.

 

--
Andrew Ellerton                          andrewe@technologyXchange.com
Software Engineer                                      +61 8 9367 7006
International Technology Exchange                  Fax +61 8 9367 7343
Australia                             http://www.technologyXchange.com


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

Date: Tue, 18 Nov 1997 02:36:28 -0500
From: Andrew <andrew2@one.net>
Subject: File Handling in Perl
Message-Id: <3471457C.28E@one.net>

Is it possible create/open a file, using a filename that is a variable?

I'm trying to write a small script that will take information from a
form and save it to a file. I need to create a separate file for each
person who fills out the form. Therefore I would basically like to use
their email addresses for the file name.  

Is this possible?

Thanks,

Andrew


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

Date: Tue, 18 Nov 1997 06:08:35 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: File Handling in Perl
Message-Id: <comdog-ya02408000R1811970608350001@news.panix.com>

In article <3471457C.28E@one.net>, andrew2@one.net wrote:

>Is it possible create/open a file, using a filename that is a variable?

yes.  what happened when you tried it?

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Tue, 18 Nov 1997 09:26:15 +0100
From: troian@saturne.rennes.thmulti.com (Troian_Pierre)
Subject: Format and comments
Message-Id: <199711180826.JAA12562@harley.tmm>

Hello,
	
I have a question : I have a perl script which is supposed to generate
csh scripts. In the csh output script, I'd like to have some comments (Line 
starting with # ). 

Is it possible to generates such comments in output files by using the perl
'format' facility ( for which a line beginning with # is a comment ) ?

I am using perl 5.004 on a Solaris 2.5.1 Sun Station 
	
Thanks for your help

--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.
 .	Troian Pierre 
-	THOMSON multimedia R&D France
 .	tel : (33) 02 99 27 35 88
-	fax : (33) 02 99 27 30 01 
 .	email : troian@saturne.rennes.thmulti.com (SUN)
-		troianp@thmulti.com (PC)
--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.




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

Date: 18 Nov 1997 10:31:33 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: Format and comments
Message-Id: <slrn672rk5.9e5.Tom.Grydeland@mitra.phys.uit.no>

On Tue, 18 Nov 1997 09:26:15 +0100,
Troian_Pierre <troian@saturne.rennes.thmulti.com> wrote:

> Is it possible to generates such comments in output files by using the perl
> 'format' facility ( for which a line beginning with # is a comment ) ?

Use the same trick as for literal @ characters:

format STDOUT =
@ @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
"#",$_
 .

while(<DATA>){
    write;
}

__DATA__
This is text
which should be printed as comments
and it works just fine.

> .	Troian Pierre 

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: 18 Nov 1997 09:37:32 GMT
From: des@corp.netcom.net.uk (Des Herriott)
Subject: Re: is h2xs supposed to do this?
Message-Id: <64rnks$m32$1@taliesin.netcom.net.uk>

In article <64q33e$33b$1@agate.berkeley.edu>,
	ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
> I would try it.  Please report.  Jason could have broken things - I
> did not check.

Yep, it looks that way.  I just tried 0.3 and it worked correctly.

I've done a little investigation into what's changed, and I don't
claim to understand the parsing code fully yet, but I think I've
found the offending line.  Line 483 of Scan.pm from v0.3:

  if ($decl =~ /\G(\w+)((\s*\[[^][]*\])*)/g) {

has changed in v0.4 to:

  # NOTE: we need the '(repeat_group)+' in the following regexp as
  # opposed to (repeat_group)*, otherwise it will match only on the
  # (\w+) ... which is not what we want
  if ($decl =~ /\G(\w+)((\s*\[[^][]*\])+)/g) {

(i.e. a '*' has changed to a '+')

So the change is obviously deliberate, but it appears to have broken
something somewhere along the line...

-- 
Des Herriott
des@corp.netcom.net.uk


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

Date: Tue, 18 Nov 1997 11:41:33 +0100
From: "Reinhard E. Voglmaier" <rv33100@ggr.co.uk>
Subject: JavaScript < -------- > Perl (CGI)
Message-Id: <347170DD.4D6A@ggr.co.uk>

Hi there ,

is anybody embedding JavaScript in Perl-CGI scripts ? 
The benefit is to be able to distinguish produce both Server-Side and
Client-Side Scripts in ONE PLACE.
I began to write a library that produces dynamically Windows-like CGI
Applications, now I'm thinking in produce the client-side dynamic part
too. If someone is interested to share the results, let me hear.


Cheers
Reinhard


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

Date: Tue, 18 Nov 1997 11:49:35 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: JavaScript < -------- > Perl (CGI)
Message-Id: <34728091.30315771@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On Tue, 18 Nov 1997 11:41:33 +0100, "Reinhard E. Voglmaier"
<rv33100@ggr.co.uk> wrote:

>Hi there ,
>
>is anybody embedding JavaScript in Perl-CGI scripts ? 

Yes. I typically use HEREDOCs to do it.

my $JavaScript=<<JS;
 ...
JS

>The benefit is to be able to distinguish produce both Server-Side and
>Client-Side Scripts in ONE PLACE.

Agreed.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Sat, 15 Nov 1997 14:31:40 +0800
From: Andrew Ellerton <andrewe@technologyXchange.com>
To: albertl@internorth.com
Subject: Re: Newbie Q: Skipping lines in output
Message-Id: <346D41CC.A83DF820@technologyXchange.com>

A Lee wrote:
> 
> Hi,
> 
> I'm writing a simple traceroute program, and I was wondering how to
> skip the first line of the traceroute output where it output's
> 
>         traceroute to <host> <ip>...
> 
> before it starts with the actual trace data.  How do I go about doing
> this?

Like Larry Wall says, there's more than one way to do it.

One way, and I take no responsibility if the Guru's say this is slow
(hey, it works), is

	@info =`traceroute ...`;
	shift @info; # dump first line
	foreach $line (@info) {
		do_something($line);
	}

etc.

I'm not sure that you want to accept the output of traceroute like that,
but its one way.

Andrew

--
Andrew Ellerton                          andrewe@technologyXchange.com
Software Engineer                                      +61 8 9367 7006
International Technology Exchange                  Fax +61 8 9367 7343
Australia                             http://www.technologyXchange.com

    "Quotes attached to email messages are a last ditch attempt 
     by the sender to express themself to the masses." -- AE


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

Date: Mon, 17 Nov 1997 23:46:16 -0800
From: Brandon Stirling <brandons@uidaho.edu>
To: frederic@xilinx.com
Subject: Re: On the fly GIF and CGI
Message-Id: <347147C8.E526F6EC@uidaho.edu>

Frederic RIVOALLON wrote:
>  $im = new GD::Image(50,50);
> .
> ..
> # Draw image
> .
> ..
> $temp = $im->gif;
> print "<img src=$temp alt=\"temp\" >";
> 
Try this:

print "Content-type: image/gif\n\n";
print $im->gif;

Printing a image is just like printing HTML.

print "Content-type: text/html\n\n";
print "What ever";

This should get you going.


-- 
Brandon Stirling
Web Technologists
Computer Services
University of Idaho


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

Date: 18 Nov 1997 09:54:13 +0100
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Perl and INETD
Message-Id: <isyb2m1t1m.fsf@godzilla.kiere.ericsson.se>

sjohnson@twisted.napanet.net (Steve Johnson) writes:

> Thats the basic idea of what I have, But like I said, when I telnet to the
> machine it just hangs there, Can someone help me out?  Thanks

Unbuffer STDOUT in your script, or it'll start waiting for input
before your messages get sent to the socket.

-- 
		    Calle Dybedahl, UNIX Sysadmin
       qdtcall@esavionics.se  http://www.lysator.liu.se/~calle/


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

Date: Tue, 18 Nov 1997 07:11:46 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: perl conversion of curly quotes out of web form
Message-Id: <ebohlmanEJtynM.4nH@netcom.com>

Bruce Wyman (bw@tiac.net) wrote:
: I'm using perl to rewrite the material into an html page and therefore
: want to change the typographically correct stuff into " and ' marks. 

: What am I overlooking in my last few hours of net searching? I know that
: according the the RFCs that the 8-bit ascii values I'm hunting for are
: 2018,2019,201c, and 201d but there's no way to have perl see those, yes?

Those obviously aren't 8-bit anything, since it takes 4 hex digits to
write them.  They're Unicode values, and unless your files use Unicode
(2-byte characters), they're not what you're seeing.  Different platforms
have different mappings for "smart quotes."  If they're originating on an
MS-Windows platform, then the single quotes are \x91 and \x92, and the
double quotes are \x93 and \x94.  I'm not sure what the Mac uses. 


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

Date: 18 Nov 1997 09:54:53 +0100
From: ckc@hobbes.ejoper.dmi.min.dk (Casper K. Clausen)
Subject: Re: Perl Tutotial
Message-Id: <wvp67pq60pt.fsf@hobbes.ejoper.dmi.min.dk>

Simon Thangasamy <r64st@morgan.ucs.mun.ca> writes:

> Can anyone please tell me where I can find a Perl tutorial on the web.

<URL: http://www.ncsa.uiuc.edu/General/Training/PerlIntro/whatIs.html>

It's not very elaborate, but it'll get you started. Note that either
"Learning Perl" or "Programming Perl" (both from O'Reilly books),
depending on your prior knowledge ("Learning" for utter newbies,
"Programming" for people who know programming and want to move to
Perl), come highly recommended.

Regards,
Kvan.
-- 
-------Casper Kvan Clausen------ | 'Ah, Warmark, everything that passes
----------<ckc@dmi.dk>---------- |  unattempted is impossible.'
           Lokal  544            |   
I do not speak for DMI, just me. |        - Lord Mhoram, Son of Variol.      


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

Date: Tue, 18 Nov 1997 01:08:21 -0000
From: <alw421s@cnas.smsu.edu>
Subject: Possible?@!?!?!?!
Message-Id: <64reji$pbo$1@ursa.smsu.edu>

I am trying to create a script that finds out who it is accessing my page,
and after finding out who it is, displaying either my original web
page....or if it someone "special", I want it to display a different .html
document....is this possible??? HELP HELP HELP :)




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

Date: Tue, 18 Nov 1997 02:53:25 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Possible?@!?!?!?!
Message-Id: <comdog-ya02408000R1811970253250001@news.panix.com>

In article <64reji$pbo$1@ursa.smsu.edu>, <alw421s@cnas.smsu.edu> wrote:

>I am trying to create a script that finds out who it is accessing my page,
>and after finding out who it is, displaying either my original web
>page....or if it someone "special", I want it to display a different .html
>document....is this possible??? HELP HELP HELP :)

sure it's possible, but you have to specify the conditions for special
status.  but this is unrelated to Perl, so follow-ups go down the hall
to comp.infosystems.www.authoring.cgi :)

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 18 Nov 1997 10:07:07 +0000
From: Richard Caley <rjc@liddell.cstr.ed.ac.uk>
Subject: Re: SEGV from perl 5.004_4, solaris 5.5.1 (with example code)
Message-Id: <eyhhg9av7lg.fsf@liddell.cstr.ed.ac.uk>


Here is some code which causes my perl to Bus Error. I presume the
differentce between this Bus Error and my previous SEGV is not
important (unless I have found _two_ bugs within a few days, and it
has been one of those weeks).


--- 8< --- 8< --- CUT HERE for perlbug.prl --- 8< --- 8< ---
#!/usr/local/bin/perl -w

$global = new Class "g";
print "$global\n";

foreach $i (1, 2, 3, 4, 5)
    {
    print "$i\n";
    my ($obj) = new Class $i;
    print ref($obj), "\n";
    }

print "$global\n";
exit(0);


package Class;

sub new 
{
    my($c, $n) = @_;
    my ($self) = [ $n ];

    print "create $n\n";
    bless $self, $c;
}

sub DESTROY
{
    my ($self) = @_;

    print "destroy $$self[0]\n";
    bless $self, "dead";
}

--- 8< --- 8< --- perlbug.prl end --- 8< --- 8< ---
-- 
rjc@cstr.ed.ac.uk			_O_
					 |<



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

Date: 18 Nov 1997 09:53:27 +0000
From: Richard Caley <rjc@liddell.cstr.ed.ac.uk>
Subject: Re: SEGV from perl 5.004_4, solaris 5.5.1
Message-Id: <eyhiutqv888.fsf@liddell.cstr.ed.ac.uk>


I have isolated a line which when commented out prevents the SEGV. Of
course I'm not sure this is the actual cause...

The problem seems to be that in the DESTROY method for a class I bless
the object being destryed into a new class (so that if I call DESTROY
explicitly and still have a reference somewhere I will get an error I
can understand when I try and use it).

I'll try and come up with an example smaller than my whoe program.

Meanwhile any confirmation that someone else has seen this problem
would be most apreciated.


-- 
rjc@cstr.ed.ac.uk			_O_
					 |<



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

Date: Tue, 18 Nov 1997 07:28:51 GMT
From: Bob Nelson <bnelson@netcom.com>
Subject: sequence point?
Message-Id: <64rg3j$2pl$1@renpen.nelson.org>

Is the behaviour of ``$i = 3; $i = $i++'' ^(un|implementation-)*defined$ 
in Perl?

-- 
========================================================================
          Bob Nelson -- Dallas, Texas, USA (bnelson@iname.com)
             http://www.geocities.com/ResearchTriangle/6375
========================================================================


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

Date: Tue, 18 Nov 1997 12:15:07 +0100
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: setenv problem (read the FAQ)
Message-Id: <347178BB.446B@theo.phy.uni-bayreuth.de>

Hi,

Daniel Bar Or (Beniluz) wrote:
> 
>  On Win Nt 4.0 station. using perl5
>  I'm trying to set a new environment variable from a perl script.
 [...]
>  The program terminates succesfully
>  But when i go out to the commnad prompt the new env var is not set.

Take a look at the Perl Frequently Asked Questions:

   I {changed directory, modified my environment} in a perl
   script. How come the change disappeared when I exited the
   script? How do I get my changes to be visible? 

(should be part of your perl distribution)


Bye, Eike
-- 
=======================================================================
>>--->>    Eike Grote  <eike.grote@theo.phy.uni-bayreuth.de>    <<---<<
-----------------------------------------------------------------------
 Home Page, Address, PGP,...:  http://www.phy.uni-bayreuth.de/~btpa25/
-----------------------------------------------------------------------
 PGP fingerprint:      1F F4 AB CF 1B 5F 4B 1D 75 A1 F9 C5 7B 3F 37 06
=======================================================================


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

Date: Tue, 18 Nov 1997 11:49:26 +0200
From: "Daniel Bar Or (Beniluz)" <danibo@amdocs.com>
Subject: setenv problem
Message-Id: <347164A6.21D5@amdocs.com>

Hi all
----------

 On Win Nt 4.0 station. using perl5
 I'm trying to set a new environment variable from a perl script.

   $new_env="xxx";
   $ENV{'MYVAR'}=$new_env;

 I've tried also : 

   system("set MYVAR=xxx");

 or

   `set MYVAR=xxx` ;

 The program terminates succesfully
 But when i go out to the commnad prompt the new env var is not set.

 Can anybody help ?

 Thanks 
       Dan


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

Date: Tue, 18 Nov 1997 11:48:11 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: setenv problem
Message-Id: <34718039.30227865@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On Tue, 18 Nov 1997 11:49:26 +0200, "Daniel Bar Or (Beniluz)"
<danibo@amdocs.com> wrote:

>Hi all
>----------
>
> On Win Nt 4.0 station. using perl5
> I'm trying to set a new environment variable from a perl script.

[snip]

> The program terminates succesfully
> But when i go out to the commnad prompt the new env var is not set.
>
> Can anybody help ?

The change only affects the subshell in which Perl is running. Once
Perl exits, the subshell is gone and you can no longer see the changes
to those variables because they are gone as well.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Sun, 16 Nov 1997 17:10:06 -0000
From: "Chris Wilson" <chris@cjetech.co.uk>
Subject: User restriction
Message-Id: <346f2927.0@news.dmu.ac.uk>

Hello,

I wish to set up a voting booth system which will only let each person vote
once.

However:
IPs are out, as most people have dynamic ips;
cookies are too easily changed;
emails are out as some people have multiple email addresses (some of us have
about infinite!).

Otherwise I could use a password protection system, but people would
probably be able to register twice anyway.  HELP!

I suppose it doesn't have to be perl, even.

Cheers

Chris Wilson




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

Date: Tue, 18 Nov 1997 21:22:13 +1300
From: "Richard Mayston" <maystonr@ihug.co.nz>
Subject: Win32::EventLog problems...
Message-Id: <64rj02$l26$1@dot.ihug.co.nz>

Using Perl for Win32 Build 313 gives me

C:\>evt.pl witt020 System 10
Modification of a read-only value attempted at C:\Perl\lib/Win32/EventLog.pm
line 81.

which looks like it is complaining about the $_[0] use in the eventlog.pm
ie...

OpenEventLog($handle, $ServerName, $SourceName);
 $_[0] = {'handle' => $handle,
  'Source' => $SourceName,
  'Computer' => $ServerName };

Does anyone have a functioning example of eventlog use?, or know how I could
fix it?


The evt.pl code is...

use Win32::EventLog;if($#ARGV < 2) {
 die "usage: perl evt.pl MYSERVER System 10\n"; }
$machine  = $ARGV[0];
$eventlog = $ARGV[1];
$limit    = $ARGV[2];
my ($EventLog, $count, $first, $key);
$first = $count = 0;
my $event={ 'Source'              =>NULL,
 'Computer'            =>NULL, 'Length'              =>NULL,
 'Category'            =>NULL, 'RecordNumber'        =>NULL,
 'TimeGenerated'       =>NULL, 'Timewritten'         =>NULL,
 'EventID'             =>NULL, 'EventType'           =>NULL,
 'ClosingRecordNumber' =>NULL, 'Strings'             =>NULL,
 'Data',               =>NULL, };
Open Win32::EventLog($EventLog,$eventlog,$machine) || die $!;
$EventLog->GetOldest(\$first) || die $!;$EventLog->GetNumber(\$count) || die
$!;
$EventLog->Read((EVENTLOG_SEEK_READ |
EVENTLOG_BACKWARDS_READ),$first+$count,$event);
for $i ($first+$count-$limit+1..$first+$count) {

$EventLog->Read((EVENTLOG_SEQUENTIAL_READ|EVENTLOG_BACKWARDS_READ),0,$event)
;
 ($sec,$min,$hour,$mday,$mon,$year,$sday,$yday,$isdst) =
localtime($event->{'TimeGenerated'});;
 print sprintf("%15s -> %02d\-%02d\-%02d,
%02d:%02d\n",'timestamp',$year,$mon+1,$mday,$hour,$min);
 #to get a readable EventId $event->{'EventID'} = $event->{'EventID'} &
0xffff;
 foreach $key ('RecordNumber','Category','Source','Strings')  {
  print sprintf( "%15s -> %s\n",$key, $event->{$key} );
  } print "\n";
 }


Mucho gracias,
Richard Mayston     maystonr@ihug.co.nz





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

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

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