[15522] in Perl-Users-Digest
Perl-Users Digest, Issue: 2932 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 3 11:05:31 2000
Date: Wed, 3 May 2000 08:05:13 -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: <957366313-v9-i2932@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 3 May 2000 Volume: 9 Number: 2932
Today's topics:
Re: *** To retrieve remote files regularly? <tony_curtis32@yahoo.com>
Re: bourne 'dot' or csh 'source behavior <rick.delaney@home.com>
Re: capture HTML!! (Bart Lateur)
Creating IIS V4 virtual directory using Perl... <smckee@umich.edu>
Re: HELP : Script works on Command Line but not as CGI <carey_bingham@TransCanada.com>
Re: HELP : Script works on Command Line but not as CGI <jeff@vpservices.com>
How do I change the Color of a Link sparky21@my-deja.com
Re: How do I change the Color of a Link <red_orc@my-deja.com>
Re: How do I change the Color of a Link <care227@attglobal.net>
http:request et Firewall <suteau@site-eerie.ema.fr>
Re: Keys of Hash (Randal L. Schwartz)
Re: Keys of Hash (Bernd Witzgall)
Re: Keys of Hash <Vincent.Murphy@Baltimore.Com>
Killing a query with DBI/DBD <jeffmed@mediaone.net>
Re: lib/anydbm.t TEST FAILED (M.J.T. Guy)
Parse a String <martin@mert.globalnet.co.uk>
Re: Parse a String <michael.schlueter@philips.com>
Re: Parse a String <andy@i-a.co.uk>
Re: Parse a String <bmb@ginger.libs.uga.edu>
Re: Parse a String <rhomberg@ife.ee.ethz.ch>
Re: Parse a String <rhomberg@ife.ee.ethz.ch>
Re: Parse a String <billy@arnis-bsl.com>
Re: Parse a String <sariq@texas.net>
Re: Parse a String <aqumsieh@hyperchip.com>
Re: Perl CGI Script Crashes on Win2K but not at Command <jeff@vpservices.com>
Perl developers urgently needed <ronaNOroSPAM@jmms.co.uk.invalid>
Perl subroutine...how to return HoHoH? <smckee@umich.edu>
Re: Perl subroutine...how to return HoHoH? <samay1NOsaSPAM@hotmail.com.invalid>
Re: Perl subroutine...how to return HoHoH? <aqumsieh@hyperchip.com>
Re: Perl2EXE Reassembler <rootbeer@redcat.com>
Q: search/replace and pattern matching <brock@gbgraphics.com>
Re: Q: search/replace and pattern matching <rhomberg@ife.ee.ethz.ch>
Re: Q: search/replace and pattern matching <aqumsieh@hyperchip.com>
Re: Reading and Writing to a file <bmb@ginger.libs.uga.edu>
Re: reg.expr. for correct parentheses? (Tad McClellan)
Re: Saving Uploaded Files using CGI.pm nobull@mail.com
Re: tricking the reg-ex syntax nobull@mail.com
Re: tricking the regex syntax <michael.schlueter@philips.com>
Re: tricking the regex syntax <aqumsieh@hyperchip.com>
Want to study programming? ping29007670@my-deja.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 03 May 2000 09:13:01 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: *** To retrieve remote files regularly?
Message-Id: <87itwvrac2.fsf@shleppie.uh.edu>
>> On Wed, 03 May 2000 20:18:33 +0800,
>> I'm a good man <"goodman888"@hongkong.com(remove this part)> said:
> I need to retrieve some text and image files from a
> remote site on a regular interval through FTP
> (non-anonymous login).
> Can I do that with ASP, Perl or PHP? (I prefer PHP)
Well, since this is comp.lang.perl.misc,
perldoc Net::FTP
You can find it wih:
http://search.cpan.org/
A nice module to do ftp sessions for you.
hth
t
------------------------------
Date: Wed, 03 May 2000 13:13:56 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: bourne 'dot' or csh 'source behavior
Message-Id: <39102710.7418DD56@home.com>
Jonathan Stowe wrote:
>
> On Tue, 02 May 2000 17:11:10 -0500, Andrew N. McGuire Wrote:
> >
> > #!/usr/bin/perl -w
> >
> > use strict;
> >
> > my $config = "/path/to/some/config/file";
> > %ENV = ();
> > my @shenv = `sh -c ". $config; /usr/bin/env"`;
> > chomp @shenv;
> > %ENV = map { split /=/ } @shenv;
> >
> > print map { "$_ => $ENV{$_}\n" } keys %ENV;
> >
>
> Maybe this ought to be in the FAQ. I'd pod it and submit it Andrew.
I agree, this is pretty cool. Though it looks like it could be done in
fewer ops (I'm not playing golf):
%ENV = split /[=\n]/, `sh -c ". $config; /usr/bin/env"`;
Though if one has "=" in their env vars perhaps a modification of the
original would be better:
%ENV = map { split /=/, $_, 2 } @shenv;
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Wed, 03 May 2000 13:18:44 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: capture HTML!!
Message-Id: <39181ff5.12565906@news.skynet.be>
"Daniel Lee" wrote:
>I used a cgi script to
>print out a HTML page. I would like to add a print feature on it whereby a
>user can print the current contents. Therefore I need to send the HTML page
>to another cgi script to parse it. However I'm not sure how to send the
>content of the current HTML page. Any help would be appreciated.
Try something like
$captured = `./thatscript.cgi`;
after which you can strip the content-type header, parse the HTML file,
e.g. using HTML::TokeParser, and spit it out with a new content-type
header.
--
Bart.
------------------------------
Date: Wed, 3 May 2000 09:09:06 -0400
From: "Shawn McKee" <smckee@umich.edu>
Subject: Creating IIS V4 virtual directory using Perl...
Message-Id: <TxVP4.304$R12.5829@news.itd.umich.edu>
I am trying to create a set of virtual directories in IIS V4 under WinNT V4.
The only examples of doing this that I have found involve either C++ code or
VBScript's GetObject function.
I haven't been able to find a way to get Perl (or PerlScript) to
do the equivalent of GetObject (CreateObject works fine though).
Does anyone out there know a way, using Perl, to connect to the
IIS metabase and add virtual directories and applications?
I am using ActiveState build 522 and NT is SP6.
Any insights much appreciated!
Shawn McKee
------------------------------
Date: Wed, 3 May 2000 16:09:42 +0200
From: Carey bingham <carey_bingham@TransCanada.com>
To: Craig Berry <cberry@cinenet.net>
Subject: Re: HELP : Script works on Command Line but not as CGI when using packages !
Message-Id: <39103326.B48AA622@TransCanada.com>
You are a god send :) I actually had done that in previous scripts just out
of habit, why I didn't this time I have no idea but it worked :)
I added this line to the start of the script :
use lib("d:\\cgi\\surveys\\devt\\employee_survey\\");
I tried swapping the above with :
require("d:\\cgi\\surveys\\devt\\employee_survey\\FormWrite.pl");
and it still worked !
Thank you for you suggestion, I thought I was going looney !!
Carey
Craig Berry wrote:
> Carey bingham (carey_bingham@TransCanada.com) wrote:
> [snip]
> : If I put the functions back into the Survey.pl, it works fine as a CGI
> : with no modifications...
>
> My guess: Your web server doesn't set . (current working dir) to where
> the script is run from (common under IIS, for example). Cure is to
> require by absolute (file system, not web) path, or put the absolute path
> into @INC.
>
> --
> | 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, 03 May 2000 07:28:17 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: HELP : Script works on Command Line but not as CGI when using packages !
Message-Id: <39103781.F2F7E6D8@vpservices.com>
Carey bingham wrote:
>
> use lib("d:\\cgi\\surveys\\devt\\employee_survey\\");
It's cleaner to trash the double backslashes. Perl understands forward
slashes just fine on windoze. And if there are no double quotes, you
don't need double backslashses, so I recommend writing that as
'd:\cgi\surveys\devt\employee_survey'
or even better as
'd:/cgi/surveys/devt/employee_survey'
--
Jeff
------------------------------
Date: Wed, 03 May 2000 13:29:38 GMT
From: sparky21@my-deja.com
Subject: How do I change the Color of a Link
Message-Id: <8ep9jd$tid$1@nnrp1.deja.com>
This seems simple, but I can't find the answer. All my web links come up
a blue. How in both html and with the cgi.pm mod do I do this.
Forgive me for the simplicity of this question.
-Tom
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 03 May 2000 13:57:51 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: How do I change the Color of a Link
Message-Id: <8epb8k$vk0$1@nnrp1.deja.com>
In article <8ep9jd$tid$1@nnrp1.deja.com>,
sparky21@my-deja.com wrote:
> This seems simple, but I can't find the answer. All my web links come
up
> a blue. How in both html and with the cgi.pm mod do I do this.
>
The first part of this question (the answer to which may have eliminated
the need for the second part), is better suited in a cgi authoring
group.
For the HTML part, you want to look at the ALINK, LINK, and VLINK
parameters of the <BODY> tag. you might also want to pick up some sort
of reference for HTML.
As for CGI.pm, the documentation included with the module will provide
some help, look for "Creating the HTML document header"
> Forgive me for the simplicity of this question.
> -Tom
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 03 May 2000 10:17:50 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: How do I change the Color of a Link
Message-Id: <3910350E.C898FBA@attglobal.net>
sparky21@my-deja.com wrote:
>
> This seems simple, but I can't find the answer. All my web links come up
> a blue. How in both html and with the cgi.pm mod do I do this.
This has nothing to do with CGI.pm and less to do with Perl.
Your question is one of HTML tags and their attributes.
Also, it has a slight relation browsers as well, since the
browser can over ride the color selected in the HTML and
display all links as, for example, blue.
> Forgive me for the simplicity of this question.
> -Tom
Simplicity is not a problem, I ask very simple questions
all the time. In fact, you will learn that simple
questions are better than complex ones.
------------------------------
Date: Wed, 03 May 2000 16:45:42 +0200
From: Nicolas Suteau <suteau@site-eerie.ema.fr>
Subject: http:request et Firewall
Message-Id: <39103B94.84E13243@site-eerie.ema.fr>
Bonjour,
j'utilise le petit programme suivant sur Pc sous windows. Tout
fonctionne lorsque j'utilise ma machine perso et un provider normal.
A mon bureau, je dois avant de me connecter utiliser socksCap32. Mais je
ne sais pas faire fonctionner perl avec ce programme. Perl ne peut plus
se connecter =E0 internet. Pouvez-vous m'aider ? (peut-on configurer le
port de sortie ?)
Nico.
#!c:/perl/bin/perl -w
print "Content-type: text/html\n\n";
use CGI;
require LWP::UserAgent;
$ua =3D new LWP::UserAgent;
$url =3D "http://www.clubsoleil.net/";
### se connecter =E0 la page web distante ###
$lookup =3D new HTTP::Request 'GET', $url ;
$reponse =3D $ua->request($lookup);
@lignes =3D split (/\n/, $reponse->content);
$page =3D join ("", @lignes);
print ("$page");
exit;
------------------------------
Date: 03 May 2000 06:26:35 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Keys of Hash
Message-Id: <m14s8f933o.fsf@halfdome.holdit.com>
>>>>> "Samay" == Samay <samay1NOsaSPAM@hotmail.com.invalid> writes:
Samay> Hi, I have
Samay> $X{a}{b} = 'c';
Samay> $X{a}{d} = 'e';
Samay> $X{p}{b} = 'd';
Samay> $X{p}{r} = 'x';
Samay> etc..
Samay> I want to get the keys for this Hash in pair
Samay> In other words
Samay> I need to have the pair
Samay> a b
Samay> a d
Samay> p b
Samay> p r
Samay> How I can get it??
for my $first (sort keys %X) {
for my $second (sort keys %{$X{$first}}) {
"you now have $first and $second - enjoy!";
}
}
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 3 May 2000 13:33:41 GMT
From: bernd.witzgall@gmx.de (Bernd Witzgall)
Subject: Re: Keys of Hash
Message-Id: <slrn8h0aks.2f9.bernd.witzgall@bart.megatron.de>
Samay <samay1NOsaSPAM@hotmail.com.invalid> wrote
on Wed, 03 May 2000 05:52:56 -0700:
>Hi, I have
> $X{a}{b} = 'c';
> $X{a}{d} = 'e';
> $X{p}{b} = 'd';
> $X{p}{r} = 'x';
>
>etc..
>
>I want to get the keys for this Hash in pair
>In other words
>I need to have the pair
>a b
>a d
>p b
>p r
>
>How I can get it??
#!/usr/bin/perl -w
use strict;
my %X;
$X{a}{b} = 'c';
$X{a}{d} = 'e';
$X{p}{b} = 'd';
$X{p}{r} = 'x';
for my $outer (keys %X) {
for my $inner (keys %{$X{$outer}}) {
print "$outer $inner\n";
}
}
__END__
See also perldoc perlref and perldoc perlreftut.
------------------------------
Date: Wed, 03 May 2000 14:39:14 GMT
From: Vincent Murphy <Vincent.Murphy@Baltimore.Com>
Subject: Re: Keys of Hash
Message-Id: <xjg8zxritpu.fsf@gamora.us.cybertrust.com>
>>>>> "Randal" == Randal L Schwartz <merlyn@stonehenge.com> writes:
>>>>> "Samay" == Samay <samay1NOsaSPAM@hotmail.com.invalid> writes:
Samay> Hi, I have
Samay> $X{a}{b} = 'c';
Samay> $X{a}{d} = 'e';
Samay> $X{p}{b} = 'd';
Samay> $X{p}{r} = 'x';
Samay> etc..
Samay> I want to get the keys for this Hash in pair
Samay> In other words
Samay> I need to have the pair
Samay> a b
Samay> a d
Samay> p b
Samay> p r
Samay> How I can get it??
Randal> for my $first (sort keys %X) {
Randal> for my $second (sort keys %{$X{$first}}) {
Randal> "you now have $first and $second - enjoy!";
---------------^
a print may help here. :-)
Randal> }
Randal> }
------------------------------
Date: Wed, 03 May 2000 14:57:10 GMT
From: "Jeffrey P. Medeiros" <jeffmed@mediaone.net>
Subject: Killing a query with DBI/DBD
Message-Id: <a7XP4.75170$YU2.935527@typhoon.ne.mediaone.net>
Is there an API call to kill a query with DBI/DBD? I would like to kill a
query in the case of mistyped information or an unusually long query.
I'm using the Informix DBD.
------------------------------
Date: 3 May 2000 14:59:37 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: lib/anydbm.t TEST FAILED
Message-Id: <8epesp$pil$1@pegasus.csx.cam.ac.uk>
In article <3908421A.563A92A3@tcd.ie>, Paul Reilly <pareilly@tcd.ie> wrote:
>
>RH Linux 6.2
>Just installed perl 5.005_3 from source.
>When running make test , all the tests pass except for lib/anydbm
>
>lib/abbrev..........ok
>lib/anydbm..........FAILED test 12 Failed 1/12 tests, 91.67% okay
>lib/autoloader......ok
The corresponding test in perl5.6.0 has this comment added
# anydbm.t test 12 will fail when AnyDBM_File uses the combination of
# DB_File and Berkeley DB 2.4.10 (or greater).
# You are using DB_File $DB_File::VERSION and Berkeley DB $compact
#
# Berkeley DB 2 from version 2.4.10 onwards does not allow null keys.
# This feature will be reenabled in a future version of Berkeley DB.
#
print "ok 12 # skipped: db v$compact, no null key support\n" ;
So the error's harmless, except that it tells you your dbm doesn't
support null keys.
>When I run the test on it's own, it fails, but the script says:
>
>Can't locate Fcntl.pm in @INC (@INC contains: ../lib) at anydbm.t line
>11.
That looks like you're running the test in the wrong environment.
When running a not-yet-installed Perl, the libraries won't be in the
right place, so @INC has to be fixed up. The test should do this
correctly if you ensure that the current directory is either the Perl
source tree or the t/ directory, and do
./perl t/lib/anydbm.t
There are further instructions in the INSTALL document.
>And if you look at the lib/anydbm.t script it says:
>
>#If Fcntl is not available, try 0x202 or 0x102 for O_RDWR|O_CREAT
>use Fcntl;
That looks like a piece of historical junk. AFAIK the Fcntl module
should be available on any platform that supports DB_File.
>Should Fcntl be in my @INC and does it work on Linux 6.2?
Yes. See above. Fcntl is certainly present under Linux.
>What is Fcntl?
It defines useful constants for use by sysopen(), flock(), fcntl() etc.
perldoc Fcntl (when you've got your Perl installed :-)
Mike Guy
------------------------------
Date: Wed, 3 May 2000 14:33:53 +0100
From: "Martin Elliott" <martin@mert.globalnet.co.uk>
Subject: Parse a String
Message-Id: <8epa8u$h7v$1@gxsn.com>
How can I remove 'white space' from the beginning of a string, e.g. "
mystring" ?
Thanks in advance :-)
Martin
------------------------------
Date: Wed, 3 May 2000 16:54:22 +0200
From: "Michael Schlueter" <michael.schlueter@philips.com>
Subject: Re: Parse a String
Message-Id: <8epao7$o6v$1@porthos.nl.uu.net>
E.g.:
#!/usr/bin/perl -w
use strict;
my $x=" mystring" ;
$x=~s/\s//g; # replace any whitespace (\s) by nothing
# the g is for global substitution
------------------------------
Date: Wed, 03 May 2000 15:06:32 +0100
From: Andy Jeffries <andy@i-a.co.uk>
Subject: Re: Parse a String
Message-Id: <39103268.E9480F5B@i-a.co.uk>
Michael Schlueter wrote:
>
> E.g.:
>
> #!/usr/bin/perl -w
>
> use strict;
> my $x=" mystring" ;
>
> $x=~s/\s//g; # replace any whitespace (\s) by nothing
> # the g is for global substitution
Although this isn't actually what he asked for. He wanted white space
removed from the beginning of a string:
#!/usr/bin/perl -w
use strict;
my $x=" mystring";
$x =~ s/\s(\S.*)/$1/;
Should do the trick (is there not a trim function in Perl?).
--
Andy Jeffries
Head of Web Development
Internet Assist Ltd.
Web : www.i-a.co.uk
Tel : +44 (0)20 8547 3700
------------------------------
Date: Wed, 3 May 2000 10:29:40 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Parse a String
Message-Id: <Pine.A41.4.10.10005031028001.18964-100000@ginger.libs.uga.edu>
On Wed, 3 May 2000, Martin Elliott wrote:
> How can I remove 'white space' from the beginning of a string, e.g. "
> mystring" ?
>
> Thanks in advance :-)
>
> Martin
perldoc -q beginning
See also:
perldoc perlfaq
perldoc perldoc
--
Brad
------------------------------
Date: Wed, 03 May 2000 16:32:54 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Parse a String
Message-Id: <39103896.F5E51E8A@ife.ee.ethz.ch>
Martin Elliott wrote:
>
> How can I remove 'white space' from the beginning of a string, e.g. "
> mystring" ?
It's in the faq
perldoc -q blank
- Alex
------------------------------
Date: Wed, 03 May 2000 16:35:02 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Parse a String
Message-Id: <39103916.37F9AB9A@ife.ee.ethz.ch>
Andy Jeffries wrote:
> $x =~ s/\s(\S.*)/$1/;
This removes the first space found in the string, regardless where it
is.
The answer in the faq is better. And correct.
- Alex
------------------------------
Date: Wed, 03 May 2000 14:26:17 GMT
From: Ilja <billy@arnis-bsl.com>
Subject: Re: Parse a String
Message-Id: <8epcth$1j9$1@nnrp1.deja.com>
In article <8epao7$o6v$1@porthos.nl.uu.net>,
"Michael Schlueter" <michael.schlueter@philips.com> wrote:
> E.g.:
>
> #!/usr/bin/perl -w
>
> use strict;
> my $x=" mystring" ;
>
> $x=~s/\s//g; # replace any whitespace (\s) by nothing
> # the g is for global substitution
>
Sorry, IMHO you are wrong. The OP's questions was:
>> How can I remove 'white space' from the beginning of a string, e.g. " mystring" ?
Your example removes *all* whitespaces, not just the leading ones !
Try something like: $x =~ s/^\s*//;
Ilja.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 03 May 2000 09:47:26 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Parse a String
Message-Id: <39103BFE.A6F1B33B@texas.net>
Martin Elliott wrote:
>
> How can I remove 'white space' from the beginning of a string, e.g. "
> mystring" ?
perldoc -q space
Then:
perldoc perldoc
perldoc perl
perldoc perltoc
- Tom
------------------------------
Date: Wed, 03 May 2000 14:49:36 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Parse a String
Message-Id: <7abt2nr8n3.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>
Andy Jeffries <andy@i-a.co.uk> writes:
> Michael Schlueter wrote:
> >
> > E.g.:
> >
> > #!/usr/bin/perl -w
> >
> > use strict;
> > my $x=" mystring" ;
> >
> > $x=~s/\s//g; # replace any whitespace (\s) by nothing
> > # the g is for global substitution
>
> Although this isn't actually what he asked for. He wanted white space
> removed from the beginning of a string:
>
> #!/usr/bin/perl -w
>
> use strict;
> my $x=" mystring";
>
> $x =~ s/\s(\S.*)/$1/;
Why the complications? Just remove the space(s):
$x =~ s/^\s*//;
Of course, the FAQs have a lot to say about this. Check out perlfaq4.
--Ala
------------------------------
Date: Wed, 03 May 2000 07:31:39 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Perl CGI Script Crashes on Win2K but not at Command
Message-Id: <3910384B.F7A168DD@vpservices.com>
John wrote:
>
> Thanks for this help Sam. From what you've said and what I learned is that
> is the IUSR_ is not a local user, thefore it has no right to the machine.
> The problem that I now encounter, is when I give the IUSR_ right's to the
> databases, it still doesn't seem to matter.
Is the DSN for the database a system DSN?
--
Jeff
------------------------------
Date: Wed, 03 May 2000 06:58:56 -0700
From: JM Selection <ronaNOroSPAM@jmms.co.uk.invalid>
Subject: Perl developers urgently needed
Message-Id: <09e68980.5ab4a3e2@usw-ex0104-031.remarq.com>
We are urgently seeking Perl developers for a variety of
exciting roles in many different sectors.
Please apply direct to RONA@JMMS.CO.UK
Or view our website at WWW.JMMS.CO.UK
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Wed, 3 May 2000 09:23:47 -0400
From: "Shawn McKee" <smckee@umich.edu>
Subject: Perl subroutine...how to return HoHoH?
Message-Id: <DLVP4.306$R12.6018@news.itd.umich.edu>
I have a Perl subroutine which generates a HoHoH:
mysub {
undef %a;
...
$a{$b}{$c}{$d} = $e;
...
return \%a; # This doesn't work correctly (or maybe it does
} # but I don't know how to correctly dereference it!
How do I return this to the caller correctly and how should the
caller dereference it?
I tried:
%new = mysub();
foreach $akey (keys %new) {
print " Found akey = $akey\n";
foreach $bkey (keys %{$new{$akey}} ) {
print " Found akey:bkey $akey:$bkey\n";
foreach $ckey ( keys %{{$new{$akey}{$bkey}}} {
print " Found akey:bkey:ckey $akey:$bkey:$ckey\n";
}
}
}
The foreach loops don't work (Finds only 1 akey as a HASH value).
Any pointers? Thanks,
Shawn McKee
------------------------------
Date: Wed, 03 May 2000 06:33:32 -0700
From: Samay <samay1NOsaSPAM@hotmail.com.invalid>
Subject: Re: Perl subroutine...how to return HoHoH?
Message-Id: <07deff02.541477fe@usw-ex0104-031.remarq.com>
In article <DLVP4.306$R12.6018@news.itd.umich.edu>, "Shawn
McKee" <smckee@umich.edu> wrote:
>I have a Perl subroutine which generates a HoHoH:
>
> mysub {
>
> undef %a;
could have used my %a;
>....
> $a{$b}{$c}{$d} = $e;
>....
> return \%a; # This doesn't work correctly (or maybe it does
> } # but I don't know how to correctly
dereference it!
>
>How do I return this to the caller correctly and how should the
>caller dereference it?
>
>I tried:
>
>%new = mysub();
$new = mysub()
>foreach $akey (keys %new) {
foreach $akey (keys %{$new})
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Wed, 03 May 2000 14:53:43 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Perl subroutine...how to return HoHoH?
Message-Id: <7a8zxrr8g9.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>
"Shawn McKee" <smckee@umich.edu> writes:
> I have a Perl subroutine which generates a HoHoH:
>
> mysub {
>
> undef %a;
You don't need to undef %a. Just declare it:
my %a;
> ...
> $a{$b}{$c}{$d} = $e;
> ...
> return \%a; # This doesn't work correctly (or maybe it does
> } # but I don't know how to correctly dereference it!
This returns a reference to the hash. Good.
> How do I return this to the caller correctly and how should the
> caller dereference it?
>
> I tried:
>
> %new = mysub();
This is wrong. mysub() returns a reference to a hash (not a hash). A
reference is a scalar, so you would do something like:
$new = mysub();
Now, $new refers to the hash that was created in mysub().
> foreach $akey (keys %new) {
foreach $akey(keys %$new) {
> print " Found akey = $akey\n";
> foreach $bkey (keys %{$new{$akey}} ) {
foreach $bkey (keys %{$new->{$akey}}) {
> print " Found akey:bkey $akey:$bkey\n";
> foreach $ckey ( keys %{{$new{$akey}{$bkey}}} {
foreach $ckey (keys %{$new->{$akey}{$bkey}}) {
> print " Found akey:bkey:ckey $akey:$bkey:$ckey\n";
> }
> }
> }
>
> The foreach loops don't work (Finds only 1 akey as a HASH value).
>
> Any pointers? Thanks,
Yeah. You need to read more on references. Checkout the following
docs:
perlref
perlsub
perlreftut
perllol
perldsc
--Ala
------------------------------
Date: Wed, 3 May 2000 07:33:06 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl2EXE Reassembler
Message-Id: <Pine.GSO.4.10.10005030728170.13677-100000@user2.teleport.com>
On Wed, 26 Apr 2000, Ron Sommer wrote:
> I´ve found an Perl-Script on there intranet, which is compiled with
> perl2exe
> Is there any chance to get the source-code out of the compiled perl ?
If you have the author's permission, it should be trivial to get the
source. :-)
But are you actually asking for help in stealing source code that an
author doesn't want you to have?
Still, technologically, it should be possible to extract the source code;
someone should make a program to do so. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 03 May 2000 09:15:17 -0500
From: Brock Gunter-Smith <brock@gbgraphics.com>
Subject: Q: search/replace and pattern matching
Message-Id: <B5359EA5.1B34%brock@gbgraphics.com>
I'm trying to write a VERY basic routine to parse a file of e-mail
addresses, clean up the addresses and discard addresses that are an invalid
format...but I'm having trouble. When I read in each line I do:
$address =~ s/[^\w\.-@]//g;
I want to remove all characters that do NOT belong to the set [a-z A-Z 0-9 -
. @] This seems to be working ok...if there is a better way I would gladly
use it.
if ($address =~ /^(.+)@(.+\.)(.+)/) { $goodAddress = 0; }
Here is where I run into trouble though. I want to set $goodAddress to 0 if
$address does NOT have the format (any letters)@(anyletters).(anyletters)
This way, if it's a NON-valid format I know not to write it back to the
file...this code isn't working though. How do I check for that pattern
properly so that it works 100%? Thanks.
-> Brock
------------------------------
Date: Wed, 03 May 2000 16:37:11 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Q: search/replace and pattern matching
Message-Id: <39103997.5CA4BD6E@ife.ee.ethz.ch>
Brock Gunter-Smith wrote:
>
> I'm trying to write a VERY basic routine to parse a file of e-mail
> addresses, clean up the addresses and discard addresses that are an invalid
> format...but I'm having trouble. When I read in each line I do:
Check out Abigail RFC::RFC822 on CPAN to check email addresses
- Alex
------------------------------
Date: Wed, 03 May 2000 14:47:47 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Q: search/replace and pattern matching
Message-Id: <7aem7jr8q4.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>
Brock Gunter-Smith <brock@gbgraphics.com> writes:
> I'm trying to write a VERY basic routine to parse a file of e-mail
> addresses, clean up the addresses and discard addresses that are an invalid
> format...but I'm having trouble. When I read in each line I do:
>
> $address =~ s/[^\w\.-@]//g;
>
> I want to remove all characters that do NOT belong to the set [a-z A-Z 0-9 -
> . @] This seems to be working ok...if there is a better way I would gladly
> use it.
Your way if fine, except that I would not backwach the dot, since
there is no need for it. Also, note that the above will keep any
underscores as they are part of \w.
Call me paranoid, but I would also rearrange those a bit:
$address =~ s/[^\w.@-]//g;
> if ($address =~ /^(.+)@(.+\.)(.+)/) { $goodAddress = 0; }
>
> Here is where I run into trouble though. I want to set $goodAddress to 0 if
> $address does NOT have the format (any letters)@(anyletters).(anyletters)
> This way, if it's a NON-valid format I know not to write it back to the
> file...this code isn't working though. How do I check for that pattern
> properly so that it works 100%? Thanks.
Checkout perlfaq9:
How do I check a valid mail address?
--Ala
------------------------------
Date: Wed, 3 May 2000 10:33:51 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Reading and Writing to a file
Message-Id: <Pine.A41.4.10.10005031032360.18964-100000@ginger.libs.uga.edu>
On Wed, 26 Apr 2000, Carter Hamilton wrote:
> I would like to open a text file and append something to the end of certain
> lines. Is there any way to do this without copying the information to a new
> file? I would like to do something like this:
>
> while (<TEXT>) {
> if (/$pattern/) {
> print TEXT chomp($_) . $newStuff . "\n";
> }
> else {
> print TEXT $_;
> }
> }
perldoc -q "how do i change one line in a file"
See also:
perldoc perlfaq
perldoc perldoc
--
Brad
------------------------------
Date: Wed, 3 May 2000 09:07:29 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: reg.expr. for correct parentheses?
Message-Id: <slrn8h094h.7bi.tadmc@magna.metronet.com>
On Wed, 03 May 2000 14:11:30 +0200, Joern Stein <eedjoes@eed.ericsson.se> wrote:
>I'm trying to get a list of all correctly parenthesized expressions from
>a string. For example, if I have
>Is that possible with Perl's regular expressions?
Perl FAQ, part 6:
"Can I use Perl regular expressions to match balanced text?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 03 May 2000 14:06:00 +0100
From: nobull@mail.com
Subject: Re: Saving Uploaded Files using CGI.pm
Message-Id: <u9hfcfss07.fsf@wcl-l.bham.ac.uk>
Tom Phoenix <rootbeer@redcat.com> writes:
> On Tue, 2 May 2000, Mike wrote:
>
> > I have looked at a couple of examples using CGI.pm to upload files.
> > Each of these examples do things like echo back the contents, etc.
> >
> > But none show how to actually save the file in a specific location.
>
> Do you know how to write a file of your own to a specific location, in a
> non-CGI program? It's done in the same basic way when using CGI.pm. See
> the docs for open() in the perlfunc manpage, the perlopentut manpage, or
> both. If you have further questions after reading those docs, feel free to
> ask again. Cheers!
Actually you may want to consider using the copy() subroutine from
File::Copy. It may be necessary for a good craftsman to be skilled
with hand-tools but eschewing power-tools completely is not the sign
of a good craftsman.
If the file likely to be large and the temporary directory is likely
to be on the same filesystem as the destination then maybe move()
would be better still.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 03 May 2000 14:01:13 +0100
From: nobull@mail.com
Subject: Re: tricking the reg-ex syntax
Message-Id: <u9itwvss86.fsf@wcl-l.bham.ac.uk>
"Daniel Berger" <djberg96@hotmail.com> writes:
> $option = 'i';
> $_ =~ /pattern/$option
BTW: $_ =~ is redundant!
> But Perl doesn't like this. Is there any way to trick it?
$option = '(?i)';
/${option}pattern/
For details: perldoc perlre
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 3 May 2000 16:41:25 +0200
From: "Michael Schlueter" <michael.schlueter@philips.com>
Subject: Re: tricking the regex syntax
Message-Id: <8ep9vu$nm7$1@porthos.nl.uu.net>
Hi Daniel,
What do you want to achieve? Do you need assignment? Do you want to make a
case-decision? Is $opt always just one character? Etc.
Michael
------------------------------
Date: Wed, 03 May 2000 14:58:38 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: tricking the regex syntax
Message-Id: <7a66svr882.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>
"Daniel Berger" <djberg96@hotmail.com> writes:
> I would like to do the following:
>
> $opt = 'i';
> $line =~ /pattern/$opt
>
> Perl doesn't like that (and yes, I've tried different
> permutations of quotes, etc).
>
> Is there a way to make this work? Thanks in advance.
Yes, and it is described in the perlre docs. You should consult them
for more info, but I'll give you a preview:
$line =~ /(?$opt:pattern)/;
--Ala
------------------------------
Date: Wed, 03 May 2000 14:15:12 GMT
From: ping29007670@my-deja.com
Subject: Want to study programming?
Message-Id: <8epc8v$ja$1@nnrp1.deja.com>
Would you like to study your preferred
programming language as a self teacher and make
quick progresses in order to conquer the cyberspace?
There is a shortcut available:
start studying the simple and elegant language used in the Nasa
space shuttles: Forth.
It gives you complete control over your computer and, as it shows what
is
behind the scenes, makes the move to any other language easy,
even to Java.
Compiler and book are for free.
Free email support also possible.
Check out this page http://www.ping.be/4talig/Forth/Index.shtml
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
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 2932
**************************************