[11503] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5103 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 10 16:07:29 1999

Date: Wed, 10 Mar 99 13:00:19 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 10 Mar 1999     Volume: 8 Number: 5103

Today's topics:
    Re: cobol line seq. file - one very long line - <gellyfish@btinternet.com>
    Re: Combining Files (Larry Rosler)
    Re: Continue Script After Error? (Larry Rosler)
    Re: Debugging perl code (embedded interpreter) (Ilya Zakharevich)
    Re: declaring a local in a while <zenin@bawdycaste.org>
    Re: declaring a local in a while (Sean McAfee)
        DynaLoader fails w/ DBI after mSQL install; threaded Pe rupe7@my-dejanews.com
    Re: IPC::open2 warning? (Wayne C. McCullough)
    Re: Location: headers <hartleh1@westat.com>
    Re: MS Excel to HTML converter? <rose@gsc.nrcan.gc.ca>
        Newbie question about references/deferencing (Scott Stark)
    Re: Ok, this is a weird phenomenon... <staffan@ngb.se>
    Re: Perl refuses to work in my browser, only in MSDos <jglascoe@giss.nasa.gov>
    Re: Printing in Perl (Bart Lateur)
        problems reading HTML file (Cybernetic Bear)
    Re: problems with readdir jstrike@execpc.com
    Re: Problems with referencing array (Larry Rosler)
    Re: q// vs. '' (Jari Aalto+mail.perl)
        RegEx extended ASCII problem desprem@statcan.ca
    Re: Speed-optimizing regular expressions <uri@ibnets.com>
        Webalizer - CLF, ELF, MS_ELF - conversion script (Jerry Cornelius)
    Re: why does my browser show my scripts instead of runn <jglascoe@giss.nasa.gov>
    Re: why does my browser show my scripts instead of runn <mgeorgiadis@hotmail.com>
    Re: why does my browser show my scripts instead of runn <jglascoe@giss.nasa.gov>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 9 Mar 1999 23:07:36 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: cobol line seq. file - one very long line -
Message-Id: <7c49jo$u5$1@gellyfish.btinternet.com>

On Tue, 09 Mar 1999 14:18:44 -0600 Dale Phillips wrote:
> Thank you very much!
> 
> Do happen to know how to Zero pad a $var? 
> 
> printf "%10s",$var;
> 
> where var is only 3 digits but needs to be 10 with leading zeros?
> 

printf "%0.10d",$var;

perldoc -f sprintf

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Mon, 8 Mar 1999 06:54:39 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Combining Files
Message-Id: <MPG.114d8489f661c1fc98970c@nntp.hpl.hp.com>

In article <36e483e2.1381253@news.skynet.be> on Mon, 08 Mar 1999 
08:31:56 GMT, Bart Lateur <bart.lateur@skynet.be >says...
 ...
>   $i = 0; %data = ();
>   # read
>   while(defined($file = shift)) {
> 	open(IN,$file) or die "Can't open file $file: $!";
> 	while(<IN>) {
> 		chomp;
> 		next unless length; # skip empty lines
> 		my($name,$value) = split/\t/;
> 		$data{$name}->[$i] = $value;
> 	}
> 	$i++;
>   }

This code creates sparse arrays.  Its use of memory is O(N ** 2).

>   # write
>   {
> 	local($\,$,) = ("\n","\t");
> 	local $^W;  # do not output "undefined values" warnings

So this code ignores all the unused elements in all the sparse arrays.

'push' on each array is better than a single global array index.

But at least you are in the right solution space.  I can't fathom what 
the other responders had in mind!  :-)

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


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

Date: Mon, 8 Mar 1999 07:11:07 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Continue Script After Error?
Message-Id: <MPG.114d8868d28c31f998970e@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7c0h87$tuu$1@nnrp1.dejanews.com> on Mon, 08 Mar 1999 
12:53:29 GMT, pault2000@my-dejanews.com <pault2000@my-dejanews.com 
>says...
 ...
> ... The script works fine but if it comes across a
> corrupt html file (e.g. one which has not been ftp'd properly and has ended
> up as zero k) the script grinds to a halt. Could anyone advise me as to how
> to get the script to continue if a problem arises.
 ... 
>  $bakup=~/$re/is or die "re messed up";

