[11598] in Perl-Users-Digest
Perl-Users Digest, Issue: 5198 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 22 13:07:23 1999
Date: Mon, 22 Mar 99 10:00:23 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 22 Mar 1999 Volume: 8 Number: 5198
Today's topics:
[HELP PLS] Reg Exp for "a number" sergei_klimov@my-dejanews.com
Re: [HELP PLS] Reg Exp for "a number" (Larry Rosler)
Re: [HOW TO?] Strip all but certain characters from a s <spike_YYwhiteYY@YYdellYY.com>
Re: Can't read a text file with weird characters in it. <cassell@mail.cor.epa.gov>
date in perl under nt <pepp@pepp.de>
Re: date in perl under nt (Bob Trieger)
Difficult hex code replacement problem thst@my-dejanews.com
Re: embeded Perl on Win32 <Piotr.Martyniuk@softax.com.pl>
Re: Help Needed Please!!! mcol@ictlux.com
Re: Help please - can't open .pl file <"rhrh@hotmail.com,or,rhardicr"@ford.com>
Re: HTML in email (Jonathan Stowe)
Re: HTML in email (Jonathan Stowe)
Http_referer registers page script is called from experiment@my-dejanews.com
increasing buffer size <davem@nortak.com>
LOOKING for Module/Library ?! <vlierd@uni-oldenburg.de>
Re: LOOKING for Module/Library ?! (Randy Kobes)
looking for script... <rcj@lucent.com>
Migrating from Remdey 3,2 -> 4.0 using arsperl <bruce.ferguson@tdstelecom.com>
Need help modifying text string search function <jerry_willard@adc.com>
Re: Net::FTP (Jonathan Stowe)
On the fly gif in Win 95 using gnuplot3.7 <anupamb@worldnet.att.net>
Re: One liner? (Abigail)
Passing @ references into and outof sub procedures. <kimntodd@dontspamus.execpc.com>
Perl with SSI <jxu@centuple.com>
perl-5.005.02 make test fails on lib/ipc_sysv <matthew@cmold.com>
Re: Problem with image display <psl1@home.com>
read binary data p3qa3@yahoo.com
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 22 Mar 1999 15:33:15 GMT
From: sergei_klimov@my-dejanews.com
Subject: [HELP PLS] Reg Exp for "a number"
Message-Id: <7d5nrr$n1l$1@nnrp1.dejanews.com>
Hi!
Could anyone please help me to compose a correct Regular Expression to
manage the following task? I have been studying Perl for several days only and
cannot solve this myself.
So, given is the file with numbers and/or alphanumeric strings; numbers may
be in different formats (e.g., 1.1, or +1.1, or -1.1e-1, or +1.1E+00, etc).
Fortunately, decimal only. Moreover, "incorrect numbers" may present (e.g.,
1.1.1, or 1.1e-1.1, etc.). Sample file may look like this:
=================================
111111111.1111111111
111111.11111111111
0.
.0
0.0
..
.FG.
..
.2e-55
33e+22
34e23
34e-45
3.4e3
-3.4e-5
3.4e+5
.........
.
.........
. . .......
.
.
.
1..1
1. .1.
.1.
.. ..
1111.1111.111
.e+12
23e23e
-12-345
+67 -89e77
-34e-56
+77-E88
======================================================
Additional spaces, blank lines, several strings in one line - everything is
possible :-(
Now, the task is to extract correct numbers from that jumble. One more
condition: only those lines are required that contains only one number, i.e.
line "+67 -89e77" does not match, despite of both numbers are correct.
I have been trying to invent a generalized RegExp for "a number" but
failed. I believe there exists a RegExp that I need but I cannot find it or
work it out myself. Please, help.
What I need to extract from the sample above (correct numbers) is as
follows: ================================= 111111111.1111111111
111111.11111111111 0. .0 0.0 .2e-55 33e+22 34e23 34e-45 3.4e3 -3.4e-5 3.4e+5
-34e-56 ======================================================
Thanks for any help!
Sergei
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 22 Mar 1999 08:02:23 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: [HELP PLS] Reg Exp for "a number"
Message-Id: <MPG.1160096997c23aca9897a5@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7d5nrr$n1l$1@nnrp1.dejanews.com> on Mon, 22 Mar 1999
15:33:15 GMT, sergei_klimov@my-dejanews.com <sergei_klimov@my-
dejanews.com >says...
> Could anyone please help me to compose a correct Regular Expression to
> manage the following task? I have been studying Perl for several days only and
> cannot solve this myself.
Acquaint yourself with the Perl FAQ, which is available on your own
system or on the Web from http://www.perl.com/. The answer is in
perlfaq4: "How do I determine whether a scalar is a
number/whole/integer/float?
Please set your newsreader to wrap lines at no more than about 72
characters.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 18 Mar 1999 15:36:50 -0600
From: "Spike White" <spike_YYwhiteYY@YYdellYY.com>
Subject: Re: [HOW TO?] Strip all but certain characters from a string
Message-Id: <7d600p$amv$1@galaxy.us.dell.com>
#!/usr/local/bin/perl
$var = <STDIN>;
if ($var =~ /.*S/) {
$var =~ s/[^S\d]*//g;
$var =~ s/(\d{8}).*/$1/;
$var = "${var}S";
} else {
$var =~ s/\D*//g;
}
print "$var\n";
Interestingly, I tried to do it in a single regex using (?:...) and {7}. It
failed.
Jason Hatcher wrote in message <7c27f6$dpo@enews2.newsguy.com>...
>I am looking for an efficient way to strip a string down to only certain
>characters.
>
>The output is 8 numbers followed by a the letter "S" or a number.
>
>example "4321-8765-S" would return 43218765S
>or "4321 876A5 A S" would return 43218765S
>or "432 1876-58 " would return 432187658
>
>Any advice would be appreciated.
>
>Thanks Again, Jason Hatcher
>
>
------------------------------
Date: Mon, 22 Mar 1999 09:22:40 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Can't read a text file with weird characters in it. Help.
Message-Id: <36F67C60.CA49C8F9@mail.cor.epa.gov>
Rick Delaney wrote:
> [posted & mailed]
> David L. Cassell wrote:
> > But since that means Jason is probably using a Wintel box, he might
> > not have 'perldoc'.
> This is silly, especially when you are recommending to others using
> ActivePerl to use perldoc -q.
Indeed. As I wrote to Rick in an e-mail, this is due to a massive
attack of schizophrenia on my part. I have been attempting to
address multiple conflicting issues.. and obviously not doing a
good enough job in the process. Since I have heard from some posters
that they had no idea what or where 'perldoc' was, I have been
trying to skirt the issue somewhat for ActivePerl builds where
the users are more likely to know how to get to their html docs.
> One of the nice things about perldoc is that it does work on systems
> without a proper man command.
Agreed.
> Give enough tools to the POBs and they might just dig their way out.
It worked for me. But sometimes I wonder which end of the shovel
some of these users are holding. :-)
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Mon, 22 Mar 1999 17:23:14 +0100
From: "r|digerD" <pepp@pepp.de>
Subject: date in perl under nt
Message-Id: <7d5qnn$gti$1@nuss.hannover.sgh-net.de>
this is my first contact with newsgroups
working with a little perlscript to print out date and time there is no
problem with my linux.
the line:
$date_command = " /bin/date";
what is the correct syntax under nt to get the actually time and date?
thanx for your help
------------------------------
Date: Mon, 22 Mar 1999 16:35:34 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: date in perl under nt
Message-Id: <7d5ric$gpa$3@holly.prod.itd.earthlink.net>
"r|digerD" <pepp@pepp.de> wrote:
>what is the correct syntax under nt to get the actually time and date?
perldoc -f localtime
Good luck,
Bob Trieger
sowmaster@juicepigs.com
------------------------------
Date: Mon, 22 Mar 1999 17:18:33 GMT
From: thst@my-dejanews.com
Subject: Difficult hex code replacement problem
Message-Id: <7d5u0t$svk$1@nnrp1.dejanews.com>
I was really surprised about the following problem:
Assuming that there is a file with the following contents (in hex code):
...
20 64 73 64 73 20 67 68
66 68 6B 0D 0A 1A 20 20
67 66 64 67 20 68 66 64
....
Now I want to replacing this mysterious 1A bytes with a blank (20)
For that I am applying the following statements to the file
@oldlines = <OLDFILE>;
...
for ($i = $#oldlines; $i >= 0; $i--) {
$oldlines[$i] =~ s/\x1A/\x20/g; }
...
But this doesn't work. Why ?
Bye
Thomas
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 22 Mar 1999 17:56:45 GMT
From: "Piotrek" <Piotr.Martyniuk@softax.com.pl>
Subject: Re: embeded Perl on Win32
Message-Id: <7d5u5s$b6o$1@euler.softax.com.pl>
Hi
J|rgen Ibelgaufts wrote in message <36F653DA.C3FF852E@gfc-net.de>...
>Piotrek,
>
>I got the following running (a C source and a batch file for compiling and
>linking). I use the standard distribution (GS-Perl) 5.005 compiled with MS
Visual
>C 4.00; this program compiles and links at least with Visual C 4 and 5 (I
don't
>know about version 6).
>
Well, the program you send compiles and links also with Visual C 6 (I've
tried it),
but this doesn't solve my problem.
The program I posted differs from yours.
I was using for example Perl variable PL_na (it's something like
"not known"), and with this variable the error I mentioned still remains
(I've got linking
error PL_na is unresolved external). What is more interesting I've searched
perl
header files for PL_na and it seems that is not defined at all.
So if anybody could make this sample run on Win32, I would be very grateful.
(this is sample from perlembed documentation)
--- code
#include <EXTERN.h>
#include <perl.h>
static PerlInterpreter *my_perl;
main (int argc, char **argv, char **env)
{
char *embedding[] = { "", "-e", "0" };
my_perl = perl_alloc();
perl_construct( my_perl );
perl_parse(my_perl, NULL, 3, embedding, NULL);
perl_run(my_perl);
/** Treat $a as an integer **/
perl_eval_pv("$a = 3; $a **= 2", TRUE);
printf("a = %d\n", SvIV(perl_get_sv("a", FALSE)));
/** Treat $a as a float **/
perl_eval_pv("$a = 3.14; $a **= 2", TRUE);
printf("a = %f\n", SvNV(perl_get_sv("a", FALSE)));
/** Treat $a as a string **/
perl_eval_pv("$a = 'rekcaH lreP rehtonA tsuJ'; $a = reverse($a);", TRUE);
printf("a = %s\n", SvPV(perl_get_sv("a", FALSE), PL_na));
perl_destruct(my_perl);
perl_free(my_perl);
}
--- end of code
Thanks
Piotrek
------------------------------
Date: 22 Mar 1999 16:51:45 +0100
From: mcol@ictlux.com
Subject: Re: Help Needed Please!!!
Message-Id: <lvlngpr08e.fsf@sonyx.ictlux.com>
On Line Auctions UK <support@onlineauctions.co.uk> writes:
> If any one could answer this for me i'd be eternally grateful.
> I've got a html form that sends three fields to a cgi script but the cgi
> script doesn't read the fields. It works on my own computer but when i
> upload it to the server it doesn't. here's a cut down version of the
> html code and below that is the cgi script.
> <FORM ACTION="http://www.host.com/ucgi-bin/tyh/g.cgi" METHOD="POST"
i dont' see a </form> tag here.
maybe that's the problem
cumarc
--
ignorance of your culture is not considered cool - the Residents (1978)
-- http://www.perreira.lu
------------------------------
Date: Mon, 22 Mar 1999 14:53:41 +0000
From: Richard H <"rhrh@hotmail.com,or,rhardicr"@ford.com>
Subject: Re: Help please - can't open .pl file
Message-Id: <7d5lgm$4to8@eccws1.dearborn.ford.com>
Mark Austin wrote:
>
> Need to incorporate a Perl / CGI script for my web-site.
> Got a freeware script (wwwboard.pl) that is near perfect but need to make a
> few amendments (the author states this is allowed).
> WWWboard was written for unix and I will be hosting it on a unix server
> site.
> Downloaded the latest version (5. something) of Perl and the Microsoft fix
> thing they say necessary (I'm using Win95).
> All auto-installed ok but when I double click on any of the .pl files, the
> Perl scripting screen flashes up and then off again in a split second
Your computer has associated .pl with perl.exe, when you double click
on any .pl file it will launch the dos prompt and run your script,
unless your eyesights very good, thats not much use.
Use the MS-DOS prompt and run your script with
>perl script.pl
then you should see your output and the window will stay open.
Richard H
------------------------------
Date: Mon, 22 Mar 1999 15:59:24 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: HTML in email
Message-Id: <36f6688b.25569921@news.dircon.co.uk>
On Mon, 22 Mar 1999 15:48:07 +0200, "WB" <webmaster@noit.phnet.fi>
wrote:
>What wrong in the following code....?
>
>open (MAIL,"|$mailprogram");
>
Err it doesnt automatically dial up the Pizza delivery service and
order a Large vegetarian with added Jalapeno ?
/J\
------------------------------
Date: Mon, 22 Mar 1999 16:02:59 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: HTML in email
Message-Id: <36f66965.25787377@news.dircon.co.uk>
On Mon, 22 Mar 1999 15:59:24 GMT, gellyfish@btinternet.com (Jonathan
Stowe) wrote:
>On Mon, 22 Mar 1999 15:48:07 +0200, "WB" <webmaster@noit.phnet.fi>
>wrote:
>
>>What wrong in the following code....?
>>
>>open (MAIL,"|$mailprogram");
>>
>
>Err it doesnt automatically dial up the Pizza delivery service and
>order a Large vegetarian with added Jalapeno ?
>
Damn, damn, damn, damn It was crossposted to alt.perl and I didnt
notice damn damn .....
/J\
------------------------------
Date: Mon, 22 Mar 1999 16:47:33 GMT
From: experiment@my-dejanews.com
Subject: Http_referer registers page script is called from
Message-Id: <7d5s71$rat$1@nnrp1.dejanews.com>
I have a script that records info about a webpage vistor. However the
http_referer evironment varible registers the page I call the script from!
The script is called using the <img src= tag with the script outputing an
invisible image.
Is there a way to stop this and get it to record the referer to the page?
Any help would be apreciated.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 22 Mar 1999 11:36:22 -0500
From: "Dave McIntyre" <davem@nortak.com>
Subject: increasing buffer size
Message-Id: <7d5rkh$gvt$1@nntp2.uunet.ca>
Is it possible (or desirable) to increase the buffer size
when writing out large files? I understand the default buffer
to be about 8K; I'd like to increase it to 64K or so.
Dave
------------------------------
Date: Mon, 22 Mar 1999 16:07:15 +0100
From: Claus van de Vlierd <vlierd@uni-oldenburg.de>
Subject: LOOKING for Module/Library ?!
Message-Id: <36F65CA3.C07A0E87@uni-oldenburg.de>
Hello ,
according to "The PERL Module Reference" , vol. 2 (Siever + Futato ;
O'Reilly nov. 1997 , p. 835)
I wanted to use "CGI::Form" -- but I did not find it on the
"../perl/CPAN/Modules/by-module/CGI" - Web -Page.
(I found strange (??!) thing sas "CGI-Formelware" etc. -- no
"CGI::Form" .
anybody around who could help me ?!?
Perhaps I d o not understand these things correctly -- perhaps
"CGI::Form" is not at all a "Module"
but a "library" ??! And where could I find libraries ?!?
kind regards :
Claus van de Vlierd (in light confusion ..)
------------------------------
Date: 22 Mar 1999 16:08:07 GMT
From: randy@theory.uwinnipeg.ca (Randy Kobes)
Subject: Re: LOOKING for Module/Library ?!
Message-Id: <slrn7fcral.k39.randy@theory.uwinnipeg.ca>
On Mon, 22 Mar 1999 16:07:15 +0100,
Claus van de Vlierd <vlierd@uni-oldenburg.de> wrote:
>I wanted to use "CGI::Form" -- but I did not find it on the
>"../perl/CPAN/Modules/by-module/CGI" - Web -Page.
Hi,
This is in the CGI-modules-2.76.tar.gz package, under
http://www.perl.com/CPAN/authors/id/LDS/
--
Best regards,
Randy Kobes
Physics Department Phone: (204) 786-9399
University of Winnipeg Fax: (204) 774-4134
Winnipeg, Manitoba R3B 2E9 e-mail: randy@theory.uwinnipeg.ca
Canada http://theory.uwinnipeg.ca/
------------------------------
Date: Mon, 22 Mar 1999 09:00:18 -0600
From: "Raymond C. Jender" <rcj@lucent.com>
Subject: looking for script...
Message-Id: <36F65B02.3D0DA54E@lucent.com>
I'm looking for a script that will:
1. take an input value (ID number)
2. search a flatfile for the ID #
(alternative: search directory for filename=ID#
and return contents of file. Actually may
be a preferred method!)
3. return everything found between
the current ID and the next ID #.
The file format would be something like this:
12345: blah blah text blah blah text. more text
more text.....
final line of text...
32784: text.......
text, more text....
more text....
55467: text.....
more text....
even more text...
So, if I had a simple single entry HTML form with ID number,
entering 12345 would return everything up to the next ID number.
The text after ID# is variable in size.
The available search type engines don't seem to do what I need.
If you know of anything, please let me know!
Thanks..
------------------------------
Date: 22 Mar 1999 16:51:59 GMT
From: "TDS" <bruce.ferguson@tdstelecom.com>
Subject: Migrating from Remdey 3,2 -> 4.0 using arsperl
Message-Id: <01be7484$4f0c64f0$9006d786@miwi509>
Has anyone found any major hurdles using scripts built for 3.0 Remedy
version,
on Remedy 4.0. ?
Thanks,
MadisonWI
------------------------------
Date: Mon, 22 Mar 1999 09:25:17 -0800
From: JWW <jerry_willard@adc.com>
Subject: Need help modifying text string search function
Message-Id: <36F67CFD.65DF61B6@adc.com>
I inherited a cgi script (below) that needs to be modified. Im
competent to work on html part, but not the Perl code. The scripts
function is to search for parts data in a delimited text file. The page
has three data input boxes: Search String, Part Number, and Prefix; plus
two action buttons: Search and Show. Parts can be searched for by their
part number or by a character string. The first two digits of part
numbers (called prefix) designate the material category. The text file
is sorted in prefix order. Entering a prefix (which is optional) limits
the search to a single category; without a prefix the whole file is
searched.
Heres what I need:
Our part numbers no longer have the two digit prefix. I need to change
the Prefix box to a four digit "Category" field. (It will actually be a
drop box with a list of the categories). The sort order of the text file
will be category, part number. The script needs to be changed to work
with the new Category field. Also, the original Part Number field was
suppose go directly to the record without searching through the entire
file (using a look/grep function), but I dont think it ever worked. So
Ill delete it and have only a single Part Number/ Search String field.
Thanks. Jerry
-----------------------------------------------------------------------------------------------
$dbFile = 'compdata/compdat.dlm';
#######################################################
&ReadParse();
$foundmax = 200;
$prefix = $in{'prefix'};
$search = $in{'search'};
$part = $in{'part'};
$show = $in{'show'};
$fsize = '3';
$hface = "Verdanna";
$iface = "Foobar";
if( $show ) {
$header = "Part # $part";
} else {
$header = "Search Results";
}
open( DB, $dbFile ) || die "Cannot open component database";
print "Content-Type: text/html\n\n";
print "<HTML>";
(snip html stuff)
# </TR>
#EOH
while( <DB> ) {
# don't allow null searches
unless ($part || ($prefix || $search)) {
print <<"EOH";
<TR>
<TD BGCOLOR="#dddddd" ALIGN="center" COLSPAN=4>No parameters
specified.</TD>
</TR>
EOH
last;
}
if( $show ) {
next unless /^$part/i;
} else {
next unless /^$prefix/i && /$search/i;
}
( $PN, $revision, $description, $cost, $vendorName, $unk,
$vendorPN, $link ) =
split( /~/, $_ );
# test for overlimit search
$found++;
if ($found > $foundmax) {
print <<"EOH";
<TR>
<TD BGCOLOR="#dddddd" ALIGN="center" COLSPAN=4>Search exceed
$foundmax
record limit.</TD>
</TR>
EOH
last;
}
------------------------------
Date: Mon, 22 Mar 1999 15:49:54 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Net::FTP
Message-Id: <36f66603.24921938@news.dircon.co.uk>
On 22 Mar 1999 13:10:18 GMT, fl_aggie@thepentagon.com (I R A Aggie)
wrote:
>On Mon, 22 Mar 1999 12:56:29 GMT, Jonathan Stowe
><gellyfish@btinternet.com> wrote:
>
>+ On Mon, 22 Mar 1999 12:25:12 +0100, David Van den Brande
>+ <brandeda@se.bel.alcatel.be> wrote:
>
>+ >is there a Net::FTP command that changes the local working directory ?
> ^^^^^^^^^^^^^^^^^^^^^^^
>+ $ftp->cwd("/pub");
>+ I'd clean your glasses next time you are reading the documentation ;-}
>
>Ummm...no. The key word is *local*. Care for some windex? ;)
>
>+ >Or, is there a way to give a local path within a get command
>+ >$ftp->get(/home/usr/tmp/localfilename,remotefilename) ?
>
>Ummm...you mean like:
> $ftp->get($there,$here);
>??? What Jonathan said about glassess and the documentation...
>
D'oh !!! I'll have to find that screen cleaning stuff ...
/J\
------------------------------
Date: 22 Mar 1999 16:52:46 GMT
From: Anupam Bakshi <anupamb@worldnet.att.net>
Subject: On the fly gif in Win 95 using gnuplot3.7
Message-Id: <36F67566.E891EDC@worldnet.att.net>
> Hi,
> In my perl cgi script, I'm opening a pipe from gnuplot to generate a gif
> file on the fly without any temporay files. It works on any Unix box but
> not on Win95.
>
> I've isolated the problem to the following:
> In a DOS window if I type
>
> wgnuplot.exe command_file > test1.gif
>
> #where command file has the folowing:
> :
> set terminal gif ...
> plot .....
> :
>
> "test1.gif" is a bad gif file which I can't view in a browser.
>
> However, if I do the following, it works.
>
> wgnuplot.exe command_file
> #command_file
> :
> set terminal gif ...
> set output "test2.gif"
> plot ....
> :
>
> The "test2.gif" is a good gif file.
>
> So I'm wondering if the DOS shell is incerting any characters in the gif
> file test1.gif which is making it unreadable.
>
> I'll appreciate any help or pointers.
> Anupam.
------------------------------
Date: 22 Mar 1999 17:07:29 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: One liner?
Message-Id: <7d5tch$24d$1@client2.news.psi.net>
Allan M. Due (All@n.due.net) wrote on MMXXIX September MCMXCIII in
<URL:news:PFpJ2.5595$DM5.2279@news.rdc1.ct.home.com>:
[] Sara Young <syoung@actcom.co.il> wrote in message
[] news:7d52ai$pp$1@lnews.actcom.co.il...
[] : Let's say you have an array of @positions and a $delimiter.
[] : Your task is to take a $line and insert the delimiter in the correct
[] : character locations. For example, if:
[] : @positions = (4, 6);
[] : $line = 'hello there';
[] : $delimiter = ',';
[] : Then the output should be:
[] : hel,lo, there
[] :
[] : Is it possible to do this with one line of code?
[]
[] Needs the latest version of perl, otherwise move the foreach.
[]
[] #!/usr/local/bin/perl -w
[] #use strict;
[]
[] my @positions = (4, 6);
[] my $line = 'hello there';
[] my $delimiter = ',';
[]
[] substr($line,$_,0,$delimiter) foreach (@positions);
[] print $line;
That doesn't work.
This does:
substr ($line, $_ - 1, 0) = $delimiter foreach sort {$b <=> $a} @positions;
Note the sort. That's required because nothing says that @positions is
an ordered array. (If it is, reverse will do).
Abigail
--
perl -wleprint -eqq-@{[ -eqw\\\\- -eJust -eanother -ePerl -eHacker -e\\\\-]}-
------------------------------
Date: Mon, 22 Mar 1999 10:39:14 -0600
From: "End User" <kimntodd@dontspamus.execpc.com>
Subject: Passing @ references into and outof sub procedures.
Message-Id: <7d5roe$8eu$1@ffx2nh3.news.uu.net>
Perhaps someone can help me out there.
here is my little snip that isnt working right:
@DBC;
@todd = netdom_bdc(DOMAIN);
foreach $todd(@todd){
print "BDC for DOMAIN= $todd\n";}
sub netdom_bdc{
open(NETDOM, "netdom /domain:$_[0] BDC|");
while (defined($line=<NETDOM>)){
if ($line =~ /^BDC/){
$dc = substr($line,12,15);
$dc =~ s/\s//;
push (@BDC, $dc);
}
return (\@bdc);
}
}
It should return a list of machines that are BDC's in my domain. Instead,
this is what it gives me:
BDC of DOMAIN = ARRAY(0x9b623c)
Why cant I get it to return the list of servers?
Thanks in advance,
--
Todd Hayward
Global Analyst, Systems Engineer
MCSE, Compaq ACT
noc at bakernet dot com
------------------------------
Date: Mon, 22 Mar 1999 16:30:44 GMT
From: john xu <jxu@centuple.com>
Subject: Perl with SSI
Message-Id: <36F66EE0.CF1ACF04@centuple.com>
All:
I am wrinting perl cgi code and am expecting this program get data from
form and send a shtml back to sender. everything works fine except SSI.
The retuned shtml page has SSI which parse other infomation to this
shtml
file. When it returned a page, I saw SSI don't work. The tags still
there and
seems not evaluate by the browser. I tried using MSIE or NS Navigator
which both just keep SSI tags not being evaluated. I don't know what's
wrong. I am using Apache web sever and shtml pages work just fine if the
page is not returned by cgi code. Somebody would like give me some
suggestion or help?
Here is the part of codes related to the cgi code:
#
sub feedback {
if (defined($FEEDBACK) #Defined somewher as $FEEDBACK =
"thanks.shtml"
&& open(FILE, "<$DOCROOT/$FEEDBACK")) { #$DOCROOT = "htdocs"
undef $/;
$_ = <FILE>; # Read file into $_
close FILE;
s/src=\"images/src=\"\/images/g; #change relative path to
absolute one
s/href=\"/href=\"\//g;
print "Content-type: text/html\n\n" . "$_";
return;
}
# Could not open HTML file! Send a generic form.
print <<EOF
Thanks for completing our form.
EOF ;
}
Please reply to jxu@centuple.com so that I won't miss your mail.
----------------------------------------------
John
jxu@centuple.com
------------------------------
Date: Mon, 22 Mar 1999 10:57:12 -0500
From: Matthew Kleinmann <matthew@cmold.com>
Subject: perl-5.005.02 make test fails on lib/ipc_sysv
Message-Id: <36F66858.FF3D9949@cmold.com>
I am trying to compile perl-5.005.02 on a Sun Sparcstation 1+ running
SunOS 4.1.4 with gcc version 2.8.1. It compiles just fine but when I
do a make test, I get the following error:
lib/ipc_sysv.......FAILED at test 1
When I do the perl harness as recomended I get the following error:
lib/ipc_sysv........dubious
Test returned status 22 (wstat 5632, 0x1600)
DIED. FAILED tests 1-16
Failed 16/16 tests, 0.00% okay
It looks to me like all of the lib/ipc_sysv functions are failing.
Has anybody else seen this kind of thing before? I read through all the
documentation and did not see this addressed. I have had a few
thoughts:
1) this is a normal error for an old version of Sun OS and it never will
pass
these tests...
2) I need to re-build my kernel with something added to it to enable
this.
I did take a second and look over the GENERIC kernel and I found
nothing
that looked like it would lead to this kind of error though.
3) I answered one (or more) of the configuration questions wrong.
I am looking to do two things with perl, (1) run majordomo and (2) use
the
modmysql with apache. I am tempted to try it and see if it works with
this one section broken, but if it is fixable I would like to have it
pass all of it's tests.
Any help woudl be appriciated. Thanks!
--Matthew
--
Matthew Kleinmann
CMOLD
31 Dutch Mill Road
Ithaca, NY 14850
echo "moc@dlomc.wehttam" | rev | tr @. .@
------------------------------
Date: Mon, 22 Mar 1999 17:41:00 GMT
From: Paul <psl1@home.com>
Subject: Re: Problem with image display
Message-Id: <36F67FE1.30D36873@home.com>
Abigail,
Thanks for your reply. I have the problem fixed.
--Paul
Abigail wrote:
>
> Paul (psl1@home.com) wrote on MMXXIX September MCMXCIII in
> <URL:news:36F5B0BA.A589797F@home.com>:
> '' Hello all,
> ''
> '' I am attempting to display an image (.gif) on a web page depending on
> '' the time of day. When the script runs, instead of the gif image, I get a
> '' broken image icon appearing in the web page.
>
> So, it looks like your web page worked. There's no point in posting the
> code that generates that web page. Of course, something went wrong in
> creating/linking the images, we you don't tell us how the images are
> generated. The code that generates the web pages however, suggest that
> the images are fixed. Hence, it doesn't look like a Perl problem at all.
>
> Abigail
> --
> perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'
------------------------------
Date: Mon, 22 Mar 1999 17:03:06 GMT
From: p3qa3@yahoo.com
Subject: read binary data
Message-Id: <7d5t42$s1u$1@nnrp1.dejanews.com>
Dear Perl Gurus ;-))
I have a question concerning read data from a file in binary format.
The file contains an array of data points and a header with information
about this and that.
All is arranged like:
---------------- Header start --------------------
user char[20]
date char[9]
time char[9]
substance char[25]
array_size_x short
array_size_y short
....
--------------- Header stop ----------------------
--------------- Data start -----------------------
array[array_size_x,array_size_y] of floating point values
--------------- Data stop ------------------------
<EOF>
So I started to read the file with
...
while(<INFILE>){($a,$b,$c ...)=unpack('a25a9a9a25s2...',$_}
Now I have the header information stored in $a, $b, $c ...
Next is to read the data. The size of the array is different from file
to file, but it is stored in the header at least. So how to read the data ?
I tried:
$read=sysread(<INFILE>,$data,$length);
with $length = some_integer_value
But this was somehow wrong.
After this print $read gives nothing and the same for $data.
Help please, thanks Frank
Please CC to
fb@bsax.de
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
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 5198
**************************************