[9623] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3217 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 21 16:27:13 1998

Date: Tue, 21 Jul 98 13:00:23 -0700
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, 21 Jul 1998     Volume: 8 Number: 3217

Today's topics:
    Re: Bug in regex quantifiers? <*@qz.to>
    Re: Can a Crontab run perl script <barmar@bbnplanet.com>
    Re: compare arrays <jdporter@min.net>
        Debugging Perl 5.x skillit@my-dejanews.com
        Debugging Perl 5.x skillit@my-dejanews.com
        Eval Problem (Paul Sisson)
    Re: GIF Line-Breaks in Perl <wesley@nospam.com>
    Re: GIF Line-Breaks in Perl <wesley@nospam.com>
    Re: Help! splitting a text file into separate files (Greg Bacon)
        Hiding input ("Rick Bauman")
        Is there a location that I can lookup perl commands? <dfreed@ns1.com>
    Re: Is there a location that I can lookup perl commands (Aaron B. Dossett)
    Re: More on Perl Conference 2.0 <jdporter@min.net>
    Re: NEED HELP find a CGI/PERL class??? (Eric Harley)
    Re: novice Q; reading columns of numbers <jdporter@min.net>
        PC arrow keys <melinda@acm.org>
    Re: Perl CGI's under Windows NT (Steve Linberg)
        permissions? <mmacdonald@del.net>
    Re: Q: Coding Quiz result format? (Steve Linberg)
    Re: Refox...........~!!!!!!!!!!!! (Steve Linberg)
    Re: regexp question <*@qz.to>
        Sorting Lists of Lists bhoyle@huntersville.org
    Re: Sorting Lists of Lists (Eric Harley)
        Subroutine Mystery (monty hindman)
    Re: Turning 13 lines of text into one <larryq@nospam.tuttle.com>
        Using splice with for (Matt Knecht)
        Win32 installed solved! (was Re: Win32 install prob--an <sponge@iav.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 21 Jul 1998 18:05:25 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Bug in regex quantifiers?
Message-Id: <eli$9807211401@qz.little-neck.ny.us>

In comp.lang.perl.misc, Bryan Miller <millerb@patchsvr.fc.hp.com> wrote:
> Actually in the intended application the regex is much more complex
> so it's not just a matter of adding anchors.  The number is embedded
> in a much longer expression.

Then post the whole RE. Regular expressions are very context sensitive
and your simplification for posting can change the problem significantly.

It basically boils down to \d{n,m} will find a match in any string
that has at least n digits. If you want to enforce the m limit you
must have suitable boundaries.

Elijah
------
#!/usr/local/bin/perl5 -- # -*- my ny.pm sig -*-
$_=$^ ;s;s;sss;;s^.^ju^&&s&P+&\n&&&(s(_..)(ers)||s|^|^^|)&&s(T)(q(st%eg))eg;
s<.(o).><$& new 1$$>i+s+\dst.+$a--||reverse(q(rep k))+ge;s*%.+u* so+*i;s=\++
="me"=mex&&s%ege%l$"hke%;$a||s/^\S+ /\/\//;s;\d+;yor;;s[KE]<ac$&>i;print $_;


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

Date: Tue, 21 Jul 1998 19:08:33 GMT
From: Barry Margolin <barmar@bbnplanet.com>
Subject: Re: Can a Crontab run perl script
Message-Id: <RG5t1.40$DF4.1377568@cam-news-reader1.bbnplanet.com>

In article <6p22mk$5j1$1@nnrp1.dejanews.com>,  <magyir@my-dejanews.com> wrote:
>You need to make sure that you reference the location of your Perl compiler in
>your cron because the subshell running cron may not have it exported to it.
>When u run from command line you're in a particular shell and it obviously
>knows where perl is, but the subshell u use fro your crons may not have perl
>setup. either 1) export it in the command being cronned or 2) export perl to
>this shell, depending on how many perl progs u wanna run at 'crontime'

The interpreter in a script's #! line has to be a full pathname, so nothing
needs to be exported to find Perl.

-- 
Barry Margolin, barmar@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.


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

Date: Tue, 21 Jul 1998 19:38:04 GMT
From: John Porter <jdporter@min.net>
Subject: Re: compare arrays
Message-Id: <35B4EFA5.46F@min.net>

Larry Rosler wrote:
> 
> In article <35B3B8E8.41F1@min.net> on Mon, 20 Jul 1998 21:32:22 GMT, John
> Porter <jdporter@min.net> says...
>   "@x" eq "@y" . . . is even worse.
> 
> That is way overstated.  If the arrays match, the stringizing approach is
> about twice as fast as the loop.  If the first mismatch is halfway
> through, they are about the same.  So on average they are about the same.
> 
> I posted the benchmarks on July 14.

