[13038] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 448 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 10 15:07:13 1999

Date: Tue, 10 Aug 1999 12:05:16 -0700 (PDT)
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, 10 Aug 1999     Volume: 9 Number: 448

Today's topics:
    Re: *Yet another* Net::FTP question (Jason Kohles)
        <== Help with date sorting==> <khowe@performance-net.com>
    Re: <== Help with date sorting==> (Matthew Bafford)
    Re: ActivePerl PerlScript -- funny problems <cassell@mail.cor.epa.gov>
    Re: Anyone know how to use perl to parse data and gener (Matt)
    Re: Anyone know how to use perl to parse data and gener <KLeucht@bigfoot.com>
        Are PerlApp and Perl2exe the same? dakbat@hotmail.com
        array of structures skyfaye@my-deja.com
    Re: array of structures <sariq@texas.net>
    Re: array of structures n0jokeg@my-deja.com
    Re: array of structures (Larry Rosler)
    Re: Connecting to an Oracle DB with PERL 5 (Jacqui Caren) (Jacqui Caren)
    Re: Creating variables on the fly with CGI.pm? <vlad@doom.net>
    Re: Date::Manip SLOW <AgitatorsBand@yahoo.com>
    Re: DBD Driver for Lotus Notes <cassell@mail.cor.epa.gov>
    Re: exists problem <gene@tekdata.com>
    Re: finding array size <USENET@questionexchange.com>
    Re: Help - Split Function Blowing My Mind Away!! (Anno Siegel)
        HELP: Use of regular expression (Anno Siegel)
    Re: HELP: Use of regular expression (Larry Rosler)
    Re: Illegal division by zero when testing for a directo <cantrela@agcs.com>
    Re: just days away f7.8ez5.88ox <Graeme@greywall.demon.co.uk>
        Known Issues with perl <sadunuth@us.oracle.com>
    Re: list length (Randal L. Schwartz)
    Re: list length <USENET@questionexchange.com>
    Re: Pattern Matching + inlandpac@my-deja.com
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 10 Aug 1999 17:29:04 GMT
From: robobob@poseidon.8fish.com (Jason Kohles)
Subject: Re: *Yet another* Net::FTP question
Message-Id: <slrn7r0oav.gtl.robobob@poseidon.8fish.com>

On Tue, 03 Aug 1999 15:58:06 GMT, Richard Lawrence wrote:
>
It worked, really? or did it appear to work and then you added 'use strict'
to avoid the impending flame?

jason ~ 155 > perl -w ftp.pl
Global symbol "%options" requires explicit package name at ftp.pl line 7.
Execution of ftp.pl aborted due to compilation errors.

>So I tried this:
>
>#!/usr/bin/perl -w
>
>use strict;
>use Net::FTP;
>
>my @options;
    ^^^^^ This is a list

>$options{"Port"} = 99; 
    ^^^^^ This is a hash
>
>my $ftp = Net::FTP->new("somewhere.org", @options);
                                          ^^^^^^ list again

>assuming that it would fail becase the server i'm testing it on doesn't
>run FTP on port 99. Well it still worked so I can only assume that I'm
>not setting the port thing correctly.
>
Actually it failed because you didnt read the perlvar manpage

>Can anyone point me in the right direction for setting this and hence I
>can also then set the timeout option?
>

my $ftp = Net::FTP->new("somewhere.org", Port => 99, Timeout => 60);


-- 
        Jason Kohles -- jason@mediabang.com
        http://www.mediabang.com/

          "This is as bad as it can get, but don't bet on it."


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

Date: Tue, 10 Aug 1999 15:33:39 -0300
From: "Kevin Howe" <khowe@performance-net.com>
Subject: <== Help with date sorting==>
Message-Id: <7a_r3.37796$5r2.74576@tor-nn1.netcom.ca>

I am looking to sort a set of dates with the following format in
most_recent-least_recent order.

August 10, 1999
September 20, 1999
December 13, 1999

Can anyone give me an example of how I might go about it?

Thanks




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

Date: Tue, 10 Aug 1999 18:50:44 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: <== Help with date sorting==>
Message-Id: <slrn7r0sdu.cit.*@dragons.duesouth.net>

