[11257] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4857 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 9 17:07:20 1999

Date: Tue, 9 Feb 99 14:00:24 -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, 9 Feb 1999     Volume: 8 Number: 4857

Today's topics:
    Re: Advance Data Structure Question <jglascoe@giss.nasa.gov>
    Re: Advance Data Structure Question <bmb@ginger.libs.uga.edu>
    Re: Advance Data Structure Question <jglascoe@giss.nasa.gov>
    Re: Advance Data Structure Question <uri@ibnets.com>
    Re: Bug and cool debugging technique (5.004_04) <fuzzy825@hotmail.com>
    Re: callback functions (Alastair)
    Re: Converting CSV to LDIF <aarontav@cs.berkeley.edu>
    Re: Converting CSV to LDIF (Craig Berry)
    Re: cookies pointers droby@copyright.com
        determining number of returned rows in DBI.pm... <mgwhit@ibm.net>
        extracting data from returned script <T.Elenbaas@stud.tue.nl>
    Re: extracting data from returned script <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: HELP on assoc. array <jglascoe@giss.nasa.gov>
    Re: Help with @array droby@copyright.com
    Re: Helpdesk script (Alastair)
    Re: How do I get local IP Address ? <rlamb@compuserve.com>
        How to calculate number of working days? <shah@xnet.com>
        lists within hashes <wmwilson1@go.com>
        Matching elements in arrays or hashes? mattd@ukcc.uky.edu
    Re: Newbie: Help to convert korn script <fuzzy825@hotmail.com>
    Re: Newbie: Help to convert korn script <jglascoe@giss.nasa.gov>
    Re: Newbie: Help to convert korn script <jglascoe@giss.nasa.gov>
    Re: Newbie: Help to convert korn script jimhutchison@metronet.ca
    Re: Perl 'zine <uri@ibnets.com>
    Re: Perl 'zine <jjarrett@ecpi.com>
        perl floating points <abukar@insidewire.com>
    Re: perl floating points (Clinton Pierce)
    Re: perl floating points <ludlow@us.ibm.com>
    Re: please,please,please help me for my sanity. SSI exe <bencas@bigfoot.com>
        Prevent showing header <debot@xs4all.nl>
    Re: Question: Arrays of associative arrays <ludlow@us.ibm.com>
        Regular expressions and handleing new lines chris_bordeleau@lotus.com
        send email to NT Exhange server or post office mail <fuzzy825@hotmail.com>
        Suppres special characters <mobradov@newbridge.com>
    Re: The best way to learn C? (Walter Tice USG)
    Re: Very Very Newbie- re: perl5.0042-bindist.04bc <fuzzy825@hotmail.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 09 Feb 1999 14:50:21 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: gip <gibsonc@aztec.asu.edu>
Subject: Re: Advance Data Structure Question
Message-Id: <36C0917D.5E228308@giss.nasa.gov>

gip wrote:
> 
> ## I've simplified my problem to the following question:
> ##
> ## How can I get the count of the particular number of 'members' in this
> structure???
> ##
> ##
> 
> $structures = {}; # clear structure

<snip>

my $total = 0;

for my $href (values %structures)
{
	my $num_members = @{ $href->{'members'} };
	my $total += $num_members;
}


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

Date: Tue, 9 Feb 1999 15:17:08 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
To: gip <gibsonc@aztec.asu.edu>
Subject: Re: Advance Data Structure Question
Message-Id: <Pine.A41.4.02.9902091511530.21668-100000@ginger.libs.uga.edu>

On Tue, 9 Feb 1999, gip wrote:

> ## I've simplified my problem to the following question:
> ##
> ## How can I get the count of the particular number of 'members' in this
> structure???
> ##
> ##

Since you know your structure, cycle through looking for "member"
keys in the various hashes and then do something like this:

  $count = @{$structures{abc}{members}};

Which is the same as:

  $count = scalar @{$structures{abc}{members}};


HTH,

-Brad



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

Date: Tue, 09 Feb 1999 15:09:10 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: jglascoe@giss.nasa.gov
Subject: Re: Advance Data Structure Question
Message-Id: <36C095E6.A923CCA6@giss.nasa.gov>

Jay Glascoe wrote:
> 
<snip>
> my $total = 0;
<snip>
>         my $total += $num_members;
	  ^^
urf.  delete that my, it's already been declared.


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

Date: 09 Feb 1999 15:51:27 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Advance Data Structure Question
Message-Id: <39pv7jcncg.fsf@ibnets.com>