The "compare strings" method only has speed advantage when the elements
of the arrays have already been stringized.  Your benchmarks reflect
this case.  In the generalized case, where one cannot assume that the
elements have all been stringized, the "brute force" method is faster.

Here are my benchmarks.  I tested cases where the arrays
differed by only one element, either at the end, or at
the half-way point.  I tested cases where elements of
the arrays were either all references, all numberes, or
all strings.

Items are refs
  Differing at the end:
    as_strings:  4 secs ( 3.53 usr  0.41 sys =  3.94 cpu)
    longhand__:  3 secs ( 2.62 usr  0.00 sys =  2.62 cpu)
  Differing in the middle:
    as_strings:  2 secs ( 1.80 usr  0.00 sys =  1.80 cpu)
    longhand__:  1 secs ( 1.39 usr  0.00 sys =  1.39 cpu)

Items are nums
  Differing at the end:
    as_strings:  1 secs ( 1.18 usr  0.00 sys =  1.18 cpu)
    longhand__:  1 secs ( 0.69 usr  0.00 sys =  0.69 cpu)
  Differing in the middle:
    as_strings:  2 secs ( 1.17 usr  0.00 sys =  1.17 cpu)
    longhand__:  0 secs ( 0.40 usr  0.00 sys =  0.40 cpu)

Items are strings
  Differing at the end:
    as_strings:  0 secs ( 0.15 usr  0.00 sys =  0.15 cpu)
    longhand__:  1 secs ( 0.68 usr  0.00 sys =  0.68 cpu)
  Differing in the middle:
    as_strings:  0 secs ( 0.15 usr  0.00 sys =  0.15 cpu)
    longhand__:  1 secs ( 0.40 usr  0.00 sys =  0.40 cpu)
 

-- 
John Porter


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

Date: Tue, 21 Jul 1998 19:17:20 GMT
From: skillit@my-dejanews.com
Subject: Debugging Perl 5.x
Message-Id: <6p2pfv$4o5$1@nnrp1.dejanews.com>

$ test2.pl
Bad name after CLEARSTART_HOME:: at test2.pl line 36.

 I am really getting tired of this message!!!!
Does anyone know of a good resource for debugging perl?
Is there a perldoc explaining error messages?


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 21 Jul 1998 19:17:18 GMT
From: skillit@my-dejanews.com
Subject: Debugging Perl 5.x
Message-Id: <6p2pft$4o4$1@nnrp1.dejanews.com>

$ test2.pl
Bad name after CLEARSTART_HOME:: at test2.pl line 36.

 I am really getting tired of this message!!!!
Does anyone know of a good resource for debugging perl?
Is there a perldoc explaining error messages?

For those of you who just love to solve problems look at the
following code. See anything obvious? {beside the point that it is incomplete}
I believe the problem lies somewhere within the getenv subroutine.

#!/mnt/opt/bin/perl -w
use Getopt::Std;
use File::Basename;
getopts ('abc');

# Identify the platform (a necessary evil).

$is_NT = 1 if (&getenv('OS') eq 'Windows_NT');

######################################################################

# Change the following paths to reflect the specific site needs

if ($is_NT) {

    # CLEARSTART_HOME must be defined (on NT) by the batch file that
    # invokes the Perl script.

    $i = &getenv('CLEARSTART_HOME');


$tmp_filename  = 'c:\temp\' . $$ . ".txt";
   $cfg_dir     = $i . "\\config";
   $aging_dir       = $i . "\\aging";
   $utils_dir       = $i . "\\utils";
   $cleartool       = "cleartool";
   $clearprompt = "clearprompt";
   $sep     = "\\";
   $dflts       = "clrstart.dft";

} else {

    # On UNIX systems, CLEARSTART_HOME may be defined.  If not, it
    # gets set here for convenience:

   $i = &getenv('CLEARSTART_HOME');
    if (! $i) {
        $i = dirname ($0);
    $ENV{'CLEARSTART_HOME'} = $i;
    }
$tmp_filename = '/tmp' . $$ . "cs";
   $cfg_dir     = $i . "/config";
   $aging_dir       = $i . "/aging";
   $utils_dir       = $i . "/utils";
   $cleartool       = "/usr/atria/bin/cleartool";
   $clearprompt = "/usr/atria/bin/clearprompt";
   $sep     = "/";
   $dflts       = ".defaults";

}


}
&A_OPT if ( defined ( $opt_a )) ;
sub A_OPT {

 print " Actions for A_OPT go here " ;
&PRV_TEMPLATE

}


&B_OPT if ( defined ( $opt_b )) ;
sub B_OPT {
          print " Actions for B_OPT go here " ;
}

&C_OPT if ( defined ( $opt_c )) ;
sub C_OPT {
          print " Actions for C_OPT go here " ;
}