And so it happened, on Tue, 10 Aug 1999 15:33:39 -0300, Kevin Howe"
<khowe@performance-net.com> typed random characters into perl, and ended
up with the following posted to comp.lang.perl.misc: 
: I am looking to sort a set of dates with the following format in
: most_recent-least_recent order.
: 
: August 10, 1999
: September 20, 1999
: December 13, 1999
: 
: Can anyone give me an example of how I might go about it?

Year first, month second, day last.

#!/usr/bin/perl -w

my %months = (
    'January' => 0,  'February' =>  1,  'March'     =>  2,
    'April'   => 3,  'May'      =>  4,  'June'      =>  5,
    'July'    => 6,  'August'   =>  7,  'September' =>  8,
    'October' => 9,  'November' => 10,  'December'  => 11, # just in case
                                                           # we get more
                                                           # months,
                                                           # (JAL)R.
);

my @unsorted = (
    'August    10, 1999',  'September 20, 1999', 'December  13, 1999',
    'April      1, 2000',  'November   3, 1900', 'November   3, 1000',
    'November  23, 1900',  'January   21, 1994', 'May       30, 5432'
);

my @sorted   =
    map  {
        $_->[0]
    }
    sort {
        $a->[3]          <=>          $b->[3]
                         ||
        $months{$a->[1]} cmp $months{$b->[1]}
                         ||
        $a->[2]          <=>          $b->[2]                         
    }
    map  {
        [$_, split /\s*,?\s+/]
    } @unsorted;

use Data::Dumper;

print Dumper(\@unsorted, \@sorted);
__END__
 
: Thanks

HTH,

--Matthew


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

Date: Tue, 10 Aug 1999 11:47:22 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: ActivePerl PerlScript -- funny problems
Message-Id: <37B073BA.5D8B2CE1@mail.cor.epa.gov>

Nick Liebmann wrote:

[a not-quite-perfectly-accurate response, snipped by moi]
> I hope that helps

I really doubt it.  John's question was a specific one about
$main::document and ActiveState's PerlScript.  Do you know what
is causing the *actual* question he poses?

I now leave this in, so his question can be seen once again:

X> John M. Dlugosz <john@dlugosz.com> wrote in message
X> news:9AAE839D71B8FC6D.3AB3323DC4B76392.3902CF75BC3996F5@lp.airnews.net...
X> > Here is an illustration of the problem I mentioned earlier (see test.html
X> > file below).  If $main::document is assigned to, the Perl engine crashes.
X> > It doesn't even have to execute that statement -- just having it in the
X> > script is enough!  When the problem line is commented out, you will see a
X> > report on all the symbols in the main package.  'document' is not one of
X> > them.
X> >
X> > Can anybody shed some light on this, please?
X> >
X> > --John
X> >
X> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
X> > "http://www.w3.org/TR/REC-html40/strict.dtd">
X> >
X> > <html lang="en">
X> > <head>
X> >  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
X> >  <title>script testing</title>
X> >
X> >
X> > <SCRIPT LANGUAGE="PerlScript">
X> > sub foo
X> >  {
X> >  foreach $name (sort keys %main::) {
X> >     $window->document->write ("$name<BR>");
X> >     }
X> >  }
X> >
X> > sub bar
X> >  {
X> >  # this works.
X> >  $documentX= 5;
X> >  #this crashes Perl
X> > # $document= 5;     #un-comment this line to illustrate problem.
X> >  }
X> >
X> > </SCRIPT>
X> > </head>
X> >
X> > <body>
X> > <SCRIPT LANGUAGE="PerlScript">
X> > foo();
X> > # note that bar isn't called! The presence of $document= in the program is
X> > enough to cause problems.
X> > </SCRIPT>
X> > </body>

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 10 Aug 1999 18:27:53 GMT
From: mck@iag.net (Matt)
Subject: Re: Anyone know how to use perl to parse data and generate excel  reports    automatically?
Message-Id: <37b26e58.15467541@news.iag.net>

I do not think that you can use OLE do to this, because OLE and Excel
are Windows technologies. Of course, you cannot run Excel on Solaris.

