[15671] in Perl-Users-Digest
Perl-Users Digest, Issue: 3083 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 18 06:13:06 2000
Date: Thu, 18 May 2000 03:05:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <958644316-v9-i3083@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 18 May 2000 Volume: 9 Number: 3083
Today's topics:
"perldoc -f local" fails <jcook@strobedata.com>
Re: $0 doesn't give full path <new_user@email.msn.com>
Re: $0 doesn't give full path <you.will.always.find.him.in.the.kitchen@parties>
Re: *Please Help.New to Perl and CGI* <gellyfish@gellyfish.com>
Bug or Feature: Can't dereference array ref inside hash (Steve Leibel)
Re: Check to see if an array value is null <godzilla@stomp.stomp.tokyo>
Re: Check to see if an array value is null <uri@sysarch.com>
Re: credit card validation.....isn't working <dennis_marti@yahoo.com>
Delay in Perl <chpshi@connection.com>
Re: Delay in Perl (Craig Berry)
Re: Delay in Perl (Steve Leibel)
extracting a list from multiple regex matches (Jed Parsons)
Re: extracting a list from multiple regex matches <phill@modulus.com.au>
File lock (Jimtaylor5)
Fixed number of fields <risj5@hotmail.com>
Re: help - undef $/; ? (Neil Kandalgaonkar)
how to call PerlIS.dll in my own win32 programs <fchen0000@usa.net>
How to convert a long integer into hex <a.goode@qut.edu.au>
Re: How to execute "cat *.c" ??? (Villy Kruse)
Re: If slices are so great <new_user@email.msn.com>
Long datatype update problem <geoff@crc-sugar.jcu.edu.au>
Re: manipulating a text file with perl <gellyfish@gellyfish.com>
Re: Mixed results! <gellyfish@gellyfish.com>
Re: More Newbie Questions - Manipulating Data.... <gellyfish@gellyfish.com>
Re: MS Documents to text---help <gellyfish@gellyfish.com>
Re: MS Documents to text---help <HUhlmann@stn-atlas.de>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 18 May 2000 00:13:44 -0700
From: Jim Cook <jcook@strobedata.com>
Subject: "perldoc -f local" fails
Message-Id: <39239828.7337EA6B@strobedata.com>
It seems that no matter what I type after perldoc, I get the message
No documentation found for "*".
I've seen enough references to using perldoc that I would like to be
able to use it.
I downloaded the sources and built my own, and did a "make install"
Any clues?
--
jcook@strobedata.com Live Honourably 4/1 - 4/3 + 4/5 - 4/7 + . . .
2000 Tuesdays: Feb/last 4/4 6/6 8/8/ 10/10 12/12 9/5 5/9 7/11 11/7 3/14
Strobe Data Inc. home page http://www.strobedata.com
My home page O- http://jcook.net
------------------------------
Date: Wed, 17 May 2000 21:35:08 -0700
From: "|" <new_user@email.msn.com>
Subject: Re: $0 doesn't give full path
Message-Id: <Od3dYIIw$GA.348@cpmsnbbsa07>
> how can i get the fullpath? there has to be a way.
I'll preface this by saying that I'm a novice to Perl, so my advice may be
off base but I think
$dir = system("pwd")
should work on a Unix/Linux sys
jj
------------------------------
Date: Thu, 18 May 2000 21:27:02 +1200
From: "Tintin" <you.will.always.find.him.in.the.kitchen@parties>
Subject: Re: $0 doesn't give full path
Message-Id: <958641990.555191@shelley.paradise.net.nz>
"| " <new_user@email.msn.com> wrote in message
news:Od3dYIIw$GA.348@cpmsnbbsa07...
>
> > how can i get the fullpath? there has to be a way.
>
>
> I'll preface this by saying that I'm a novice to Perl, so my advice may
be
> off base but I think
>
> $dir = system("pwd")
>
> should work on a Unix/Linux sys
make it
$dir = `pwd`;
------------------------------
Date: 18 May 2000 08:19:53 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: *Please Help.New to Perl and CGI*
Message-Id: <8g05ip$a4r$1@orpheus.gellyfish.com>
On 17 May 2000 02:37:43 GMT SaintJAVA wrote:
>
> I have recently began learning Perl with the purpose of using it to write CGI
> scripts. I think I can grasp the Perl language, but I've found difficulty
> testing my scripts in a Web environment.
>
> I've installed the Microsoft Personal Web Server that comes with Windows 98
> hoping that its built in CGI bin would work out. It hasn't. Whenever I call a
> perl script in my cgi-bin directory I get a HTTP 500 - Internal server error
> message.
>
> Could anyone tell me:
> How can I configure my Windows server to excecute the perl scripts in my
> cgi-bin when I call them from a web page form?
>
> Is there an online resource that you know for a fact tells how to set up your
> webserver to process CGI requests?
>
The Activeperl documentation contains a FAQ that describes the configuration
of most common HTTP servers. If you have any further problems then you
will be better off asking in comp.infosystems.www.servers.ms-windows as
this applies equally to any language that uses an 'interpreter'.
/J\
--
Son, this is the only time I'm ever gonna say this. It is not okay
to lose.
--
fortune oscar homer
------------------------------
Date: Wed, 17 May 2000 23:03:51 -0700
From: stevel@coastside.net (Steve Leibel)
Subject: Bug or Feature: Can't dereference array ref inside hash
Message-Id: <stevel-1705002303510001@192.168.100.2>
If I have a hash reference, one of whose keys is an array ref, like this:
$myhash = {
arrayref => (),
};
In theory I should be able to dereference the arrayref using syntax such as
@$myhash->{arrayref}
However every variant of that gets errors, as the following program shows.
Is this a bug or a feature? Is there a better way to do what I want
without using an intermediate variable to hold the array ref?
I'm using 5.005_03 on FreeBSD.
Steve L
stevel@coastside.net
#!/usr/local/bin/perl
$myhash = {
arrayref => (),
};
#
# This gets a syntax error (when uncommented, of course):
# "Type of arg 1 to push must be array (not hash elem)"
#
#push (@$myhash->{arrayref}, 47);
#
# Trying parens doesn't help. This gets:
# "Scalar found where operator expected"
#
#push (@($myhash->{arrayref}), 47);
#
# The only way to make this work is to use an
# intermediate variable to hold the reference:
#
$bogus_array_ref = $myhash->{arrayref};
push (@$bogus_array_ref, 47);
$myhash->{arrayref} = $bogus_array_ref;
#
# Now use the same cheap trick to demonstrate
# that we have indeed pushed 47 onto the array.
# This program does produce the output x = 47.
#
$bogus_array_ref = $myhash->{arrayref};
foreach $x (@$bogus_array_ref) {
print "x = $x\n";
}
------------------------------
Date: Wed, 17 May 2000 23:05:10 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Check to see if an array value is null
Message-Id: <39238816.AEC24F3C@stomp.stomp.tokyo>
Ben Bostow wrote:
> I am trying to write a while loop that runs through an
> array and stops as soon as an array possition has no value.
How about a foreach loop instead?
This bit of code proved to be one of my
most challenging to write in Plain English.
This has to be the most verbose code and
most difficult to write in a simple fashion,
I have tossed together to date.
Ben, this code can shortened, sweetened
and made more eloquent. However, in doing
this, this code would no longer be written
in Plain English and would be challenging
simply to understand what is happening at
each step of processing. Eloquence is your
task if you adopt this method.
As is my best intent, I have included more
than asked. There are a number of techniques
included in this code which will be of help
to you, beyond finding an "empty" element.
An array is created with an empty element.
A counter is initialized to zero.
A loop begins and looks at each element.
A print takes place to confirm operation.
An empty element is found.
A "last" statement ends the loop.
A couple of new variables are created.
A nice print confirms all works right.
That's a squirrel's nutshell viewpoint.
This line:
print "Element $counter is: $element \n";
is included as a diagnostic tool to confirm
the loop 'stops' when it should, just before
element number 4, "Nyuk Nyuk". I use many
different diagnostic tools like this rather
than rely on buggy pragma hints and other
similar functions in Perl. I know my tool
will work. I also know pragma hints do not
always work right. This is also a tool not
available in Perl automation as well! This
diagnostic line would be removed in my
final script, along with other tools.
This line:
last;
is what terminates your loop after
finishing off, then jumps to the
next 'whatever' in line for the
program; create new variables.
Although not needed, my new variables,
'before' and 'after' show you how to
grab a value from a variable ($counter)
and manipulate this value without altering
or destroying the original variable, $counter.
Some subtraction and addition take place
to setup for showing how to access elements
in an array by numerical reference. Before is
one element number less than your empty
element and, after, well, it is clear
what it does.
These two lines show you how to mechanically
access any element in an array by number:
Previous Element Is $Test_Array[$before]
Next Element Is $Test_Array[$after]";
Note the array name is used but is
prefaced with $ instead of @ as normal.
My final print is redundant confirmation
all went well by including the previous
and next element:
Element Number 3 Is Empty
Previous Element Is Curly
Next Element Is Nyuk Nyuk
So there you have it, in old fashion
Plain English to be easy to read and
to understand. This is just one method
of several to find an 'empty' element
and jump out of a loop. Works just as
well for locating any element, empty
or not.
Hopefully, my test code and discussion
provides you with additional information
which may prove to be of use. Do look over
my use of diagnostic tools in this script.
These are life savers and worth a bit of
extra effort in developing any script.
Writing your own diagnostic tools are
extremely reliable, you can word your
tools in plain understandable English
and, use them where you want without
any need to worry if a pragma hint
popup is right or totally wrong. Your
tools, if written well, will never
tell you a lie.
Pragma hints and similar are effective
tools and have great value. However,
you need to know when to use them and
when not to use them, along with your
remembering pragma hints are known to
be wrong under some circumstances. Use
them when you can. Don't when you know
you shouldn't.
If you decide to try this, decide to play
with this, just upload it to your server
and point your browser in the right direction.
Tear this code apart, break it, fix it and,
in the process, you will learn a few things.
Godzilla!
Test code first, printed results last.
Remember to change your Perl locale
in the first line. Perl 4 - 5, is ok.
Test Script
__________________
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
@Test_Array = ("Larry", "Moe", "Curly", "", "Nyuk Nyuk");
# initialize counter:
$counter = 0;
# loop through array:
foreach $element (@Test_Array)
{
# print visual confirmation of "last" working:
print "Element $counter is: $element \n";
if ($element eq "")
{
# jump out of loop
last;
}
$counter++;
}
# create some new variables for fun:
$before = $counter;
$before = ($before - 1);
$after = $counter;
$after = ($after + 1);
# print final results:
print "
Element Number $counter Is Empty
Previous Element Is $Test_Array[$before]
Next Element Is $Test_Array[$after]";
exit;
Printed Results
__________________
Element 0 is: Larry
Element 1 is: Moe
Element 2 is: Curly
Element 3 is:
Element Number 3 Is Empty
Previous Element Is Curly
Next Element Is Nyuk Nyuk
------------------------------
Date: Thu, 18 May 2000 06:33:57 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Check to see if an array value is null
Message-Id: <x7g0rggyek.fsf@home.sysarch.com>
>>>>> "G" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
well, you said to flame on your code so i will do so.
G> #!/usr/local/bin/perl
no -w. what else is new?
no use strict.
G> foreach $element (@Test_Array)
G> {
G> # print visual confirmation of "last" working:
G> print "Element $counter is: $element \n";
G> if ($element eq "")
G> {
G> # jump out of loop
G> last;
G> }
learn to use modifiers. why spend 5 lines when 1 will do.
last if $element eq '' ;
G> $counter++;
so you know ++ and probably --, so
G> $before = $counter;
G> $before = ($before - 1);
why didn't you use them here? or why the parens? you don't really
think = has a higher precedence than -?
G> $after = $counter;
G> $after = ($after + 1);
or why not just:
$before = $counter - 1 ;
$after = $counter + 1 ;
you seem to like to make short things too long. typical of your verbiage
in english too.
G> # print final results:
G> print "
G> Element Number $counter Is Empty
G> Previous Element Is $Test_Array[$before]
G> Next Element Is $Test_Array[$after]";
use here docs for that. much cleaner and easier to read. oops you don't
know the correct here doc syntax. and it is perl4 too. oh well.
G> exit;
why don't you do that.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Thu, 18 May 2000 01:57:29 -0400
From: Dennis Marti <dennis_marti@yahoo.com>
Subject: Re: credit card validation.....isn't working
Message-Id: <dennis_marti-057CD3.01572918052000@news.starpower.net>
In article <OFETy6Ew$GA.249@cpmsnbbsa02>, "babylon93"
<babylon93@ariannaoils.com> wrote:
> the cards aren't being processed real-time. I have been working with
> something I thought would work for 16-digit card numbers, but it doesn't
> really do that well.........
>
> I have converted it into actionscript for Flash, and it just doesn't make
> any sense, now, why it would work. First the perl I'm speaking of....
Did it work in Perl, but not in actionscript?
Either way, the perl you posted was pretty ugly. Making better use of
arrays and subroutines would make it more readable, and probably easier
to port (or debug).
This is just a translation of your 90+ line subroutine (card16). I have
no idea if it does anything meaningful with credit card numbers.
sub two_mod_ten {
my $i = shift;
my $j = $i * 2;
($j < 10) ? $j : int($j/10) + $j%10;
}
sub card16_b {
my @cc = split //, shift;
my $val = 0;
for (my $i=0; $i<@cc; $i++) {
if ($i % 2) {
$val += $cc[$i];
} else {
$val += two_mod_ten($cc[$i]);
}
}
if (substr($val,1,1) != 0) {
&invalid_cc;
}
}
I don't know actionscript, but one thing I did notice was that all the
Substring calls except one in the last While loop started indexing at 1.
> Substring ( Eval ("cc"&i&"a"), 0, 1 )
Dennis
------------------------------
Date: Thu, 18 May 2000 01:30:18 -0400
From: "Alex Shi" <chpshi@connection.com>
Subject: Delay in Perl
Message-Id: <39238061@nntp.connection.com>
Hi all,
How can I set a time delay or sleep (5 or 10 seconds) in Perl?
Thanks!
Alex
--------------------------------------------------
Please visit http://www.stonix.com
Please subscribe to our E-commerce newsletter:
subscribe-ecdigest@stonix.com?subject=Subscribe
Get your free email at http://stonix.zzn.com
--------------------------------------------------
------------------------------
Date: Thu, 18 May 2000 05:52:29 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Delay in Perl
Message-Id: <si718tl08ta80@corp.supernews.com>
Alex Shi (chpshi@connection.com) wrote:
: How can I set a time delay or sleep (5 or 10 seconds) in Perl?
Perl helps those who help themselves. Especially when you successfully
guess the name of the function, you should be able to answer questions
like this using the doc right there on your own machine. 'perldoc -f
sleep'.
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "The road of Excess leads to the Palace
of Wisdom" - William Blake
------------------------------
Date: Wed, 17 May 2000 23:06:02 -0700
From: stevel@coastside.net (Steve Leibel)
Subject: Re: Delay in Perl
Message-Id: <stevel-1705002306020001@192.168.100.2>
In article <39238061@nntp.connection.com>, "Alex Shi"
<chpshi@connection.com> wrote:
> How can I set a time delay or sleep (5 or 10 seconds) in Perl?
>
sleep(5); # sleep five seconds
or even
$howlong = sleep(5);
When sleep() completes, $howlong tells how long it actually slept. If
sleep is awoken early (by catching a signal, for example) $howlong
provides a clue.
Steve L
stevel@coastside.net
------------------------------
Date: 18 May 2000 04:20:22 GMT
From: jed@socrates.berkeley.edu (Jed Parsons)
Subject: extracting a list from multiple regex matches
Message-Id: <8fvr26$lmc$1@agate.berkeley.edu>
Hi, all,
Here's my problem. I want to scan a text for a number of strings of
text connected by + signs. For example:
a b+c d e+f+g+h i j
In this text, I would want to capture the set [ab] as well as [efgh].
I'm trying to do this with a regex, but am having trouble. I'm thinking
of a solution along these lines
@matches = ($text =~ /(\w+)(?:\+(\w+))*/g)
You don't need to tell me this doesn't work :-) I'm not sure exactly
where I'm going wrong. Can anyone offer me some suggestions?
Many thanks in advance,
Jed
--
Jed Parsons http://socrates.berkeley.edu/~jed/
(Jed's another Plautus hack?) jed@socrates.berkeley.edu
-------------------------------------------------------------
grep(do{for(ord){$S+=$_&7;grep(vec($s,+$S++,1)=1,5..$_>>3)}},
------------------------------
Date: Thu, 18 May 2000 15:26:05 +1000
From: Peter Hill <phill@modulus.com.au>
Subject: Re: extracting a list from multiple regex matches
Message-Id: <39237EED.1ADF@modulus.com.au>
Jed Parsons wrote:
>
> Hi, all,
>
> Here's my problem. I want to scan a text for a number of strings of
> text connected by + signs. For example:
>
> a b+c d e+f+g+h i j
>
> In this text, I would want to capture the set [ab] as well as [efgh].
> I'm trying to do this with a regex, but am having trouble. I'm thinking
> of a solution along these lines
>
> @matches = ($text =~ /(\w+)(?:\+(\w+))*/g)
>
> You don't need to tell me this doesn't work :-) I'm not sure exactly
> where I'm going wrong. Can anyone offer me some suggestions?
>
@matches = $text =~ /\w\+[+\w]*\w\b/g;
works for me, including 'strings' as well as characters, for the narrow
definition of 'strings' to not include spaces etc.
--
Peter Hill,
Modulus Pty. Ltd.,
http://www.modulus.com.au/
------------------------------
Date: 18 May 2000 08:05:34 GMT
From: jimtaylor5@aol.com (Jimtaylor5)
Subject: File lock
Message-Id: <20000518040535.09511.00003427@ng-cn1.aol.com>
I'm trying to write to a temporary file while I make changes to my original
file to avoid corruption of the file if someone quits in the middle of it
working. Can someone tell me what I am doing wrong, or a more effective way of
accomplishing this task. Your help is appreciated.
open (MYPAGE,"$dat")
flock MYPAGE, 2;
@lines = <MYPAGE>;
flock MYPAGE, 8;
close(MYPAGE);
open (BAK, ">$datbak")
flock BAK, 2;
foreach $line @lines {
if ($line eq "frank") {
#do something
}
}
use File::Copy;
copy ("$datbak", "$dat");
flock BAK, 8;
close (BAK);
------------------------------
Date: Thu, 18 May 2000 10:22:29 +0200
From: "R" <risj5@hotmail.com>
Subject: Fixed number of fields
Message-Id: <LMNU4.3807$JL6.11056@nntpserver.swip.net>
I'm working on a script that handles the input from a webpage-form so that
all fields are filled in to a file. I.e not only the fields that are filled
in by the user, the number of fields must be fixed.
If a user don't fill in the address, that field must be filled in anyway in
the file by the perlscript.
Anyone who knows how to do this??
Thanks in advance
Rikard
------------------------------
Date: 18 May 2000 06:05:16 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: help - undef $/; ?
Message-Id: <8g016s$jp0$1@newsflash.concordia.ca>
In article <3923390D.1B896753@uk2.net>,
Nadja Herkova <spam-abuse@uk2.net> wrote:
>it makes good sense now. I checked perlvar, but was difficult to
>understand. I read a dictionary to find slurp
"slurp" is derived from an English word meaning to suck up a liquid
quickly and noisily, like someone "slurping" soup.
In perl, it is preferred to process a line of a file at a time.
This makes the program simpler and consumes less memory.
This block reads lines from FILE, changes foo to bar, and prints
the results:
while (<FILE>) { # this is a short way of saying
# while ( defined ($_ = <FILE>) ) {
s/foo/bar;
print;
}
However, occasionally it is not possible or convenient to use the
line-by-line method. Let's say you wanted to replace the sequence
blah
boing
blah
with
blahboingblah
You could work out a line-by-line technique, but it would be easier
to "slurp" the whole file and work on the file as if it were a single
scalar.
You can do this most easily by manipulating the variable '$/'. When
perl is reading in a line, what it is doing is reading in until it
sees $/. By default $/ is the "\n". You could assign $/ to be
"the" if you wanted.
But if you undef $/, perl will read in the whole file the first time
you access it:
undef $/;
$whole_file = <FILE>;
$whole_file =~ s/blah\nboing\nblah/blahboingblah/g;
print $whole_file;
>so, if i undef $/ - it will only affect if i use $/ elsewhere in the
>program ? or does it have affect on other commands - i will look
$/ is a global. Changing it may cause problems elsewhere in your
program. To confine the effects of changing it, you have to use local();
open FILE, $filename or die $!;
{
local $/ = undef;
$whole_file = <FILE>;
}
close FILE;
local() is one of those functions you want to avoid if possible, but
you have to use it in this situation. See man perlfunc for more
discussion on that.
--
Neil Kandalgaonkar
neil@brevity.org
------------------------------
Date: Thu, 18 May 2000 01:57:22 -0500
From: fchen0000 <fchen0000@usa.net>
Subject: how to call PerlIS.dll in my own win32 programs
Message-Id: <39239452.B8B5142B@usa.net>
I have been asking for this question for years, but seems still no clue.
I have a own win32 GUI program that like to use Perl as an assistant.
system("perl.exe my.pl");
would work, but it spawns a DOS prompt each time. More over,
sometimes the single command prompt gives me illegal instruction.
I know PerlIS.dll is an ISAPI extention. What I want is, though, an
IIS server like thing to use PerlIS.dll -- not necessary to be
"internet"
related.
Any1 actually knows the answer or want to help tackling this problem?
Or, it is some kind of secret that does not belong to public domain?
Best regards!
------------------------------
Date: Thu, 18 May 2000 19:26:55 +1000
From: "Andrew Goode" <a.goode@qut.edu.au>
Subject: How to convert a long integer into hex
Message-Id: <8g0d60$i99$1@dove.qut.edu.au>
I have a long integer which I want to convert into hex.
e.g.
$value = 9969772182300;
the hex value should be 44BABB1C
But with any of these conversions, I get an integer overflow error, or a
value of FFFFFFFF:
1) $hexValue = hex($value);
2) $hexValue = sprintf ("%X", $value);
3) $hexValue = sprintf ("%lX", $value);
I have read Math::BigInt, but am unsure of the usage.
I hope someone can offer a simple solution to this seemingly simple problem.
Thanks
Andrew
------------------------------
Date: 18 May 2000 08:11:35 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: How to execute "cat *.c" ???
Message-Id: <slrn8i79dm.1re.vek@pharmnl.ohout.pharmapartners.nl>
On Wed, 17 May 2000 17:33:18 GMT,
Pete M. Wilson <wilsonpm@drop.gamewood.net> wrote:
>I'll assume you're talking Unix... :-)
>
>The shell handles the wildcard expansion for Unix, so invoke the shell
>instead of the command:
>*UNTESTED CODE*
>
>system($ENV{"SHELL"},"cat","*.c");
>
>or expand the glob yourself (the shell expands it by replacing it with
>a separate argument per matching filename - try echo *.c to see it
>happen).
>
>
There is a difference when system gets exactly one argument
or more than one argument. In the latter case the command will
be invoked directly without the help of the shell, but in the former
the shell will be invoked if the string contains metacharacters.
Check these two eamples.
$ perl -we 'system "/bin/echo", "*TMP.txt"'
*TMP.txt
$ perl -we 'system "/bin/echo *TMP.txt"'
L10786-6TMP.txt xxxxx-L7392-5TMP.txt
BTW, sometimes you should test your examples.
$ perl -we 'system($ENV{"SHELL"},"/bin/echo","*TMP.txt");'
/bin/echo: /bin/echo: cannot execute binary file
$ perl -we 'system($ENV{"SHELL"}, "-c", "/bin/echo *TMP.txt");'
L10786-6TMP.txt xxxxx-L7392-5TMP.txt
The shell need the -c flag to interpret the next argument as
commands, and then the entire command line should be in one string
only.
Villy
------------------------------
Date: Wed, 17 May 2000 21:33:20 -0700
From: "d" <new_user@email.msn.com>
Subject: Re: If slices are so great
Message-Id: <OIEYXHIw$GA.323@cpmsnbbsa07>
oops
------------------------------
Date: Thu, 18 May 2000 15:36:15 +1000
From: Geoff <geoff@crc-sugar.jcu.edu.au>
Subject: Long datatype update problem
Message-Id: <3923814F.39E0CF31@crc-sugar.jcu.edu.au>
This is an SQL problem really.. but any help would be good
I am having a problem doing an update on a column in a table which is of
a long datatype. My interface is the following, but my problem is
happening at the SQL level
Browser-Perl Script-Oraperl Module-Oracle
Essentially, the perl stuff generates a string which it sends to oracle
as an SQL statement, and it is giving me an error ORA:1704 when the
string literal within the statement is more than 4000 characters. ie:
UPDATE PEOPLE
SET LIFE_STORY="this is the literal string which has to be <4000 chars
to work"
WHERE ID=3
(strange already as oracle says it can only handle string literals of
2000 characters) Anyway I can send up to 4000 characters and update
successfully, but any more gives me the 1704 message. I thought this
was weird cos a varchar2 has a max size of 4000 also. I need to send
more than this amount of chars to the database.
Anyhow, I'm trying to do this in anyway possible without using PL/SQL -
is there any way of perhaps doing an update-append style statement in
SQL, or to bypass this problem with the long datatype? It seems weird
to have a datatype which can handle so many characters and only be able
to send x amount of chars in a string literal to it.
PS - I had to play with $ora_long in Perl to get to submit anything at
all to the datatype, but as I said the problem now lies in the SQL I
think
If there's no way of doing it in straight SQL could someone maybe give
me an example of the PL/SQL needed (something about the bind datatype?),
and if they know whether this can be sent via the &ora_do statement in
Oraperl?
Any help greatly appreciated,
Geoff.
------------------------------
Date: 18 May 2000 07:50:36 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: manipulating a text file with perl
Message-Id: <8g03rs$4g7$1@orpheus.gellyfish.com>
On Wed, 17 May 2000 13:02:00 -0400 Brian E. Seppanen wrote:
> I'm trying to write a perl script that will examine a file in the
> following format. The most important information I hope to glean from the
> file is the name of the printer from the Req-Id column and the Date.
>
> bell_med: waiting for billing to come up
> Req-Id Owner Size Date
> billing-63 kaye 1795 May 11 14:05
>
> I'm trying to set up a job that runs in cron to examine the output of
> lpstat to alert me of print daemons dying. The print jobs are very small lab
> results, so I want to be alerted after a job has been waiting for a half
> an hour. I don't need to store any state information, the check would be
> performed each time from the data in the date field.
>
> I'm a perl novice and I'm really not quite sure how to proceed. I most
> likely don't have a need for the first two lines. Here's what I have.
>
> I'd really appreciate any insights.
>
> #! /usr/bin/perl -w
> system "rexec xxx.xxx.xxx.xxx lpstat > /tmp/status";
> #open the file /tmp/status
> open (F,/tmp/status);
> #if /tmp/status is a zero length file everything is cool
> while (<F>) || die;
> #analyze the file
> #for each $queue with spooled files
> #for each job in $queue assign $count
> #get $ptime from Date string
> #compare $ptime to current time if time exceeds 30minutes send a page
> system "mail -s \"`hostname` Printer error on $queue, $count spooled job(s)\" seppanen+page@hawking";
> end
>
I would cut out the temporary file and just go straight for the data (
I havent tested this as I dont have access to either rexec lpstat on
the train ):
#!/usr/bin/perl -w
use strict;
chomp(my @lpjobs = `rexec <host> lpstat`)
for (@lpjobs)
{
next if /^\s*$/ || /^Req-Id/ ;
my ( $job_id,$user,$size,$date ) = unpack "a18a10a10a*",$_;
my ( $queue ) = $job_id =~ /^(\S*)-\d+/;
# etc
}
You might need to fix the unpack format ...
/J\
--
Oh, that's hot. There isn't a man alive that wouldn't get turned on by
that. Well, g'night.
--
fortune oscar homer
------------------------------
Date: 18 May 2000 08:08:23 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Mixed results!
Message-Id: <8g04t7$7u7$1@orpheus.gellyfish.com>
On Wed, 17 May 2000 14:31:35 GMT Hassoun wrote:
> hi
>
> after collecting data from an HTML form, my cgi script returns all the
> data but in a random order. is there a way to return it in the same
> sequence of the form? any clues?
>
You are not using CGI.pm then. From the section of that module's manpage
entitled :
FETCHING THE NAMES OF ALL THE PARAMETERS PASSED TO YOUR
SCRIPT:
You will read:
NOTE: As of version 1.5, the array of parameter names
returned will be in the same order as they were submitted
by the browser. Usually this order is the same as the
order in which the parameters are defined in the form
/J\
--
When I look at the smiles on all the children's faces,,...I just know
they're about to jab me with something.
--
fortune oscar homer
------------------------------
Date: 18 May 2000 07:07:08 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: More Newbie Questions - Manipulating Data....
Message-Id: <8g01ac$rq0$1@orpheus.gellyfish.com>
On Wed, 17 May 2000 10:54:51 -0700 Mur wrote:
> Heck, this is just too easy:
>
> perl -e '$n=q(012345); print join(q(,),$n,$n=~/\d/g)'
>
> The trick is this:
>
> @digits = $n =~ /\d/g;
>
> This will set @digits to each match of the pattern in the string
> $n. \d is a digit (0-9).
>
No it wont. I think you mean :
@digits = $n =~ /(\d)/g;
The capturing brackets are important.
/J\
--
Just a statue? Is the Statue of Liberty just a statue? Is the Leaning
Tower of Pizza just a statue?
--
fortune oscar homer
------------------------------
Date: 18 May 2000 08:26:52 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: MS Documents to text---help
Message-Id: <8g05vs$bfk$1@orpheus.gellyfish.com>
In comp.lang.perl.misc JB Goss <jgoss@goss-com.com> wrote:
> I am looking for something simple to strip the crud out of MS documents and
> just leave the text... any ideas?
>
[gellyfish@orpheus work]$ strings daspec.doc | more
Works for me.
/J\
--
Bart, I don't want to alarm you, but there may be a bogeyman or bogeymen
in the house!
--
fortune oscar homer
------------------------------
Date: 18 May 2000 10:34:37 +0200
From: Hendrik Uhlmann <HUhlmann@stn-atlas.de>
Subject: Re: MS Documents to text---help
Message-Id: <m33dngl0iq.fsf@nspc65.atlas.de>
>>>>> "JB" == JB Goss <jgoss@goss-com.com> writes:
JB> Well, since I posted this is lang.perl, I thought one would
JB> understand I wanted something in Perl to do this... I shall
JB> be more explicit... I am looking for a Perl script for a Unix
JB> machine that will strip the crud out of a MS Word document and
JB> just leave the text (all text).
Maybe that 'mswordview' helps. It converts MS-Word (8) to html. It's
not a perl module, but maybe it do what you want...
--
CU
Hendrik
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 3083
**************************************