s/die/warn/;

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


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

Date: 10 Mar 1999 20:57:25 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Debugging perl code (embedded interpreter)
Message-Id: <7c6mbl$8s1$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to 
<hemantp@writeme.com>],
who wrote in article <7c5mq3$f2j$1@nnrp1.dejanews.com>:
> I am embedding a perl interpreter in my C++ program.
> And invoking the perl subroutines using "perl_call_pv".
> 
> I am not able to debug the perl code using -d switch of perl.

How did you try it?  Did you put -d into perl_parse() (sp?) argv?  Did
you set $^P?

Ilya


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

Date: 10 Mar 1999 20:15:31 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: declaring a local in a while
Message-Id: <921097103.351408@thrush.omix.com>

Marty Landman <marty@catnmoose.com> wrote:
: I would like to know about the following:
:  my $buffer;
:  $buffer .= $_ while <File>;
: if I were to say 'my $buffer .= $_ while <File>;' I'm thinking that'd be
: wrong or at minimum inefficient since the 'my' would try to execute in a
: loop.

	Why not try it...?  You've already typed out the code...I'm sure
	it would take you less time to test it then it would to post this
	message...

: Is this correct, is there a reasonable way to code this functionality in
: one stmt?

	my $buffer = join '', <FILE>;

	Or faster and a bit nicer on memory:

	{ local $/; my $buffer = <FILE> }

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Wed, 10 Mar 1999 20:40:25 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: declaring a local in a while
Message-Id: <ZMAF2.10818$Ge3.43008020@news.itd.umich.edu>

In article <921097103.351408@thrush.omix.com>,
Zenin  <zenin@bawdycaste.org> wrote:
>	{ local $/; my $buffer = <FILE> }

 ...then $buffer goes out of scope at the end of the block, and the file
contents are lost.

ITYM:

my $buffer;
{ local $/; $buffer = <FILE> }

Or even:

my $buffer = do { local $/; <FILE> };

-- 
Sean McAfee                                                mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!


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

Date: Wed, 10 Mar 1999 20:13:21 GMT
From: rupe7@my-dejanews.com
Subject: DynaLoader fails w/ DBI after mSQL install; threaded Perl needed ?
Message-Id: <7c6joo$a3g$1@nnrp1.dejanews.com>

Greetings all,

Are certain modules (e.g. DBD:mSQL or DBI)  _expecting_ that Perl
be threaded ?

I get an error from DynaLoader about PL_thr_key not found, but
referenced in DBI.so. I think the DBI module that mSQL installed
is causing problems.

If the above is the case (expected ver of perl), how does one keep
track of which modules will work w/ others (Solaris or Linux) ?

In gratitude for any help,
-Rup.

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


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

Date: 10 Mar 1999 20:51:58 GMT
From: wayne@Glue.umd.edu (Wayne C. McCullough)
Subject: Re: IPC::open2 warning?
Message-Id: <7c6m1e$9ti$1@hecate.umd.edu>

chrissv@my-dejanews.com wrote:
: I want to use the IPC::open2 function, but read this ominous warning on the
: man page:

: "It will not create these file handles for you. You have to do this yourself.
: So don't pass it empty variables expecting them to get filled in for you."

: I am relatively new to PERL - how do I create the file handles? I'm assuming
: that the standard 'open' function creates them for me, since I don't do
: anything special.

: Can somebody give me a perl snippet as to how to create the handles, call
: open2, and print to the pipe?

: I looked on the web and usenet and couldn't find a good example.

I have had the same problem.  The short answer is that I have no clue
what they are talking about.  But let me provide two code snippets
that seem to work:


#!/usr/local/bin/perl5 -w
use IPC::Open3;
open3 (FOO,BAR,ERR,"checkmail");
$a = <ERR>;
close ERR;
if (! $a) { print "you are not loved\n"; }
else { print $a; }


#!/usr/local/bin/perl5 -w
use IPC::Open3;
*FOO = 6;
*BAR = 7;
*ERR = 8;
open3 (\*FOO,\*BAR,\*ERR,"checkmail");
$a = <ERR>;
close ERR;
if (! $a) { print "you are not loved\n"; }
else { print $a; }


The difference between these two code snipits is that the second one
will work with 'use strict' whereas the first will not.