One alternative method would be to write a Perl program to create the
data file in comma-delimited ASCII format (.CSV) on the Solaris box,
which Excel on a Windows PC will readily read. In fact, if I am not
mistaken, the installation of Excel sets Windows to assume .CSV files
are associated with Excel.

On Tue, 10 Aug 1999 13:46:43 -0400, Kurt Leucht <KLeucht@bigfoot.com>
wrote:

>I'm confused.  I saw an example somewhere in a perl newsgroup of using
>the Win32::OLE Module to write data into an Excel spreadsheet.  My
>question is:  Was this module written strictly for perl on Windows
>machines, or can I use it to write an Excel spreadsheet from a perl
>script on my Solaris?
>
>Thanks,
>Kurt
>(KLeucht@bigfoot.com)
>



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

Date: Tue, 10 Aug 1999 13:46:43 -0400
From: Kurt Leucht <KLeucht@bigfoot.com>
Subject: Re: Anyone know how to use perl to parse data and generate excel  reports    automatically?
Message-Id: <37B06583.6C4D5A0E@bigfoot.com>

I'm confused.  I saw an example somewhere in a perl newsgroup of using
the Win32::OLE Module to write data into an Excel spreadsheet.  My
question is:  Was this module written strictly for perl on Windows
machines, or can I use it to write an Excel spreadsheet from a perl
script on my Solaris?

Thanks,
Kurt
(KLeucht@bigfoot.com)



"Harlan Carvey, CISSP" wrote:
> 
> >
> > >     I want to know if it is possible to write a perl script that will parse
> > > throught data from a file and port extracted data into MS Excel spreadsheet.
> >
> 
> Since you specifically asked for Excel, you will need to use the Win32::OLE
> package.  Dave Roth has an excellent book available and the examples are
> in a .zip file at his web site...http://www.roth.net
> 
> The example in question is one that gathers EventLog entries from across the
> enterprise and imports the data into an Excel spreadsheet...
> 
> Carv


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

Date: Tue, 10 Aug 1999 17:37:47 GMT
From: dakbat@hotmail.com
Subject: Are PerlApp and Perl2exe the same?
Message-Id: <7opo1a$lck$1@nnrp1.deja.com>

 The subject says it all. I have seen PerlApp on ActiveState's site and
perl2exe on a seperate website (www.perl2exe.com). Are they the same?
If not does anyone know the advantages/disadvantages of each? Thanks

--

David
dakbat@hotmail.com


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 10 Aug 1999 17:36:11 GMT
From: skyfaye@my-deja.com
Subject: array of structures
Message-Id: <7opnua$lbs$1@nnrp1.deja.com>

Hi,

  I know how to create a structure using hash.
e.g.  $mystructvar = ("field1", "", "field2", "", "field3", "");

My question is how do you create an array of structures?

Thanks,
Hung



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 10 Aug 1999 13:05:34 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: array of structures
Message-Id: <37B069EE.E44B4EEE@texas.net>

skyfaye@my-deja.com wrote:
> 
> Hi,
> 
>   I know how to create a structure using hash.
> e.g.  $mystructvar = ("field1", "", "field2", "", "field3", "");
> 
> My question is how do you create an array of structures?
> 
> Thanks,
> Hung

perldoc perldsc

discusses:

- arrays of arrays
- hashes of arrays
- arrays of hashes
- hashes of hashes
- more elaborate constructs

- Tom


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

Date: Tue, 10 Aug 1999 18:18:22 GMT
From: n0jokeg@my-deja.com
Subject: Re: array of structures
Message-Id: <7opqd1$n8h$1@nnrp1.deja.com>

In article <7opnua$lbs$1@nnrp1.deja.com>,
  skyfaye@my-deja.com wrote:
> Hi,
>
>   I know how to create a structure using hash.
> e.g.  $mystructvar = ("field1", "", "field2", "", "field3", "");
>
> My question is how do you create an array of structures?
>
Each array element will be a hash reference.

@stuff =
	(
	 {
	  field1 => "",
	  field2 => "",
	 },
	 {
	  field1 => "",
	  field2 => "",
 	 },
	);

