[12375] in Perl-Users-Digest
Perl-Users Digest, Issue: 5975 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 13 02:07:21 1999
Date: Sat, 12 Jun 99 23:00:19 -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 Sat, 12 Jun 1999 Volume: 8 Number: 5975
Today's topics:
Re: ActivePerl Win98 CGI Problem <mark.dootson@ndirect.co.uk>
Re: Alter name of an array? <tchrist@mox.perl.com>
better way? (Filip M. Gieszczykiewicz)
Re: Call Shell Script <rootbeer@redcat.com>
Re: File Locking <tchrist@mox.perl.com>
Re: gd question <rootbeer@redcat.com>
Help on "while" behavior sought <onecor@hotmail.com>
Re: Help on "while" behavior sought <uri@sysarch.com>
Re: help with matching patterns (Randal L. Schwartz)
Re: importing comma-delimited data into perl? <tchrist@mox.perl.com>
Re: Log file (Marcel Grunauer)
MLDBM Error. HELP! <david@coppit.org>
Re: multiple match & replace regexp (Hasanuddin Tamir)
Re: PerlScript ... what features are missing? (Marcel Grunauer)
Re: PerlScript ... what features are missing? <rootbeer@redcat.com>
Problems with foreing characters <jphilrob@axess.com>
Re: Problems with foreing characters <rootbeer@redcat.com>
Re: Pull out HREFs from text? <rootbeer@redcat.com>
Re: sorting <rootbeer@redcat.com>
Re: sorting (Larry Rosler)
Re: Subs that can operate on $_ in void context? <rootbeer@redcat.com>
Re: using perl scripts in VC++'s post-build step <rootbeer@redcat.com>
Re: Which first unlock() or close()? Unclear FAQ. (Ronald J Kimball)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 13 Jun 1999 03:51:48 +0100
From: "Mark Dootson" <mark.dootson@ndirect.co.uk>
Subject: Re: ActivePerl Win98 CGI Problem
Message-Id: <37631224.0@news.netdirect.net.uk>
Assuming you selected to associate .plx with perlis.dll during installation,
just save your scripts with the .plx extension.
Richard H wrote in message <375E869C.4A23FFFA@hotmail.com>...
>the1bob@my-deja.com wrote:
>>
>> Folks,
>>
>> I realize this may be a configuration question, which is why I already
>> persued some other newsgroups and listservs before coming here. Any
>> help would be truly appreciated...
>>
>> I have ActivePerl build 516 installed on a Win98 PC running the default
>> PWS web server software. I need to get Perl CGI scripts working. All
>> of my scripts run perfectly from the command line.
>>
>> Here is the simple CGI script that I am testing:
>>
>> print "Content-Type: html\/text\n\n";
>er.. why???? ^^^^^^^^^^
>try: text/html\n\n
>might help.
>
>Richard H
------------------------------
Date: 12 Jun 1999 21:58:11 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Alter name of an array?
Message-Id: <37632c53@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
"Paul Batt" <pbatt@pop.agri.ch> writes:
:Can you manipulate the name of an array? I'd need a way to continuously add
:a number to the names of arrays while creating them. The name of the first
:array should be @array_1, the next one should be called @array_2, etc. Is
:that possibly somehow or is there any alternate way?
That's wrong. Use a real data structure. I have never heard a C
programmer ask to do this. I have never heard a Pascal programmer ask
to do this. I have never heard a Fortran programmer ask to do this.
I have never heard a Java programmer ask to do this. What is it about
Perl programmers that leads them to this urge?
=head2 How can I use a variable as a variable name?
Beginners often think they want to have a variable contain the name
of a variable.
$fred = 23;
$varname = "fred";
++$$varname; # $fred now 24
This works I<sometimes>, but it is a very bad idea for two reasons.
The first reason is that they I<only work on global variables>.
That means above that if $fred is a lexical variable created with my(),
that the code won't work at all: you'll accidentally access the global
and skip right over the private lexical altogether. Global variables
are bad because they can easily collide accidentally and in general make
for non-scalable and confusing code.
Symbolic references are forbidden under the C<use strict> pragma.
They are not true references and consequently are not reference counted
or garbage collected.
The other reason why using a variable to hold the name of another
variable a bad idea is that the question often stems from a lack of
understanding of Perl data structures, particularly hashes. By using
symbolic references, you are just using the package's symbol-table hash
(like C<%main::>) instead of a user-defined hash. The solution is to
use your own hash or a real reference instead.
$fred = 23;
$varname = "fred";
$USER_VARS{$varname}++; # not $$varname++
There we're using the %USER_VARS hash instead of symbolic references.
Sometimes this comes up in reading strings from the user with variable
references and wanting to expand them to the values of your perl
program's variables. This is also a bad idea because it conflates the
program-addressable namespace and the user-addressable one. Instead of
reading a string and expanding it to the actual contents of your program's
own variables:
$str = 'this has a $fred and $barney in it';
$str =~ s/(\$\w+)/$1/eeg; # need double eval
Instead, it would be better to keep a hash around like %USER_VARS and have
variable references actually refer to entries in that hash:
$str =~ s/\$(\w+)/$USER_VARS{$1}/g; # no /e here at all
That's faster, cleaner, and safer than the previous approach. Of course,
you don't need to use a dollar sign. You could use your own scheme to
make it less confusing, like bracketed percent symbols, etc.
$str = 'this has a %fred% and %barney% in it';
$str =~ s/%(\w+)%/$USER_VARS{$1}/g; # no /e here at all
Another reason that folks sometimes think they want a variable to contain
the name of a variable is because they don't know how to build proper
data structures using hashes. For example, let's say they wanted two
hashes in their program: %fred and %barney, and to use another scalar
variable to refer to those by name.
$name = "fred";
$$name{WIFE} = "wilma"; # set %fred
$name = "barney";
$$name{WIFE} = "betty"; # set %barney
This is still a symbolic reference, and is still saddled with the
problems enumerated above. It would be far better to write:
$folks{"fred"}{WIFE} = "wilma";
$folks{"barney"}{WIFE} = "betty";
And just use a multilevel hash to start with.
The only times that you absolutely I<must> use symbolic references are
when you really must refer to the symbol table. This may be because it's
something that can't take a real reference to, such as a format name.
Doing so may also be important for method calls, since these always go
through the symbol table for resolution.
In those cases, you would turn off C<strict 'refs'> temporarily so you
can play around with the symbol table. For example:
@colors = qw(red blue green yellow orange purple violet);
for my $name (@colors) {
no strict 'refs'; # renege for the block
*$name = sub { "<FONT COLOR='$name'>@_</FONT>" };
}
All those functions (red(), blue(), green(), etc.) appear to be separate,
but the real code in the closure actually was compiled only once.
So, sometimes you might want to use symbolic references to directly
manipulate the symbol table. This doesn't matter for formats, handles, and
subroutines, because they are always global -- you can't use my() on them.
But for scalars, arrays, and hashes -- and usually for subroutines --
you probably want to use hard references only.
--
[End of diatribe. We now return you to your regularly scheduled
programming...]
--Larry Wall in Configure from the perl distribution
------------------------------
Date: 13 Jun 1999 05:58:23 GMT
From: fmgst+@pitt.edu (Filip M. Gieszczykiewicz)
Subject: better way?
Message-Id: <7jvh9v$ahe$1@usenet01.srv.cis.pitt.edu>
I pass information back and forth between a processing script and some
individual files using the last 4 lines of each file. Ie. the file
contains INFO + 4 lines that nobody ever sees except my big script.
Directly translating this from the !/bin/sh monster that this _used_
to be yields:
-----------------chop-with-axe----------------chop-with-axe---------------------
open (HAND1,$readfile) or
&Die("ERROR: Can't open '$readfile'!\n",__LINE__);
open (HAND2,">$FSECTION") or
&Die("ERROR: Can't write to '$FSECTION'!\n",__LINE__);
# Slurp in whole file - we'll only care about last 4 lines
@tmpstack = <HAND1> or
&Die("ERROR: Can't open or '$readfile' empty!\n",__LINE__);
#
# Ugly... and probably really retarded...
@tmpar = split(pop(@tmpstack)); # last line
$tmpvar1 = $tmpar[1]; # last line's item
@tmpar = split(pop(@tmpstack)); # last-1 line
$tmpvar2 = $tmpar[1]; # last-1 line's item
@tmpar = split(pop(@tmpstack)); # last-2 line
$tmpvar3 = $tmpar[1]; # last-2 line's item
@tmpar = split(pop(@tmpstack)); # last-3 line
$tmpvar4 = $tmpar[1]; # last-3 line's item
#
# Dump them in "correct order"
print HAND2 $tmpvar4;
print HAND2 $tmpvar3;
print HAND2 $tmpvar2;
print HAND2 $tmpvar1;
flush(HAND2);
#
close (HAND1); close (HAND2);
-----------------chop-with-axe----------------chop-with-axe---------------------
Now, other than playing with [hide and] seek, is there a better "simple"
way of extracting JUST the last 4 lines into variables? The split is
needed (I think?) because I really want just the second item on each
line, of the form:
TLJINTERNALIGNORE <value1>
...
TLJINTERNALIGNORE <value4>
Big script runs through dozens of 200-600KB files and I want to make it
as "interactive" as possible (ie. minimize the lag between executing
script and it being done :-).
Vitals:
Perl5.004_04 on AMDK6/300 & 128MB under Linux RH 5.2 (2.2.2 kernel)
Much thanks for reading this far and responding.
Cheers,
Filip.
P.S. Have read FAQ, have books, have all perl Nutshell books, etc. :)
--
Filip "I'll buy a vowel" Gieszczykiewicz | http://www.repairfaq.org/
Always and everything for the better!
Now exploring whatever, life, and the meaning of it all... and 'not' :-)
------------------------------
Date: Sat, 12 Jun 1999 21:42:34 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Call Shell Script
Message-Id: <Pine.GSO.4.02A.9906122139160.6999-100000@user2.teleport.com>
On Sat, 12 Jun 1999, Raj wrote:
> Can a Shell Script be invoked from CGI/Perl Script?
Since shell scripts (and other programs) can be called from Perl scripts,
they can generally be called from Perl scripts running in a CGI
environment.
> if so ...how?
In the same way you call other programs from a Perl program which isn't
running in a CGI environment. See the perlfunc and perlop manpages for
information on system(), qx``, and piped open(), to get started. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 12 Jun 1999 23:06:40 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: File Locking
Message-Id: <37633c60@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
lr@hpl.hp.com (Larry Rosler) writes:
:That depends. If the OS supports lockf(2), there is a flag F_TEST 'test
:region for lock'. The region can be the entire file.
This seems like a silly idea, beause it would seem that either you're
opening yourself up to a race condition, or else you're right back where
you started from. Perhaps I'm missing something.
:One could invoke lockf() using syscall with the appropriate arguments.
Only if it's actually a system call in the technical sense of the
word. It often is not.
I don't see what LOCK_NB wouldn't address, but I'm also not
entirely sure what the original querent really needed to know.
--tom
--
I dunno, I dream in Perl sometimes...
--Larry Wall in <8538@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Sat, 12 Jun 1999 22:45:12 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: gd question
Message-Id: <Pine.GSO.4.02A.9906122244440.6999-100000@user2.teleport.com>
On Sun, 13 Jun 1999 bababozorg@aol.com wrote:
> does anyone knows if i can make more than 1 image (gif) with the
> module GD at the same time?
If you can't, your GD is broken. Or you are. :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 13 Jun 1999 04:42:27 GMT
From: "Not So Newbie"<onecor@hotmail.com>
Subject: Help on "while" behavior sought
Message-Id: <929248947.13122@router1.nyct.net>
I've been trying to write an elementary program to
put two lines of an input file into one line of the
output (variants, three lines into one, etc.)
I've done it, using a for loop.
I first tried:
while (<INPUT>) {
$one = <INPUT>; chomp $one;
$two = <INPUT>; chomp $two;
print " $one $two \n";
}
But this skips the first line and every third line
afterwards. I'm missing something. I can't find it
in the books I have. TIA.
------------------------------
Date: 13 Jun 1999 01:31:03 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Help on "while" behavior sought
Message-Id: <x73dzwis4o.fsf@home.sysarch.com>
>>>>> "NSN" == Not So Newbie <Not> writes:
your name is a misnomer. this is such a newbie problem.
NSN> while (<INPUT>) {
that reads a line. it is stored in $_ by default since you didn't assign it.
and you never use the line so it discarded in the next iteration.
NSN> $one = <INPUT>; chomp $one;
NSN> $two = <INPUT>; chomp $two;
those read the second and third lines as you have seen.
there are many ways to fix this. here is a simple one.
while( defined( $one = <INPUT> ) ) {
# defined may not be necessary, depending on your version of perl
$two = <INPUT> ;
chomp $one, $two ;
etc.
}
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: 12 Jun 1999 20:59:31 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: help with matching patterns
Message-Id: <m1yahopx7g.fsf@halfdome.holdit.com>
>>>>> "Pete" == Pete <psalzman@landau.ucdavis.edu> writes:
Pete> i'd like to write a routine that searches /usr/dict/words for specified
Pete> strings.
Pete> where in $pattern, lowercase is literal and uppercase is a place holder.
Pete> so if $pattern = AaBe
Pete> name, cake and have are matched
Pete> tate, babe and dade are NOT matched
Pete> if $patter = ABBk
Pete> look, book are matched
Pete> back, hack are not matched
That's a good puzzle, so I decided to take it on. The only ambigious
part of the spec was if a template letter (A B) could be the same or
not as a literal letter (a e). I imagined you using this for amateur
crypto, so I presumed not.
Here's what I came up with. Check out the displayed regex to see what
I did. Basically, you need a negative lookahead to make sure that the
next "." you're about to match isn't one of the previous memories, or
one of the literal letters.
If a template letter *can* duplicate a literal letter, then
make my @avoid be empty instead of conditionally full.
#!/usr/bin/perl -w
use strict;
open WORDS, "/usr/dict/words" or die "no more words: $!";
for (@ARGV) {
my @avoid = do {
my @lits = /[a-z]/g;
@lits ? "[" . join("", @lits) . "]" : ()
};
my %template;
my $regex = "^";
for (split //) {
if (/[a-z]/) {
$regex .= "$_";
} elsif (/[A-Z]/) {
if (exists $template{$_}) {
$regex .= $template{$_};
} else {
my $id = 1 + keys %template;
if (@avoid) {
$regex .= "(?!" . join("|", @avoid) . ")";
}
$regex .= "(.)";
push @avoid, $template{$_} = "\\$id";
}
} else {
warn "ignoring $_";
}
}
$regex .= "\$";
print "$_ => $regex\n";
seek WORDS, 0, 0;
while (<WORDS>) {
next unless /$regex/i;
print;
}
}
Here's a sample run:
$ pat AaBe ABBk ABBA ABCDEFGHIJKLM ABCDEFGHIJKLMN
AaBe => ^(?![ae])(.)a(?![ae]|\1)(.)e$
bade
bake
bale
bane
bare
base
cafe
cage
cake
came
cane
cape
care
case
cave
dale
dame
Dane
dare
date
Dave
daze
face
fade
fake
fame
fare
fate
faze
gale
game
gape
gate
gave
gaze
hale
hare
hate
have
haze
jade
Jake
Jane
Kane
Kate
lace
lake
lame
lane
late
Laue
mace
made
make
male
mane
mare
mate
maze
name
Nate
pace
page
pale
pane
pare
pate
pave
race
rage
rake
rape
rate
rave
raze
safe
sage
sake
sale
same
sane
sate
save
take
tale
tame
tape
vale
vane
vase
wade
wage
wake
wane
ware
wave
Yale
ABBk => ^(?![k])(.)(?![k]|\1)(.)\2k$
book
cook
hook
leek
look
meek
nook
peek
rook
seek
took
week
ABBA => ^(.)(?!\1)(.)\2\1$
Abba
Anna
boob
deed
noon
Otto
peep
sees
ABCDEFGHIJKLM => ^(.)(?!\1)(.)(?!\1|\2)(.)(?!\1|\2|\3)(.)(?!\1|\2|\3|\4)(.)(?!\1|\2|\3|\4|\5)(.)(?!\1|\2|\3|\4|\5|\6)(.)(?!\1|\2|\3|\4|\5|\6|\7)(.)(?!\1|\2|\3|\4|\5|\6|\7|\8)(.)(?!\1|\2|\3|\4|\5|\6|\7|\8|\9)(.)(?!\1|\2|\3|\4|\5|\6|\7|\8|\9|\10)(.)(?!\1|\2|\3|\4|\5|\6|\7|\8|\9|\10|\11)(.)(?!\1|\2|\3|\4|\5|\6|\7|\8|\9|\10|\11|\12)(.)$
consumptively
copyrightable
unpredictably
ABCDEFGHIJKLMN => ^(.)(?!\1)(.)(?!\1|\2)(.)(?!\1|\2|\3)(.)(?!\1|\2|\3|\4)(.)(?!\1|\2|\3|\4|\5)(.)(?!\1|\2|\3|\4|\5|\6)(.)(?!\1|\2|\3|\4|\5|\6|\7)(.)(?!\1|\2|\3|\4|\5|\6|\7|\8)(.)(?!\1|\2|\3|\4|\5|\6|\7|\8|\9)(.)(?!\1|\2|\3|\4|\5|\6|\7|\8|\9|\10)(.)(?!\1|\2|\3|\4|\5|\6|\7|\8|\9|\10|\11)(.)(?!\1|\2|\3|\4|\5|\6|\7|\8|\9|\10|\11|\12)(.)(?!\1|\2|\3|\4|\5|\6|\7|\8|\9|\10|\11|\12|\13)(.)$
ambidextrously
$
print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 12 Jun 1999 22:56:27 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: importing comma-delimited data into perl?
Message-Id: <376339fb@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc, Jeff Zucker <jeff@vpservices.com> writes:
:Those will handle all CSV (comma separated values, also called
:comma-delimited data)
Only by those who don't know what one or more of the words "comma",
"separated", and "delimited" mean. :-)
--tom
--
"There lives more faith in honest doubt, believe me, than in half the creeds."
- Alfred, Lord Tennyson
------------------------------
Date: Sun, 13 Jun 1999 02:33:24 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: Log file
Message-Id: <376714a6.8275759@enews.newsguy.com>
On 12 Jun 1999 15:57:47 GMT, twarren10@aol.com (Twarren10) wrote:
>I am writing a simple program to log what people are seaching for and the
>number of times they search. It's basic and uncomplicated, and perl gives no
>error messages, but it doesn't work. Can anyone tell me what might cause this
>not to work. I've gone over it several times and can't catch anything wrong.
>here's the code.
What does "it doesn't work" mean? Does it die with an error? Does it
output anything? What does the log file look like? Which output do you
expect?
Put the following at the top of your program:
#!/usr/bin/perl -w
use strict;
perlfaq3: How do I debug my Perl programs?
Have you used C<-w>? It enables warnings for dubious practices.
Have you tried C<use strict>? It prevents you from using symbolic
references, makes you predeclare any subroutines that you call as bare
words, and (probably most importantly) forces you to predeclare your
variables with C<my> or C<use vars>.
>
>sub log_searches {
>
>$log_file = "search.log";
>if ("$log_file") {
That doesn't do what you think it does (I'm making a wild guess here
and assume you want to check whether that file exists). The condition
as given is true all the time, since a nonempty string (that's also
not "0" is always true).
You probably want
if (-e $log_file)
(see perldoc -q stat). Make sure the $log_file contains the complete
path to the log file, not just the file name.
> open (FILE1, "$log_file");
No need to construct a string here. See below.
> open (FILE2, ">>$log_file2");
Always check whether opening a file was successful and return the
error message:
open(FILE1, $log_file) || die "can't open $log_file: $!\n";
> @LOG = <FILE1>;
> $matched = 0;
> foreach $line (@LOG) {
> ($searched_word, $times) = split(/:/,$line);
> if ($searchstring eq $searched_word) {
> $times = ($times + 1);
times++;
> $matched = 1;
> print FILE2 "$searched_word:$times\n";
> }
> else {
> print FILE2 "$searched_word:$times\n";
> }
> }
> if ($matched == 0) {
> print FILE2 "$searched_word|1\n";
> }
> close (FILE1);
> close (FILE2);
> rename ("$log_file2", "$log_file");
> }
>else {
>exit;
>}
>}
>
The whole
if ($e $log_file) {
#whatever
} else {
exit
}
could be simplified to:
-e $log_file or die "file not found: $log_file\n";
(Some time later...)
Ok, I'm beginning to understand what you're trying to do. The log file
will look something like
word1:17
word2:23
...
But then there is no need to have two files open. Just read the whole
word list from the existing log file, close it again, process it, then
open the log file again, this time for writing, and write out the list
of words. This also removes the need to rename the file at the end
(which wouldn't have worked anyway since the old log file is still
there).
Also, to make things easier, try using a hash like in the following
completed program (use the documentation for any parts you might not
be comfortable with):
#!/usr/bin/perl -w
use strict;
my $log_file = "search.log";
my $searchstring = "word3";
-e $log_file or die "file not found: $log_file\n";
open(FILE, $log_file) || die "can't open $log_file for reading: $!\n";
my %count = map { chomp; split /:/ } <FILE>;
close FILE;
$count{$searchstring}++;
open(FILE, ">$log_file") || die "can't open $log_file for writing:
$!\n";
print FILE join "\n", map { "$_:$count{$_}" } keys %count;
close FILE;
HTH
Marcel
------------------------------
Date: Sun, 13 Jun 1999 00:53:13 -0400
From: David Coppit <david@coppit.org>
Subject: MLDBM Error. HELP!
Message-Id: <Pine.GSO.4.05.9906130044450.22728-100000@mamba.cs.Virginia.EDU>
I get this error:
MLDBM error: Second level tie failed, "Invalid argument" at NCDatabase.pm line 3
Can't open database: Invalid argument
on this line:
$db_obj = tie (%db, 'MLDBM', $thedb, O_RDWR|O_CREAT, 0666)
or die "Can't open database: $!\n";
The code works fine on Solaris & RedHat running 5.00502 and 5.00503.
Poking around in MLDBM's TIEHASH, I find that it's croaking right here:
$db = $db->TIEHASH(@_)
or carp "MLDBM error: Second level tie failed, \"$!\""
and return undef;
Printing "$db @_" on both platforms shows them seeing the same $db and @_.
I'm stuck. :( Got any clues?
Thanks for any help,
David
_________________________________________________________________________
David Coppit - Graduate Student david@coppit.org
The University of Virginia http://coppit.org/
"Yes," said Piglet, "Rabbit has Brain." There was a long silence.
"I suppose," said Pooh, "that that's why he never understands anything."
------------------------------
Date: 13 Jun 1999 19:04:17 GMT
From: hasant@trabas.co.id (Hasanuddin Tamir)
Subject: Re: multiple match & replace regexp
Message-Id: <slrn7m6dp2.dfa.hasant@borg.intern.trabas.co.id>
On Sat, 12 Jun 1999 07:18:03 -0700, Larry Rosler <lr@hpl.hp.com> wrote:
> In article <slrn7m3vvq.6t5.hasant@borg.intern.trabas.co.id> on 13 Jun
> 1999 00:06:17 GMT, Hasanuddin Tamir <hasant@trabas.co.id> says...
> > On Fri, 11 Jun 1999 19:18:32 +0200, Ondrej Palkovsky <xpalo03@vse.cz> wrote:
> > > regurg wrote:
> > > > What I don't know, however is this: what if I want to
> > > > replace $1 ... $3 with something else? Analagous to this
> > > > (which doesn't work):
> > > > if (/...( )...( )...( )/) {
> > > > $1 = "foo";
> > > > $2 = "bar";
> > > > $3 = "smar";
> > > > }
> ...
> > > What about
> > > s/(...) (...) (...) /$1foo$2bar$3smar/;
> >
> > search for `subroutine substitution'.
> > shortly, you need a subroutine to process
> > each match found.
> >
> > s/...(MATCH1|MATCH2).../a_function($1)/e
>
> Why do you need a subroutine? Any code can be evaluated; a subroutine
> call is just one special case.
I was just trying to give a picture how the code
from the past posting looked like.
--
-hasan-
uhm, no more sig(h)
------------------------------
Date: Sun, 13 Jun 1999 02:40:47 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: PerlScript ... what features are missing?
Message-Id: <37681972.9503335@enews.newsguy.com>
On Sat, 12 Jun 1999 20:19:09 -0700, "Ken Snyder" <ksnyde@msn.com>
wrote:
>When using "PerlScript" under ASP I noticed that assigning a variable like
>this:
>
> $myVariable << 'END_OF_HTML';
> <html>
> hello world
> </html>
> END_OF_HTML
> print $myVariable;
>
>Doesn't work. It works fine under just Perl. Anyone have an idea how I can
>get this to work under PerlScript? Anyone know the functional list of
>things that don't work under PerlScript?
Shurely shome mishtake.
$myVariable = << etc.
Instead of print $MyVariable, try:
$Response->Write($MyVariable);
HTH
Marcel
------------------------------
Date: Sat, 12 Jun 1999 21:49:25 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: PerlScript ... what features are missing?
Message-Id: <Pine.GSO.4.02A.9906122147010.6999-100000@user2.teleport.com>
On Sat, 12 Jun 1999, Ken Snyder wrote:
> Newsgroups: comp.lang.perl, comp.lang.perl.misc
If your news administrator still carries comp.lang.perl, please let him
or her know that that newsgroup has not existed since 1995. If you
have such an outdated newsgroup listing, you are probably missing out
on many other valid newsgroups as well. You'll be doing yourself and
many others a favor to use only comp.lang.perl.misc (and other valid
Perl newsgroups) instead.
> When using "PerlScript" under ASP I noticed that assigning a variable
> like this:
>
> $myVariable << 'END_OF_HTML';
> <html>
> hello world
> </html>
> END_OF_HTML
> print $myVariable;
>
> Doesn't work.
Well, of course not! Besides the syntax error and HTML error, you can't
(simply) indent here-documents like that.
> Anyone know the functional list of
> things that don't work under PerlScript?
If the release notes don't tell you, complain. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 13 Jun 1999 03:15:28 GMT
From: "Jean-Philippe Robichaud" <jphilrob@axess.com>
Subject: Problems with foreing characters
Message-Id: <01beb54b$266ffa40$34a6eccd@ruth>
Hi, I'm writting code with perl 5 for win32... I have a script who retreive
the path of a specific file and print it into a plain text file.
Here is my problem : if the path contain a character like 'i' ascii=136,
it will be printed as |, which is not really what I want... In fact, the
string
E:\mp3files\Bichard Mix\
become :
E:\mp3files\B|chard Mix\
What can I do (except rename the directories !) ?
Thanks for your help
--
Jean-Philippe Robichaud
jphilrob@axess.com
http://www.axess.com/users/alainr/
"Perfection is achieved, not when there is nothing left to add,
but when there is nothing left to take away. "
- Antoine de St. Exupery
------------------------------
Date: Sat, 12 Jun 1999 22:54:17 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Problems with foreing characters
Message-Id: <Pine.GSO.4.02A.9906122246280.6999-100000@user2.teleport.com>
On 13 Jun 1999, Jean-Philippe Robichaud wrote:
> I have a script who retreive the path of a specific file and print it
> into a plain text file.
> if the path contain a character like '=E9' ascii=3D136, it will be printe=
d
> as |, which is not really what I want...
Perl shouldn't be mangling filenames. Can you make a short (five lines or
so) example program which shows how this happens?
In my testing, I don't see Perl causing this problem on a Unix system,
although you may need to pipe the output through another program (such as
od on Unix) to see just which characters are being output.
perl -lwe 'print while <weird*>'
You may need to use double quotes to use that command line on a
Windows-type system. Cheers!
--=20
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 12 Jun 1999 21:50:52 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Pull out HREFs from text?
Message-Id: <Pine.GSO.4.02A.9906122150250.6999-100000@user2.teleport.com>
On Sun, 13 Jun 1999, Ken Williams wrote:
> I would like to preserve all the hrefs within the text before I strip
> out the html. How could I do this?
Use a parser. CPAN has HTML::Parser. Good luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 12 Jun 1999 21:32:14 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: sorting
Message-Id: <Pine.GSO.4.02A.9906122126030.6999-100000@user2.teleport.com>
On 12 Jun 1999, Jimtaylor5 wrote:
> How would I sort the names and numbers so they list correctly.
Have you seen the entry on sorting in perlfunc? And in the FAQ? Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 12 Jun 1999 14:31:43 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: sorting
Message-Id: <MPG.11cc717f6a1041d3989bd2@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <19990612141635.01261.00000970@ng-fb1.aol.com> on 12 Jun 1999
18:16:35 GMT, Jimtaylor5 <jimtaylor5@aol.com> says...
> I have a file which holds a list of two fields (name and how many sales) and I
> would like to sort the list with the highest sales on top. For example the list
> is like this:
> Bob jones|9
> Jim jones|2
> David jones|10
> Sally jones|1
> Bill Bates|3
>
> etc. I want to sort it so david is on top and the next highest sales (bob
> jones) next, etc., etc., to the end of list.
>
> I read the file in, but how do I sort it and then save it. can anyone help me
> out with this? Please. How would I sort the names and numbers so they list
> correctly.
perlfaq4: "How do I sort an array by (anything)?"
perldoc -f chomp
perldoc -f split
perldoc -f sort
PS: Set your newsreader to wrap shorter lines, say 72 characters.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 12 Jun 1999 21:22:00 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Subs that can operate on $_ in void context?
Message-Id: <Pine.GSO.4.02A.9906122048020.6999-100000@user2.teleport.com>
On Sat, 12 Jun 1999, Marcel Grunauer wrote:
> is there a way for a sub to operate on the default variable ($_) if it
> is used in a void context, much like chop and chomp do?
Of course, $_ isn't Perl's only default; it's just Perl's favorite
default. But I don't think that you mean "void context" there. (Do you?) I
think you mean something like this:
my_func($fred); # should use $fred
my_func; # should use $_ by default
Each of those is called in a void context (unless either is the return
value of a sub-like block).
You can check the number of parameters passed to your function by
examining @_ in a scalar context. But beware! If someone calls your sub
the wrong way, it won't necessarily get zero arguments.
&my_func; # implicitly passes current @_ to &my_func
In addition, if you want your sub to modify the (possibly implicit)
parameter, it gets more complex. You could use code like this:
sub my_inc (;$) {
# Use the passed arg, or use $_ if no arg
my $ref = @_ ? \$_[0] : \$_;
# Now use $$ref as the variable
++$$ref;
}
It may be safer and easier to simply ask the caller to explicitly name the
parameters. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 12 Jun 1999 21:45:55 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: using perl scripts in VC++'s post-build step
Message-Id: <Pine.GSO.4.02A.9906122143350.6999-100000@user2.teleport.com>
On Sat, 12 Jun 1999, Dominik wrote:
> @files = < @ARGV >;
> The name specified is not recognized as an
> internal or external command, operable program or batch file.
> internal error: glob failed at my.pl line 1.
This last line is in perldiag; have you seen it? But the answer is that
you probably didn't mean to glob like you did. Did you simply want to copy
the array? Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 13 Jun 1999 00:30:13 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Which first unlock() or close()? Unclear FAQ.
Message-Id: <1dtban4.13g14zy1xee5goN@p37.tc1.metro.ma.tiac.com>
Mats Pettersson <mats.pettersson@falukuriren.se> wrote:
> I read the FAQ (perlfag5) on flock(), but it seems a bit unclear about
> which order to do things.
In general, you should close(), but not unlock(). When you close the
filehandle, the lock is released automatically. If you unlock() the
file before closing it, you may have a race condition where another
process can access the file before you close it.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
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 5975
**************************************