In short I haven't a clue, but this is what has worked for me.

W


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

Date: Wed, 10 Mar 1999 15:13:01 -0500
From: Henry <hartleh1@westat.com>
Subject: Re: Location: headers
Message-Id: <36E6D24D.23E9A25F@westat.com>

Thanks.  I found it.  The answer is not spelled out but it is mentioned.  I'm glad
some people don't mind actually answering questions, however.

Henry

brian d foy wrote:

> In article <36E6C949.7A334F3A@westat.com>, Henry <hartleh1@westat.com> posted:
>
> > brian d foy wrote:
> >
> > > In article <36E6ABFF.3FF6C00E@westat.com>, Henry <hartleh1@westat.com> posted:
> > >
> > > > What I need is some way to tell it target="_top" but the Location:
>
> > > the CGI Meta FAQ has references to documents that tell you how to
> > > work with frames. :)
>
> > It has references to documents that tell you how to work with frames in HTML.  I
> > know how to build frames.  The questions is, what can I do in Perl to send the
> > user to a location and put that in the "_top" frame?  None of the documents
> > referenced in the Meta FAQ even approach the subject.
>
> notice the title of that section is "Working with Frames", not "Building
> Frames".  there's a reason for that.  your problem is that you need to
> know how to work with frames.
>
> if you had read those documents, you would have found your answer - that's
> why i mentioned them.  if you refuse to help yourself, there's not much
> we can do for you.
>
> note, also, that this question is also in the CGI FAQ, also referenced
> in the CGI Meta FAQ.
>
> --
> brian d foy
> CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>



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

Date: Wed, 10 Mar 1999 13:08:11 -0700
From: "David Rose" <rose@gsc.nrcan.gc.ca>
Subject: Re: MS Excel to HTML converter?
Message-Id: <7c6j1q$jog24@nrn2.NRCan.gc.ca>

Gary-

Two possibilities:

1.) We use Excel 97 and it has a Save as HTML option under File. Excel97 can
also upload/download files for ftp/http sites. Can all be done as a macro
which is really Visual Basic. .

2.) Perl for Windows will let you run Excel as a scripting language. You
then can use perl to upload your files to your Web site. The ONLY problem I
had was in getting docs. Dave Roth's recent book "Windows NT: Win32 Perl
Programming", Macmillian Technical Publishing 1998 should give you all you
need. One example I saw, which may have come from Roth, has perl taking
stock values and entering then into an Excel spreadsheet; creating graphs in
Excel; updating a database by SQL calls; and finally invoking Exchange
e-mail. All in four pages of code!!

Certainly has good promise although I just played around with it so can't
say how well it suits your need.

- Dave Rose

================================================
David Rose, Gological Survey of Canada, Calgary
Phone: (403) 292-7129    Fax: (403) 292-5377
E-Mail: rose@gsc.nrcan.gc.ca

Gary Kakazu wrote in message <36DEC986.F1578F4F@tdstelecom.com>...
>I'd like to automate the process of taking Microsoft Excel files and
>displaying them on the web. Are there any perl modules that will take an
>Excel file (.xls format) and convert it to an HTML table?
>
>Thanks,
>Gary
>gary.kakazu@tdstelecom.com
>




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

Date: 10 Mar 1999 19:52:24 GMT
From: sstark@informix.com (Scott Stark)
Subject: Newbie question about references/deferencing
Message-Id: <7c6iho$k4q3@webint.na.informix.com>

I'm a newbie learning about references, and I'm having trouble passing a value 
from a subroutine using references. I'm not sure what I've done wrong here.

Here's a code snippet:

	&check_flags2(\$preserve);
	print "The value of preserve is " . ${$preserve} . ".\n";

	sub check_flags2 {
	 my($preserveP)=@_;
	 $$preserveP=1;
	}

When I run it I get the following message (line 20 is the print line):

 	Can't use string ("1") as a SCALAR ref while 
	"strict refs" in use at getargsP.pl line 20.

Can someone tell me what I'm doing wrong? If I don't "use strict" all I get is:

	The value of preserve is .

thanks, and apologies for the simple-minded nature of this post.

Scott Stark



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

Date: Wed, 10 Mar 1999 21:05:11 +0100
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: Ok, this is a weird phenomenon...
Message-Id: <36E6D077.DDC80CF4@ngb.se>