or you could go and do
$stuff[0]{'field1'}="";
$stuff[0]{'field2'}="";
etc..

You can also push new hashes onto the array and do it in a loop or
whatever.
The most important thing to understand is that $stuff[0] is a reference
(pointer) to an anonymous hash. Consult the docs for more info:
http://www.perl.com/cgi-bin/pace/pub/doc/manual/html/pod/perlref.html

~konrad


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 10 Aug 1999 11:39:28 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: array of structures
Message-Id: <MPG.121a11b69537aab9989e1e@nntp.hpl.hp.com>

In article <7opnua$lbs$1@nnrp1.deja.com> on Tue, 10 Aug 1999 17:36:11 
GMT, skyfaye@my-deja.com <skyfaye@my-deja.com> says...
>   I know how to create a structure using hash.
> e.g.  $mystructvar = ("field1", "", "field2", "", "field3", "");

No it doesn't.  Run it with the '-w' flag and you will see why.

> My question is how do you create an array of structures?

my @array_of_hash_references = map {} => 1 .. 10;

Read perldsc (Data Structure Cookbook).

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


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

Date: Tue, 10 Aug 1999 17:58:26 GMT
From: Jacqui.Caren@ig.co.uk (Jacqui Caren) (Jacqui Caren)
Subject: Re: Connecting to an Oracle DB with PERL 5
Message-Id: <FG9GLF.BMu@ig.co.uk>

In article <01beca20$fd26df60$f57db89d@mwatkins.boulder.lexmark.com>,
Mark Watkins <mwatkins@nospam.lexmark.com> wrote:
>David, 
>
>I do a very similar thing in Perl on a Sybase database.  Basically, Sybase
>has a
>program called isql which allows you to use the following command line
>options:
>isql -Uusername -Ppassword -iInputfile > tmp.file

Urghhh! I stopped doing this over five years ago?
I cannot imagine anyone having to access an RDBMS
using such tacky interfaces in this day and age...

and where is the $$ in the file name - what happens when you hit
the double hit bug in IE - you get two parrallel identical
requests one almost immediately after the first.
The above line would easily result in an emply or corrupted
tmp file...

>output to 
>This allows me to do a simple system(command) in perl and redirect the
>a file.  I then open the file in perl and parse the data into variables in
>perl.

and why not do a pipe open or use backticks? and get rid of the tmpfile.

>I assume sqlplus for Oracle has similar ways of doing this.  It may not be
>the most
>ellegant but it was WAY easier then using the ODBC library in perl.

It is also very dangerous esp when the data may have spaces, newlines
or binary data - or heaven help us NLS issues...

>I use this programming to get to the database via an intranet and generate
>queries
>through Netscape or IE5.  It works very well for the number of users I
>have.

First traditional CGI and transactional relational databases are not
a good mix.  You end up hammering the DB for even low hit rates.
For instance a simple list of values page can take say 4 secs as
CGi but (after first load) takes 0.01 secs due to cached connections
and cursors - sun IPC 12 meg ram - remote oracle and TP SCSI disk
packs. In fact one system here a mod_perl script ran faster than a
simple HTML page request - mainly due to the fact that the local
disk was quite slow and the remote oracle was very FAST...


I do not want to go into the various reason why such archiac "sqlpipe"
techniques are so dangerous. but what could be simpler than