# Various defaults and constants.

 $view_mode      = "current";
 $startexec      = 0;
 $exec_cmd       = "";
 $view_tag       = "";

if ($is_NT) {
 $default_viewstore  = "\"\\\\%COMPUTERNAME%\\%HOMEDRIVE%%HOMEPATH%\"(:)";
 $default_viewhost   = '';
 $default_viewhpath  = '';
 $default_viewgpath  = '';
     } else {
 $default_viewstore  = "\"\$HOME\"";
 $default_viewhost   = '';
 $default_viewhpath  = '';
 $default_viewgpath  = '';

 $default_tmode      = '\'unix\'';   # Really should be "native"
 $default_umask      = '\'002\'';
 $default_avobs      = '';
 $default_vobdir     = '';
}

######################################################################
#
# &getenv(<env-var-name);
#
# returns the value of the supplied environment variable.
# On UNIX, this is equivalent to $ENV{<env-var-name>}; on
# NT we must do a case-insensitive search...
#

sub getenv {
    local($e) = shift;
 local($m);

    return($ENV{$e}) unless ($is_NT);

    local($ee) = "\U$e\E";

    foreach (keys %ENV) {
        return($ENV{$_}) if ($_ eq $e);
        $m = "\U$_\L";
        return($ENV{$_}) if ($m eq $ee);
        print "$m";
        print "$e";
    }
#    return($ENV{$e}) if exists( $ENV{$e} );
#    return($ENV{ "\U$e\E" }) if exists( $ENV{ "\U$e\E" });

    return(undef);
}



################################################################################
#
#$branchname = &getbranch;
#sub get_branch {


#my ( $


# Setting $filename to the value of the output of the subroutine
# and feeding into that the value of $the_branch.

$filename = &prv_template( $the_branch );

sub prv_template {


# $the_branch is read in and set to $branch via @_
    my ( $branch ) = @_;

# we set the value of $tmp
# I elected to do this globally.
#   my ( $tmp_filename ) = 'c:\temp\' . $$ . ".txt";


    open(TMP, "> $tmp_filename") ||
        die "Unable to create $tmp_filename: $!\n";

  print TMP "element * CHECKEDOUT\n";  print TMP "element *
 .../$branch/LATEST\n";	print TMP "element *
 .../cia_itest_sol25_33_dev/LATEST -mkbranch $branch\n";  print TMP "element *
RW_REL_LATEST_SOL25_DEVTOOL -mkbranch $branch\n";  print TMP "element *
RW_REL_LATEST_SOL25 -mkbranch $branch\n"; print TMP "element *
RW_REL_LATEST_DEVTOOL -mkbranch $branch\n";  print TMP "element *
RW_REL_LATEST -mkbranch $branch\n";  print TMP "element *
TOOL_REL_LATEST_SOL25_DEVTOOL -mkbranch $branch\n";  print TMP "element *
TOOL_REL_LATEST_SOL25 -mkbranch  $branch\n";  print TMP "element *
TOOL_REL_LATEST_DEVTOOL -mkbranch  $branch\n";	print TMP "element *
TOOL_REL_LATEST -mkbranch  $branch\n";	print TMP "element *
LIB_REL_LATEST_SOL25_DEVTOOL -mkbranch $branch\n";  print TMP "element *
LIB_REL_LATEST_SOL25 -mkbranch $branch\n";  print TMP "element *
LIB_REL_LATEST_DEVTOOL -mkbranch $branch\n";  print TMP "element *
LIB_REL_LATEST -mkbranch $branch\n";  print TMP "element *
REL_LATEST_SOL25_DEVTOOL -mkbranch $branch\n";	print TMP "element *
REL_LATEST_SOL25 -mkbranch $branch\n";	print TMP "element *
REL_LATEST_DEVTOOL -mkbranch $branch\n";  print TMP "element * REL_LATEST
-mkbranch $branch\n";  print TMP "element * .../main_sol25_devtool/LATEST
-mkbranch $branch\n";  print TMP "element * .../main_sol25/LATEST -mkbranch
$branch\n";  print TMP "element * .../main_devtool/LATEST -mkbranch
$branch\n";  print TMP "element * /main/LATEST -mkbranch $branch\n";

    close(TMP);

    return $tmp_filename;
}

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 21 Jul 1998 12:03:56 -0700
From: admin@the-signal.com (Paul Sisson)
Subject: Eval Problem
Message-Id: <admin-ya02408000R2107981203560001@news.smartlink.net>

I am experiencing problems with eval that I am unable to resolve. The
script in question will receive a search string from a form, process the
terms by separating terms into optional, required or forbidden terms using
the booloean operators in the search string.

After processing the terms, the script traverses down the tree, starting at
the base directory specified in the form, and will collect all text files.
Each of these files will then be searched, and the file will be marked as
"found" if it contains all required terms, any optional terms, and no
forbidden terms.

