[6474] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 99 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 12 06:07:09 1997

Date: Wed, 12 Mar 97 03:00:21 -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           Wed, 12 Mar 1997     Volume: 8 Number: 99

Today's topics:
     Re: ARGUMENTS - HELP <fritz@fuse.net>
     Customer Satisfaction Report (Alan Fraser)
     Re: dupe checking and compressing in string <b.leguen@ctr.renault.fr>
     Re: Efficient multiple regexp searching (Mark J Hewitt)
     Grep function question (Triantafyllos Marakis)
     Re: How can I include another perl script within a perl (Tim Gim Yee)
     Re: How do I autoexecute perl from html <lupex@ascu.unian.it>
     Re: Install help for 5.003 on Solaris? (Jim Rudolf)
     Installing Modules under Macperl & Getting the best out geoff@no.spam.leeds.ac.uk
     Is possible in perl run a string like a piece of progra <Maurizio.Belluati@cselt.stet.it>
     Learning Perl's object-oriented features (Gihan Perera)
     Re: matching whitespace? <dehon_olivier@jpmorgan.com>
     Re: operations with dates in PERL.... (Tim Gim Yee)
     Passing variables to perl script <harry@infoseek.com>
     Re: Problem with grep function (Tim Gim Yee)
     Re: Sort, System() problem. (Michael Constant)
     Re: Standard "Reaper" procedure doesn't work on Solaris (Brian L. Matthews)
     Re: Who makes more $$ - Windows vs. Unix programmers? (Brock Hollingsworth)
     WWW, and grabbing input from a command (Paul Forsyth)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 10 Mar 1997 23:07:41 -0500
From: Fritz <fritz@fuse.net>
Subject: Re: ARGUMENTS - HELP
Message-Id: <3324DA8D.35D2@fuse.net>

Coulon wrote:
> 
> Hello,
> I would like to write a Perl script what gets command line arguments,
> but I don't know how to do it. Is it stored in a variable/array ?
> Thanks for your help.
> Xavier Coulon
> X.Coulon@herts.ac.uk

Command line arguments are in the special array @ARGV.  The first
argument is $ARGV[0], next $ARGV[1], etc.


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

Date: Wed, 12 Mar 1997 00:19:14 -0500
From: a_fraser@one.net (Alan Fraser)
Subject: Customer Satisfaction Report
Message-Id: <a_fraser-1203970019140001@port-28-39.access.one.net>

I've just put together a script and a corresponding HTML form that will
prompt the reader for information regarding satisfaction with a service
and then e-mail the result back to you.  It requires minimal tailoring for
use and is available at my home page below.  Click the Source Code button
and then click CommCard for details.  No charge, no banners, etc.

-- 
Alan Fraser
Home Page:  http://w3.one.net/~a_fraser/
E-mail:           a_fraser@one.net


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

Date: Wed, 12 Mar 1997 09:59:11 +0100
From: Bertrand Le Guen <b.leguen@ctr.renault.fr>
To: Honza Pazdziora <adelton@fi.muni.cz>
Subject: Re: dupe checking and compressing in string
Message-Id: <3326705F.167E@ctr.renault.fr>

Honza Pazdziora wrote:
> 
> Bertrand Le Guen <b.leguen@ctr.renault.fr> writes:
> Could someone tell me how (or where to find the way to do it)
> to easily check a string for duplicate caracters and simplify it to
> only one occurence.
> in fact if
> $LINE="========AAAAAABBBBBBcccdddeeee******";
> i would like as result to get
> $LINE="=ABcde*";
> i've take a look at the perlop man page and at the FAQ and didn't get
> any easy way to do it !
> It is in the perlop man page ;-)
yes i saw it now :-O, i was looking to substitution s/// !

> $ perl
> $LINE="========AAAAAABBBBBBcccdddeeee******";
> $LINE =~ tr/\000-\377//s;
> print $LINE, "\n";
> prints
> =ABcde*
> Hope this helps.
yes thank's to all of you that have answered me !
but now i realized that's it not exactly what i want but you drive me on
the good way for doing it !
in fact if
$LINE="=======AAAAAABBBBBBcccdddeeee******";
the result may be
$LINE="=AAAAAABBBBBBcccdddeeee*";
i want to compress all but alpha-numeric caracters !
the result operation is ok with :

$LINE = ~ tr/[\000-\057][\072-\100][\134-\140][\173-\377]//s;