my $csr = $dbh->prepare('select table_name
from user_tables
where table_name like ?');

my ($name,@tables);
# get AB_* table names
$csr->execute('AB_%');
while (($name) = $csr->fetchrow_array()) {
	push @tables,$name;
}

# get *_XY table names
$csr->execute('%_XY');
while (($name) = $csr->fetchrow_array()) {
	push @tables,$name;
}

$csr->finish();

I expect you could do the same with a couple of pipe/system
calls but it would take approx 5 times as long and require
a LOT more database and system resources...

DBI is a database *INDEPENDANT* interface so migration between
databases (including CSV thru to Orace/Sybase etc) becomes a
questions of SQL changes or features if any...

Once you start using cached connections and cursors
etc you find you can cut a 5 day script (N million
web pages) down to 3-7 hours runtime - and this
is mainly due to disk-bound io. raid and mirroring
helps here...

We have a DBD::Oracle system generating one seven page
full colour postscript report every second - that is
seven pages full of business quality graphs and tables
of formatted data every second.  The system was installed
(and runs on) three desktop suns...

So, using DBI can save you a lot of time effort and
give a major poerfomrance boost if your are prepared to
read the friendly manual...

See Tim Bunces session on DBI and the Web at the perl
conference for more information.

Jacqui
-- 
Paul Ingram Group Ltd,140A High Street,Godalming GU7 1AB United Kingdom
Email: J.Caren@ig.co.uk Fax: +44 1483 419419 Phone: +44 1483 424424
A rather special Perl vacancy :-) http://www.ig.co.uk/about/jobs.html
Use SmartCards in e-commerce systems? http://www.smartaxis.com/



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

Date: 10 Aug 1999 13:25:09 GMT
From: <vlad@doom.net>
Subject: Re: Creating variables on the fly with CGI.pm?
Message-Id: <7op97l$5g6$1@news.servint.com>

Abigail <abigail@delanet.com> wrote:
> 83 chars. Again. Enough of this bullshit.
> *ploink*


Whatever Abigail, I can't believe you have nothing better to do than sift through posts
and and and make lame remarks like the above.  If you have nothing useful to say, then
don't say it.  Or better yet don't read any of my posts...

Oops 88 chars...oh no!

-v


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

Date: Tue, 10 Aug 1999 17:36:52 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: Date::Manip SLOW
Message-Id: <UqZr3.1335$EG4.232173@news.shore.net>

Stone Cold <paulm@dirigo.com> wrote:
: I'm using the Date::manip module to print a range of dates (e.g. Jan-
: 99, Feb-99, Mar-99, etc).  I'm finding, though, that this modules
: really slowed down my CGI program.  Before I started using the module,
: my output would come up in browser pretty fast.

: So, does anyone know how to speed up the date::manip module?

I don't think it can be sped up since it's a huge honking module that does
everything under the sun (regarding dates). There are, however, a large
number of other, more specialized date modules available (as standard
modules or on CPAN) that may be more suited to your particular needs.

--Art

-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: Tue, 10 Aug 1999 11:51:00 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: DBD Driver for Lotus Notes
Message-Id: <37B07494.E53A7ABE@mail.cor.epa.gov>

Declan wrote:
> Has anyone come across a DBD driver for Lotus Notes?

I don't have an answer for you, but I do have a pointer.
I think this has been discussed on the win32-perl-users listserv
which is archived at ActiveState [ www.activestate.com ].
You can also subscribe to this listserv (and others, including
a database one) at
http://www.activestate.com/support/mailing_lists.htm

You can make your own guess why they have the mailing lists 
under 'support'.  :-)

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 10 Aug 1999 13:11:10 -0500
From: Gene LeFave <gene@tekdata.com>
Subject: Re: exists problem
Message-Id: <37B06B3E.3F8879A0@tekdata.com>

The exact error log is:
 .     Premature end of script headers 
 .     Syntax error in file ... at line 68,
 .     next 2 tokens  " exists $in"
 .     Execution of  ...  aborted due to compilation errors.

Gene

