[13597] in Perl-Users-Digest
Perl-Users Digest, Issue: 1007 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 6 19:05:49 1999
Date: Wed, 6 Oct 1999 16:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <939251108-v9-i1007@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 6 Oct 1999 Volume: 9 Number: 1007
Today's topics:
Re: (?p{}) was [Re: Backreference in Regex Code Block?] (Ilya Zakharevich)
Re: <<EOL and Sub <samay1NOsaSPAM@hotmail.com.invalid>
Re: C style was Re: Random Numbers <uri@sysarch.com>
Re: Caliing method by reference with arrow operator (Martien Verbruggen)
Chartbug?? bjoern.jammer@stud.uni-hannover.de
Re: Conversion ASCII flat file into Excel spreadsheet f mcnam@my-deja.com
Re: Exporting ENViroment variables back to the shell <dwb1@home.com>
Getting Win Perl working with MS Personal Web Server <send@no.junk.mail>
HELP! Passing vars to sub not working <marc@fearby.com>
Re: Killfiles (Martien Verbruggen)
Magic #! line problem Sandeep.Bhagwat@kla-tencor.com
Re: Memory leak in assignment (Ilya Zakharevich)
Parsing Through Multiple lines jtgr8guy@my-deja.com
Parsing through Multiple text lines jtgr8guy@my-deja.com
Perl & java <surya@ucdavis.edu>
Re: Perl & java <laurensmith@sprynet.com>
Re: Perl Libraries <cassell@mail.cor.epa.gov>
Re: Perl WildCards ??? HELP (Larry Rosler)
Quick Help Please <Ry989@hotmail.com>
Re: Quick Help Please (Bill Moseley)
Re: Regular Expressions with ÔÕÖØŒŠÙÚÛÜÝŸÞàáâãäåæçèéê c (Bill Moseley)
Re: We do complex Perl Programming (Michel Dalle)
Re: We do complex Perl Programming <news@elmbronze.demon.co.uk>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Oct 1999 21:59:59 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: (?p{}) was [Re: Backreference in Regex Code Block?]
Message-Id: <7tggov$9m2$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to lt lindley
<lee.lindley@bigfoot.com>],
who wrote in article <7tg0n3$778$1@rguxd.viasystems.com>:
> :>> What I'm trying to do is create a regex that applies itself
> :>> recursively:
> :>>
> :>> $exp = qr/^(x|\((.*)\)(?{ $2 =~ m{$exp} }))$/;
> :>>
> :>> which would behave like a recursive-descent parser. But
> :>> I have to solve this reference problem.
>
> :>Just use (?p{}) instead.
>
> All of the other fish ignored the lure, but I'm a sucker for
> shiny new regexp toys, so I'll bite. What does (?p{}) do (or what
> will it do when I eventually get a perl that has it)?
Well, it is ugly. I still hope that a better syntax may make into
5.6.0 (I'm trying to force myself into this new shiny and ugly
versioning scheme). So let us discuss a better syntax (not existing
now ;-):
Given a p-modifier (`P'ostponed), the "interpolated variables" are
considered to contain regular expressions. They are "interpolated"
not when REx is compiled, but at *run time*.
Say,
$foo = qr{ < $foo > # Postponed $foo in brackets
| # Or nothing
}px;
will match any sequence of nested < and >, as in "<<<<<>>>>>".
Current *workaround* against non-existing //p is {?p{EXPR}}. It
evaluates EXPR at run time, then uses the result as the regular
expression to match at the given position.
$foo = qr{ < (?p{$foo}) > # Postponed $foo in brackets
| # Or nothing
}px;
Hope this helps,
Ilya
------------------------------
Date: Wed, 06 Oct 1999 14:15:33 -0700
From: Samay <samay1NOsaSPAM@hotmail.com.invalid>
Subject: Re: <<EOL and Sub
Message-Id: <0a0133f8.15e0fe01@usw-ex0102-016.remarq.com>
Thanks ALL.
Both solutions are useful,
Thanks also for poiting to FAQ
Samay
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: 06 Oct 1999 18:39:01 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: C style was Re: Random Numbers
Message-Id: <x74sg4qflm.fsf@home.sysarch.com>
>>>>> "ll" == lt lindley <ltl@rgsun5.viasystems.com> writes:
ll> Abigail <abigail@delanet.com> wrote:
ll> :>which actually walks through the array in reverse order. I would
ll> :>write that as:
ll> :> for (my $i = @xvals; $i --;)
ll> :>which looks simpler to me.
ll> Aiieee! Even your C-style for loops look more Perlish than my Perl!
my prefered c counter/pointer loop is:
for ( ptr = addr, i = max_cnt ; --i >= 0 ; ptr++ ) {
even in c i rarely indexed. pointers are the way to go. so switching to
perl foreach loop (also having done them in (c) shell) was easy.
but you can program c in any language (was fortran).
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Wed, 06 Oct 1999 22:50:25 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Caliing method by reference with arrow operator
Message-Id: <RmQK3.225$bM2.14343@nsw.nnrp.telstra.net>
On Wed, 6 Oct 1999 14:06:30 +0200,
Igor V. Solodovnikov <siv@helpco.kiev.ua> wrote:
>
> Is it possible to call method if i have only a reference to it?
> Consider following example:
>
> ...
> my $self=shift;
> my $methodref=shift;
> ....
> #i known that i can call it without arrow operator:
> $methodref->($self);
> ....
> #but why following syntax doesn't works?:
> $self->&{$methodref}();
>
> Do you know any workaround?
You could use a closure. The perltoot documentation explains a bit,
there's some stuff in perlfaq7 and perlref and perlsub also contain
some info.
I wouldn't bother for this simple case :) The first method you use
above works fine.
Martien
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | Curiouser and curiouser, said Alice.
NSW, Australia |
------------------------------
Date: Thu, 07 Oct 1999 00:49:39 +0200
From: bjoern.jammer@stud.uni-hannover.de
Subject: Chartbug??
Message-Id: <37FBD203.58AE459B@stud.uni-hannover.de>
Hi
I tried to create some on-the-fly pictures with the Chart-module(0.99b).
It seems, that the x-axe is shifted to the left. When I say
set->grid-lines, the grid-lines began on the left of the graph.
|
|
|_____________________
| | | | | |
^ x-ticks
see what I meen?
Whats wrong with this??
------------------------------
Date: Wed, 06 Oct 1999 21:45:22 GMT
From: mcnam@my-deja.com
Subject: Re: Conversion ASCII flat file into Excel spreadsheet file
Message-Id: <7tgftf$fs2$1@nnrp1.deja.com>
In article <01bf0e83$1da4d6b0$480e7891@be14p072>,
"Vorname Name" <Vorname.Name@pcm.bosch.de> wrote:
> Unfortunately, I am forced to rely on NT and was
> asked to convert output from an Oracle Server which
> is run on HP-UX into MS's proprietary Excel format.
I have attached a Perl script that will write *unformatted* text and
numbers to a single worksheet in Excel binary file format. I have tested
the script on Win 3.11, Win95, NT4.0, Sun0S 4.1. I have tested the
output binary file with Excel 5 and Excel 97. I am unable to test it
with Excel 2000.
The script implements the BIFF5 file format for Excel versions 5
onwards. The main, if not only, source of reference for the "binary
interchange file format" (BIFF) file format used by Excel is the
Microsoft Press, "Excel Developer's Kit", ISBN 1-55615-632-4 (for
version 5). Until recently there was an online version of this at
http://msdn.microsoft.com/library/default.htm .
This is not industrial strength code. It is a minimal subset of the
binary information that could be included in an Excel file. The
following caveats apply:
1. Portability: To be fully portable the script needs a function to
guarantee the byte arrangement of the 64bit double in xl_write_number().
Also, to facilitate portability I've used little-endian signed shorts.
This limits the maximum row and column size to 32,768 instead of 65,536.
I am working on these points.
2. SDK: I don't know why the DIMENSIONS records can be zero. Handy
though.
3. Power diverted from shields: There should be error checking in the
script, it should be a module and the initialisation and finalisation
should be centralised.
4. Design goals: There are easier ways of doing this; CSV. And better
ways; OLE/COM, ODBC or perhaps the new HTML format in Excel 2000.
This message has been posted separately to microsoft.public.excel.sdk.
This message has been tested with a filter to remove all items that
might be offensive to CLPM. The filter is written in AWK. ;)
John.
#!/usr/bin/perl
#/////////////////////////////////////////////////////////////////
#
# p2xls: Perl script to implement minimal Excel binary file.
#
# john.exeng@abanet.it
#
# Writes doubles and text in Excel BIFF5 format, in a single
# worksheet without formatting. Writes integers as doubles.
#
# Limits (number, description, cause):
# 255 : Maximum number of characters in a string. Excel 5.
# 16,384 : Maximum number of rows or columns. Excel 5.
# 32,768 : Maximum no. of rows or columns in Excel 97. This script.
# Note: This is a problem with this implementation,
# the actual limit is 65,536.
#
# For details of the Excel "Binary Interchange File Format" (BIFF) file
# format refer to the "Excel Developer's Kit", Microsoft Press.
#
# Each Excel BIFF binary record has the following format:
# Record name - Identifier, 2 byte
# Record length - Length of the subsequent data, 2 bytes
# Record data - Data, variable length
#
# The following binary records are implemented:
# [BOF]
# [DIMENSIONS]
# [NUMBER]
# [LABEL]
# [EOF]
#
#/////////////////////////////////////////////////////////////////
use strict;
# Add your own code to determine the OS and hardware
# The following will work for MS-Dos, Win3.1x, Win9x, NT
my $Windows = 1;
my $Intel = 1;
# The following works for a Sun Sparcstation (and perhaps others).
# See comment in xl_write_number().
# my $Windows = 0;
# my $Intel = 0;
open XL_FILE, ">perl.xls" or die "Can't open file. It may be in use by
Excel.\n";
if ($Windows == 1){
# binmode is essential on Windows platforms
binmode(XL_FILE);
}
# Write binary header information
xl_write_bof();
xl_write_dimensions();
# Write some numbers
xl_write_number(0, 2, 3); # Writes 3
xl_write_number(1, 2, 3.00000); # Writes 3
xl_write_number(2, 2, 3.00001); # Writes 3.00001
xl_write_number(3, 2, 3.14159); # TeX revision no.?
# Write some text
xl_write_label (0, 0, "Hello Excel!");
# Write binary end of file
xl_write_eof();
##################################################################
# xl_write_bof()
#
# Writes Excel BOF record to indicate the beginning of a file
# in the compound document format.
##################################################################
sub xl_write_bof {
my $name = 0x0809; # Record identifier
my $length = 0x0008; # Number of bytes to follow
my $version = 0x0005; # Excel BIFF version 5
my $type = 0x0010; # Set to zero
my $build = 0x0000; # Set to zero
my $year = 0x0000; # Set to zero
my $header = pack "vv", $name, $length;
my $data = pack "vvvv", $version, $type, $build, $year;
print XL_FILE $header . $data;
}
##################################################################
# xl_write_eof()
#
# Writes Excel EOF record to indicate the end of a file in the
# compound document format.
##################################################################
sub xl_write_eof {
my $name = 0x000A; # Record identifier
my $length = 0x0000; # Number of bytes to follow
my $header = pack "vv", $name, $length;
print XL_FILE $header;
}
##################################################################
# xl_write_dimensions() # No arguments or
# xl_write_dimensions($first_row, $last_row, $first_col, $last_col)
#
# Writes Excel DIMENSIONS to define the area in which there is data.
# Setting these values does not seem to have an effect. A bug.
##################################################################
sub xl_write_dimensions {
my $name = 0x0000; # Record identifier
my $length = 0x000A; # Number of bytes to follow
my $row_min; # First row
my $row_max; # Last row plus 1
my $col_min; # First column
my $col_max; # Last column plus 1
my $reserved = 0x0000; # Reserved by Excel
if (@_ == 0){
$row_min = 0;
$row_max = 1;
$col_min = 0;
$col_max = 1;
}else{
$row_min = $_[0];
$row_max = $_[1] +1;
$col_min = $_[2];
$col_max = $_[3] +1;
}
my $header = pack "vv", $name, $length;
my $data = pack "vvvvv", $row_min, $row_max, $col_min, $col_max,
$reserved;
print XL_FILE $header . $data;
}
##################################################################
# xl_write_number($row, $col, $num)
#
# Write a double to the specified row and column (zero indexed).
# An integer can be written as a double. Excel will display an
# integer.
##################################################################
sub xl_write_number {
my $name = 0x0203; # Record identifier
my $length = 0x000E; # Number of bytes to follow
my $row = $_[0]; # Zero indexed row
my $col = $_[1]; # Zero indexed column
my $xf = 0x0000; # The cell format - not implemented here
my $num = $_[2];
my $header = pack "vv", $name, $length;
my $data = pack "vvv", $row, $col, $xf;
my $xl_double;
# NOTE: Byte order for 64bit double.
# As a test case 1.2345 should appear as;
# 0x8D 0x97 0x6E 0x12 0x83 0xC0 0xF3 0x3F
# This is the case for x86 hardware so pack the double as it is.
# If not swap the bytes. You will have to roll your own byte-
# swapping function. There is an example below.
if ($Intel == 1){
$xl_double = pack("d", $num);
}else {
# Byte swap for the Supersparc-11
$xl_double = pack("d", $num);
my @bytes = split(//, $xl_double);
@bytes = reverse(@bytes);
$xl_double = join('', @bytes);
}
print XL_FILE $header . $data . $xl_double;
}
##################################################################
# xl_write_label ($row, $col, $string)
#
# Write a string to the specified row and column (zero indexed).
# NOTE: there is an Excel 5 defined limit of 255 characters.
##################################################################
sub xl_write_label {
my $name = 0x0204; # Record identifier
my $length = 0x0008 + length($_[2]); # Number of bytes to follow
my $row = $_[0]; # Zero indexed row
my $col = $_[1]; # Zero indexed column
my $xf = 0x0000; # The cell format - not implemented here
my $strlen = length($_[2]);
my $str = $_[2];
my $header = pack "vv", $name, $length;
my $data = pack "vvvv", $row, $col, $xf, $strlen;
print XL_FILE $header . $data . $str;
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 06 Oct 1999 21:29:21 GMT
From: "Daniel W. Burke" <dwb1@home.com>
Subject: Re: Exporting ENViroment variables back to the shell
Message-Id: <Pine.LNX.4.10.9910061626350.12449-100000@cc569157-a.warn1.mi.home.com>
On Wed, 6 Oct 1999, Daniel W. Burke wrote:
> I'm trying to figure out a way to export an enviroment variable back to
> the shell. I've been looking and experimenting for a while now, and havn't
> been able to come up with anything that works.
>
> Does such a thing exist that will allow me to do what I need to do? Or am
> I going about it all wrong?
>
Thanks for the suggestions on this one.... the changing LD_LIBRARY_PATH in
an BEGIN block didn't work for some reason... so I spent the morning talking
the only person with root to that machine into fixing it! All is well in the
land of Dementia :)
Dan.
------------------------------
Date: Thu, 7 Oct 1999 11:36:44 +1300
From: "Peter Sundstrom" <send@no.junk.mail>
Subject: Getting Win Perl working with MS Personal Web Server
Message-Id: <939288958.175489@shelley.paradise.net.nz>
I've finally bitten the bullet and decided to install perl and MS personal
Web server on my win98 machine to test my unix CGI scripts.
I'm having problems getting the Web server to recognise the perl scripts as
a valid CGI script. The perl scripts are correct as I can run them from the
command line and they spit out the appropriate HTML code.
I read through the ActivePerl FAQ in the section for "Web Servers" and saw
that I needed to add a registry setting for the web server to recognise perl
scripts.
Under Script Maps I added a new string value:
Name Data
.pl c:\perl\bin\perl.exe
I'm not very familar with the registry, so is this entry correct?
After changing this I stopped and started the web server. Whenever I try to
run the CGI it comes back with:
HTTP Error 403
403.2 Forbidden: Read Access Forbidden
This error can be caused if there is no default page available and directory
browsing has not been enabled for the directory, or if you are trying to
display an HTML page that resides in a directory marked for Execute or
Script permissions only.
I can verify that the CGI directory is correct as I can run the default
htimage.exe and imagemap.exe
------------------------------
Date: Thu, 07 Oct 1999 08:41:20 +1000
From: Marc Fearby <marc@fearby.com>
Subject: HELP! Passing vars to sub not working
Message-Id: <37FBD010.5DC5A39D@fearby.com>
Hi, I'm relatively new to Perl - I've read loads of documentation and
tutorials and think I've got variable passing to sub-routines figured
out, except when I try to pass a variable to a sub-routine which I got
from another sub-routine, it doesn't work :-( Below is my short program
(in full, just in case it matters). When I put this all in one program
without using sub-routines, it works perfectly.
I've got a few print statements all over the place so that I can see
what the $dbh variable contains at each step. Basically, when I pass
the $dbh variable to the &DoSql sub-routine, it contains nothing, yet,
when I print $dbh before doing the &DoSql bit, I get what it's supposed
to contain (something like this: DBI::db=HASH(0xe4b974)
This is extremely bizarre and I can't see that I've made any mistakes
anywhere.
BEGIN PERL SCRIPT
==================================================================
#!perl -w
use strict;
use MIME::Base64;
use DBI;
print "Content-type: text/html\n\n", "<HTML>\n<BODY>\n";
my ($user,$pass) = &GetUserInfo;
my $dbh = &DbConnect($user,$pass);
print "DBH at top: $dbh\n<P>";
&DoSql($dbh);
&DbDisConnect($dbh);
print "<HTML>\n<BODY>\n";
sub DbConnect {
my ($user,$pass) = $_;
my $dbh;
my $dsn = "dbi:ODBC:test";
$dbh = DBI->connect($dsn, $user, $pass, { RaiseError => 1 })
|| die "Cannot connect: $DBI::errstr\n" unless $dbh;
print "DBH in connect: $dbh\n<P>";
return $dbh;
}
sub DoSql {
my $dbh = $_;
my ($sql,$sth,@row);
print "DBH inside DoSql: $dbh\n<P>";
$sql = "SELECT * FROM TABLE1";
$sth = $dbh->prepare($sql);
# Check for errors.
if($@){
$dbh->disconnect;
print "Content-type: text/html\n\n";
print "An ERROR occurred! $@\n";
exit;
} else {
print "executing SQL\n";
$sth->execute;
}
while (@row = $sth->fetchrow_array) {
# print $pointer->{'text'};
print "$row[0]\t$row[1]\t$row[2]\n\n";
}
}
sub GetUserInfo {
my ($auth, $authstr, $authtype, $userpass, $uid, $pwd);
if ($auth = $ENV{HTTP_AUTHORIZATION}) {
($authtype, $authstr) = split /\s/, $auth;
if ($authtype =~ /basic/i) {
$userpass = decode_base64($authstr);
($uid, $pwd) = split /:/, $userpass;
print "<H2>Authorization details:</H2>\n",
"<H4>type = $authtype</H4>\n",
"<H4>username = $uid</H4>\n",
"<H4>password = $pwd</H4>\n";
return ($uid,$pwd);
} else {
print "<H2>Authorization type not supported:\n",
"<H4>type = $authtype</H4>\n";
}
} else {
print"<H2>User not logged on!</H2>\n";
}
}
sub DbDisConnect {
my $dbh = $_;
print "DBH inside disconnect: $dbh\n<P>";
$dbh->disconnect;
}
==================================================================
END PERL SCRIPT
E-mail: marc@fearby.com
ICQ: 13045454
------------------------------
Date: Wed, 06 Oct 1999 22:42:37 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Killfiles
Message-Id: <xfQK3.222$bM2.14343@nsw.nnrp.telstra.net>
On 6 Oct 1999 12:15:50 GMT,
Martien Verbruggen <mgjv@wobbie.heliotrope.home> wrote:
> Another reason is people who have shown to not be willing to do any
Boy.. split infinitives, ungrammatical construction, and a
misconfigured newsreader at home. I guess I'll have to be more careful
reading news at home :)
Martien
--
Martien Verbruggen |
Interactive Media Division | +++ Out of Cheese Error +++ Reinstall
Commercial Dynamics Pty. Ltd. | Universe and Reboot +++
NSW, Australia |
------------------------------
Date: Wed, 06 Oct 1999 22:10:16 GMT
From: Sandeep.Bhagwat@kla-tencor.com
Subject: Magic #! line problem
Message-Id: <7tghbu$gqr$1@nnrp1.deja.com>
I am trying to write a perl script for a HP-UX where the location of
perl need not be /usr/local/perl.
The script starts as follows.
#!/bin/sh -- # -*- perl -*-
eval 'exec perl $0 ${1+"$@"}
if 0;
BEGIN { require 5.003 }
$::VERSION = sprintf "%d.%02d", "1", "45";
And then it goes with the normal strings processing.
The script works OK on SunOS4 and Solaris but when I try to run the
script on HP, sh gives an error, '-- # perl: invalid flag'.
Any help to overcome this problem would be appreciated.
Thanks in advance.
-Sandeep
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 6 Oct 1999 21:50:03 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Memory leak in assignment
Message-Id: <7tgg6b$9j3$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Dan Sugalski
<dan@tuatha.sidhe.org>],
who wrote in article <vNHK3.6154$S32.14705@news.rdc1.ct.home.com>:
> Actually, it's more like 220 Meg (Well, 260M with the list overhead). Perl
> scalars are 22 bytes a pop, more or less, plus the size of your string
> buffer (if it's been stringified) plus any extra magic.
??? Are on architecture with 11-byte words, or what? ;-) I think
there is some discussion of overhead of Perl storage in
perldoc perddebug
Ilya
------------------------------
Date: Wed, 06 Oct 1999 21:40:12 GMT
From: jtgr8guy@my-deja.com
Subject: Parsing Through Multiple lines
Message-Id: <7tgfjq$fho$1@nnrp1.deja.com>
Hi there,
I've looked for ways to read in and parse thru
text files on this newgroup, but I'm still having
trouble figuring out how to read this in...
I have this as part of a text file:
----------------------------------------------
Elapsed Time = 0 : 9 : 4
The script finished at: 9/20/99 1:43:49 PM
Total Tests = 13
Total Passed = 13
--------------------------------------------------
Is it better to try to all this in a buffer
before parsing?
I have matched "Elapsed Time = " to start reading
in the time. But it doesn't seem to match the
time and store them into $1, $2, $3 when I use
parentheses. How would I read each line
individually(while<>)? I have this bit of code
to try tomatch the time and input them once I
find "Elapsed Time =", but it doesn't seem to be
inputing the time:
while (<INFILE>) { #reading in each line?
if (m/Elapsed Time = / || /ElapsedTime:/){
#look for "Elapsed Time = "
print "Found\n";
#correct way to read in the time?
if (m/([0-9]+) : ([0-9]+) : ([0-9]
+)/) {#matching the time and group hr, min,sec
$hour=$1;
$min=$2;
$sec=$3;
print "$hour"; #doesn't print
}
}
}
I'm new to the perl language, but any and all
help would be greatly appreciated.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 06 Oct 1999 22:07:05 GMT
From: jtgr8guy@my-deja.com
Subject: Parsing through Multiple text lines
Message-Id: <7tgh60$goa$1@nnrp1.deja.com>
Hi there,
I'm new to perl and I havent' been able to find answers specific
to my questions..
Any and all help would be greatly appreciated..
I have this below as part of a text file..
Elapsed Time = 0 : 9 : 4
Total Tests = 13
Total Passed = 13
Microsoft Upgrade 2000 for the Test Passed !
*
-------------------------------------------------------
I read in the file and matched "Elapsed Time = ". This should move the
cursor right before the 0 : 9 : 4, but as I tried to match the time and
use parentheses to group the hr, min,and sec. It didnt' seem to match
the time even if it's in this format that I specified (hr : min : sec)
to match. Please take a look at this code and see if I'm matching this
correctly... Also, how would I read in each line one at a time? (while
<>)? Should I read each line into an associative array starting at
Elapsed Time and then parse it?
while (<INFILE>) { #while reading in each line?
#print "Line $. = <$_>\n"; #print out each line of file
if (m/Elapsed Time = / || m/Elapsed Time:/) {
print "Found\n"; #need to start reading line
by line and parse thru..
if (m/([0-9+]) : ([0-9]+) : ([0-9]+)/) {
#does this match hr : min : sec ?
print "found time";
$hour=$1;
$min=$2;
$sec=$3;
print "$1";
}
#How do I go to the next line to parse thru?
I want to eventually output :
Microsoft Upgrade 2000, 13, 13, 0hrs 9min 4secs,
so I want to parse thru these lines and store the field data into
scalars. Once again, thanx in advance for all the suggestions.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 6 Oct 1999 15:11:57 -0700
From: "Surya P Kommareddy" <surya@ucdavis.edu>
Subject: Perl & java
Message-Id: <7tggut$9o2$1@mark.ucdavis.edu>
Hi all,
I would like to use Javascript inside perl programs. If this is possible
please inform me which version of Perl to be installed. I searched the web
but I could find only how to use perl script inside java.
Thanks in anticipation.
Surya.
------------------------------
Date: Wed, 6 Oct 1999 15:21:26 -0700
From: "Lauren Smith" <laurensmith@sprynet.com>
Subject: Re: Perl & java
Message-Id: <7tgi22$uhi$1@brokaw.wa.com>
Surya P Kommareddy wrote in message <7tggut$9o2$1@mark.ucdavis.edu>...
>Hi all,
> I would like to use Javascript inside perl programs. If this is
possible
>please inform me which version of Perl to be installed. I searched the
web
>but I could find only how to use perl script inside java.
1) Java and Javascript are two different languages.
2) I'm assuming that you want to do CGI stuff
3) You can head over to www.activestate.com and download their latest
version of Perl.
>
>Thanks in anticipation.
No problem, ex-post facto
Lauren
------------------------------
Date: Wed, 06 Oct 1999 14:06:21 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perl Libraries
Message-Id: <37FBB9CD.99F95DA4@mail.cor.epa.gov>
M.J.T. Guy wrote:
>
> Bill Moseley <moseley@best.com> wrote:
[snip of correct answer]
> >This should be put into the FAQ ;)
>
> But it already is:
>
> perlfaq8: How do I keep my own module/library directory?
Umm Mike, I think you missed the smiley Bill inserted there.
I think Bill knows this by now.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 6 Oct 1999 14:27:55 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl WildCards ??? HELP
Message-Id: <MPG.12655eb41dee917798a050@nntp.hpl.hp.com>
In article <Pine.BSF.4.05.9910061631250.9891-100000@monet.bestweb.net>
on Wed, 06 Oct 1999 20:27:34 GMT, Mike Salter <msalter@bestweb.net>
says...
> > LR> I assume you mean the Unix/POSIX 'grep' command, not the Perl 'grep'
> > LR> function. The latter works on a list, which requires reading the entire
> > LR> file at once, not one line at a time.
>
> Larry:
> Is there a problem with:
>
> print grep /1200/, <INPUT>;
>
> Supposedly grep uses $_ for each line anyway.
Yes, there is indeed a problem with that. Read what I said above. It
is inappropriate to read a large file into memory for processing, when
one line at a time will suffice. But that is exactly what the diamond
<> operator does in list context.
From perlop:
If a <FILEHANDLE> is used in a context that is looking for a list, a
list consisting of all the input lines is returned, one line per list
element. It's easy to make a LARGE data space this way, so use with
care.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 6 Oct 1999 18:03:10 -0400
From: "Ry989" <Ry989@hotmail.com>
Subject: Quick Help Please
Message-Id: <7tgh8k$bn2$1@nntp3.atl.mindspring.net>
I need to write a script that will take input from a form, search for it,
and if it exists go one place and if it does then go to another place.
(Like when your signing up for something that will see if your username
exists already or not.) Can anyone please help me with this, or point me to
somewhere that can tell me how to do this? Thanks VERY much to everyone
that can help me with anything!
- Ry989@hotmail.com
------------------------------
Date: Wed, 6 Oct 1999 15:32:01 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Quick Help Please
Message-Id: <MPG.12656dba64f1cfc99897e1@206.184.139.132>
Ry989 (Ry989@hotmail.com) seems to say...
> I need to write a script that will take input from a form, search for it,
> and if it exists go one place and if it does then go to another place.
> (Like when your signing up for something that will see if your username
> exists already or not.) Can anyone please help me with this, or point me to
> somewhere that can tell me how to do this? Thanks VERY much to everyone
> that can help me with anything!
Sure. I'd recommend posting the code you have so far and the exact
trouble you are having, including all error messages generated when run
from the command line. This will allow us to fully help you with your
perl program.
While we are waiting, type in at your local prompt:
perldoc CGI
perldoc perl
And read as much as you can.
If you use a search engine you will find lots of examples on the web to
do exactly what you want. My advice is write your own code instead
using code written by others, as it will save you time in the long run,
and contrary to the news reports, most programs are not Y2K ready.
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: Wed, 6 Oct 1999 15:21:49 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Regular Expressions with ÔÕÖØŒŠÙÚÛÜÝŸÞàáâãäåæçèéê characters
Message-Id: <MPG.12656b5c3df9944c9897e0@206.184.139.132>
David Cassell (cassell@mail.cor.epa.gov) seems to say...
> Bill Moseley wrote:
> > My question is in dealing with 8 bit characters such as:
> > ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØŒŠÙÚÛÜÝŸÞàáâãäåæçèéêëìíîïðñòóôõöøœšßùúûüýþÿ
> >
> > How should I match a word boundary? I'm unclear if use locale will
> > help. Or do I need to create my own word boundary as described in
> > "Creating custom RE engines" in perlre?
>
> 'use locale;' can help, if you specify a locale which has the
> desired characters in it. Otherwise, \w won't match all the
> thingies you want.
Thanks for responding David, and sorry for the duplicate posting..
I guess this isn't really a locale issue, but rather I have a data base
that is mostly in English, but has many words with non-English letters.
So I want to expand the meaning of \b and \w to include other letters.
I need to look at perlre some more, as it's the \b that I find confusing
to setup. I need to look at perllocale again, too.
Thanks,
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: 6 Oct 1999 21:14:24 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: We do complex Perl Programming
Message-Id: <7tge3g$6fa$1@nickel.uunet.be>
sehgal@del2.vsnl.net.in (Sahil) wrote in <7th2f6$n1u$1@news.vsnl.net.in>:
>Hi,
>We are an E-commerce based company and do any type of complex Perl
>programming in record time.
Congratulations. What is your record up to now ? :o
Michel.
------------------------------
Date: Wed, 6 Oct 1999 23:21:13 +0100
From: Dave Eastabrook <news@elmbronze.demon.co.uk>
Subject: Re: We do complex Perl Programming
Message-Id: <6kLlrGAZt8+3Ewx0@elmbronze.demon.co.uk>
on Wed, 6 Oct 1999 Michel Dalle <michel.dalle@usa.net> wrote
>sehgal@del2.vsnl.net.in (Sahil) wrote in <7th2f6$n1u$1@news.vsnl.net.in>:
>>Hi,
>>We are an E-commerce based company and do any type of complex Perl
>>programming in record time.
>
>Congratulations. What is your record up to now ? :o
78!
:Dave
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 1007
**************************************