>>>>> "g" == gip  <gibsonc@aztec.asu.edu> writes:

  g> ## I've simplified my problem to the following question:
  g> ##
  g> ## How can I get the count of the particular number of 'members' in this
  g> structure???
  g> ##

  g> $structures = {}; # clear structure

  g> %structures = (

those 2 are not the same thing. the first is a hash ref and the second is
a hash variable.

  g>       DUMODE_T => {
  g>         structureName => "DUMODE_T",
  g>         size => "16",
  g>           members => [
                          ^
that should be a { if you want another anon hash.


  g>             name    => "IBIT",
<SNIP>
  g>           },


where is the { for the set of hash elements below?

  g>             name    => "SBIT",
<SNIP>
  g>             type    => "enum",
  g>           },

  g>         ],
  g>       },


check you [] and {} carefully. i can't follow what you are trying to do
here because of all the bugs in that area. the question about member
counts is meaningless unless the structure is clean.


this one looks cleaner than the first one.

  g>       AIRGROUNDLOGIC_T => {
  g>         structureName => "AIRGROUNDLOGIC_T",
  g>         size => "8",
  g>         members => [
  g>           {
  g>             name    => "ONGROUND",

<SNIP>
  g>             size    => "4",
  g>           },
  g>         ],
  g>       },

the other poster had a correct answer to how to count the members. you
could hack it into a map if you wish for a one liner but it is not worth
the effort IMO

hth,

uri


-- 
Uri Guttman                             Hacking Perl for Ironbridge Networks
uri@sysarch.com				uri@ironbridgenetworks.com	


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

Date: 9 Feb 1999 20:40:03 GMT
From: "Fuzzy " <fuzzy825@hotmail.com>
Subject: Re: Bug and cool debugging technique (5.004_04)
Message-Id: <01be546c$2d9938d0$cc34dea1@cbcgren091454>

Used it with MKS's perl 5.003 and it worked just fine.

Fuzzy

ajs@ajs.com wrote in article <79oig7$dqk$1@nnrp1.dejanews.com>...
> I've discovered a bug (causes SEGV) in 5.004_04, and was wondering if
anyone
> with quick access to 5.005 could test this for me:
> 
> for($i=0;$i<2;$i++) {
>   if ($i==1) {
>     $m++;
>     goto X; # Try to simulate switch/case drop-through
>   } elsif ($i == 0) {
>    X:
>     $m--;
>   }
> }
> 
> This crashes 5.004_04 reliably on my RedHat Linux systems. It's the goto
that
> does it.
> 
> However, while I was trying to find it, I found this really neat way of
> tracking down SEGV's (which, thankfully isn't all that useful for perl,
in
> the general case):
> 
> $SIG{SEGV}=sub{ package foo; use Carp; croak("SEGV") };
> 
> This line will cause perl to tell you what perl code was executing when
the
> interpreter woofed it's cookies, because it puts the signal handler in a
> different package. croak() reports the first caller in a different
package, so
> it finds the code that gacked.
> 
>    -AJS
> 
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own  
 
> 


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

Date: Tue, 09 Feb 1999 21:53:29 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: callback functions
Message-Id: <slrn7c1bl1.56.alastair@calliope.demon.co.uk>

Kbulgakov <kbulgakov@aol.com> wrote:
>How are arguments passed to a callback function in Perl/Tk?

comp.lang.perl.tk

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Tue, 09 Feb 1999 13:02:25 -0800
From: Aaron Tavistock <aarontav@cs.berkeley.edu>
Subject: Re: Converting CSV to LDIF
Message-Id: <36C0A261.89E534EC@cs.berkeley.edu>

What is a CSV file?

I've done alot of scripts for converting other formats into LDIF, but I
have no idea what CSV is.


Aaron Tavistock

Martin Lvnnar wrote:
> 
> Hi,
> 
> Is there a script/module to quickly convert CSV files to LDIF files?
> 
> /martin lvnnar


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

Date: Tue, 09 Feb 1999 21:31:39 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Converting CSV to LDIF
Message-Id: <%O1w2.51$SX1.720@newsfeed.slurp.net>

Aaron Tavistock (aarontav@cs.berkeley.edu) wrote:
: What is a CSV file?

"Comma separated values".  Typically, in addition to commas separating
values, values may be double-quoted strings to protect internal commas,
and double quotes inside such strings may be backslashed to protect them.

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "The hills were burning, and the wind was raging; and the
       clock struck midnight in the Garden of Allah."


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

Date: Tue, 09 Feb 1999 19:57:48 GMT
From: droby@copyright.com
Subject: Re: cookies pointers
Message-Id: <79q3vm$phv$1@nnrp1.dejanews.com>

In article <36c05ba9.3572797@news.frognet.net>,
  mtoledo@frognet.net (Matt) wrote:
> On Mon, 8 Feb 1999 10:13:50 +1100, Patrick Fong
> <patfong@yoyo.cc.monash.edu.au> wrote:
>
> >I dont think you can use Perl to read and write cookies... then again I am
> >newbie :-).
>
> There is a perl library that you can use that automates a lot of
> cookie handling.  I found it at...
>
>  HTTP Cookie Library           Version 2.1
>
>  Copyright 1996 Matt Wright    mattw@worldwidemart.com
>

There's another.  And you can find it on your system, if you're using a recent
version of Perl.  It's called CGI.pm, and was written by a programmer with a
much better track record.

--
Don Roby

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


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