Anno Siegel wrote:
> 
> Gene LeFave  <gene@tekdata.com> wrote in comp.lang.perl.misc:
> >Tom,
> >
> >Thanks for your reply.   I finally located the error log and perl gives
> >a message about illegal tokens  exists $in
> 
> Could you reproduce the error message exactly?  "token" appears
> exactly once in perldiag, and not in a message.
> 
> >Is it possible that the exists function doesn't exist in earlier
> >versions?   Since I found it in a perl book on version 5 I thought it
> >would work on all 5.x versions.
> 
> It's been around far longer than perl5.
> 
> >This is only one line in pages of perl code so I can't really change the
> >way $in is used.   It is created by a cgi library script.  I have
> >searched numerous books, online samples, etc.  and I can't find any
> >other way to do this.  The problem is that I need to distinquish between
> >the Econf parameter being present or not.  If it is present a null value
> >is perfectly acceptable.   In other places in the source the phrase:
> >
> >     $something  = $in {'something'}
> >is used frequently.    I originally used this but there is no
> >distinction that I can be find between   $in{'something'} =  ""    and
> >$in{'something'} being undefined.
> 
> With respect to hashes, you can distinguish three situations. This is
> explained in perldoc -f exists.  To quote:
> 
>     print "Exists\n"    if exists $array{$key};
>     print "Defined\n"   if defined $array{$key};
>     print "True\n"      if $array{$key};
> 
> So you can tell the difference between a '' value and an undefined
> value.
> 
> >Since the script is in an application that we supply to hundreds of
> >customers, it is extremely desirable that it works in all 5.x perls'. So
> >I'm looking for a version insensitive way to do this.
> 
> It's certainly not the perl version that is the problem, except
> you have a buggy build (*very* unlikely).
> 
> Anno


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

Date: 10 Aug 1999 19:3:22 GMT
From: QuestionExchange <USENET@questionexchange.com>
Subject: Re: finding array size
Message-Id: <693qx@questionexchange.com>

> It's easy to find the size (in bytes) of a file with -s.   How
> do you find the size of an array or a splice?  how could I, for
> example, take 400 bytes of an array?  thanks and apologies if
> this is in any of the FAQs - I couldn't find it.  Margaret

You cannot find the size of an array in  bytes. You can find
the number of elements and then use functions like split,
splice, join to manipulate arrays.

-- 
  This answer is courtesy of QuestionExchange.com
  http://www.questionexchange.com/servlet1/showUsenetGuest?ans_id=2444&cus_id=USENET&qtn_id=1680


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

Date: 10 Aug 1999 17:23:24 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Help - Split Function Blowing My Mind Away!!
Message-Id: <7opn6c$nmn$1@lublin.zrz.tu-berlin.de>

Larry Rosler <lr@hpl.hp.com> wrote in comp.lang.perl.misc:
>In article <7op9q6$n84$1@lublin.zrz.tu-berlin.de> on 10 Aug 1999 
>13:35:02 -0000, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> says...
>> Larry Rosler <lr@hpl.hp.com> wrote in comp.lang.perl.misc:
>> 
>> >Write that line thus:
>> >
>> >     @record = split(/\|/, $_[0]);
>> >
>> >And all will be well.  (This is on my Top Ten list of Perl surprises for 
>> >beginners.  The vertical bar is a popular field separator!)
>> 
>> A case of "Ceci n'est pas une pipe"?
>
>You bet it isnt.  It is ASCII VL (vertical line).  Calling it a 'pipe' 
>(as the poster did, and which I refused to echo) boggles one's mind with 
>irrelevant semantics from an unrelated domain.

The twisted logic in that quote allows me to reply: Why, that's
what I said.

Anno


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

Date: 10 Aug 1999 17:09:25 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: HELP: Use of regular expression
Message-Id: <7opmc5$nl9$1@lublin.zrz.tu-berlin.de>

Dominique Crétel  <dominique.cretel@cfwb.be> wrote in comp.lang.perl.misc:
>Hi,
>
>I have a problem on determining a RE:
>
>I use UNPACK function with the format "A11A12A256A12A41A31".
>
>I would like to sum every length field "A" with a RE (for example, the
>result of this format should be 363).
>
>I have tried this but it isn't very powerfull!
>------code-------------------------------------------
>#!/usr/bin/perl
>$format = "A11A12A256A12A41A31";
>@t = split(/A/, $format); $len = 0;
>for $x (@t) {$len += $x;}
>print "somme=$len\n";
>------code-------------------------------------------
>
>How can I manage this?

Well, basically your code looks fine to me.  I have to mention that
you run without -w and don't use strict.  Union rules, you know?

Otherwise, the only problem I see is that you are getting an
initial empty string in @t because the format begins with a
delimiter[1].  This *will* cause a warning when -w is in place, but
the result should be what you expect.  How does the code not work
as intended?

Anno

I think TomC isn't looking, so maybe I can get away with that.


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