I attempted to build the file search into an eval, but when run it dies
with the error message, "Can't modify scalar ref constructor in scalar
assignment at (eval 1) line 1, near "$1)"

I suspect that if this problem was fixed, there would be more...

If someone could please look at the relevant code and suggest a solution, I
would be most appreciative. Thanks in advance.

-----START CODE-----


#...TERM PROCESSING...

   # build regexps by type
   @terms = split /\s+/, $str;
   $a = $b = $c = 0;

   $ANDS = 'next unless ';
   $NOTS = 'next if m{(?:';
   $ORS  = 'next unless m{(?:';
   
   foreach $term (@terms) {
      next if $term =~ m{\b(?:and|not|or)\b};      # just in case
      $term =~ s{$temp}{\\s+}og;             # fix quoted strings

      # add regexp assertions
      $term =~ s{\*}{\\w*}g;
      $term =~ s{(.*)}{\\b$1\\b};

      if ($term =~ s{^(\\[bw\*])*\+}{$1}) {
         $ANDS .= $a ? " && m{$term}is" : "m{$term}is";
         $a++;
      }
      elsif ($term =~ s{^(\\[bw\*])*\-}{$1}) {
         $NOTS .= $b ? "|$term" : $term;
         $b++;
      }
      else {
         $ORS .= $c ? "|$term" : $term;
         $c++;
      }
   }
   
   $ANDS = $a ? $ANDS . ';' : undef;
   $NOTS = $b ? $NOTS . ')}is;' : undef;
   $ORS  = $c ? $ORS  . ')}is;' : undef;
}

sub search {
   my ($str,$file,%mtime,@found,$search);

   $search  = 'while (<>) { study;';
   $search .= 'm{$TITLE_PAT}os && (\$title{\$ARGV} = \$1);';
   $search .= 'm{$DESC_PAT}os  && (\$desc{\$ARGV}  = \$1);';
   $search .= 'next unless \$title{\$ARGV} && \$desc{\$ARGV};';
   
   $search .= 's{<script.*<\\/script>}{ }gis;';
   $search .= 's{<style.*<\\/style>}{ }gis;';
   $search .= 's{&[a-zA-Z]+\;}{ }gis;';
   $search .= 's{<(?:[^>]|\\n)*>}{ }gis;';
   
   $search .= $NOTS if $NOTS;
   $search .= $ANDS if $ANDS;
   $search .= $ORS  if $ORS;
   
   $search .= '\$mtime{\$ARGV} = (stat(\$ARGV))[9];';
   $search .= 'push @found, \$ARGV;';
   $search .= '}';

    @ARGV = @FILES;
   undef $/;
   eval $search;
   abort($@) if $@;
   $/ = "\n";

   # sort and collect matched files
   @found > 0 and @MATCH = sort { $mtime{$b} <=> $mtime{$a} } @found;
}


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

Date: Tue, 21 Jul 1998 15:28:53 -0500
From: Wesley Miaw <wesley@nospam.com>
Subject: Re: GIF Line-Breaks in Perl
Message-Id: <35B4FA05.EAA25657@nospam.com>

Larry Rosler wrote:
> 
> In article <35B43680.3CD758B8@nospam.com> on Tue, 21 Jul 1998 01:34:42 -
> 0500, Wesley Miaw <wesley@nospam.com> says...
> ...
> > I'm encountering trouble with the following Perl code in a CGI when executed
> > on Windows NT using IIS 4.0 and Perl for win32 build 316 (Perl 5.003).
> >
> >     print "Content-type: image/gif\n\n";
> >     open(IMAGE, "$members_dir\\$id\\$id\.gif") or return 0;
> >     binmode IMAGE;
> >     while (<IMAGE>) {
> >         print $_;
> >     }
> >     close IMAGE;
> 
> You have to do
> 
> binmode STDOUT;
> 
> also.  You should do that before the first 'print' statement.

Thanks. That was a stupid mistake on my part.
-- 
Wesley Miaw                               wesley@woais.com
World of Artists Internet Services        http://www.woais.com/
71 Middlesex Drive                        Tel: 518-439-0412
Slingerlands, NY 12159                    FAX: 518-439-9722


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

Date: Tue, 21 Jul 1998 15:27:34 -0500
From: Wesley Miaw <wesley@nospam.com>
Subject: Re: GIF Line-Breaks in Perl
Message-Id: <35B4F9B6.662B3D28@nospam.com>

Craig Berry wrote:
> 
> Useful secret:  Forward slashes work just fine in paths given as arguments
> to system calls, even under DOSish OSes.  Also, backwhacking '.' doesn't
> do anything.  So you can rewrite this more legibly as
> 
>   open IMAGE, "$members_dir/$id/$id.gif" or return 0;