bye !
-- 
Bertrand Le Guen
CAD/CAM & SGI/Unix Admin 
Web Master (Intranet)
mailto:b.leguen@ctr.renault.fr


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

Date: Wed, 12 Mar 1997 10:44:54 GMT
From: mjh@elsabio.demon.co.uk (Mark J Hewitt)
Subject: Re: Efficient multiple regexp searching
Message-Id: <33268191.10676395@news.demon.co.uk>

Mark J Hewitt posted 27 lines in <332503db.1283104@news.demon.co.uk> that
included:

I know it is bad for to reply to one's own postings, but I thought you
might like to see the test script I'm using.

Actually, on a 200k input file, the `evel' approach has reduced the search
time from 76 sec to about 5 sec - so maybe I'm just not going to get any
better.

Anyway, there may be techniques here that could be of use to others doing
similar tasks:

#!/usr/local/bin/perl
#
###########################################################################
# cm_report - test version of script to process build manager's log files.
#
# This script is written to be as (speed) efficient as I know how.  The
essence is that
# a large number of regular expressions need to be matched against each
line
# of the logfile.  Form each line, three aspects are measured:
#
# 1) Does the line match a regular expression
# 2) Does this line require a state change or an error report?
# 3) Extract key variables (like host or project etc.) from each line.
#
# This could be done with a long if...elif...else loop, but that would mean
# recompiling all the regular expressions each time.  So the approach taken
# is to describle the patterm matches in a data structure, and write a
matcher
# dynamically against this definition.  This is then eval'd, thus compiling
# the regular expressions just once.
#
# Any lines that are not recognised will be output in the report
#
#
# Mark J. Hewitt.  March 1997.  Cyrano (UK).
#
# History
#
# 10-mar-97 mjh Assume single logfile on stdin for now
#
#
###########################################################################
#
use strict;
use Benchmark;
use Data::Dumper;

#
# This is the match definition.  It is a data structure with the following
# fields:
#
# 1 string The regular expression, with (...) submatches embedded for
#          "interesting" substrings.
#
# 2 list   List of hash key names into which the substrings will be set.
#          The number of elements of these must match the number of
#          parenthesised subexpressions in the regular expression.
# 3 string Name of new state to be entered when this match occurs, or
#          "undef" if no change implied
# 4 string 'true' or 'false' corresponding to an assesment of whether this
#          match should be regarded as an error or not.
#
#

my @matchdef = (
		[q{^\s*Updating database with file '(.+)'},
[qw(productpath)], undef, 'false'],
		[q{^Ccm session ([a-zA-Z_\.]+:[0-9]+) started at (.+)$},
		     [qw(session starttime)], 'started', 'false'],
		[q{^INFO Building for platform (.*)$}, [qw(platform)],
'building', 'false'],
		[q{^Starting Automated Dependency Generation\.\.\.on host
(.*)$},
		     [qw(host)], 'depgen', 'false'],
		[q{^Dependency Generation failed$}, undef,
'depgen_complete', 'true'],
		[q{^Dependency Generation succeeded$}, undef,
'depgen_complete', 'false'],
		[q{^\*\*\* Error code\s+([^ ]+)\s+while building target
\`(.+)\' on host\s+([^ ]+)\s+.*$},
		     [qw(make_error target host)], 'making', 'true' ],
		[q{^Starting Continuus/CM ObjectMake\.\.\.on host (.*)$},
[qw(host)], 'making', 'false'],
		[q{^INFO Reconfiguring ([^\s]+) in ([^\s]+)},
		     [qw(project workarea)], 'reconfiguring', 'false'],
		[q{^Reconfigure for ([^ ]+) complete with ([^ ]+) out of
([^ ]+) objects replaced\.},
		     [qw(project repobj totobj)], 'reconfigure_complete',
'false'],
		[q{^[%-](.*), (.*)}, [qw(VMSerrcode VMSerrtext)], undef,
'true'],
                [q{^OK\s+Build of (.*)$}, [qw(project)], 'build_complete',
'false'],
		[q{^OK\s+Reconfigure of (.*)$}, [qw(project)],
'reconfigure_complete', 'false'],
		[q{^Reconfigure complete\.$}, undef,
'reconfigure_complete', 'false'],
                [q{^Reconfiguring project ([^ ]+) from object version ([^
]+)\.\.\.$},
		     [qw(project obver)], 'reconfiguring', 'false'],
                [q{^Reconfiguring project ([^ ]+), reselecting root object
version\.\.\.$},
		     [qw(project)], 'reconfiguring', 'false'],
		[q{^Starting reconfigure process\.\.\.$}, undef,
'reconfiguring', 'false'],
		[q{^Continuus engine exiting\.}, undef, 'finished',
'false'],
		[q{^Running make remotely on '(.*)'\.}, [qw(host)],
'remote_make', 'false'],
		[q{^Continuus/CM ObjectMake succeeded}, undef,
'make_complete', 'false'],
		[q{^ccm_make: No target to make\.}, undef, 'make_complete',
'true'],
		[q{^ccm_make: Warning: \`(.*)\' not remade because of
errors\.$},
		     [qw(target)], 'make_complete', 'true'],
		[q{^WARN ([^ ]+) (.*)$}, [qw(project warning)], undef,
'false'],
		[q{^\s*Accounting information:\s*$}, undef, undef, undef],
		[q{^\s*Buffered I/O count:\s+([^\s]+)\s+Peak working set
size:\s+([^\s]+)\s*$},
		     [qw(VMSbio VMSpeakWSS)], 'VMS_job_completed', undef],
		[q{^\s*Charged CPU time:\s+([^\s]+)\s+Elapsed
time:\s+([^\s]+)\s*$},
		     [qw(VMStimeCPU VMStimeElapsed)], 'VMS_job_completed',
undef],
                [q{^\s*Direct I/O count:\s+([^\s]+)\s+Peak page file
size:\s*([^\s]+)\s*$},
		     [qw(VMS_direct_I/O VMSpagefilepeak)],
'VMS_job_completed', undef],
		[q{^\s*([^\s]+)\s+job terminated at\s+(.*)$},
		     [qw(VMSuser VMStime_complete)], 'VMS_job_completed',
undef],
		[q{^\s*Page faults:\s+([^\s]+)\s+Mounted
volumes:\s+([^\s]+)\s*$},
		     [qw(VMSpagefaults VMSmountvols)], 'VMS_job_completed',
undef],
		[q{^FAIL Could not build (.*)$}, [qw(project)],
'build_complete', 'true'],
		[q{^INFO Build: Executing (.*)$}, [qw(command)], undef,
'false'],
		[q{^(.*)\.\.\.on host: (.*)$}, [qw(command host)], undef,
'false'],
		[q{^INFO Building\s+([^\s]+)\s+project\s+([^\s]+)\s*$},
		     [qw(ccm_state project)], 'building', 'false'],
		[q{^Updating Bill-of-Materials for (.*)\.\.\.$},
[qw(project)], 'BOM', 'false'],
		);

#
# The values of matched substrings are held in the %param hash
#
my %param = ();
my $state = "idle";			# Build state
my $error = "false";			# Error state
my $line_number = 0;			# Current logfile line number
my $line;				# Current logfile line


# DEBUG
    $Data::Dumper::Indent = 1;
    print Data::Dumper->Dumpxs([\@matchdef], [qw(*matchdef)]);
# END DEBUG


#my $t = timeit(1, "direct_method()");
#print "Direct method takes:",timestr($t),"\n";

my $t = timeit(1, "eval_method()");
print "Eval method takes:",timestr($t),"\n";

exit 0;


sub matched
{
    print "_" x 79, "\n";

    for (sort keys %param)
    {
	printf "%16s = %s\n", $_, $param{$_};
    }
    print "-" x 30, " state /$state/ error /$error/\n"
}


sub unmatched
{
    my $line = $_;

    print "Unmatched line <$line>\n";
}


sub eval_method
{
    my $match_engine = build_matcher();

#   print $match_engine;
    eval $match_engine;
}


sub direct_method
{
  logline:
    while(<>)
    {
	$line_number++;

	chomp;
	study;
	next logline if m{^\s*$} or m{^\s*\cG\s*$} or m{^\s*\cM\s*$};

	$line = $_;

        print "DEBUG line $line_number = <$line>\n";

        my $match;
        for $match (@matchdef)
        {
	    my $matchvar;
	    if(defined @$match[1])
	    {
	        my @matchval = m{@$match[0]};
	        my $tokens = @$match[1];
	        if (scalar @matchval > 0)
	        {
		    if(scalar @matchval != scalar @$tokens )
		    {
		        printf "Internal Error: %d substrings, %d
variables\n",
		               scalar @matchval, scalar @$tokens;
		    }
		    else
		    {
		        my $varindex = 0;

  		        for $matchvar (@$tokens)
		        {
			    $param{$matchvar} = $matchval[$varindex++];
		        }
		    }
		    $state = @$match[2] if defined @$match[2];
		    $error = @$match[3] if defined @$match[3];
		    matched();

		    next logline;
	        }
	    }
	    else
	    {
	        if(m{@$match[0]})
	        {
		    $state = @$match[2] if defined @$match[2];
		    $error = @$match[3] if defined @$match[3];
		    matched();

		    next logline;
	        }
	    }
        }
        unmatched($_);
    }
}


sub build_matcher
{
    my $engine = "";

    $engine .= "logline:\n";
    $engine .= "while(<>)\n";
    $engine .= "{\n";
    $engine .= "    my \@matchval;\n";
    $engine .= "    my \$nmatch;\n";
    $engine .= "    \$line_number++;\n";
    $engine .= "    chomp; study; \n";
    $engine .= "    next logline if m{^\\s*\$}o or m{^\\s*\\cG\\s*\$}o or
m{^\\s*\\cM\\s*\$}o;\n";
    $engine .= "    \$line = \$_;\n";
    $engine .= "    print \"DEBUG line \$line_number = <\$line>\\n\";\n";

    my $match;
    for $match (@matchdef)
    {
    	my $matchvar;
	if(defined @$match[1])
	{
	    my $tok;
	    my $varindex = 0;
	    my $tokens = @$match[1];
	    my $ntok = scalar @$tokens;

	    $engine .= "    \@matchval = m{@$match[0]}o;\n";
	    $engine .= "    \$nmatch = scalar \@matchval;\n";
	    $engine .= "    if (\$nmatch > 0)\n";
	    $engine .= "    {\n";
	    $engine .= "	if(\$nmatch != $ntok)\n";
	    $engine .= "	{\n";
	    $engine .= "	    print \"Internal Error: \$nmatch
substrings, $ntok variables\\n\";\n";
	    $engine .= "	}\n";
	    $engine .= "	else\n";
	    $engine .= "        {\n";

	    for $tok (@$tokens)
	    {
		$engine .= "            \$param{\'$tok\'} =
\$matchval[$varindex];\n";
		$varindex++;
	    }

	    $engine .= "	}\n";
	}
	else
	{
	    $engine .= "    if(m{@$match[0]}o)\n";
	    $engine .= "    {\n";
	}
	$engine .= "        \$state = \"@$match[2]\";\n" if defined
@$match[2];
	$engine .= "	    \$error = \"@$match[3]\";\n" if defined
@$match[3];
	$engine .= "	    matched();\n";
	$engine .= "	    next logline;\n";
	$engine .= "    }\n";
    }
    $engine .= "    unmatched(\$_);\n";
    $engine .= "}\n";

    return $engine;
}

-- 
Mark J. Hewitt        at home         mjh@elsabio.demon.co.uk


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

Date: Tue, 11 Mar 1997 02:27:35 GMT
From: ceetm@cee.hw.ac.uk (Triantafyllos Marakis)
Subject: Grep function question
Message-Id: <E6uxHz.9Cx@cee.hw.ac.uk>

I am trying to construct a function that will count the 
number of occurances of a string to a file.

So far I've written the following code:

open(IN_FILE, $in_file) or
  die "Program Fault; File cannot be found:$in_file\n";
while ($line = <IN_FILE>)
{                          
  $line = lc($line);
  
  @list = split(/ /, $line);
  $strings_per_line = grep(/$string/, @list); #count the occurance
				              #of the string
  $counter += $strings_per_line;
}
close(IN_FILE);

But if a string is contained more than once in a word      
(e.g. ......hello......hello... it increases the counter 
by one)

How is it possible to change the code above to achieve the goal?

--
TRIANTAFYLLOS MARAKIS     |Email:ceetm@cee.hw.ac.uk
BSc in Computer Science IV|Web  :http://www.cee.hw.ac.uk/~ceetm
HERIOT-WATT University    |George Burnett Hall(2.54), Heriot-Watt Univ.,
Edinburgh, Scotland       |Edinburgh,EH14 4AS, Scotland UK




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

Date: Wed, 12 Mar 1997 00:38:53 GMT
From: tgy@chocobo.org (Tim Gim Yee)
Subject: Re: How can I include another perl script within a perl script ??? Help
Message-Id: <3325f6dd.15920292@news.oz.net>

On Mon, 10 Mar 1997 15:13:00 -0700, Kris Houghton <krisho@exabyte.com>
wrote:

>  # How can I use the stuff in perl script1 in perl script2.

>From the new FAQ...

There are three basic ways of running external commands: 

    system $cmd;                # using system()
    $output = `$cmd`;           # using backticks (``)
    open (PIPE, "cmd |");       # using open()

 ...darn.  Same answer as the old FAQ :)


-- Tim Gim Yee             tgy@chocobo.org
http://www.dragonfire.net/~tgy/moogle.html
"Will hack perl for a moogle stuffy, kupo!"


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

Date: Wed, 12 Mar 1997 10:59:21 +0100
From: Roberto Lupi <lupex@ascu.unian.it>
To: Ian Johnston <ianj@trials.co.uk>
Subject: Re: How do I autoexecute perl from html
Message-Id: <Pine.LNX.3.93.970312105646.15185A-100000@ascu.unian.it>



On Mon, 13 Jan 1997, Ian Johnston wrote:

> I've just written my own perl page counter (beginner!).
> How do I invoke the script from a web page, or any script
> automatically from a web page without SSI and without a clickable link
> (which I call the manual method)

> P.S. My script looks for a certain marker within the page:-

> and increments the number it sees. I just need the script to be
> invoked when the page is accessed. Maybe something in the html header
> or something. I've looked up the perl books I have and also the online
> perl/cgi faq's but can't see anything.

You need SSI to do this... If you can't use SSI, use a script to generate
your page on-the-fly.



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

Date: Wed, 12 Mar 1997 11:30:21 +0100
From: rudolf@metadesign.de (Jim Rudolf)
Subject: Re: Install help for 5.003 on Solaris?
Message-Id: <rudolf-1203971130210001@jim.metadesign.de>


sajjad@icarus.cc.uic.edu (Sajjad Lateef) wrote:

> : > Briefly, Configure makes a list of *hundreds* of signal names, and
> : > that causes problems later in the script. 
> : Jim, what kind of problems are you getting? My Configure script exits
> : with a Shell syntax error and I'm wondering if it's the same problem.
> 
>         Hmm .. that means that I am not the only one. <whew>    
> 
[..]
> Only giving "-lm -lsocket -lnsl" options to compiler as per
> perl archive notes on compiling perl on Solaris.

The archive notes I found appear to be for 5.002; I don't know if 
there are changes for 5.003.

> Configure does the following: (starting around line 7963)
>         a: Prepares a list of signal names from signal.h...
[..]
>         f: Generates the values for the two variables sig_name and sig_num
>         from signal.lst that are then stored in config.h lines 1531 and 1532.
>                 f1: It also prints the values of the signals from $sig_name
>         These variables contain 4000+ SIGNAL Names and Numbers each. 
>         Here: awk barfs saying something like "input line too long"

I don't know if there are later ramifications, but I made the following
quick hack to the awk script to bail out after listing 50 signals.  This
is starting from line 8033 in Configure:

END {
     if (nsig == 0) { nsig = maxsig + 1 }
         nsig = 50
 ...

I added the last line above.  Then Configure and make depend worked OK.

Next problem:  During the make step, there is a compile failure in mg.c 
at line 601... something about troubles with struct sigaction.  I edited
config.sh and changed d_sigaction to undef.

Next problem: I get loads of parse errors while trying to compile a 
dynamic version of POSIX.c.  At this point I gave up.  I figure that
my environment is common enough that I must be doing something wrong
to be having this many problems.

My system: Sun Ultra, Solaris 2.5, gcc 2.5.6, perl 5.003

Cheers,

Jim
________________________________________________________________________
Jim Rudolf           MetaDesign plus GmbH           rudolf@metadesign.de

        "I have left orders to be awakened at any time in case of 
          national emergency, even if I'm in a cabinet meeting."
                             -- Ronald Reagan


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

Date: Tue, 11 Mar 1997 09:35:05 +0000 (GMT)
From: geoff@no.spam.leeds.ac.uk
Subject: Installing Modules under Macperl & Getting the best out of Makemaker
Message-Id: <332599EE.5E7E@no.spam>

I feel compelled to ask a question about Macperl in this group because
I have been unable to get the answers I need from any FAQ, deja news or
the usual Macperl sources (which, sadly, appear to be slumbering).

My objective is to install the libwww modules(s). (To be honest, at this
stage, I would be pleased to receive guidance on installing any module).

The biggest obstacle so far is the fact that Makemaker seems to crash
reliably on the Mac (this has been reported before).

Even if Makemaker worked well, I would be left with a makefile, and the
Mac does not have a make.

Perhaps installation on the Mac is intended to be done only using MPW
(tool).

Does anyone have any guidance, or could anyone point me in the right 
direction?

Ben.


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

Date: Wed, 12 Mar 1997 11:01:22 +0100
From: Maurizio Belluati <Maurizio.Belluati@cselt.stet.it>
Subject: Is possible in perl run a string like a piece of program?
Message-Id: <5g5v72$r5n@server-b.cs.interbusiness.it>

Hello,

We've a perl application that need to read math functions stored (like
strings) in a file. After read the function we need to process it. So a
possible solution is to write a subroutine that read the function parse
its string rappresentation end return the result. It could be better if
in perl there is a function that receives as input a piece of perl code
(so we write the function in perl syntax) and run it. 
Does perl have it?

Thank you for any help.

Maurizio.Belluati@cselt.stet.it


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

Date: Wed, 12 Mar 1997 08:58:33 GMT
From: gihan@pobox.com (Gihan Perera)
Subject: Learning Perl's object-oriented features
Message-Id: <33266e98.11146448@news.q-net.net.au>

Hi,

I wonder if anybody can point me in the direction of a good
introduction to the object-oriented features of Perl (Preferably
on-line).

I have "Programming Perl", but I found the O-O stuff
difficult to  understand (Maybe because it's so closely related
to packages and stuff that it's not such a big deal???).

Is there a comparison between Perl and C++ in this respect?
Or Perl and Java? And if not, would such a thing be useful?
I've written a "Java for C++ folks" introduction (see my home
page if you're interested), so I wouldn't mind doing something
similar for Perl, if there's enough interest.

Thanks in advance. Post or e-mail - I'll post a summary of
e-mail replies which aren't posted.

Regards,
Gihan
---------------------------------------------------------------------------------------------
gihan@pobox.com
http://www.pobox.com/~gihan


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

Date: 12 Mar 1997 11:24:17 +0100
From: Olivier Dehon <dehon_olivier@jpmorgan.com>
Subject: Re: matching whitespace?
Message-Id: <njzn2s9mmr2.fsf@jpmorgan.com>

astroweb@astron (alex filippenko) writes:

> 
> 
> i know i could look it up but i am 20min away from any perl book....sorry
> 
> how do I match an intederminate amount of whitespace... 
> 
> i thought... /' '.*/... but doesn't work.. 
> 

I think that online documentation of perl should be enough to solve
this kind of problems... Look at the CPAN (http://www.perl.com/CPAN),
I think you could find perl manpages in HTML format.

Furthermore, maybe you get a faster answer if you go get your book
that's 20 min away ! Usenet will take you more than 20 min to get the
answer !

BTW, to match an amount of whitespce, I would use: /\s*/ or / */ to
match only the 0x20 character

Hope this helps.
Olivier Dehon


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

Date: Wed, 12 Mar 1997 01:23:41 GMT
From: tgy@chocobo.org (Tim Gim Yee)
Subject: Re: operations with dates in PERL....
Message-Id: <332602e5.19000461@news.oz.net>

On Mon, 10 Mar 1997 22:19:09 -0600, Gustavo Espinosa Tavitas
<gespinos@nic.mx> wrote:

>Hi!

'po!

>$sec=0,$min=0,$hour=0
>$mday=DD,$mon=MM,$year=YYYY,

hm... 4 digit year...

>$wday,$yday,$idst ( i don't know what to do with these )

Nor do I :)

>and then 
>$initial_date=timelocal($sec,$min,$hour,
>              $mday,$mon,$year,$wday,$yday,$idst)
>now $initial_date has the date in seconds since 1970, 
>and i just have to add the equivalent of XX days in seconds,right?
>Wrong!!! timelocal just don't gives me anything i expect.
>Can anyone explain me how can i make this work ...?

localtime() returns the $year as 'year-1900'.  
So 1997 => 97, 2001 => 101, etc.
Bet timelocal() and localtime() are compatible.

$year -= 1900; # before feeding timelocal()



-- Tim Gim Yee             tgy@chocobo.org
http://www.dragonfire.net/~tgy/moogle.html
"Will hack perl for a moogle stuffy, kupo!"


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

Date: Mon, 10 Mar 1997 21:30:26 -0800
From: Harry Slaughter <harry@infoseek.com>
To: harry@infoseek.com
Subject: Passing variables to perl script
Message-Id: <3324EDF2.7162@infoseek.com>

I'm writing a very simple test that will be hosted at dozens of ISPs and
test our little website. There are about half a dozen variables that
will need to be set up at each ISP. 

Rather than editing the tests themselves, I'd like to set up some sort
of "wrapper" that can be set up *once* at each ISP. If I ever need to
update the tests, I will simply dist out the new scripts; the variables
will already be contained in the wrapper. 

My problem is passing variables from a wrapper to the script. It seems
to me that the best bet would be to set up a bourne shell wrapper and
call on my scipts using "perl" from bourne. This way, I do not have to
set up #!/path/to/perl at the beginning of each script (I don't want to
have to touch the perl scripts once they are at the ISP). 

Should I just pass the variables to the script as arguments, or is there
some more reliable means? I also thought about using a "require [file]"
and putting all my variables in that file, but this would not set the
Perl path in each script. 

Another option would be to create a "setup" script that wrote the
variables into the tests for me, but my goal is to be able to put the
perl scripts on the ISPs as "black boxes" and not have to edit them *at
all*.

I've been going back and forth on this all day, and I'm hoping there's
someone who's done something similar and might be able to help.

Thanks.

Harry Slaughter



======================================================
    Harry Slaughter              harry@infoseek.com
 Infoseek Corporation           Voice:  408.567.2920
2620 Augustine Dr. #250          Fax:  408.986.1889
 Santa Clara, CA 95054         http://www.infoseek.com
======================================================


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

Date: Wed, 12 Mar 1997 01:08:25 GMT
From: tgy@chocobo.org (Tim Gim Yee)
Subject: Re: Problem with grep function
Message-Id: <3325fc28.17275560@news.oz.net>

On Tue, 11 Mar 1997 02:29:51 GMT, Triantafyllos Marakis
<ceetm@cee.hw.ac.uk> wrote:

>I am trying to construct a function that will count the
>number of occurances of a string to a file.
>
>So far I've written the following code:
>
>open(IN_FILE, $in_file) or
>  die "Program Fault; File cannot be found:$in_file\n";

$! will tell you the real reason it couldn't open the file.

>while ($line = <IN_FILE>)
>{
>  $line = lc($line);

Or use ignore case in your matching pattern.  If nothing else 'i' is
less typing.

>  @list = split(/ /, $line);

This splits on a space, not necessarily splitting into words.

>  $strings_per_line = grep(/$string/, @list); #count the occurance
>                                              #of the string
>  $counter += $strings_per_line;
>}
>close(IN_FILE);
>
>But if a string is contained more than once in a word
>(e.g. ......hello......hello... it increases the counter
>by one)

open IN_FILE, $in_file or die "Poop: $!";
undef $/;
$line = <IN_FILE>; # slurp whole file... yum!
$counter++ while $line =~ /$string/gi; # or /\b$string\b/gi
close INFILE;


-- Tim Gim Yee             tgy@chocobo.org
http://www.dragonfire.net/~tgy/moogle.html
"Will hack perl for a moogle stuffy, kupo!"


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

Date: 12 Mar 1997 02:37:07 -0800
From: mconst@soda.CSUA.Berkeley.EDU (Michael Constant)
Subject: Re: Sort, System() problem.
Message-Id: <5g610j$o4n@soda.CSUA.Berkeley.EDU>

Tom Phoenix  <rootbeer@teleport.com> wrote:
>Have you tried the multi-argument form of system?
>
>    system('sort', '+1n', '-t::', '-o', 'output.file', 'input.file');

Not necessary in this case, because perl is smart enough not
to call a shell even if you use the original poster's

    system("sort +1n -t:: -o output.file input.file");

Perl only calls a shell if the input to system contains any
shell metacharacters; otherwise, it splits the input and calls
the requested program directly.

But even if you wanted to use the multiple-argument form of
system to make sure the shell never gets involved, you can
make it look a little nicer:

    system qw[sort +1n -t:: -o output.file input.file];
-- 
        Michael Constant (mconst@soda.csua.berkeley.edu)


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

Date: 11 Mar 1997 23:33:47 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: Standard "Reaper" procedure doesn't work on Solaris.
Message-Id: <5g5m8r$7gf$1@halcyon.com>
Keywords: fork, reaper, ipc

In article <5g54o1$1s6$1@celebrian.otago.ac.nz>,
Gideon King <gideon@csarc.otago.ac.nz> wrote:
|sub REAPER 
|{ 
|	$SIG{CHLD} = \&REAPER;  # loathe sysV
|	$waitedpid = wait;
|	logmsg "reaped $waitedpid" . ($? ? " with exit $?" : '');
|}
|$SIG{CHLD} = \&REAPER;
|If I comment out the line
|	$SIG{CHLD} = \&REAPER;  # loathe sysV

This is completely out of left field, so it may have nothing to do with
anything. However, at one time, because of the way SIGCHLD worked on
System V, you had to reset the signal *after* the wait, otherwise
SIGCHLD would be raised again immediately. If that was the entire
story, I would expect an infinite loop, but maybe Solaris only
inherited part of the behavior and SIGCHLD just gets raised once
more? What happens if the "loathe sysV" line is moved after the wait
line?

Just a thought, and I apologize if this has no relation to reality...

Brian
-- 
Brian L. Matthews				Illustration Works, Inc.
	For top quality, stock commercial illustration, visit:
		  http://www.halcyon.com/artstock


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

Date: Wed, 12 Mar 1997 07:40:56 GMT
From: blh @ anon.net (Brock Hollingsworth)
Subject: Re: Who makes more $$ - Windows vs. Unix programmers?
Message-Id: <332657e0.1800555@jeffnet.org>

The people who replied that you should, "Learn everything you can
regardless of platform" (I'm paraphrasing of course) are dead on.  If
you focus on programming skills, not a particular platform, you are
more likely to stay busy.  I myself started in DOS, moved to Win 3.1,
then Mac, 95, NT, UNIX, NeXT.  Really, once you understand the general
concepts, it's not too difficult to program on any platform thrown on
your desk.

Also, do it for love, not money, or don't do it at all.  I've never
met a programmer or consultant who was in it for the money who was
worth a damn.  If your just looking for a paycheck you'll end up a
faceless drone in a large corporation grinding out C++ code for
projects you may never see running.  Follow your heart.  If you like
UNIX better, you'll do better at it.  Besides, rarely do you stay
working with the same platform for very long (unless your a big iron
guy).

Lastly, the company I'm employed by works closely with many corporate
IS departments down to local business with just a few employees.  One
pattern we're seeing is that some of those who are using UNIX are
trying to find a less expensive solution.  The reason?  UNIX
programmers, consultants, hardware, and software cost more than
Windows NT, 95, or even Mac, solutions.  So while you might make more
money being a UNIX programmer or consultant, you may also be pricing
your skills out of a market with cheaper alternatives.  Just the other
day I was speaking to a consultant who told me, "Yeah, it's great.  I
make $150 an hour for UNIX consulting at company XYZ.  UNIX
adminstration isn't easy, you know."  To which I replied, "Yes, that's
why XYZ just hired us to switch them over to NT"  (Actually, I was a
bit more tactful than that).  In the process of deciding on the new
technology, company XYZ even mention this guy specifically as one of
the reasons their support costs were so high.  Not that this is sort
of a mass migration from UNIX, but we are defintely seeing a shift.
It's bad for the bottom line, but better for the customers.

Brock Hollingsworth


futureprog@bridge.net.NOSPAM.PLEASE (Future Programmer) wrote:

>Subject says it all. Based on your personal experience and statistics,
>where a good programmer can make more money - in Windows or Unix arena?
>Unix appeals more to me and is more advanced technically, but I am
>afraid that it is losing the market share to Windows 95. I want to be in
>the consulting field.
>
>I am a recent college graduate in NYC and have offers to work in
>both fields.  Please do not start Windows vs. Unix OS flamewar.
>Your insighful observations are appreciated. Please followup.
>

Monster Zero


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

Date: Mon, 10 Mar 1997 15:04:16 +0000 (GMT)
From: paulf@scs.leeds.ac.uk (Paul Forsyth)
Subject: WWW, and grabbing input from a command
Message-Id: <332422D7.A6D@scs.leeds.ac.uk>

Hi,

I've tried looking around but can't seem to find an answer to this
although I know it should be straightforward...

I have some files to unzip using the unix zcat command, and I want to
grab its output and put into a list. However, I am calling this via a
WWW form.

I have tried the following

open(LOG, "zcat <$accessL|");

This seems to work fine using the command line but if I call it using my
form it fails to. It works perfectly if I am simply opening a file but
not with this.

Any suggestions are greatly appreciated!

Thanks

Paul
   ____________________________________     
  /                                    \    Paul Forsyth
 / E: paulf@scs.leeds.ac.uk             \   Computer Science
{  W: http://www.scs.leeds.ac.uk/paulf/  }  University Of Leeds
 \ P: +44-113-233-6789                  /   Leeds LS2 9JT
  \____________________________________/    United Kingdom


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

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

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