[19056] in Perl-Users-Digest
Perl-Users Digest, Issue: 1251 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 5 14:05:33 2001
Date: Thu, 5 Jul 2001 11:05:10 -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: <994356310-v10-i1251@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 5 Jul 2001 Volume: 10 Number: 1251
Today's topics:
Re: [Q] WHY don't constant and require/do mix? (Jay Tilton)
Can't understand exec() results <mnemotronic@mind\no-spam/spring.com>
Core Dump on ODBC data_sources check? (Oblique)
Correct way to open a .jpg image and save? <mlaw@talk21.comNOSPAM>
Re: Counting occurances on a line <tom.melly@ccl.com>
Re: Counting occurances on a line <tschmelter@statesman.com>
Re: executing perl in a browser on win2k server <bart.lateur@skynet.be>
Re: Is there no solution to a malformed header? (Pape Toure)
Last chance to propose lightning talks for TPC 2001 <mjd@plover.com>
Re: limiting cgi input from specific IP's <andrew@mvt.ie>
Re: Net::Telnet logging on problem..... <yasser@x-unity-x.demon.co.uk>
Re: Net::Telnet logging on problem..... <r1ckey@home.com>
Newbie Question <ken@hallitech.com>
Perl method for finding current working dir <Graham.T.Wood@oracle.com>
Re: Perl method for finding current working dir <tony_curtis32@yahoo.com>
Re: Perl method for finding current working dir <mjcarman@home.com>
Re: perldoc -q (Tad McClellan)
Re: perldoc -q <thelma@alpha2.csd.uwm.edu>
putting arrays in arrays!?!? <mr.thanquol@gmx.de>
Re: putting arrays in arrays!?!? (Tad McClellan)
Re: putting arrays in arrays!?!? (Anno Siegel)
Re: putting arrays in arrays!?!? <godzilla@stomp.stomp.tokyo>
regular expression ..doh ! mbower@ibuk.bankgesellschaft.de
Re: regular expression ..doh ! <tony_curtis32@yahoo.com>
Re: regular expression ..doh ! (Tad McClellan)
Re: regular expression ..doh ! mbower@ibuk.bankgesellschaft.de
Re: regular expression ..doh ! <james@zephyr.org.uk>
Re: regular expression ..doh ! <godzilla@stomp.stomp.tokyo>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 05 Jul 2001 17:46:32 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: [Q] WHY don't constant and require/do mix?
Message-Id: <3b4497a6.166042708@news.erols.com>
On 5 Jul 2001 01:57:02 -0400, kj0 <kj0@mailcity.com> wrote:
>Thank you, that's very helpful. But there's one thing that's still
>puzzling, if one looks at inheritance:
> ------------------------------------------------------------
> # file incl.pl
> use constant CUATRO => 4;
> 1;
> ------------------------------------------------------------
> # file A.pm
> package A;
> BEGIN {
> require "include.pl"; # require works here
> }
> use strict;
> sub talk() { print(CUATRO."\n"); }
> sub new {
> my $class = shift;
> my $self = {};
> bless $self, $class;
> }
> 1;
> ------------------------------------------------------------
> # file B.pm
> package B;
> BEGIN {
> do "include.pl"; # require does not work here
> }
> use strict;
> use A;
> @B::ISA = ('A');
> sub speak() { print(CUATRO."\n"); }
> 1;
> ------------------------------------------------------------
> #!/usr/local/bin/perl -w
> use strict;
> use A;
> use B;
> my $a = new A();
> $a->talk();
> my $b = new B();
> $b->speak();
> 1;
> ------------------------------------------------------------
> >% C.pl
> 4
> 4
> >%
>
>But, if the definitions of B is changed slightly, by replacing the
>"do" statement in the BEGIN block by a "require" statement, then
>
> >% C.pl
> 4
> CUATRO
> >%
>
>I.e. "require" works in the case of A.pm but does not work in the case
>of B.pm. What's up with that?
From perldoc -f require
[...]
Otherwise, demands that a library file be included if it hasn't
already been included.
[...]
Package A has already required include.pl, and with no package of its own, A
is where the CUATRO constant lives. Requiring include.pl again under
package B does nothing. do 'file', on the other hand, doesn't care if the
file's been done before.
If in one module you say,
require "include.pl";
and in the other,
require "./include.pl";
you can trick it into believing they're different files, so it will be
loaded into each namespace. Not that I'm endorsing this kind of
foolishness. It's just to give insight into how require works.
But none of that should matter much. You mention inheritance, then ignore
its strength. Rather than have an identical CUATRO constant clog up two
namespaces, have B require A, then use the method it inherits.
sub speak() {
my $self = shift;
print($self->CUATRO . "\n");
}
------------------------------
Date: Thu, 05 Jul 2001 10:13:18 -0600
From: pt <mnemotronic@mind\no-spam/spring.com>
Subject: Can't understand exec() results
Message-Id: <3B44921E.F202167B@mindspring.com>
(Win98 2nd ed, ActiveState Perl 5.6.1, bld 626)
I'm executing an external program ("c:\blah blah blah\blackd.exe")
from within Perl. Following is the code that does it. Entering this,
the BLACKICE_ENGINE is a "use constant" containing the path to the exe
file. $CmdParam is either "start" or "stop".
----- cut here -----
# Run BlackIce daemon (BLACKD.EXE) as a separate process. Running it
# with backticks doesn't seem to work properly ....
# sometimes the EXE never returns.
if (fork() == 0)
{
print "child : exec blackice and exit\n" ;
my $BI = BLACKICE_ENGINE ;
print "child : black ice = $BI\n";
exec($BI,$CmdParam) or print STDERR "child : exec call failed:
$!\n" ;
# The following exit is superfluous, as the exec call never
returns.
exit ;
}
print "parent\n" ;
# parent continues ...
----- cut here -----
When this code runs, the blackice firewall does what it should
(either start or stop), but I get an error message (below) that says it
isn't an error message. The "print" after the "exec()" doesn't appear
to execute, which is what I expect. Everything seems to work, but for
that long "can't exec ....." error message, which I don't think I'm
printing ..... Where does it come from?
----- cut here -----
child : exec blackice and exit
child : black ice = D:\Program Files\Network ICE\BlackICE\blackd.exe
parent
Can't exec "D:\Program Files\Network ICE\BlackICE\blackd.exe": No error
at
d:\user\src\perl\RotoRouter.pl line 526 (#1)
(W exec) An system(), exec(), or piped open call could not execute
the
named program for the indicated reason. Typical reasons include:
the
permissions were wrong on the file, the file wasn't found in
$ENV{PATH}, the executable in question was compiled for another
architecture, or the #! line in a script points to an interpreter
that
can't be run for similar reasons. (Or maybe your system doesn't
support
#! at all.)
----- cut here -----
Remove the obvious anti-spam to reply.
------------------------------
Date: 5 Jul 2001 10:42:02 -0700
From: gdobbs_2000@yahoo.com (Oblique)
Subject: Core Dump on ODBC data_sources check?
Message-Id: <7db4060f.0107050942.3f32a58d@posting.google.com>
Here's the problem-
I've been using Postgres as my database of choice for awhile now, and
have been using the DBI->data_sources('Pg'); method in several of my
scripts to list the databases, as they fluctuate.
However, I've recently had to implement MSSQL for one of the company's
programs, and upon trying to list the data sources for MSSQL,i get a
core dump.
The data sources don't seem to be set up incorrectly, as I can connect
and interact with them.
Here is the error i get when i try this line of code in the perl
debugger
DB<17> @hello = DBI->data_sources('ODBC');
Signal SEGV at /usr/lib/perl5/5.00503/perl5db.pl line 1239
DB::eval called at /usr/lib/perl5/5.00503/perl5db.pl line 1133
DB::DB called at -e line 1
Aborted
it even kicks me out of the perl debugger...
------------------------------
Date: Thu, 5 Jul 2001 19:07:51 +0100
From: Matt L. <mlaw@talk21.comNOSPAM>
Subject: Correct way to open a .jpg image and save?
Message-Id: <9i29rq$e0$1@neptunium.btinternet.com>
Hi!
On a previous post I was advised not to open an image file like so:-
$file = param('file');
open (SAVE, ">../images/$file") || die $!;
while (<$file>) {
print SAVE $_;
}
But instead, I should use the function read(), I have the Perl cookbook
which says to use this for fixed length records by doing this:-
until ( eof(FILE) ) {
read(FILE, $record, $recordsize) == $RECORDSIZE or die "short read\n";
@FIELDS = unpack($TEMPLATE, $record);
}
Is this the right way to go about receiving my file from the html form and
writing it to disk? If so can anyone explain the syntax a little?
If it is not the right way, what is?
Many thanks,
Matt.
------------------------------
Date: Thu, 5 Jul 2001 16:07:15 +0100
From: "Tom Melly" <tom.melly@ccl.com>
Subject: Re: Counting occurances on a line
Message-Id: <3b4482a3$0$3756$ed9e5944@reading.news.pipex.net>
"Tom Melly" <tom.melly@ccl.com> did not write in message
news:3b447fa2$0$3764$ed9e5944@reading.news.pipex.net...
> > The most important issue, though, is indicated by the warning generated
> with -w:
> > Use of implicit split to @_ is deprecated at foo.pl line XX.
> >
Hmm, the warning doesn't show up under windows, does under linux, same perl
version (5.6.0). Wha' happen' ?
------------------------------
Date: Thu, 05 Jul 2001 17:29:24 GMT
From: Tim Schmelter <tschmelter@statesman.com>
Subject: Re: Counting occurances on a line
Message-Id: <3B44A3F1.8276C6A4@statesman.com>
Tom Melly wrote:
> "Tom Melly" <tom.melly@ccl.com> did not write in message
> news:3b447fa2$0$3764$ed9e5944@reading.news.pipex.net...
>
> > > The most important issue, though, is indicated by the warning generated
> > with -w:
> > > Use of implicit split to @_ is deprecated at foo.pl line XX.
> > >
>
> Hmm, the warning doesn't show up under windows, does under linux, same perl
> version (5.6.0). Wha' happen' ?
C:\WINDOWS\Desktop>perl -v
This is perl, v5.6.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2000, Larry Wall
Binary build 623 provided by ActiveState Tool Corp. http://www.ActiveState.com
Built 16:27:07 Dec 15 2000
<snip>
C:\WINDOWS\Desktop>perl -we "split /:/, 'Hello:Goodbye'"
Use of implicit split to @_ is deprecated at -e line 1.
What build of ActivePerl are you using? Are you calling the script with
warnings (-w or "use warnings;")?
------------------------------
Date: Thu, 05 Jul 2001 15:09:52 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: executing perl in a browser on win2k server
Message-Id: <1t09kt4fu81mmb9nrgr9tla2h363jt8fos@4ax.com>
<chris@wmccmsvr.ssr.hp.com> wrote:
>all the
>scripts to handle and regurgitate user input were written in perl for
>UNIX. The office recently upgraded a new server to Windows 2000 Server,
I would never ever call that an upgrade.
--
Bart.
------------------------------
Date: 5 Jul 2001 08:59:45 -0700
From: pape_toure@yahoo.com (Pape Toure)
Subject: Re: Is there no solution to a malformed header?
Message-Id: <644fbcc7.0107050759.47653e51@posting.google.com>
Thank you very much...
this helped a lot and now it works thanks again :-)
Peace,
Pape
------------------------------
Date: Thu, 05 Jul 2001 11:40:16 -0400
From: Mark-Jason Dominus <mjd@plover.com>
Subject: Last chance to propose lightning talks for TPC 2001
Message-Id: <20010705154016.27524.qmail@plover.com>
Lightning talks are five-minute long talks. They are easy to give and
easy to prepare.
Submissions are still being accepted for the lightning talk session at
TPC 2001 in San Diego this month. To submit, send email with:
* The talk title
* A description up to four sentences long
to
mjd-tpc-lightning+@plover.com
QUestions may be sent to the same address. For more details, see
http://perl.plover.com/lt/lightning-talks.ora.html
Submitters will be notified between July 8 and July 15 about whether
their submissions were accepted.
------------------------------
Date: Thu, 5 Jul 2001 17:17:24 +0100
From: "Andrew" <andrew@mvt.ie>
Subject: Re: limiting cgi input from specific IP's
Message-Id: <9i23v4$ma7$1@kermit.esat.net>
"Craig Berry" <cberry@cinenet.net> wrote in message
news:tjq3scnnb0eb43@corp.supernews.com...
> news.sohoskyway.com (jestersi@metacrawler.com) wrote:
> : > --*-- "Magick is the art and science of causing change in conformity
> : > | with Will." - Aleister Crowley
> : You should read the book "Satan wants me" is a good read and some of the
> : plot has to do w/mr. crowley
> : although they kinda depict him as a fat heroine addict.
>
> Quite likely because he was, in fact, a fat heroin addict. Among many,
> many other things, of course.
I prefer slim heroines myself. I wouldn't say I'm addicted though - I can
quit anytime I want :-)
Andrew
------------------------------
Date: Thu, 05 Jul 2001 17:08:32 +0100
From: "Yas" <yasser@x-unity-x.demon.co.uk>
Subject: Re: Net::Telnet logging on problem.....
Message-Id: <g9017.8436$A51.1372092@monolith.news.easynet.net>
In article <cT_07.14147$wr.68920@news1.frmt1.sfba.home.com>, "Rickey
Ingrassia" <r1ckey@home.com> wrote:
> In comp.lang.perl.misc Yas <yasser@x-unity-x.demon.co.uk> wrote:
>>In article <maI07.12100$wr.62100@news1.frmt1.sfba.home.com>, "Rickey
>>Ingrassia" <r1ckey@home.com> wrote:
>><snip>
>
> --snip--
>
>>Thns for your help.... now there is a new problem....
>
>>below is my code:
>
>>#!/usr/bin/perl -w
>
>>use Net::Telnet;
>
>>$HOST = new Net::Telnet(Port => "10001", Errmode => "return", Prompt =>
>>'/[?>:#\]][ ]*$/'); $HOST->open("MY IP");
>
>>$username="admin";
>>$password="<PASSWORD>";
>
>>$HOST->input_log("/tmp/input.log");
>
>>$HOST->login("$username","$password");
>
>>@test = $HOST->cmd("help");
>>$HOST->close;
>
>>print @test."\n";
>
>>It should print loads of help commands... but instead prints 0... ive
>>tried other commadns and instead prints just numbers....
>
>>thnx in advance for any help
>
> What's in your input.log file? Does the prompt regex match your prompt?
>
Hmmmmm..... sort of...
Iam telneting to a console server that is attached to a Sun Netra X1....
So once authenticated i get a blank line and i have to press enter once
to get:
lom>
ive tried sending a CR but recieve the same problem....
below is the output of my input.log:
bash-2.03# cat /tmp/input.log
login: ahbash-2.03#
which is a bit strange...
thnx
------------------------------
Date: Thu, 05 Jul 2001 17:10:05 GMT
From: Rickey Ingrassia <r1ckey@home.com>
Subject: Re: Net::Telnet logging on problem.....
Message-Id: <Nb117.14441$wr.69887@news1.frmt1.sfba.home.com>
In comp.lang.perl.misc Yas <yasser@x-unity-x.demon.co.uk> wrote:
>In article <cT_07.14147$wr.68920@news1.frmt1.sfba.home.com>, "Rickey
>Ingrassia" <r1ckey@home.com> wrote:
>> In comp.lang.perl.misc Yas <yasser@x-unity-x.demon.co.uk> wrote:
>>>In article <maI07.12100$wr.62100@news1.frmt1.sfba.home.com>, "Rickey
>>>Ingrassia" <r1ckey@home.com> wrote:
>>><snip>
>>
>> --snip--
>>
>>>Thns for your help.... now there is a new problem....
>>
>>>below is my code:
>>
>>>#!/usr/bin/perl -w
>>
>>>use Net::Telnet;
>>
>>>$HOST = new Net::Telnet(Port => "10001", Errmode => "return", Prompt =>
>>>'/[?>:#\]][ ]*$/'); $HOST->open("MY IP");
>>
>>>$username="admin";
>>>$password="<PASSWORD>";
>>
>>>$HOST->input_log("/tmp/input.log");
>>
>>>$HOST->login("$username","$password");
>>
>>>@test = $HOST->cmd("help");
>>>$HOST->close;
>>
>>>print @test."\n";
>>
>>>It should print loads of help commands... but instead prints 0... ive
>>>tried other commadns and instead prints just numbers....
>>
>>>thnx in advance for any help
>>
>> What's in your input.log file? Does the prompt regex match your prompt?
>>
>Hmmmmm..... sort of...
>Iam telneting to a console server that is attached to a Sun Netra X1....
>So once authenticated i get a blank line and i have to press enter once
>to get:
>lom>
>ive tried sending a CR but recieve the same problem....
>below is the output of my input.log:
>bash-2.03# cat /tmp/input.log
>login: ahbash-2.03#
>which is a bit strange...
>thnx
Well, first off I want to apologize and eat my words. You'll need to use
the dump_log method to find this problem. I'll bet that it is a prompt regex
problem. With dump_log you will be able to see the exact characters that
are exchanged. Also since you are going through a terminal server (or so it
appears) you may want to use a "$host->print("")" to send the CR (still eating
my words). I was able to reproduce your exact problem by tweaking my prompt
and making the regex not match.
In my own defense, I did state in my first post "...the following code works on
98.865% of the devices I connect to."
--
____ __
______/_ | ____ | | __ ____ ___.__.
\_ __ \ |/ ___\| |/ // __ < | |
| | \/ \ \___| <\ ___/\___ |
|__| |___|\___ >__|_ \\___ > ____|
_________________\/_____\/____\/\/_____
---------------------------------------
------------------------------
Date: Thu, 05 Jul 2001 15:25:47 GMT
From: "News" <ken@hallitech.com>
Subject: Newbie Question
Message-Id: <%F%07.3745$oa1.458102@newsread1.prod.itd.earthlink.net>
I am learning Perl for the first time, so be gentle. I successfully wrote
my first 'hello world' program. Now I am trying to pass a variable from an
html file (a form) to a perl script and use the perl script to print out the
variable. I'm doing this to better understand the basics associated with
variables and the relationship between html and perl.
I have a form in the html file that looks like this:
<form name="Name" action="cgiscript" method="post">
Name; <input type="text" name="name" size="20">
</form>
I execute the perl like this:
<h1><a href="cgi/mailer.pl">Run Form</a></h1>
The cgi script looks like this:
#!/usr/local/bin/perl
#
# test.pl-- my first mailer program
#
use CGI;
my $page = new CGI; my $paramvalue = $page->param('name');
print "Content-type: text/html\n\n" ;
# Print the HTML response page to STDOUT
print <<EOF ;
<html>
<head><title>CGI Results</title></head>
<body>
<h1>Hello, world.</h1>
<p>$paramvalue</p>
</body>
</html>
EOF
exit ;
$parmvalue doesn't show anything when I execute it. I know I'm missing
something. Hopefully, I'm not too far out into left field.
I would appreciate any help in this matter.
Ken
------------------------------
Date: Thu, 05 Jul 2001 15:40:40 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Perl method for finding current working dir
Message-Id: <3B447C68.1A9AE93@oracle.com>
This is a multi-part message in MIME format.
--------------7C5A84659E7184E680CAF817
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Does nobody know this or are you just choosing not to answer?
How can you determine the directory your script is running in from
within the script, without calling an external program that differs on
Windows and Unix?
Graham Wood
--------------7C5A84659E7184E680CAF817
Content-Type: text/x-vcard; charset=UTF-8;
name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
filename="Graham.T.Wood.vcf"
begin:vcard
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.T.Wood@oracle.com
fn:Graham Wood
end:vcard
--------------7C5A84659E7184E680CAF817--
------------------------------
Date: 05 Jul 2001 10:42:11 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Perl method for finding current working dir
Message-Id: <871ynvfkmk.fsf@limey.hpcc.uh.edu>
>> On Thu, 05 Jul 2001 15:40:40 +0100,
>> Graham Wood <Graham.T.Wood@oracle.com> said:
> Does nobody know this or are you just choosing not to
> answer? How can you determine the directory your script
> is running in from within the script, without calling an
> external program that differs on Windows and Unix?
What was wrong with John Krahn's reply?
Message-ID: <3B42F248.5CAD6B5@acm.org>
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How to find pwd in Perl
Date: Wed, 04 Jul 2001 10:37:59 GMT
t
--
Beep beep! Out of my way, I'm a motorist!
------------------------------
Date: Thu, 05 Jul 2001 11:33:55 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Perl method for finding current working dir
Message-Id: <3B4496F3.85CCBAB9@home.com>
Graham Wood wrote:
>
> Does nobody know this or are you just choosing not to answer?
No need to get snippy. It could be either (nobody owes anyone a
repsonse, after all) or it could just be that Usenet can be rather
tempermental about message propagatiion.
> How can you determine the directory your script is running in from
> within the script
use FindBin;
# Script directory is $FindBin::Bin
-mjc
------------------------------
Date: Thu, 5 Jul 2001 10:59:03 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: perldoc -q
Message-Id: <slrn9k905n.glf.tadmc@tadmc26.august.net>
Thelma Lubkin <thelma@alpha2.csd.uwm.edu> wrote:
>We are often urged to use perldoc -q to search the documentation for
It only searches _part of_ the documentation (about 10% of what
is available), namely the Perl FAQs.
>help on something that we can describe in a short phrase, but where we
>don't know associated function names.
>The perldoc on my system does not support the -q option.
You have an old perl (and perldoc) then.
>I am in no
>position to get the administrators to do anything about this, so can
>you suggest alternatives for me?
Get the tarball for a more modern perl.
Copy the perldoc from the new perl to some place early in your path.
You may need to edit it to make it compatable with your Old Perl.
Viola!
Or, just go to:
www.perldoc.com
but it does not appear that you can restrict their search to
only the Perl FAQs. An opportunity for improvement!
Or, just write a Perl program that searches the Perl FAQs for you:
----------------------------------
#!/usr/bin/perl -w
# perldoc-q -- look for search terms in FAQs
use strict;
die "USAGE: perldoc-q <searchterm>\n" unless @ARGV == 1;
my $searchterm = shift;
@ARGV = glob '/usr/lib/perl5/5.6.0/pod/perlfaq*.pod';
while (<>) {
next unless /^=head2 .*$searchterm/;
(my $fname = $ARGV) =~ s#.*/##; # extract basename (non-portably)
print "$fname: $_";
}
----------------------------------
You will need to change the glob() argument to reflect where the
*.pod files got installed on your particular system.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 5 Jul 2001 16:06:10 GMT
From: Thelma Lubkin <thelma@alpha2.csd.uwm.edu>
Subject: Re: perldoc -q
Message-Id: <9i239i$vqq$1@uwm.edu>
Tad McClellan <tadmc@augustmail.com> wrote:
: Thelma Lubkin <thelma@alpha2.csd.uwm.edu> wrote:
:>help on something that we can describe in a short phrase, but where we
:>don't know associated function names.
:>The perldoc on my system does not support the -q option.
: You have an old perl (and perldoc) then.
<snip helpful suggestions>
: Or, just write a Perl program that searches the Perl FAQs for you:
<snip a full program to do just that>
thank you very much: I'm going to try this one.
--thelma
: Tad McClellan SGML consulting
: tadmc@augustmail.com Perl programming
: Fort Worth, Texas
------------------------------
Date: Thu, 5 Jul 2001 18:46:48 +0200
From: "felix" <mr.thanquol@gmx.de>
Subject: putting arrays in arrays!?!?
Message-Id: <9i25ju$mdc$1@crusher.de.colt.net>
hi,
in first
I'm new to perl!
in second
I'm hopelessly lost
I want to put the content of an array in an array like this and addititonaly
scalar values
@small_array = (1 , 2 , 3);
$some_value = '4' ;
$some_more_value = '5';
@BIG_ARRAY = (@small_array , $some_value , $some_more_value)
and afterwards the output should look like this
1
2
3
4
5
... can somebody give me a hand with this??
thx
felix
------------------------------
Date: Thu, 5 Jul 2001 12:10:27 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: putting arrays in arrays!?!?
Message-Id: <slrn9k94bj.gu0.tadmc@tadmc26.august.net>
felix <mr.thanquol@gmx.de> wrote:
> I'm hopelessly lost
No you're not.
>I want to put the content of an array in an array like this and addititonaly
^^^^^^^^
>scalar values
>@small_array = (1 , 2 , 3);
That is putting the contents of a list into an array. Perl FAQ, part 4:
"What is the difference between a list and an array?"
>$some_value = '4' ;
>$some_more_value = '5';
>
>
>@BIG_ARRAY = (@small_array , $some_value , $some_more_value)
>
>and afterwards the output
Err, your code above does not make any output...
>should look like this
>1
>2
>3
>4
>5
>
>
>... can somebody give me a hand with this??
You do not need a hand with it. It works as you have it.
Did you try it?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 5 Jul 2001 17:06:51 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: putting arrays in arrays!?!?
Message-Id: <9i26rb$3cd$2@mamenchi.zrz.TU-Berlin.DE>
According to felix <mr.thanquol@gmx.de>:
> hi,
>
> in first
> I'm new to perl!
> in second
> I'm hopelessly lost
>
>
> I want to put the content of an array in an array like this and addititonaly
> scalar values
> @small_array = (1 , 2 , 3);
> $some_value = '4' ;
> $some_more_value = '5';
Why are you quoting '4' and '5' but not 1, 2, 3?
> @BIG_ARRAY = (@small_array , $some_value , $some_more_value)
Why, yes. That's how it's done.
> and afterwards the output should look like this
> 1
> 2
> 3
> 4
> 5
>
> ... can somebody give me a hand with this??
print "$_\n" for @BIG_ARRAY;
Have you tried your own code? It does exactly what you want. The
only objection would be to the variable name in all-caps.
Anno
------------------------------
Date: Thu, 05 Jul 2001 10:51:51 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: putting arrays in arrays!?!?
Message-Id: <3B44A937.9BCD198F@stomp.stomp.tokyo>
felix wrote:
(snipped)
> I want to put the content of an array in an array like this and addititonaly
> scalar values
> @small_array = (1 , 2 , 3);
> $some_value = '4' ;
> $some_more_value = '5';
> @BIG_ARRAY = (@small_array , $some_value , $some_more_value)
> and afterwards the output should look like this
> 1
> 2
> 3
> 4
> 5
Add a newline character \n to each value directly,
or indirectly during a plaintext print.
You are missing a semicolon after your BIG_ARRAY assignment.
Godzilla!
------------------------------
Date: Thu, 05 Jul 2001 16:19:36 GMT
From: mbower@ibuk.bankgesellschaft.de
Subject: regular expression ..doh !
Message-Id: <3b449220.93757859@news>
I'm trying to parse form input, and would like to remove all entries
from $ENV{'QUERY_STRING'} which are of type "field"
e.g &field=1&field=2&field=3&other=no
$var1="/tableview2.pl?editcols=Go&table=atabler&view=yes&canupdate=true&field=eurex&field=rtd&field=gl&someother=yes";
print "$var1\n";
$var1 =~ s/&field=\w+(&|$)/$1/g;
print "$var1\n";
leaves me with the "&field=rtd" still in the string.....?!?!
and whilst I'm here... how can I assign the results of a regular
expression directly into another variable ?
e.g
$var1 = "hello there this is a test";
$var2 = $var1;
$var2 =~ s/test//;
I'd like to do something like $var2 = $var1 =~ s/test//; # but
this just gives me the result
------------------------------
Date: 05 Jul 2001 11:29:09 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: regular expression ..doh !
Message-Id: <87wv5ne3vu.fsf@limey.hpcc.uh.edu>
>> On Thu, 05 Jul 2001 16:19:36 GMT,
>> mbower@ibuk.bankgesellschaft.de said:
> I'm trying to parse form input, and would like to remove
> all entries from $ENV{'QUERY_STRING'} which are of type
> "field"
> e.g &field=1&field=2&field=3&other=no
Don't try to bodge it yourself, you'll only regret it down
the line.
use CGI;
my @fields = param('field');
"perldoc CGI" for more.
If you want to reconstruct the CGI argument list you can
use param() to iterate over the values and remove the
appropriate ones.
It's not clear to me why you'd want to do this though.
hth
t
--
Beep beep! Out of my way, I'm a motorist!
------------------------------
Date: Thu, 5 Jul 2001 11:57:39 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: regular expression ..doh !
Message-Id: <slrn9k93jj.gst.tadmc@tadmc26.august.net>
mbower@ibuk.bankgesellschaft.de <mbower@ibuk.bankgesellschaft.de> wrote:
>I'm trying to parse form input
That wheel has already been invented.
Use a module for URL decoding.
>how can I assign the results of a regular
>expression directly into another variable ?
"regular expressions" do not _have_ results.
"operators" have results. There are operators that make use
of regular expressions, such as m// and s///.
Maybe you meant to ask how to copy-and-modify (via one of those
operators)? If so, then see below.
>I'd like to do something like $var2 = $var1 =~ s/test//;
You are already pretty darn close:
($var2 = $var1) =~ s/test//; # the copy-and-modify idiom
:-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 05 Jul 2001 16:43:20 GMT
From: mbower@ibuk.bankgesellschaft.de
Subject: Re: regular expression ..doh !
Message-Id: <3b4498dd.95482781@news>
On 05 Jul 2001 11:29:09 -0500, Tony Curtis <tony_curtis32@yahoo.com>
wrote:
>>> On Thu, 05 Jul 2001 16:19:36 GMT,
>>> mbower@ibuk.bankgesellschaft.de said:
>
>> I'm trying to parse form input, and would like to remove
>> all entries from $ENV{'QUERY_STRING'} which are of type
>> "field"
>
>> e.g &field=1&field=2&field=3&other=no
>
>Don't try to bodge it yourself, you'll only regret it down
>the line.
too late ! my prog generates a page with several HREFS on it, and
each one is slightly different depending on the function. Whilst I
agree I could use the suggestion below, it's not what I want to do in
this case.
>
> use CGI;
> my @fields = param('field');
>
>"perldoc CGI" for more.
>
>If you want to reconstruct the CGI argument list you can
>use param() to iterate over the values and remove the
>appropriate ones.
>
>It's not clear to me why you'd want to do this though.
>
>hth
>t
>--
>Beep beep! Out of my way, I'm a motorist!
------------------------------
Date: Thu, 5 Jul 2001 18:28:06 +0100
From: James Coupe <james@zephyr.org.uk>
Subject: Re: regular expression ..doh !
Message-Id: <9Uw$47NmOKR7Ew7k@gratiano.zephyr.org.uk>
In message <3b4498dd.95482781@news>, mbower@ibuk.bankgesellschaft.de
writes
>too late ! my prog generates a page with several HREFS on it, and
>each one is slightly different depending on the function.
Using CGI.pm will not prevent you from doing this.
Not using CGI.pm will cause you to encounter many bugs in your
implementation of the protocol.
--
James Coupe PGP Key: 0x5D623D5D
EBD690ECD7A1F
It's me Nono small robot you know - friend of Ulysses B457CA213D7E6
It's me Nono small robot you know - friend of Ulysses 68C3695D623D5D
------------------------------
Date: Thu, 05 Jul 2001 10:43:58 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: regular expression ..doh !
Message-Id: <3B44A75E.F0CDACD8@stomp.stomp.tokyo>
mbower wrote:
(various snippage)
> I'm trying to parse form input, and would like to remove
> all entries from $ENV{'QUERY_STRING'} which are of type "field"
> e.g &field=1&field=2&field=3&other=no
Your "other=no" is not of a "field" type.
> $var1="/tableview2.pl?editcols=Go&table=atabler& .... ";
This is not a query string.
Consider rewriting your article in a manner which
is coherent and readily understandable.
Godzilla!
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
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 V10 Issue 1251
***************************************