Actually, I originally had it with forward slashes as you indicated, but the
script would fail to find the specified file. Don't know.

> :     binmode IMAGE;
> :     while (<IMAGE>) {
> :         print $_;
> :     }
> 
> It never makes sense to read a binary file using the default value of $/,
> which will attempt to read newline-terminated chunks which is a
> meaningless or misleading thing to do to a binary file.  Replace the above
> with
> 
>   binmode IMAGE;
>   { local $/; print scalar <IMAGE> }
> 
> That is, set "file slurp mode" then use scalar <IMAGE> to get the entire
> file as an argument to print.

Thanks for the info about $/. I found that variable when I tried to find out
what was going wrong, but didn't know what to do with it.

> Note that there are no 'line breaks' in a GIF file.  Saying it that way
> will only lead you astray.

Well, what my text editor treated as line breaks. You're right, of course.

Thanks again,
-- 
Wesley Miaw                               wesley@woais.com
World of Artists Internet Services        http://www.woais.com/
71 Middlesex Drive                        Tel: 518-439-0412
Slingerlands, NY 12159                    FAX: 518-439-9722


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

Date: 21 Jul 1998 19:53:14 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Help! splitting a text file into separate files
Message-Id: <6p2rja$8it$4@info.uah.edu>

In article <6p2f26$ndl$1@nnrp1.dejanews.com>,
	tolberv@my-dejanews.com writes:
: The Task:
: I must split the file at the ;######## lines and write every line until the
: next ;######## to a file with a filename equal to the number on the
: corresponding CLIENTS line. (eq 00012487.TXT and 0045664.TXT)  The pattern of
: the file is listed below
[snip example]

Assuming the ;##### lines are all identical, you could do something like

    $/ = ";######################################\n";

    while (<>) {
        next unless /^CLIENTS\s*=\s*(\S+)/mi;

        my $file = $1 . ".txt";
        open OUT, "> $file" or die "Failed open >$file: $!\n";
        print OUT;
        close OUT;
    }

Otherwise, you'll want to build up an array of lines and write it out
when you come across a line matching your end of record regular
expression.

Hope this helps,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Tue, 21 Jul 1998 14:56:13 +0000
From: rick@internetx.net ("Rick Bauman")
Subject: Hiding input
Message-Id: <19980721185145.AAB15012@sub.internetx.net>

If I do the following;

chop($number = <STDIN>)

How can I keep the users input from echoing back to his screen?
How can I make it echo back as a series of characters such as the *

tia
r
Rick Bauman
System Administrator/Internet Express
rick@internetx.net  www.internetx.net
finger rick@internetx.net for pgp public key
http://www.lowcountry.net/




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

Date: Mon, 20 Jul 1998 15:27:36 -0700
From: David Freed <dfreed@ns1.com>
Subject: Is there a location that I can lookup perl commands?
Message-Id: <35B3C44F.91D1C08B@ns1.com>

I want to know how to get the current date in perl. While I was thinking
about this I realized that I don't know of any place that I can look for
a command to do a specific task. Is there such a location?



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

Date: 21 Jul 1998 18:19:02 GMT
From: aarond@alpha.ewl.uky.edu (Aaron B. Dossett)
Subject: Re: Is there a location that I can lookup perl commands?
Message-Id: <6p2m2m$7of$1@service3.uky.edu>

David Freed (dfreed@ns1.com) wrote:
> I want to know how to get the current date in perl. While I was thinking
> about this I realized that I don't know of any place that I can look for
> a command to do a specific task. Is there such a location?
> 

Issue the command:

perldoc perlfunc

You may also find

perldoc perldoc

to be useful.

-- 
Aaron B. Dossett   |   Finger aarond@london.cslab.uky.edu for PGP key
dossett@bigfoot.com|      
Comp. Sci. Senior  |         http://www.ewl.uky.edu/~aarond
    University of Kentucky    1996 & 1998 NCAA Basketball Champions


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

Date: Tue, 21 Jul 1998 19:44:11 GMT
From: John Porter <jdporter@min.net>
Subject: Re: More on Perl Conference 2.0
Message-Id: <35B4F129.6743@min.net>

Randal Schwartz wrote:
> 
> Chris, you bought me a beer.  That makes you a "core developer". :-)

Hey, I've produced tons of core files in the many years I've been
developing.  I think I qualify too.

-- 
John Porter


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

Date: Tue, 21 Jul 1998 11:56:06 -0700
From: eharley@pacbell.net (Eric Harley)
Subject: Re: NEED HELP find a CGI/PERL class???
Message-Id: <eharley-2107981156060001@ppp-207-214-149-103.snrf01.pacbell.net>