Date: Tue, 10 Aug 1999 11:25:06 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: HELP: Use of regular expression
Message-Id: <MPG.121a0e5bae97a160989e1d@nntp.hpl.hp.com>

In article <7opmc5$nl9$1@lublin.zrz.tu-berlin.de> on 10 Aug 1999 
17:09:25 -0000, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> says...
+ Dominique Crétel  <dominique.cretel@cfwb.be> wrote in 
comp.lang.perl.misc:
 ...
+ >I use UNPACK function with the format "A11A12A256A12A41A31".
+ >
+ >I would like to sum every length field "A" with a RE (for example,
+ >the result of this format should be 363).
+ >
+ >I have tried this but it isn't very powerfull!
+ >------code-------------------------------------------
+ >#!/usr/bin/perl
+ >$format = "A11A12A256A12A41A31";
+ >@t = split(/A/, $format); $len = 0;
+ >for $x (@t) {$len += $x;}
+ >print "somme=$len\n";
+ >------code-------------------------------------------
+ >
+ >How can I manage this?
+ 
+ Well, basically your code looks fine to me.  I have to mention that
+ you run without -w and don't use strict.  Union rules, you know?
+ 
+ Otherwise, the only problem I see is that you are getting an
+ initial empty string in @t because the format begins with a
+ delimiter[1].  This *will* cause a warning when -w is in place, but
+ the result should be what you expect.  How does the code not work
+ as intended?

Try it with a regex instead of split().  No warnings!

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

my $format = 'A11A12A256A12A41A31';
my $len = 0;
$len += $1 while $format =~ /A(\d+)/g;
print "somme=$len\n";

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


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

Date: Tue, 10 Aug 1999 11:07:22 -0700
From: Andy Cantrell <cantrela@agcs.com>
To: Greg Miller <gregjm@sr.hp.com>
Subject: Re: Illegal division by zero when testing for a directory??
Message-Id: <37B06A5A.5AD0D8B5@agcs.com>


 On a hunch, try the following:

 $LOGSDIR="$LOC_DIR/actual/$PLATFORM/logs" ;
 if (-d $LOGSDIR) {
   # some action
 };
 
 See if the errors follows the assignment location.
 I run into this sort of monkey business from time to
 time and end up finding out that I have mismatched
 quotes (to state the obvious: this would make the code
 following the first quote look like a division by
 zero)

Greg Miller wrote:
> 
> Hi,
> 
> This morning I came in to see that my nightly tests reported
> the following error:
> 
> Illegal division by zero at runsession.pl line 968, chunk 1.
> 
> Hmmm....Here is the line that it choked on:
> ------------------------------------------
> 
> if (-d "$LOC_DIR/actual/$PLATFORM/logs")
> {$LOGSDIR="$LOC_DIR/actual/$PLATFORM/logs";}
> 
> How in the heck could this produce the division by zero?..Must be some
> kind of NFS issue?...
> 
> -Greg

-- 
Andy Cantrell  - cantrela@agcs.com
AG Communication Systems
Office (AZ) (623) 582-7495 (Voice mail)
Office (WI) (414) 249-0215
Modem  (WI) (414) 249-0239


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

Date: Mon, 09 Aug 1999 20:29:48 +0100
From: Graeme Wall <Graeme@greywall.demon.co.uk>
Subject: Re: just days away f7.8ez5.88ox
Message-Id: <67ab62f49%Graeme@greywall.demon.co.uk>

In message <37ADE300.BFD524D@virgin.net>
          Gary Jones <gazza.jones@virgin.net> wrote:

> Graeme Wall wrote:
> > 
> > In message <5IIq3.4770$dE1.6107@newreader.ukcore.bt.net>
> >           "Michael Connell" <mconnell@lineone.net> wrote:
> > 
> > > > This is no mere coincidence my friends. The Lord is Present.
> > >
> > > While he's here can he please tell us whether a ticket from London to
> > > Carlisle route Direct is or isn't valid via the Settle & Carlisle?
> > >
> > >
> > Usual request, how do you get coffee out of the keyboard :-)
> 
> Blow VERY hard.
> 
I bet you say that to all the girls :-)
-- 
Graeme Wall


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