Date: Tue, 9 Feb 1999 16:49:54 -0500
From: Matthew Whitworth <mgwhit@ibm.net>
Subject: determining number of returned rows in DBI.pm...
Message-Id: <Pine.SOL.4.05.9902091509420.2090-100000@galaga.rs.itd.umich.edu>


I'm having trouble determing the number of rows returned by a SELECT
statement using DBI and DBD::Oracle before I actually start calling
$sth->fetchrow().

I've looked at example code where the author checks $sth->rows immediately
after calling $sth->execute, but when I do that the value of $sth->rows eq
"DBI::st=HASH(0xb68b0)->rows" -- not really what I had in mind!

Here's some sample code and output:

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

use diagnostics;
use DBI;

my $dbh = DBI->connect( "dbi:Oracle:satest",
                     "system",
                     $ARGV[0],          # send on the command line...
                     {
                         RaiseError => 1,
                         AutoCommit => 0
                     }
                   ) || die $DBI::errstr;

my $sql = "SELECT name FROM customers WHERE pexec = 'mgwhitw'";
my $sth = $dbh->prepare($sql);
die "$DBI::errstr\n" unless $sth;
$sth->execute();

if ( $sth->rows ) {

    while ( my @row = $sth->fetchrow() ) {
        print @row, "\n";
    }

} else {
    print "no rows returned.", "\n";
    print '$sth->rows =', "$sth->rows", "\n";
}

$sth->finish;
$dbh->disconnect;

-----

nobhill:/usr/local/apache/htdocs/satest$ ./rowtest.pl mypassword
no rows returned.
$sth->rows =DBI::st=HASH(0xb68b0)->rows

-----

If I remove the "if ( $sth->rows )" bit, it actually prints out the values
of several rows.

-----

nobhill:/usr/local/apache/htdocs/satest$ ./rowtest.pl mypassword
Bobs Ribs
City of Bakersfield Trash Management
Scribble.com

-----

Any ideas?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
matthew whitworth
mgwhit@ibm.net




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

Date: Tue, 09 Feb 1999 21:45:00 +0100
From: Thijs <T.Elenbaas@stud.tue.nl>
Subject: extracting data from returned script
Message-Id: <36C09E4C.9E8E146B@stud.tue.nl>

Hello,

I have a problem. I want to submit a form to a site and grab the
returned page, so that
I can extract the info I want. Is this possible, and if so, can someone
please help me,

Thanx,

   Thijs



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

Date: 09 Feb 1999 22:02:09 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: extracting data from returned script
Message-Id: <83hfsvffzi.fsf@vcpc.univie.ac.at>

Re: extracting data from returned script, Thijs
<T.Elenbaas@stud.tue.nl> said:

Thijs> Hello, I have a problem. I want to submit a
Thijs> form to a site and grab the returned page, so
Thijs> that I can extract the info I want. Is this
Thijs> possible, and if so, can someone please help
Thijs> me,

You don't mention perl anywhere but I assume you
want to do this in perl.

Most of what you'll need to know is in:

    perldoc LWP
    perldoc LWP::UserAgent
    perldoc HTTP::Request

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien.  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Tue, 09 Feb 1999 15:31:42 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Larry Rosler <lr@hpl.hp.com>
Subject: Re: HELP on assoc. array
Message-Id: <36C09B2E.4F175118@giss.nasa.gov>

Larry Rosler wrote:
> 
> [Posted and a courtesy copy mailed.]
> 
> In article <36C055FA.C77480E1@giss.nasa.gov> on Tue, 09 Feb 1999
> 10:36:26 -0500, Jay Glascoe <jglascoe@giss.nasa.gov> says...
> ...
> > hi.  Attached, please find a cleaned up version of your code.
> ...
>
> <SNIP> about 1000 lines of PostScript!
> 
> And I though vcards were bad...
> 

yes.  Many apologies to usenet readers worldwide.
I shouldn't have wasted bandwidth on a silly postscript
file which merely repeated the accompanying ASCII
file (ah, but it had colors...)

	Jay Glascoe
--
http://www.giss.nasa.gov


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

Date: Tue, 09 Feb 1999 20:59:58 GMT
From: droby@copyright.com
Subject: Re: Help with @array
Message-Id: <79q7k8$ss5$1@nnrp1.dejanews.com>

In article <79pijo$fuu@bmw.hwcae.az.Honeywell.COM>,
  "gip" <gibsonc@aztec.asu.edu> wrote:
> The problem, I believe, is how you're specifying an element of an array.
>
> >      @item_array[$count] = $skuid;
>
> Should be $item_array[$count] = $skuid;
>

I don't believe it.