> hi all...
> Can someone help me in finding a CGI/PERL class to register for
> .
> I am willing to travel anywhere domestic...
> pleas e give me a web site or a place where I can contact for
> the class..
> thanks

Checkout the Orielly Perl conference in San Jose at http://perl.ora.com

-- 
Eric Harley
Freelance Programmer
  You need it done, I'm your man.

eharley@pacbell.net
http://burn.victim.com/~eharley


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

Date: Tue, 21 Jul 1998 18:44:54 GMT
From: John Porter <jdporter@min.net>
Subject: Re: novice Q; reading columns of numbers
Message-Id: <35B4E341.8C8@min.net>

It occurred to me that the upper map is superfluous, in the
predicate of a foreach.  So:

for (
  sort { $a->[0] <=> $b->[0] }
  map { [...] } <DATA>
) {
  print join( ',', @{$_->[1]} ), "\n";
}

Or, of course:

print join "\n", 
  map { join ',', @{$_->[1]} }
  sort { $a->[0] <=> $b->[0] }
  map { [...] } <DATA>;

-- 
John Porter


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

Date: Tue, 21 Jul 1998 18:09:07 GMT
From: "Quinn,M" <melinda@acm.org>
Subject: PC arrow keys
Message-Id: <35B4DB70.FCCF4843@acm.org>

I'm developing a Perl program that
requires several user inputs to form the
file that's to be created.
I seem to be able to use regex to get
rid of DEL, ESC, and whitespace. But I can't figure out
how to get rid of (or inhibit) the input
that PC arrow keys generate.
I'm new to Perl.  Using it on Slackware
Linux. (character mode only)
Melinda Quinn   melinda@acm.org


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

Date: Tue, 21 Jul 1998 14:05:13 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Perl CGI's under Windows NT
Message-Id: <linberg-2107981405130001@projdirc.literacy.upenn.edu>

In article <35b4bc50.0@news.new-era.net>, scott@softbase.com wrote:

> > Now I haven't been able to make server side executables work perse
> > using IIS. (e.g. <!--#exec cmd="..."--> so anything you can tell me
> > there will be much appreciated.
> 
> IIS doesn't support server side includes. You need to either
> learn about ASP, or get Apache or some other web browser that
> does.

IIS *does* support server side includes.  It's in the documentation.  I
have them running.  M$ doesn't particularly draw attention to this
capability, though (perhaps hoping people will lock themselves into the
IIS-specific active server solution).

Of course, this should be discussed in an appropriate place, which
clp.misc isn't.  :)
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: 21 Jul 1998 19:04:04 GMT
From: "Marjorie MacDonald" <mmacdonald@del.net>
Subject: permissions?
Message-Id: <01bdb4da$7fcdb5e0$0e01a8c0@op.net>

I'm trying to get a script to run. I didn't write it, I'm using it as a
learning tool, once I get it to run I'll make changes and see what happens.
(I learn best that way.)

We have a provider that hosts our web site. They have created a CGI
directory for my files, on a UNIX server which supposedly runs PERL. I
haven't been able to get much help or info from them, which doesn't help
matters... ('What can I run?' 'not sure...' 'Do you support any MS
extensions? Can I run VBScript? Can I make a call to a VB program?' I get
no answers...)

So I find a PERL program that SHOULD work.. upload it, try to call it and
get 
403/Permission denied. Your client does not have access to get... 

I tried calling it directly, making a link to it on a web page, etc. Same
thing. Is this something on THEIR end? Do they need to change permissions
on the directory? Would I get this message if they were running an older
version of PERL and my script was for a newer one? 

Since I don't have access to the actual web server, I can't check
anything... don't have any error logs, etc. If anybody can give me a clue
as to what might be causing this error, I can either work on fixing it or
call them and tell them what they need to check. 

Thanks!
Marjorie MacDonald
Dover, DE USA


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

Date: Tue, 21 Jul 1998 14:01:42 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Q: Coding Quiz result format?
Message-Id: <linberg-2107981401420001@projdirc.literacy.upenn.edu>

In article <x7oguom2yd.fsf_-_@sysarch.com>, Uri Guttman <uri@sysarch.com> wrote:

> i have gotten a couple of emails and several posted followups to the
> quiz. should i gather the replies and create a summary of them and my
> answers/critiques?

Sure.
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: Tue, 21 Jul 1998 14:09:46 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Refox...........~!!!!!!!!!!!!
Message-Id: <linberg-2107981409470001@projdirc.literacy.upenn.edu>

In article <6p2iqb$smo$1@nnrp1.dejanews.com>, ubitt@my-dejanews.com wrote:

> I had made a program for Inventery Control  in Foxpro for Dos 6.2 about two
> years back.  While giving  the compiled version of the software I had used
> Refox Branding to further encrypt the software so that it cannot be
> decompiled.

This is a problem, but does it have to do with Perl?  If not, you might
want to try a Foxpro newsgroup.  If so, you should state your question
more clearly.  If your question is "Can I use Perl to decrypt an encrypted
Foxpro database?", my answer is "Perhaps, but Perl doesn't have anything
specific about cracking a protected system (that I know of) that any other
language doesn't have."

Good luck.
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: 21 Jul 1998 18:23:44 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: regexp question
Message-Id: <eli$9807211410@qz.little-neck.ny.us>

In comp.lang.perl.misc, Tad McClellan <tadmc@flash.net> wrote:
> Tim Gray (tim@hcirisc.cs.binghamton.edu) wrote:
> : I am trying to come up with a regexp that will match the size
> : attribure in an HTML <FONT> tag and am failing miserably.
> : Why doesn't this expression
> : m/<font.*?\s(SIZE=.*?)[>\s]/
> : match this string?
> : <font COLOR="#006600" SIZE="+1">
>    Ahh, but it *does* match:

Yup. It will also match some hideously ugly other things, which
is perhaps why he was confused.

#!/usr/bin/perl -w

$tad_sample = '<font COLOR="#006600" SIZE="+1">';

if ( $tad_sample =~ /<font.*?\s(SIZE=.*?)[>\s]/)
   {print "in tad_sample matched '$1'\n"}
else
   {print "NOT matched in tad_sample\n"}

$eli_sample = '<font FACE="Spiffy Widgets"><sometag FOO=BAR SIZE="small">
	       <font COLOR="#006600" SIZE="+1">';

if ( $eli_sample =~ /<font.*?\s(SIZE=.*?)[>\s]/)
   {print "in eli_sample matched '$1'\n"}
else
   {print "NOT matched in eli_sample\n"}

__END__

:r! perl5 -wx %
in tad_sample matched 'SIZE="+1"'
in eli_sample matched 'SIZE="small"'

> : Any help is appreciated.
>    You don't have a problem  ;-)

Yes he does. He is using .*? rather than a normal greedy RE and has
not thought through the consequences.

I would use (for hacks where I do not need to worry about vicious
text in ALT, etc):

	/<font[^>]*\s(SIZE=[^\s>]*)/

or

	/<font[^>]*\b(SIZE=['"+\d-]*)/i

My REs, unlike Tim's, cannot go past the end of a FONT tag.

Elijah
------
insert .*?-causes-more-confusion-than-it-is-worth rant


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

Date: Tue, 21 Jul 1998 18:51:32 GMT
From: bhoyle@huntersville.org
Subject: Sorting Lists of Lists
Message-Id: <35b4d3eb.87227264@news.vnet.net>

I have a text file with the following line patterns:

field1|field2|field3|34.2|23.1|2.4|
field1|field2|field3|48.3|12.2|9.8|
field1|field2|field3|27.8|32.9|6.7|
field1|field2|field3|16.3|45.8|5.1|

I read this file into an @array. Then step through it linebyline.

What I need to do is add another field in each record to indicate the
ranking of the fourth field in relation to all the other records. The
final text file needs to look like this:

field1|field2|field3|34.2|23.1|2.4|3
field1|field2|field3|48.3|12.2|9.8|4
field1|field2|field3|27.8|32.9|6.7|2
field1|field2|field3|16.3|45.8|5.1|1

The last field is the rank based on the fourth field.

Any ideas would be greatly appreciated. I have used $a <=> $b, but it
only sorts horizontally, and not vertically.

Thanks in advance.


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

Date: Tue, 21 Jul 1998 12:58:11 -0700
From: eharley@pacbell.net (Eric Harley)
Subject: Re: Sorting Lists of Lists
Message-Id: <eharley-2107981258120001@ppp-207-214-149-103.snrf01.pacbell.net>

> I have a text file with the following line patterns:
> 
> field1|field2|field3|34.2|23.1|2.4|
> field1|field2|field3|48.3|12.2|9.8|
> field1|field2|field3|27.8|32.9|6.7|
> field1|field2|field3|16.3|45.8|5.1|
> 
> I read this file into an @array. Then step through it linebyline.
> 
> What I need to do is add another field in each record to indicate the
> ranking of the fourth field in relation to all the other records. The
> final text file needs to look like this:
> 
> field1|field2|field3|34.2|23.1|2.4|3
> field1|field2|field3|48.3|12.2|9.8|4
> field1|field2|field3|27.8|32.9|6.7|2
> field1|field2|field3|16.3|45.8|5.1|1
> 
> The last field is the rank based on the fourth field.
> 
> Any ideas would be greatly appreciated. I have used $a <=> $b, but it
> only sorts horizontally, and not vertically.


$data = "data.txt";
open DATA,$data;

while (<DATA>) {
        chomp;
        push @$vals,[split/\|/];
}

foreach $rarray(sort {$$a[3] <=> $$b[3]} @$vals) {
        $i++;
        $str = join "|",@$rarray;
        print "$str|$i\n";
}

-- 
Eric Harley
Freelance Programmer
  You need it done, I'm your man.

eharley@pacbell.net
http://burn.victim.com/~eharley


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

Date: Tue, 21 Jul 1998 18:12:39 GMT
From: montyh@umich.edu (monty hindman)
Subject: Subroutine Mystery
Message-Id: <rS4t1.4624$24.27224491@news.itd.umich.edu>

Can anyone tell me why the second program gives a compiling error?

# Works.
sub Go {
    $x = 1 ;
    @y = (1, 2, 3) ;
}
Go ;
print "$x @y \n" ;

# Doesn't work.
sub Go ;
Go ;
print "$x @y \n" ;
sub Go {
    $x = 1 ;
    @y = (1, 2, 3) ;
}
--
=======================
Monty Hindman
8500 S.W. Canyon Dr. #8
Portland, OR  97225
(503) 291-1752
montyh@umich.edu
=======================


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

Date: Tue, 21 Jul 1998 12:53:55 -0700
From: "Larry" <larryq@nospam.tuttle.com>
Subject: Re: Turning 13 lines of text into one
Message-Id: <6p2rqf$4t9$1@nnrp2.crl.com>

Thanks very much for all of your posts!  Problem is now solved thanks to
each of you.






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

Date: Tue, 21 Jul 1998 19:22:40 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Using splice with for
Message-Id: <4U5t1.94$dm.5926815@news3.voicenet.com>

I have the need to search an array[1] for a specific element, and remove
it.  splice seems like the natural way to accomplish this, however, I'm
stuck with a C style for loop when trying to find the offset where I
want to splice at.  Sample:

for (my $x = 0; $x < @array; $x++) {
    splice(@array, $x, 1), last if $array[$x] eq 'condition';
}

This works for what I need, but, this seems like a very non-Perlian way
to go about getting what I need.  I've considered using: 

@array = grep { $_ ne 'condition' } @array;

But that seems excessive.  My question is: Has anybody else come up with
an elegant solution to this?


[1] <RANT type="design philosophy">
Lets not get involved in the 'If you're searching an array, you're
doing it wrong, you should be using a hash' thread again.  Yes, I
realize that *most* of the time, this is the way to go, but this is not
one of those times.  I have a host of subs already built on using lists
of lists, which works very well for accessing a database (Specifically,
subs to process '$cursor->fetchall_arrayref' which returns a LoL).  It's
also important for me to keep the data in order (Running the proposed
hash through sort everytime I need it is ludicrous).  Having said all
this, if you want to argue this point, at least change the Subject.
</RANT>

-- 
Matt Knecht - <hex@voicenet.com>
"496620796F752063616E207265616420746869732C20796F7520686176652066
617220746F6F206D7563682074696D65206F6E20796F75722068616E6473210F"


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

Date: Tue, 21 Jul 1998 07:47:18 -1000
From: "Neal Miyake" <sponge@iav.com>
Subject: Win32 installed solved! (was Re: Win32 install prob--another idiot)
Message-Id: <6p2k7r$c3v@enews2.newsguy.com>

I wrote:
>I'm trying to install Perl for Win32 (from Activeware, version 5.003) onto
>my NT Server running IIS3.  It loads fine, and seems to work.  I can do the
>"helloworld.pl" from the command line no prob (there is a path set to the
>perl.exe file) <snip>

Just to followup on my progress:
1.  Using Clinton Gormley's suggestion, I tried this fix--Configuring and
Testing a PERL Script with IIS:
http://support.microsoft.com/support/kb/articles/q150/6/29.asp
(fortunately, I have MSDN access)
Although I have IIS4 (not IIS3), it seems like I needed to do this to make
it work.

2.  Followed this up with a post called "Perl commands in NT Q's", inquiring
about NT equivalents for some unix commands.  After trying to no avail, I
chanced on a website addressing my problem--Perl can't run external commands
(http://www.4images.com/ntperl/iis4.htm).  Anyway, I had to tweak the
registry again (always spooky).  Now I could try and make the commands work.

3.  Commands:
date--didn't realize that Perl had a built-in date commands.  Using date()
and localdate(date()), I think I've solved my problems.  Thanks again,
Clinton.
pwd--as suggested by Mark Stang, I used "cd c:" to return my directory path.
Haven't gotten a chance to check out the sites recommended by Sabre Taylor
that have unix commands ported to Win32.  Hopefully will not need to.

I know that this is not the forum for "thank you's", but I think my followup
will help anyone else trying a similar configuration.

Aloha,
Neal Miyake







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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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