Date: Tue, 10 Aug 1999 10:02:45 -0700
From: Seshu Adunuthula <sadunuth@us.oracle.com>
Subject: Known Issues with perl
Message-Id: <37B05B34.56908569@us.oracle.com>

Are there any resources to check for known issues with perl
specifically on NT, (Bug fixes between different releases) etc.

I am running into problems with perl on NT. version 5.004_01
specifically with running shell scripts from within a perl CGI
script

open (FD, "c:\\temp\\foo.bat | ");
while (<FD>)
{
   print;
}

The above script worked for most part and failed after a long
regress. Now perl refuses to execute the command foo.bat and
I am not sure where to start investigating.
(Rebooting the @#$% NT is not an option :-(  )

Does perl have any dependencies on any registry variables
that could potentionally have gotten corrupted during the
long regress?

thanx
Seshu




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

Date: 10 Aug 1999 10:46:44 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: list length
Message-Id: <m13dxrfrzv.fsf@halfdome.holdit.com>

>>>>> "Derek" == Derek Sherlock <derek_sherlock@hp.com> writes:

Derek> If you access a list in a scalar context, you get the number of
Derek> elements.

I suppose that may be hypothetically true.  But that would be just as true
as "If you access a list in a scalar context, you get PI accurate to
20 places."

Because both of them have a false premise.

LISTS do not exist in a scalar context.  Ever.

$n = @a; # no list here, just the number of elements of array @a
$n = grep /foo/, @b; # no list here, just the number of hits
$n = getpwnam 'merlyn'; # no list here, just the user ID number
$n = /foo/g; # no list here, just a true/false value if it matches
$n = <FOO>; # no list here, just the next chunk read from FOO, or undef
$n = ($a,$b,$c); # no list here, just value of $c after discarding $a and $b

Get the picture?

THERE CANNOT BE A LIST IN A SCALAR CONTEXT.  EVER.

And to jump back to this thread, the value of Thread->list in a scalar
context is entirely up to the author of the list() method, and could
be entirely unrelated to what that same construct does in a list
context.  If you want the number of elements of that list-context return
value, one easy way is:

	$count = () = Thread->list;

But that's hacky. :)  Better to read the docs and see if there's a useful
scalar value for Thread->list.

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 10 Aug 1999 19:3:17 GMT
From: QuestionExchange <USENET@questionexchange.com>
Subject: Re: list length
Message-Id: <692qx@questionexchange.com>

>   Simple Question:  Is there a way to get the number of
> elements of a list WITHOUT  assigning it to a variable?  e.g.
> Thread->list gives a list of Threads. This works fine but is
> not what I want:  @l = Thread->list; print $#l." threads in
> list";  I looked to a lot documentation as well as faqs but
> could not find a method or function to get the number of elems
> of the list.  I would expect something like Thread->list-
> >length or length(Thread->list) or anything else.  Cheers,
> Gerhard

Try scalar(Thread->list) which evaluates an expression (Thread-
>list) in scalar context

-- 
  This answer is courtesy of QuestionExchange.com
  http://www.questionexchange.com/servlet1/showUsenetGuest?ans_id=2447&cus_id=USENET&qtn_id=1659


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

Date: Tue, 10 Aug 1999 18:01:28 GMT
From: inlandpac@my-deja.com
Subject: Re: Pattern Matching +
Message-Id: <7oppdg$mdc$1@nnrp1.deja.com>


> $ perl -wne '/(((?:\S+\s+){0,5})\S*shop\S*((?:\s+\S+){0,5}))/ or print
> >           "Failed\n" and next; print "All   : $1\nBefore: $2
\nAfter :$3\n\n"'

Thank you.  If I were to use this within my perl script, does this look
correct:

$tResults = /(((?:\S+\s+){0,5})\S*$keyword\S*((?:\s+\S+){0,5}))/gi;

I tried this and I get blank results.  I am really unfamiliar with all
of this (newbie).  I have gotten quite far in most of my search
patters/regular expressions, but this one really boggles me.

I appreciate your help.

CLH


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 448
*************************************


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