You're right that this should be changed, but Perl gives a "better written as"
warning (if you're running with -w) and does the right thing.

His problem, as others have already noted, was probably just a typo in the
print statement.

I think there may be some other logic flaws though, and I suspect what the
original poster may really want is a hash with $skuid as key and $quantity as
value.

--
Don Roby

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


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

Date: Tue, 09 Feb 1999 21:50:14 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Helpdesk script
Message-Id: <slrn7c1beu.56.alastair@calliope.demon.co.uk>

Esben Fjord <efn@aakb.bib.dk> wrote:
>Does anyone know a good helpdesk script writen in perl and easy to
>implement on a Windows NT server?

These people have an application called Keystone ;

http://www.stonekeep.com/

I haven't tried it personally (I wrote my own!) ... but might.

HTH.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Tue, 9 Feb 1999 15:38:05 -0500
From: "Ronald Lamb" <rlamb@compuserve.com>
Subject: Re: How do I get local IP Address ?
Message-Id: <O2GOwqGV#GA.297@ntawwabp.compuserve.com>

>Of course, the absence of semicolons on the first two statements rather
>indicates that your presumption about testing is correct anyhow.  :-)
>
Actually, it was my cutting and pasting that was flawed.

Ron




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

Date: 9 Feb 1999 21:33:07 GMT
From: Hemant Shah <shah@xnet.com>
Subject: How to calculate number of working days?
Message-Id: <79q9ij$kta$1@flood.xnet.com>


Folks,

   I am looking for algorithm/module to calculate number of workdays,
   given a start date and end date. A work day is Mon through Fri. I do
   not care about holidays, count them as workday.
   
   Example:
      Start 06-29-1999
      End   07-06-1999
      
      6 working days
      
   Thanks in advance.

-- 
Hemant Shah                           /-------------------\    ^~~~~^
E-mail: NoJunkMailshah@xnet.com       |TECHNOLOGY         |    |    |
                                      |No place for wimps |   o|-OO-|o
TO REPLY, REMOVE NoJunkMail           |          -Dilbert |--- | () |
FROM MY E-MAIL ADDRESS.               \-------------------/    |    |
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind,                Above opinions are mine only.
it's backed up on tape somewhere.      Others can have their own.


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

Date: Tue, 09 Feb 1999 21:41:49 GMT
From: wil <wmwilson1@go.com>
Subject: lists within hashes
Message-Id: <79qa2r$v7n$1@nnrp1.dejanews.com>

I'm having a hell of a time trying to do this..although frankly I'm not even
sure that you're allowed to.  This is my first perl script so please be
gentle.

Can someone tell me how to do this, basically I'm using getopts and trying to
match the command-line arguement that's given with a matching list located
within a hash, but all I get from it is the first hostname (i.e. athena)

command line is meant to look like:
        $progname -p AIX


#!/usr/bin/perl

use strict;
use vars qw($opt_p);
use Getopt::Std;
use diagnostics;

my %presets = (	AIX	=> 	qw(athena atlas dev sat titan detroit
		      		la laredo miami newark savannah seattle),
		SUN 	=>	qw(eclipse sol scprod scdev),
		FIELD	=>	qw(detroit la laredo miami newark
				savannah seattle),
		OTHER 	=>	""	);

my @hosts = ();

getopts('p:');