Nobody wrote:

God, I feel like the Cyclop.
I won't comment your code, just point out one thing.

> 10      sub first_step;
                        ^
Now, what is that? Remove it!!!!!!!!

HTH
Staffan


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

Date: Wed, 10 Mar 1999 15:04:15 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Matthew Baines <matthewbaines@demon.co.uk>
Subject: Re: Perl refuses to work in my browser, only in MSDos
Message-Id: <36E6D03F.24B342FE@giss.nasa.gov>

[courtesy copy sent to cited author]

Matthew Baines wrote:
> 
> This is really getting me down.

:o(

> When I use Perl in Dos, it works fine.  Any recommendations would be greatly
> appreciated.

The script works off of the command line, right?
Since the script itself seems to be working, I think
this is a problem suitable for comp.infosystems.www.authoring.cgi
(i.e., I have no idea how to help you  ;^)

Be sure to read their FAQ (don't don that red suit).
http://www.dejanews.com/[ST_rn=ps]/getdoc.xp?AN=451974553

	Jay Glascoe
--  
"The number of UNIX installations has grown to 10, with more expected."
    	-- _The UNIX Programmer's Manual_, Second Edition, June, 1972.


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

Date: Wed, 10 Mar 1999 20:57:00 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Printing in Perl
Message-Id: <36e9d863.2049032@news.skynet.be>

Larry Rosler wrote:

>Why 'a seriously 
>outdated concept'?

Because it looks so unprofessional. Unreadable. If books were printed in
fixed pitch font, people would read A LOT less than they do now.

	Bart.


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

Date: Wed, 10 Mar 1999 20:21:12 GMT
From: cybear_x[nospam]@geocities.com (Cybernetic Bear)
Subject: problems reading HTML file
Message-Id: <36e6d2af.12366883@news.webhart.net>

I am trying to read an HTML file into a PERL script, but the script
doesn't read the file in properly, and for the life of me I can't
figure out why.

The HTML files I am working with are created by various sources, some
read in just fine, others seem to miss lines. I am trying to get the
title of the HTML file. the syntax I am using is:

open (FILE, $indexfile);
	while (<FILE>){
		my $line = <FILE>;
		chomp ($line);
		#print "\nUser: $user line: $line";
		if ($line =~ /<TITLE>/i){ #match line against <TITLE>
tags
			print "\nline: $line";
			$line =~ s/<TITLE>//i; #remove first title tag
			$line =~ s/<\/TITLE>//i; #remove last title
tag
			print " title: $line";
			my $titlefound = 1;
			return $line; #return title
		}

All the HTML pages work from the browser, but when they are read into
PERL using this script,  sometimes lines are missing, including the
<TITLE> tag lines.

Any ideas?

Thanks
Dave


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

Date: Wed, 10 Mar 1999 20:16:12 GMT
From: jstrike@execpc.com
Subject: Re: problems with readdir
Message-Id: <7c6js5$m37@newsops.execpc.com>

Sure....I'm by no means a Perl guru so please feel free to comment on
the code...good or bad.  There's one problem I've run into and it's
noted by the comments...perhaps you could offer an idea for that as
well.  I plan on re-writing the processlist subroutine to make it more
generic.  I have at least two other areas on our intranet where I'll
need this code.


---------------------------------
$profiledir = "e:/inetpub/wwwroot/or/";
$filetype = ".pdf";
$opcount = 0;
$workcount = 0;
$numtoshow = 4;  ## Number of items to display

##Get the listing of all the files
opendir(DIR, $profiledir) || die 'Cannot open';
local (@catagories) = grep(/$filetype$/, readdir(DIR));
closedir(DIR);

processlist(@catagories);

## I don't like doing this but I don't know of a way to get the length
of the
## arrary that contains the dirlist.  In the sort routine I can't use
a foreach
## command because when I change the order of the array it messes up
the loop.
## So the subroutine has to access $count

$count = $workcount;
@worklist = sortlist(@workload);

$count = $opcount;
@oplist = sortlist(@opreport);

printlist();

#------------------------------------------------------------------------------#
#------------------------------------------------------------------------------#
sub processlist {
local (@catagories) = @_;
  ## Process the list.
  foreach (@catagories) {
    ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime,
$mtime, $ctime) = stat $_;

    if ( index($_, "Workload") == 0 ) {  ## Workload report
      @workload[$workcount] = $_;
      $workcount ++;
    }
    elsif (index($_, "Operations") == 0){ ##Operations report
      @opreport[$opcount] = $_;
      $opcount ++;
    }
  } 
}



sub sortlist {
  local @list = @_;
  local ($x) = 0;
  local ($y) = 0;

  do {
    $y = $x + 1;
    do {
      ($dev1, $ino1, $mode1, $nlink1, $uid1, $gid1, $rdev1, $size1,
$atime1, $mtime1) = stat @list[$x];
      ($dev2, $ino2, $mode2, $nlink2, $uid2, $gid2, $rdev2, $size2,
$atime2, $mtime2) = stat @list[$y];
      if ($mtime1 < $mtime2) {
        @hold = @list[$x];
        @list[$x] = @list[$y];
        @list[$y] = @hold;
      }
      $y ++;
    } until ($y > $count);
  $x ++;
  } until ($x > $count);

  return @list;
}
---------------
That's the bulk of the code.
Works from a DOS window on 98, works from a command prompt on NT, but
when run from the browser on NT/IIS does not return $mtime.  I have no
clue as to why.

Thanks.


On Wed, 10 Mar 1999 16:08:27 GMT, dimitrio@fantom.com (Dimitri
Ostapenko) wrote:

>Could you spare a little bit of code?



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

Date: Mon, 8 Mar 1999 07:07:56 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Problems with referencing array
Message-Id: <MPG.114d87a3a537ed298970d@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7c0grf$tqc$1@nnrp1.dejanews.com> on Mon, 08 Mar 1999 
12:46:40 GMT, slamda@hotmail.com <slamda@hotmail.com >says...

<SNIP of unformatted and irrelevant code>
 
>   push
> (@hello,\@{unpack("A6A40A7A5A8A6A12A6A10A7A6A2A2A6A7A5A7A6A10A6A10A6A9A7A11A5
> A10 A6A6A2",$data)}); } close(MYFILE); $created=localtime(time);
> print("Finished Unpacking data file: $created\n\n"); print $hello[0],"\n";
> print @$hello[0];
> 
> My problem is with the last two print statements: The first displays what I
> would expect...tells me the address of the first refernce and it's
> type...however, the second print statement doesn't print anything (I am
> expecting to retrieve the list I entered with the unpack statement).
> 
> Where have I gone wrong?

Besides not submitting a legible and reduced code snippet, you have 
overlooked a small matter of binding precedence.  The following should 
do what you want:

  print @{$hello[0]};

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


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

Date: 10 Mar 1999 22:29:38 +0200
From: jari.aalto@poboxes.com (Jari Aalto+mail.perl)
Subject: Re: q// vs. ''
Message-Id: <ptrogm1ks0d.fsf@sinivuokko.i-have-a-misconfigured-system-so-shoot-me>

Jonathan Feinberg <jdf@pobox.com> writes:
> You're comparing unlike things.  The first two subs build a list of
> three values on the RHS, then assign that list to @a.  The second two
> subs build a list of one value before assigning it to @a.  Perhaps you
> meant to benchmark qw// ?  Or perhaps you meant 
> 
>   my @a = (q(a), q(abc), q(defghi));

Right, Too fast typing...  5.004_04

jari


              control:  5 secs ( 4.55 usr  0.01 sys =  4.56 cpu)
             single_q:  6 secs ( 6.75 usr  0.02 sys =  6.77 cpu)
            double_qq:  7 secs ( 6.73 usr  0.01 sys =  6.74 cpu)
               single:  7 secs ( 6.73 usr  0.01 sys =  6.74 cpu)
               double:  8 secs ( 6.75 usr  0.02 sys =  6.77 cpu)

            timethese 500_000,
            {
                control => sub { },
                double  => sub
                {
                    my $s = "1234567890";
                },
                single => sub
                {
                    my $s = '1234567890';
                },
                double_qq => sub
                {
                    my $s = qq(1234567890);
                },
                single_q => sub
                {
                    my $s = q(1234567890);
                },
            };


              control:  5 secs ( 4.54 usr  0.01 sys =  4.55 cpu)
               single: 15 secs (15.64 usr  0.01 sys = 15.65 cpu)
             single_q: 16 secs (15.76 usr  0.03 sys = 15.79 cpu)
            double_qq: 16 secs (15.65 usr  0.01 sys = 15.66 cpu)
               double: 17 secs (15.79 usr  0.01 sys = 15.80 cpu)
            double_qw: 26 secs (24.59 usr  0.04 sys = 24.63 cpu)


            timethese 500_000,
            {
                control => sub { },
                double  => sub
                {
                    my @a = ( "a" , "abc", "defghi" );
                },
                single => sub
                {
                    my @a = ( 'a' , 'abc', 'defghi' );
                },
                single_q => sub
                {
                    my @a = ( q<a> , q<abc> , q<defghi> );
                },
                double_qq => sub
                {
                    my @a = ( qq<a> , qq<abc> , qq<defghi> );
                },
                double_qw => sub
                {
                    my @a = qw( a abc defghi );
                },
            };


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

Date: Wed, 10 Mar 1999 20:43:36 GMT
From: desprem@statcan.ca
Subject: RegEx extended ASCII problem
Message-Id: <7c6lhm$blf$1@nnrp1.dejanews.com>

Hi. I've got a minor glitch I'm trying to deal with and I'm hoping one of you
fine people can help me out.

I'm trying to match text using Perl's grep function. I've narrowed down the
problem to the regular expression I'm feeding it. The script I've written has
to handle both French and English characters, and matches only full words.
And in almost all cases it does without fail. The sole exception is when the
matching text's first letter is a extended ASCII (as are French accented
characters).

Say we have this:
$TestString = "L'Idifice gouvernementale";
$TestString =~ /\bIdifice\b/;     # Match 1
$TestString =~ /Idifice\b/;       # Match 2
$TestString =~ /\bdifice\b/;      # Match 3

Oddly enough, match 1 fails. This is my problem.
Match 2 succeeds, as expected.
Match 3 also succeeds. Also very odd (in least to me).

There's never a problem when the accented character is not the first character
of the string (for example, maching for "rialiti" works fine). I got the same
results whether testing on UNIX or on Windows machines.

Does anyone have any idea?
Thanks in advance,
Remi.

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


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

Date: 10 Mar 1999 21:49:45 +0100
From: Uri Guttman <uri@ibnets.com>
To: Joe Stewart <complangperlmisc@httptech.com>
Subject: Re: Speed-optimizing regular expressions
Message-Id: <7mg17dqdcm.fsf@glory.besmarter.com>

>>>>> "JS" == Joe Stewart <complangperlmisc@NOSPAMPLEASE.httptech.com> writes:

  JS> I cut down the number of lines per run to 10000 to prevent out of
  JS> memory errors, but the speed difference is phenomenal, it only
  JS> took slightly over minute to sort an 84 meg logfile.  The old
  JS> method would have taken over an hour to run through all the
  JS> domains.

why not open all the domain log files first, store the handles by a hash
indexed by the domain name and write to the file according to the domain
in the log line. i don't have time to code up and example but it is very
straightforward and should even be faster than the sort method you got.

pseudo (but close to reality) code:

foreach $domain (@domains) {

	$handle{$domain} = IO::File->new( ">>$domain.log" ) ;
}

while ($logline = <LOG>) {

	($domain, $line ) = split( ' ', $logline, 2 ) ;
	$handle{$domain}->print $line ;
}

hth,

uri


-- 
Uri Guttman                                          Hacking Perl for USite
uri@sysarch.com				             uri@besmarter.com


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

Date: Wed, 10 Mar 1999 12:51:48 GMT
From: SPAMFILTERberry@web-x.com (Jerry Cornelius)
Subject: Webalizer - CLF, ELF, MS_ELF - conversion script
Message-Id: <36e65961.237341028@news.seanet.com>

In the unix servers newsgroup I wrote:

"Webalizer, Great product!

FAQ/README do not cover the following error I'm 
experiencing:

There are several lines in my target logfile.  
The target logfile (i tried more than 1) varies 
in size, from 100k to 220mb.  The 
logfile has been generated in IIS 4 using 
the extended logfile format.

When I run Webalizer, every line in the file 
is evaluated, and each line produces the following
error message:

"Skipping bad record (###)"

where ### = existing line number.  At the end of 
the long list of bad records, a final error message 
is produced:

"No valid records found!"

As I've said, the originating file is produced in 
IIS 4.  I ftp it from that box to my Linux box, 
which is Linux:  Caldera 1.2.  That machine's name 
is Copernicus.

I have successfully Webalized a log file produced 
on Copernicus in the Common Logfile Format.  Looks 
great.  So, I read the W3C documentation on the construction 
of log files in it's extended format, and determined 
that the IIS 4 log file is properly formatted.

I'm forced to make two assumptions.  Webalizer will 
not analyze an IIS 4 generated proprietary ELF(W3svc3) or that IIS 4 
has malformed the logfile in a way that I cannot detect."

The author of the Webalizer proggy aswered that I could fetch a 
perl script left by a helpful fellow from SE that successfully
converted the MS_ELF to CLF.  It worked like a Champ.  But now 
I'm not getting enough info.

Anyone interested in analyzing this script for me?

ftp://ftp.mrunix.net/pub/webalizer/contrib/weblog_ms2clf.pl 

Thanks in advance.
Microsoft's dogma:  If it's broke don't fix it until we get swamped by the press.
Linux Community dogma:  If it's Microsoft, it's broke.  Don't fix it.
Web Developer dogma:  mmmm, Fosters...

Berry Sizemore
Web Developer
Web-X LLC
http://www.web-x.com
berry@web-x.com
253-383-8767 xt. 231


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

Date: Wed, 10 Mar 1999 14:47:36 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Michael Georgiadis <mgeorgiadis@hotmail.com>
Subject: Re: why does my browser show my scripts instead of running them
Message-Id: <36E6CC57.19F44470@giss.nasa.gov>

[courtesy copy of post sent to cited author]

Michael Georgiadis wrote:
> 
> using activeperl on apache server windows nt 4.0 w/station. scripts run fine
> from command prompt

for some reason, the browser is treating your scripts as
regular text files.  i.e., the script is being read rather
than run.

Probably this is a FAQ on comp.infosystems.www.authoring.cgi

Is your script in the proper "cgi-bin" directory?

	Jay Glascoe
--   
"Yes, you can think of almost everything as a function,
 but this may upset your wife."
	--Larry Wall


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

Date: Wed, 10 Mar 1999 22:10:38 +0200
From: "Michael Georgiadis" <mgeorgiadis@hotmail.com>
Subject: Re: why does my browser show my scripts instead of running them
Message-Id: <7c6jml$1pd3$1@nnrp01.iafrica.com>

what do you mean 'proper' cgi bin? i put it in the bin created with apache
server/
Jay Glascoe wrote in message <36E6CC57.19F44470@giss.nasa.gov>...
>[courtesy copy of post sent to cited author]
>
>Michael Georgiadis wrote:
>>
>> using activeperl on apache server windows nt 4.0 w/station. scripts run
fine
>> from command prompt
>
>for some reason, the browser is treating your scripts as
>regular text files.  i.e., the script is being read rather
>than run.
>
>Probably this is a FAQ on comp.infosystems.www.authoring.cgi
>
>Is your script in the proper "cgi-bin" directory?
>
> Jay Glascoe
>--
>"Yes, you can think of almost everything as a function,
> but this may upset your wife."
> --Larry Wall




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

Date: Wed, 10 Mar 1999 15:40:42 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Michael Georgiadis <mgeorgiadis@hotmail.com>
Subject: Re: why does my browser show my scripts instead of running them
Message-Id: <36E6D8CA.89F29687@giss.nasa.gov>

[courtesy copy of post sent to cited author]

Michael Georgiadis wrote:
> 
> what do you mean 'proper' cgi bin? i put it in the bin created with apache
> server/

Umm, the magic directory in which cgi programs run?

I'm reading the c.i.w3.a.cgi FAQ, but none seem
to be up your alley:

Subject: 1.13 Do I have to put it in cgi-bin?
Subject: 1.14 Do I have to call it *.cgi?  *.pl?

	Jay Glascoe
--  
	Fiery Phoenix
	Oh seven-record splendor
	We will correct you


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

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

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