if(defined($opt_p)) {

	@hosts = $presets{$opt_p};
	&check_hosts;

--------snip------blah, blah blah

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


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

Date: Tue, 09 Feb 1999 21:25:19 GMT
From: mattd@ukcc.uky.edu
Subject: Matching elements in arrays or hashes?
Message-Id: <79q93i$u7d$1@nnrp1.dejanews.com>

Can the following be used to find matching elements in arrays or hashes?

@matching = grep { /@some_array/ } @data;

Here is the scenario: I have two files. One file contains one entry per
line data. Here is an example:

123abc
456def
789efg

In the other file is data of the following:

19990204^23:23:23^text^123^text^02/04/99^22:22:22^00405555^123abc^text
19990204^23:23:23^text^123^text^02/04/99^22:22:22^00405555^456def^text
19990204^23:23:23^text^123^text^02/04/99^22:22:22^00405555^789efg^text
19990204^23:23:23^text^123^text^02/04/99^22:22:22^00405555^123abc^text
19990204^23:23:23^text^123^text^02/04/99^22:22:22^00405555^456def^text

I would like to take each element of the first file and compare it to
the ninth field of the second file and calculate the number of
occurrences. Then, add all those numbers to get a total value for
occurrences of elements in file A for file B.

I have tried the following. I know that it isn't the best way to go
about this. What would work better, be more efficient?

### ---- Begin Code ---- ###

#!C:\perl\bin\perl -w

$/ = "\n";
$file = "$ARGV[0]";
$file2 = "$ARGV[1]";
@macs = ();
open(FILE,"<$file") || die "Can't open $file: $!\n";
@macs = <FILE>;
close(FILE);


open(TEMP,">temp.log") || die "Can't write file: $!\n";
open(LOG,"$file2") || die "Can't open $file: $!\n";
while(<LOG>) {
        foreach $mac (@macs) {
                $mac =~ s/^\s*(.*?)\s*$/$1/;
                if ($_ =~ /$mac/) {
                        #print TEMP "$line";
                         print "$_";
                }
        }
}
close(LOG);
close(TEMP);

$lines = 0;
open(TEMP2, "temp.log") || die "Can't open file: $!\n";
while (sysread TEMP2, $buffer, 24576) {
        $lines += ($buffer =~ tr/\n//);
        print "There are $lines lines\n";
}
close(TEMP2);

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


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

Date: 9 Feb 1999 20:24:39 GMT
From: "Fuzzy " <fuzzy825@hotmail.com>
Subject: Re: Newbie: Help to convert korn script
Message-Id: <01be546a$07144cb0$cc34dea1@cbcgren091454>

Having little idea what your'e trying to do w/ the script below (haven't
read the Korne shell chapter yet in my shell book), I can tell you this --
Perl is many many more times powerful than any of the shell scripting.

Fuzzy

Jim Hutchison <jimhutchison@metronet.ca> wrote in article
<36bf6e3a.28409160@news1.cal.metronet.ca>...
> As a newbie to perl, I'm still trying to wrap my head around the
> language.  I'm VERY used to ksh - piping, standard in/out, etc.  Maybe
> perl has these too, but they haven't jumped up & bit me yet.
> 
> I'd like advice from someone who has good knowledge of Unix scripting
> to offer suggestions on the following script.
> 
> 
>
----------------------------------------------------------------------------
-------
> #!/bin/ksh
> # Un-comment to de-bug.
> #set -x
> 
> read LINE
> while [[ $LINE != "" ]]
> do
>    set -A L $(echo $LINE)
>    IP=${L[0]}
>    URL=$(echo ${L[6]} | cut -d\/ -f1,2,3 | sed "s/\"//g")
>    BYTES=${L[8]}
>    HOUR=$(echo ${L[3]} | cut -d\: -f2)
>    echo "$IP $URL $BYTES $HOUR"
>    read LINE
> done
>
----------------------------------------------------------------------------
--------
> 
> Obviously, it accepts a piped file and selects only the wanted fields.
> The file sent to it is a proxy log for which I've written a fairly
> elaborate reporting tool (...in ksh!), but when the log is fed to this
> script, it takes 10 hrs to run.  I would assume that a perl script
> would simply open the log file & process it, as opposed to feeding the
> log file to a perl script one line at a time... right?
> 
> I certainly appreciate any help.
> 
> 
> =+=+=+=+=+=+=+=+=+=+=+=+=+=+=
> Jim Hutchison
> Senior Unix Network Analyst
> MetroNet Communications
> Calgary AB Canada
> T2P-3Y7
> 
> 
> 
> Help Wanted: Telepath. You know where to apply.
> 
> 


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

Date: Tue, 09 Feb 1999 16:27:50 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: jimhutchison@metronet.ca
Subject: Re: Newbie: Help to convert korn script
Message-Id: <36C0A856.40F9B54A@giss.nasa.gov>

Jim Hutchison wrote:
> 
 ...
> I'd like advice from someone who has good knowledge of Unix scripting
> to offer suggestions on the following script.

OO, oo!  here, let me try:

-------------------------------
# define the main routine
sub main
{
	# here's our loop
	while (<>)
	{
		my @split = split / +/;
		my $IP = $split[0];
		my $URL = join "/", (split /\//, $split[6])[0..2];
		my $BYTES = $split[8];
		my $HOUR = (split /:/, $split[3])[1];
		print "$IP $URL $BYTES $HOUR\n";
	}
}

# now go ahead and call "main"
main();
-------------------------------


NB: "HOUR" and "URL" are derived in a very weird way.  Normally
you would leverage an "s///" or "m//" style pattern matching
to keep/throw out whatever patterns you like/don't like.

> Obviously, it accepts a piped file and selects only the wanted fields.

oaky, so write the above into "foo.pl", then do
$ perl foo.pl < input_thingy

> The file sent to it is a proxy log for which I've written a fairly
> elaborate reporting tool (...in ksh!), but when the log is fed to this
> script, it takes 10 hrs to run.  I would assume that a perl script
> would simply open the log file & process it, as opposed to feeding the
> log file to a perl script one line at a time... right?

okay, you can do this:

	# in main
	local *FH = open "< input_thingy" or die "can't open thingy: $!";

	# the loop becomes
	while (<FH>)
	# ...

> I certainly appreciate any help.
> 

I hope this is helpful.


	Jay
--
http://www.giss.nasa.gov/cgi-bin/csci/change.pl


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

Date: Tue, 09 Feb 1999 16:43:55 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: jglascoe@giss.nasa.gov
Subject: Re: Newbie: Help to convert korn script
Message-Id: <36C0AC1B.92E60417@giss.nasa.gov>

Jay Glascoe screwed up:
> 
>         # in main
>         local *FH = open "< input_thingy" or die "can't open thingy: $!";

hrmph.

	local *FH;
	open FH, "< input_thingy" or die "can't open thingy: $!";

help-I'm-gettin'-my-Perlese-and-Pythonish-screwed-up!'ly y'rs,
Jay

BTW:
you don't *really* need the "my" declarations,
nor the "local *FH;" thing.  But without them
all the variables are global...  icky.


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

Date: Tue, 09 Feb 1999 21:49:39 GMT
From: jimhutchison@metronet.ca
Subject: Re: Newbie: Help to convert korn script
Message-Id: <36c04a69.4065090621@news.cal.metronet.ca>

Awesome!  The script ran with now trouble... hats off to your talent!
Because perl is a bit of a stretch from ksh, your script helps me
understand both the similarities and the differences between the two.

Thanks man...


On Tue, 09 Feb 1999 16:27:50 -0500, Jay Glascoe
<jglascoe@giss.nasa.gov> wrote:

>Jim Hutchison wrote:
>> 
>...
>> I'd like advice from someone who has good knowledge of Unix scripting
>> to offer suggestions on the following script.
>
>OO, oo!  here, let me try:
>
>-------------------------------
># define the main routine
>sub main
>{
>	# here's our loop
>	while (<>)
>	{
>		my @split = split / +/;
>		my $IP = $split[0];
>		my $URL = join "/", (split /\//, $split[6])[0..2];
>		my $BYTES = $split[8];
>		my $HOUR = (split /:/, $split[3])[1];
>		print "$IP $URL $BYTES $HOUR\n";
>	}
>}
>
># now go ahead and call "main"
>main();
>-------------------------------
>
>
>NB: "HOUR" and "URL" are derived in a very weird way.  Normally
>you would leverage an "s///" or "m//" style pattern matching
>to keep/throw out whatever patterns you like/don't like.
>
>> Obviously, it accepts a piped file and selects only the wanted fields.
>
>oaky, so write the above into "foo.pl", then do
>$ perl foo.pl < input_thingy
>
>> The file sent to it is a proxy log for which I've written a fairly
>> elaborate reporting tool (...in ksh!), but when the log is fed to this
>> script, it takes 10 hrs to run.  I would assume that a perl script
>> would simply open the log file & process it, as opposed to feeding the
>> log file to a perl script one line at a time... right?
>
>okay, you can do this:
>
>	# in main
>	local *FH = open "< input_thingy" or die "can't open thingy: $!";
>
>	# the loop becomes
>	while (<FH>)
>	# ...
>
>> I certainly appreciate any help.
>> 
>
>I hope this is helpful.
>
>
>	Jay
>--
>http://www.giss.nasa.gov/cgi-bin/csci/change.pl



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

Date: 09 Feb 1999 14:58:47 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Perl 'zine
Message-Id: <39vhhbcps8.fsf@ibnets.com>

>>>>> "JTJ" == John T Jarrett <jjarrett@ecpi.com> writes:

  JTJ> Also, when it came in print, we could have a page for Perl Monger
  JTJ> groups and their activities; a page for the Perl Institute with
  JTJ> current projects, a project highlight, and request for project
  JTJ> leaders; a sidebar on the future of perl. As far as Perl
  JTJ> Institute's trying to get Perl better recognized, I think an
  JTJ> effort like this would go a tremendous way toward doing that.

you guys are asking for a mess o'trouble. i know the publisher of tpj
and how much work he puts in for just a quarterly. also tpj does cover
all platforms, perl news, perl institute stuff and much more. he doesn't
want to issue it more often because of the work load. if you all
volunteered to help him then tpj could come more often (say bimonthly at
first and later monthly) but publishing a glossy linux journal type rag
is a major fulltime enterprise with big bucks needed and many
advertisers.

be careful what you ask for as you might need to produce it!

uri

-- 
Uri Guttman                             Hacking Perl for Ironbridge Networks
uri@sysarch.com				uri@ironbridgenetworks.com	


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

Date: Tue, 09 Feb 1999 14:33:05 -0500
From: "John T. Jarrett" <jjarrett@ecpi.com>
To: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Perl 'zine
Message-Id: <36C08D71.95DD66BC@ecpi.com>

Whoa, there. 2 of us admitted we ain't seen no TPJs but would love to and one has. I has
seen dem whatchocallit - table o'contents, there, and it'uz purdy empressive. Ain't none
o'us said TPJ was "narrow" - its juss that some o'us is such bloomin idgits compared to
you learn'd folk dat we need mo help.

Ain't none o'us mean no disrespect - we jus' like helpin folk and wud like ta get maybe
helped ou'selves abit faster. And if yoos lucky, maybe dem nice folks at Perl Mag'll get
you ta writ down some articles insteada me, huh?

I still look forward to getting a TPJ when it comes out

John T. Jarrett



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

Date: Tue, 9 Feb 1999 16:25:36 -0500
From: "Abukar Mohamed" <abukar@insidewire.com>
Subject: perl floating points
Message-Id: <36c0a703.0@diana.idirect.com>

Hi

How can I force a value like 8.9 to apear or print on the
screen as double or float value like 8.90 without using
printf function

My point is to print

$value=8.9;
$order=<<MOO
$value
MOO

on the screen as 8.90

if there is a way a can do it please email me.

Thanks

Abukar




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

Date: Tue, 09 Feb 1999 21:36:27 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: perl floating points
Message-Id: <36cea862.615966120@news.ford.com>

On Tue, 9 Feb 1999 16:25:36 -0500, "Abukar Mohamed"
<abukar@insidewire.com> wrote:

>Hi
>
>How can I force a value like 8.9 to apear or print on the
>screen as double or float value like 8.90 without using
>printf function
>
>My point is to print
>
>$value=8.9;
>$order=<<MOO
>$value
>MOO
>
>on the screen as 8.90
>
>if there is a way a can do it please email me.

You want a formatted print statement, without using printf?
'Natch:

$value=8.9;
$order=<<MOO;     # You forgot the semi
${value}0
MOO

Taa daa!!!  Thank you.  Thank you very much.  Not using printf is just
sillyness.  You might as well just hard-code everything and start
writing floats by hand....

IF what you're trying to avoid is having that printf() fall in the
middle of a string (<<MOO) then, why don't you just carry around
$value as a string, not a decimal?

$value=8.9;  $value=sprintf("5.2f", $value);
print<<MOO;
$value;
MOO

Perl doesn't care about how you spruce it up.  If ya wanna call it a
string...it's a string.  If ya wanna call it a float...it's a float.  




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

Date: Tue, 09 Feb 1999 15:53:32 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: perl floating points
Message-Id: <36C0AE5C.D47B5B32@us.ibm.com>

Abukar Mohamed wrote:

> How can I force a value like 8.9 to apear or print on the
> screen as double or float value like 8.90 without using
> printf function
> 
> My point is to print
> 
> $value=8.9;
> $order=<<MOO
> $value
> MOO
> 
> on the screen as 8.90

$ perldoc -f sprintf

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

my $value = 8.9;
$value = sprintf "%4.2f", $value;
print <<FOO;
$value
FOO


-- 
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)


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

Date: Tue, 9 Feb 1999 20:42:18 -0000
From: "el_pollo_diablo" <bencas@bigfoot.com>
Subject: Re: please,please,please help me for my sanity. SSI execing?
Message-Id: <79q6ju$kut$1@news7.svr.pol.co.uk>

Right i type this into navagators url bar and it works!

http://www.arc-interactif.com/cgi/headlines.pl?county=devon

How do i put this into a web page?

--
---
Ben
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
         ${qq$\x5F$} = q 97265646f9 and s g..g;
         qq e\x63\x68\x72\x20\x30\x78$&eggee;
         {eval if $a =~ s e..eqq qprint chr 0x$& and
\x71\x20\x71\x71qeexcess}'
el_pollo_diablo <bencas@bigfoot.com> wrote in message
news:79q3c7$hio$1@news6.svr.pol.co.uk...
>Yup I tried the things below. I've replaced the copt of the program with
the
>one posted. The chap whos made a recent post says that the program works by
>using the full url instead of an SSI what does this mean and how do i do
it?
>
>Thanks for your help everyone.
>---
>Ben
>
>John T. Jarrett <jjarrett@ecpi.com> wrote in message
>news:36C07FF1.A5B5ED89@ecpi.com...
>>Did you try the various things in your previous thread? What results
and/or
>>error messages did you get?
>>
>>If you forgot to check your earlier thread, it is still below with several
>>solutions offered.
>>
>>John T. Jarrett
>>
>>
>
>




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

Date: Tue, 09 Feb 1999 22:51:42 +0100
From: Frank de Bot <debot@xs4all.nl>
Subject: Prevent showing header
Message-Id: <36C0ADED.83B01328@xs4all.nl>

I want to excute another perl with: do(file.pl); or require(file.pl);
How can I prevent from showing the header from that script. The script
file.pl uses for showing the scripts Without Query_string and for
redirect with the Query_string.



Thanks,





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

Date: Tue, 09 Feb 1999 15:37:51 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Question: Arrays of associative arrays
Message-Id: <36C0AAAF.8EE1FF80@us.ibm.com>

Clinton Pierce wrote:
 
> On Mon, 08 Feb 1999 15:26:35 -0600, James Ludlow <ludlow@us.ibm.com>
> wrote:
> >In the meantime, don't forget that www.perl.com has links to all of the
> >Perl documentation and the faq.  In some respects, it's more convenient
> >to use than perldoc.  (Still install a full version of perl though.
> >It's a _good_ idea.)
> 
> http://www.perl.com is becoming a poorer and poorer Perl Resource
> portal than it was.  For example there are no longer pointers to
> binary distributions of Perl.  (The development community taking the
> holier-than-thou road, according to the distribution page.)

Ok.  It still has the basic documentation and the faq.  I don't see how
not providing binaries makes it any less useful for reading about Perl
syntax.

-- 
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)


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

Date: Tue, 09 Feb 1999 21:30:50 GMT
From: chris_bordeleau@lotus.com
Subject: Regular expressions and handleing new lines
Message-Id: <79q9ea$ukq$1@nnrp1.dejanews.com>

I want to have a regular expression which can scan for C++ style /* Comments
*/ and am having a hard time dealing with newlines which ocour inside of
comments.

I am handling the entire document as one big string which contains newlines.
The new lines can not be striped out of the string. And regular expression
must be one line long (as long as I want it but only one line long). I want
to use a regular expression to do all the work and do not want to use any
special perl functions.

Here is what I have now :

open(FILE,"cstcfgn.c");
$i=0 ;

while ($LINE=<FILE>) {
	$LINES="$LINES $LINE";
}

while ( $LINES =~ (/ ((\/\*)+((^\*\/)*((.*)|(\x0A)*))?(\*\/))+/gi) ) {
	$i++;
	print "$i ::    $1 \n" ;
}
close(FILE);
print "Number of comments : $i";

Thanks for your help

Chris

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


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

Date: 9 Feb 1999 20:48:53 GMT
From: "Fuzzy" <fuzzy825@hotmail.com>
Subject: send email to NT Exhange server or post office mail
Message-Id: <01be546d$69705310$cc34dea1@cbcgren091454>

Is there a way to use perl to send mail to a user in a microsoft post
office environment?

Right now this is being done through (arrrggghhhh!!!!) a Word macro.  

Fuzzy



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

Date: Tue, 09 Feb 1999 15:12:23 -0500
From: Milos Obradovic <mobradov@newbridge.com>
Subject: Suppres special characters
Message-Id: <36C096A6.2D8A62B6@newbridge.com>

I am just begginer.
My question is how I can suppres special meaning of some characters
from the command line argument??

For example, script name is test1 and command line argument is
/N$aaa11(12).
I know that:    test1 '/N$aaa11(12)'
will do, but I would like to run it without '   '   signs,
like : test1 /N$aaa11(12).

I would realy apreciate help.

Milos Obradovic
mobradov@newbridge.com





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

Date: 9 Feb 1999 21:40:36 GMT
From: tice@hunch.zk3.dec.com (Walter Tice USG)
Subject: Re: The best way to learn C?
Message-Id: <79qa0k$inc@zk2nws.zko.dec.com>

In article <stevel-0302991547190001@192.168.100.2> stevel@coastside.net (Steve Leibel) writes:
>In article <36B8D569.14C64624@crucibledesign.com>, Aidan Rogers
><aidan@crucibledesign.com> wrote:

>> Before anyone sends me deragtory flame messages, I am fully aware that
>> this is
>> the Perl newsgroup.
 
>> I am a Perl programmer, and it is the only language I really know (and
>> love). However, I want to learn how to program in C (and eventually
>> C++),

>If you are already a programmer, then by far the best book on C is "The C
>Programming Language" by Kernighan and Ritchie.  Make sure you get the 2nd
>edition (ANSI version).  

>This book is a little difficult for a complete beginner; but for a
>programmer, this is the way to go.  Start at page 1, take your time, and
>spend a few months with this book.  You'll never regret it.  In fact it
>will make you a better Perl programmer.  After all, Perl is written in C,
>right?

>Steve L

I read the original post, and thought about it.  The answer depends on how
Aidan learns.  The K+R C book is a reference book, it's not a tutorial.
Personally I learned a lot more 'C' from 'Practical C' by Oualline published
by O'Reilly (at least it was at one time, not sure if it still is). I also
learned more from 'C How to Program' by Deitel and Deitel, who are a father/
son team based I believe in the Boston area (therefore the book may not be
in wide circulation, published by Prentice-Hall - or it was).  It does have
a lot of errors which were not caught by editing (I have the 92' edition,
so perhaps they fixed that).  

Anyway, there are so MANY books out there, maybe you should drop in to
your local well stocked bookstore, and sit down for an hour or two, and
figure out which one YOU want to learn from - as with Perl, there is more
then one way to do it.

W


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

Date: 9 Feb 1999 20:18:52 GMT
From: "Fuzzy " <fuzzy825@hotmail.com>
Subject: Re: Very Very Newbie- re: perl5.0042-bindist.04bc
Message-Id: <01be5469$35c64c80$cc34dea1@cbcgren091454>

I believe win32 perl runs on a command line.  So you should essentially see
a command line program 

perl programname.pl

Enter your name? _

That sort of thing.

You could try c:\perl\perl.exe wherever\qm

Fuzzy

ron <bmusee2@pacbell.net> wrote in article
<36c077b8.6800689@news.pacbell.net>...
> I am running Win98 and am totally new to Perl..I am trying to run a
> program that operates in Perl (quotemonster) which gathers stock data
> at the end of the day.   I downloaded perl5.0042 -bindist.04bc and
> installed it via default to C:\Perl etc.  Now my very nieve question
> is ---How do I run a program ?  The quotemonster program has the
> script but I have no concept of how to run it.   I run perl and it
> opens a dos box I then enter qm and nothing happens  can anyone tell
> me what the commands should look like and should it be in dos?
> 


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

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

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