[22478] in Perl-Users-Digest
Perl-Users Digest, Issue: 4699 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 12 11:06:07 2003
Date: Wed, 12 Mar 2003 08:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 12 Mar 2003 Volume: 10 Number: 4699
Today's topics:
Re: Creating a variable with a file path/name in it <barryk2@SPAM-KILLER.mts.net>
Re: Creating a variable with a file path/name in it (Helgi Briem)
For the top UK Perl, Unix, Linux jobs.. <topjob@ecmsel.co.uk>
Re: glob causes perl.exe to crash <jvandervloet@hotmail.com>
Grabbing module name on the fly <noreply@gunnar.cc>
Re: Grabbing module name on the fly (Anno Siegel)
Re: Grabbing module name on the fly <noreply@gunnar.cc>
Re: Insert End-of-line <REMOVEsdnCAPS@comcast.net>
Re: Insert End-of-line <bobkardell@yahoo.com>
Re: Insert End-of-line <flavell@mail.cern.ch>
Re: Letting users change their password via web form... (Anno Siegel)
Re: Need Help : Passing Parameters to Functions <barryk2@SPAM-KILLER.mts.net>
Re: Need Help : Passing Parameters to Functions <uri@stemsystems.com>
Re: Need Help : Passing Parameters to Functions <jurgenex@hotmail.com>
panic error (Smiles)
PGP with Perl <dejan.tomazic@szkbanka.si>
Re: PGP with Perl <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: Problem matching a value in hash (Steph)
problem redefining a function <thens@nospam.com>
Re: problem redefining a function (Anno Siegel)
Re: problem redefining a function <REMOVEsdnCAPS@comcast.net>
Re: select ip-adress out of pipe delimited file <tore@aursand.no>
small parsing problem <grobitaille@mail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 12 Mar 2003 08:13:33 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: Creating a variable with a file path/name in it
Message-Id: <MPG.18d8fc8c27081f4c989740@news.mts.net>
In article <95401f60.0303110848.12c8e1b0@posting.google.com>, Sylvie
(eisfaerie@mad.scientist.com) says...
> Hello. My programming knowledge is pretty basic, although I've been
> doing Perl programming for some time now, so I really need help here.
>
> I am trying to create a global variable which contains a particular
> file's name (call it File for this example) and absolute path. My code
> reads something like:
> $MyFile = "/home/me/public_cgi/progXfolder/File";
>
> I store this in a subroutine which I then call whenever I need to
> open/read/write to this file. However, I am getting an error whenever
> I try opening the file:
> open (TheFile, "$MyFile") || &writeError($MyFile);
>
> &writeError is a small script that lets me know when I'm having
> trouble opening files. It writes down $MyFile in a text file, and
> according to this, $MyFile is /home/me/public_cgi/progXfolder/File so
> I know that the value of my variable is being passed correctly.
>
> I've checked the read/write privileges for the file and folders, and
> they're all correct.
>
> I'm not sure what I'm doing wrong. Can I specify the absolute path
> like this?
>
> Any help would be appreciated. Please use as much detail as possible,
> as I still consider myself a newbie at this :)
>
> Sylvie
>
Use the "$!" variable to give you a reason for the failure as in :
open (TheFile, "$MyFile") || die("Can't open $MyFile : $!\n");
--
---------
Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com
------------------------------
Date: Wed, 12 Mar 2003 15:15:25 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Creating a variable with a file path/name in it
Message-Id: <3e6f4e39.2863499754@news.cis.dfn.de>
On Wed, 12 Mar 2003 08:13:33 -0600, Barry Kimelman
<barryk2@SPAM-KILLER.mts.net> wrote:
>Use the "$!" variable to give you a reason for the failure as in :
>
> open (TheFile, "$MyFile") || die("Can't open $MyFile : $!\n");
>
Yes, but:
- use an uppercase only filehandle as recommended
in perldoc perlstyle
- use 'or' instead of that C-ish || construction that is so
error-prone. If you use 'or' you don't need the
parentheses
- you don't need to double-quote $MyFile
open FILE, $MyFile or die "Cannot open $MyFile:$!\n";
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: Wed, 12 Mar 2003 14:15:46 -0000
From: "ECM Selection Ltd" <topjob@ecmsel.co.uk>
Subject: For the top UK Perl, Unix, Linux jobs..
Message-Id: <wfHba.8661$EA6.1329541@newsfep2-win.server.ntli.net>
PhD / BSc 1st Class/ 2.1 Hons?
From recent Grad/PhD to Software Dev Mgr
For the pick of UK's top permanent High Tech jobs for R&D and applications
including:
Manufacturing Automation & Robotic Systems
Smart Product Development: C/C++, Java, Delphi, SQL/Server, Oracle, Sybase,
Access.
Real Time Financial Business Critical Info Systems: PHP/Linux/Java/SQL:
Safety Critical Software Development Toolsets:
Oracle, SQL, XML, .Net,SAOP, Matlab, Formal Methods
Data Warehousing/ Data Mining Consultancy:
Oracle, Multi-dimensional Design/Analysis,
Query /Reporting tools, OLAP
Network/RAID Storage: C/C++, Delphi, MFC, COM Win32API, OOD, Linux, NT,
SCSI, FibreChannel, TCP/IP
Mobile Communications over IP
Team Leader: - PhD + IP/Mobile protocol research, + C/C++, OpNet.
SoC /Asic/ EDA Verification Tools:
PhD, C/C++, Perl, VHDL
For more info about these and many more technically challenging jobs call
ECM
on 01638 742244
or visit www.High-Tech-Jobs.co.uk
Try the BrainBuster - win a high-tech prize!
--
To apply for these appointments you must have the right to live and work in
the EU.
ECM Selection Ltd - High-Tech Recruitment Specialists
------------------------------
Date: Wed, 12 Mar 2003 11:08:13 GMT
From: "joeri" <jvandervloet@hotmail.com>
Subject: Re: glob causes perl.exe to crash
Message-Id: <xyEba.8391$Vq.769@afrodite.telenet-ops.be>
"Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in
message news:Xns933C7030C361Felhber1lidotechnet@62.89.127.66...
> I just tested both versions of Perl. The 5.6.1 caused the error, 5.8.0
> didn't.
Hmm, I must have done sth wrong than...
Will try.
Thanks.
J
------------------------------
Date: Wed, 12 Mar 2003 12:30:03 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Grabbing module name on the fly
Message-Id: <b4n5n6$21iu6v$1@ID-184292.news.dfncis.de>
I have a Perl application with a number of app specific modules. The
user can create one or more additional modules out from a template, name
the files to [anything].pm, and save them in a directory in the local
search path designated for such additional modules. One of the 'regular'
program modules grabs the names of the actual module files via opendir,
and stores the names in @AddModNames.
This is how I'm doing it talking Perl:
+++ 'Regular' module +++
package regular;
...
for (@AddModNames) {
print addfunction ($_);
}
sub addfunction {
my $mod = shift;
require "$INC[0]/extras/$mod";
# Grabs info from a subroutine in
# the latest loaded extra module
@refs = extras();
...
}
+++ Additional module +++
package something;
...
sub regular::extras {
...
return \($var1, %var2);
}
As can be seen above, the subroutine name in the additional module
belongs to the namespace 'regular' to start with. The reason for doing
so is that, since the names are known only 'on the fly', I haven't found
any way to import or qualify names without using symlinks (which I'm
avoiding).
This leads me to the reason for this post:
- Are there any disadvantages with the described solution? I have
a feeling that it's a little 'Perl 4-ish', but it works...
- Is there any significantly better solution?
Comments appreciated.
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 12 Mar 2003 11:59:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Grabbing module name on the fly
Message-Id: <b4n7fb$fud$1@mamenchi.zrz.TU-Berlin.DE>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
> I have a Perl application with a number of app specific modules. The
> user can create one or more additional modules out from a template, name
> the files to [anything].pm, and save them in a directory in the local
> search path designated for such additional modules. One of the 'regular'
> program modules grabs the names of the actual module files via opendir,
> and stores the names in @AddModNames.
>
> This is how I'm doing it talking Perl:
>
> +++ 'Regular' module +++
>
> package regular;
> ...
> for (@AddModNames) {
> print addfunction ($_);
> }
>
> sub addfunction {
> my $mod = shift;
> require "$INC[0]/extras/$mod";
>
> # Grabs info from a subroutine in
> # the latest loaded extra module
> @refs = extras();
>
> ...
> }
>
> +++ Additional module +++
>
> package something;
> ...
> sub regular::extras {
> ...
> return \($var1, %var2);
> }
>
> As can be seen above, the subroutine name in the additional module
> belongs to the namespace 'regular' to start with. The reason for doing
> so is that, since the names are known only 'on the fly', I haven't found
> any way to import or qualify names without using symlinks (which I'm
> avoiding).
>
> This leads me to the reason for this post:
>
> - Are there any disadvantages with the described solution? I have
> a feeling that it's a little 'Perl 4-ish', but it works...
The disadvantage I see is that extras() is forced into a fixed
package ("regular") instead of the user's current package. With
a general-purpose module this can lead to conflicts. If the module
will only be used in a fixed context there may be no problem.
> - Is there any significantly better solution?
I don't know about better, but you can do run-time exportation. Prepare
the additional module as an Exporter as usual (untested code):
package Something; # Lower-case modules are pragmas by convention
require Exporter;
our @ISA = qw( Exporter);
our @EXPORT_OK = qw( extras);
sub extras { # now in package Something
...
}
In the regular module, do
require "$INC[0]/extras/$mod";
Something->import( 'extras') if Something->can( 'import');
This is more or less what "use" does at compile time.
Anno
------------------------------
Date: Wed, 12 Mar 2003 15:35:09 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Grabbing module name on the fly
Message-Id: <b4ngj6$21nu0l$1@ID-184292.news.dfncis.de>
Anno Siegel wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
>> +++ 'Regular' module +++
>>
>> package regular;
>> ...
>> for (@AddModNames) {
>> print addfunction ($_);
>> }
>>
>> sub addfunction {
>> my $mod = shift;
>> require "$INC[0]/extras/$mod";
>>
>> # Grabs info from a subroutine in
>> # the latest loaded extra module
>> @refs = extras();
>>
>> ...
>> }
>>
>> +++ Additional module +++
>>
>> package something;
>> ...
>> sub regular::extras {
>> ...
>> return \($var1, %var2);
>> }
>>
>>As can be seen above, the subroutine name in the additional module
>>belongs to the namespace 'regular' to start with. The reason for doing
>>so is that, since the names are known only 'on the fly', I haven't found
>>any way to import or qualify names without using symlinks (which I'm
>>avoiding).
>>
>>This leads me to the reason for this post:
>>
>>- Are there any disadvantages with the described solution? I have
>> a feeling that it's a little 'Perl 4-ish', but it works...
>
> The disadvantage I see is that extras() is forced into a fixed
> package ("regular") instead of the user's current package. With
> a general-purpose module this can lead to conflicts. If the module
> will only be used in a fixed context there may be no problem.
It's absolutely not a general-purpose module, so I take it that I can
well go for the current solution.
>>- Is there any significantly better solution?
>
> I don't know about better, but you can do run-time exportation. Prepare
> the additional module as an Exporter as usual
>
> [snip]
>
> In the regular module, do
>
> require "$INC[0]/extras/$mod";
> Something->import( 'extras') if Something->can( 'import');
------^^^^^^^^^
That presupposes that you know the package name in advance...
Now I realize that I made a mistake when considering various options. I
was simply stuck in the convention that the name of a module file equals
the package name (+ '.pm'), so in my instructions to the users I tell
them to change the package name to match the file name they choose.
That's obviously unnecessary; I could even state 'package regular;' at
the top of the template for the additional module files, i.e. the same
package name as in the calling module... Yeah, I think that must be the
most straight-forward solution.
Thanks for your comments, Anno, and for making me realize my mistake. ;-)
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 12 Mar 2003 07:09:35 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Insert End-of-line
Message-Id: <Xns933C52F8F2ACAsdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
"Bob Kardell" <bobkardell@yahoo.com> wrote in
news:b4mhit$565$1@slb0.atl.mindspring.net:
> Any help would be appreciated - thanks in advance,
Here's a nickel's worth of free advice: Don't post the same article
to multiple newsgroups. It annoys the natives. Either learn to do a
proper crosspost, or figure out which one newsgroup is the most
appropriate, and stick with that one.
I just answered your question in comp.lang.perl, and here it is
again!
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13
iD8DBQE+bzGAY96i4h5M0egRApOpAJ9re/iwtIS8i+NV9Jm1mWLz8JzSIQCgpGjp
S2q2RjOmWnTMN8aRr4j18a4=
=f1ci
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 12 Mar 2003 07:09:20 -0600
From: "Bob Kardell" <bobkardell@yahoo.com>
Subject: Re: Insert End-of-line
Message-Id: <b4nbjk$4ce$1@slb9.atl.mindspring.net>
Thanks for the info - I was thinking I could change $_ by inserting "\n".
( I know its not real code - the real code is much too large to put here)
Bob
"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3E6ED16E.1C1F1E30@earthlink.net...
> Bob Kardell wrote:
> >
> > I am working on trying to sort through a file like this:
> >
> > thing1,thing2,: thing3,
> > thing4, thing5,:...
> >
> > What I am looking to do is just match "thing2." If a grep on the
> > file I will get the entire line, so I did this:
> >
> > while <FILE> {
> > s/:/\n/g;
> > @final = grep { s/thing2/ } $_;
> > }
> > print @final;
>
> First, that's not real code, since it produces a syntax error.
>
> Second, simply changing ":" chars to "\n" chars does not make $_ into an
> array or list of things; it's still one thing, no matter how you munge
> it's contents.
>
> I think that you want:
>
> while(<FILE>) {
> chomp;
> print $_, "\n" for grep m/thing2/, split /:/;
> }
>
> --
> $a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
> );{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
> ]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Wed, 12 Mar 2003 14:43:39 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Insert End-of-line
Message-Id: <Pine.LNX.4.53.0303121439210.16242@lxplus065.cern.ch>
On Wed, Mar 12, Eric J. Roode rightly berated a multiposter, but then
remarked:
> I just answered your question in comp.lang.perl,
That group officially does not exist, so it's probably not a good idea
to get involved in discussions there without including an appropriate
caution and, preferably, some kind of f'up to a more-appropriate (and
officially existing ;-) group.
For sure the news server here denies the existence of comp.lang.perl,
so I'm not going to be contributing to it, anyway.
cheers
------------------------------
Date: 12 Mar 2003 11:30:17 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Letting users change their password via web form...
Message-Id: <b4n5o9$dkm$1@mamenchi.zrz.TU-Berlin.DE>
Mandrake <Mandrake@dream-server.com> wrote in comp.lang.perl.misc:
[TOFU rearranged]
> Abigail wrote:
>
> > Mandrake (Mandrake@dream-server.com) wrote on MMMCDLXXIX September
> > MCMXCIII in <URL:news:v6qvh3eup6hbcb@news.supernews.com>:
> > "" Hi guys. Anyone have a suggestion as to what I can use to allow users
> > to
> > "" change their own passwords? I tried the Expect version, and
> > unfortunately I
[...]
> > Changing passwords over the web is dangerous. My standpoint is that
> > if you can't figure out how to do it, you're not qualified enough
> > to do it.
> Ahhh, thanks for that tidbit of advice there Abigail. That means that if I
> don't know how to build an automobile that I shouldn't drive one, correct?
No, it means if you don't know how to change a tire you better learn
it (and a few more things) before embarking on a 500 mile drive through
the desert.
Anno
------------------------------
Date: Wed, 12 Mar 2003 08:16:34 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: Need Help : Passing Parameters to Functions
Message-Id: <MPG.18d8fd3b8b2b9a76989741@news.mts.net>
In article <dc2b0830.0303111527.39d08ba9@posting.google.com>, KP
(snazystyl@hotmail.com) says...
> In FirstSub $FileList is present but in the Second Sub it is not. This
> then returns a Error because it's not in the SecondSub. How would I
> pass $filelist to the SecondSub so that it can be used there as well.
> I have been reading up on Passing Parameters to Functions. But I'm
> just not getting it. Any help would be greatly appreciated.
>
> sub FirstSub
> {
> my $filelistexts;
> my $fileinfo;
> my $FileList;
> if (exists $ENV{'SYSTEMROOT'})
> {
> my $xmlfile = $ENV{"SYSTEMROOT"}.$g_xmlfilepath;
> open (FILE, $xmlfile) || die;
>
> while ($fileinfo = <FILE> )
> {
> if ($fileinfo =~ /.*<EXTENSIONS>.*/)
> {
> while ($filelistexts = <FILE>)
> {
> if ($filelistexts =~ /<REC>(.*)<\/REC>/)
> {
> $FileList = $FileList .';'. $1;
> }
> }last;
> }
> }
> }
> else
> {
> die;
> }
> }
>
> sub SecondSub
> {
> my $extleftover;
> my $NotFoundList;
> my @SystemList = split/;/, $SystemList;
>
> foreach $extleftover (@SystemList)
> {
> unless ($FileList =~ m/.*;\Q$extleftover\E;.*/)
> {
> $NotFoundList = $NotFoundList .$extleftover.';';
> }
> }
> }
When you declare a variable with "my", that restricts the scope of that
variable to the subroutine that declared the variable. However, if you
declare a variable with "local" the variable will also be known in all
subroutines called by the subroutine.
--
---------
Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com
------------------------------
Date: Wed, 12 Mar 2003 14:32:49 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Need Help : Passing Parameters to Functions
Message-Id: <x7n0k0hcz4.fsf@mail.sysarch.com>
>>>>> "BK" == Barry Kimelman <barryk2@SPAM-KILLER.mts.net> writes:
BK> When you declare a variable with "my", that restricts the scope of that
BK> variable to the subroutine that declared the variable. However, if you
BK> declare a variable with "local" the variable will also be known in all
BK> subroutines called by the subroutine.
declaring a local var in a sub just to pass it to other subs is so BAD
BAD BAD. and the my declaration in the called sub will hide it anyhow.
where did you come up with such a poor answer?
the OP needs to learn how to do basic sub calls with @_ and my vars.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: Wed, 12 Mar 2003 15:48:57 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Need Help : Passing Parameters to Functions
Message-Id: <JFIba.19882$iq1.13515@nwrddc02.gnilink.net>
KP wrote:
> In FirstSub $FileList is present but in the Second Sub it is not. This
> then returns a Error because it's not in the SecondSub. How would I
> pass $filelist to the SecondSub so that it can be used there as well.
> I have been reading up on Passing Parameters to Functions. But I'm
> just not getting it. Any help would be greatly appreciated.
[code sample snipped]
But you are not passing any parameters anywhere.
You are declaring and defining a local variable $filelist in your first
function. And then you don't do anything with it.
There are two possible solutions:
- Use a global variable instead of a local variable. DO NOT DO THAT. Global
variables are poor programming style and lead to unmanagable programs very
fast. This is general programming 101 and is no different in Perl.
- Actually pass parameters and return values:
In your first sub use a "return $filelist;" statement to return the value of
$filelist to the calling function.
There capture the value (not really necessary, you can use that value
directly, too):
my $files = firstsub();
Then call the second sub and actually pass the value as a function argument:
secondsub($files);
And inside of the second sub you can find all arguments in the variable @_.
print "@_";
jue
------------------------------
Date: 12 Mar 2003 08:02:01 -0800
From: smileypete2@yahoo.com (Smiles)
Subject: panic error
Message-Id: <63ccfece.0303120802.1e025b69@posting.google.com>
I'm not exactly a newbie. But I have never recieved a panic error
until now. I am running:
Perl Version: Activestate Perl 5.8.0 Build 804.
OS: Windows 2000 Service Pack 3
The error is "panic: COND_INIT (1816)". The application I am writing
uses threads and I believe it has something to do with that. If I
increase the number of threads the error appears sooner than later.
I would appreciate it if anyone could bring this to light for me.
Smiles
------------------------------
Date: Wed, 12 Mar 2003 13:03:26 +0100
From: "dejan" <dejan.tomazic@szkbanka.si>
Subject: PGP with Perl
Message-Id: <3e6f22c4$1@news.perftech.si>
Hi,
I'd like to retrive from pgp (DH/DSS and RSA) public keys its properties
using some perl modules. Unfortunetly PGP itself doesn't have command option
that can do that.
Can somebody link me to page where I can find more about it or give me a
hint to looking forward.
Thanks.
------------------------------
Date: Wed, 12 Mar 2003 12:09:48 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: PGP with Perl
Message-Id: <Xns933C8529E31D9elhber1lidotechnet@62.89.127.66>
dejan wrote:
> Hi,
>
> I'd like to retrive from pgp (DH/DSS and RSA) public keys its
> properties using some perl modules. Unfortunetly PGP itself doesn't
> have command option that can do that.
>
> Can somebody link me to page where I can find more about it or give me
> a hint to looking forward.
Here's a start:
http://search.cpan.org/search?query=PGP&mode=all
--
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: 12 Mar 2003 07:53:48 -0800
From: sbour@niaid.nih.gov (Steph)
Subject: Re: Problem matching a value in hash
Message-Id: <79e85d7d.0303120753.5ac1cfc@posting.google.com>
Holly cow! How more embarassing could this get?
Thanks guys.
"Christian Winter" <thepoet@nexgo.de> wrote in message news:<3e6e406b$0$6437$9b4e6d93@newsread2.arcor-online.net>...
> "Steph" <sbour@niaid.nih.gov> schrieb:
> [...]
> > print "The hash key is $match\n"
> > print "The email is $email{$match}\n";
> [...]
>
> You should end each line with a ";"
> :-)
>
> HTH
> -Christian
------------------------------
Date: Wed, 12 Mar 2003 17:42:49 +0530
From: Thens <thens@nospam.com>
Subject: problem redefining a function
Message-Id: <20030312174249.540c9005.thens@nospam.com>
Hi,
I have a function called myFatal in MyUtils module. It will give a
detailed report before issuing a exit with the error code. Now i need to
override the function in one of my scripts. Before issuing a fatal error
i want another function to be called which will clean up all the
temporary files. I dont want to write a wrapper function over the
original and inside it call the function that cleans up all the
temporary files.
I did this
#! /usr/local/bin/perl -w
use strict;
use MyUtils;
*myFatal = \&scriptFatal; # From now when i say myFatal it will be scriptFatal
..
..
myFatal(2, "Iam dying"); # Before dying clean the temp files and then die
..
# remove all the temp files and then call myfatal
sub scriptFatal{
removeTempFiles();
MyUtils::myFatal(@_);
}
sub removeTempFiles{
...
...
}
The issue with this the perl compiler issues a warning saying
'subroutine myFatal is redefined'. Is there any other way i can do this.
I tried using no strict before the globbing. Still it does not work for me.
Your help is greatly appreciated.
Thanks and regards,
Thens.
------------------------------
Date: 12 Mar 2003 12:39:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: problem redefining a function
Message-Id: <b4n9qi$hah$2@mamenchi.zrz.TU-Berlin.DE>
Thens <thens@nospam.com> wrote in comp.lang.perl.misc:
[...]
> The issue with this the perl compiler issues a warning saying
> 'subroutine myFatal is redefined'. Is there any other way i can do this.
> I tried using no strict before the globbing. Still it does not work for me.
Put
BEGIN { undef &myFatal }
before the second definition.
Anno
------------------------------
Date: Wed, 12 Mar 2003 07:16:41 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: problem redefining a function
Message-Id: <Xns933C542D43B8Csdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Thens <thens@nospam.com> wrote in
news:20030312174249.540c9005.thens@nospam.com:
> Hi,
>
> I have a function called myFatal in MyUtils module. It will give a
> detailed report before issuing a exit with the error code. Now i need
> to override the function in one of my scripts. Before issuing a fatal
> error i want another function to be called which will clean up all the
> temporary files. I dont want to write a wrapper function over the
> original and inside it call the function that cleans up all the
> temporary files.
Perhaps the Hook::LexWrap module would do what you need.
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13
iD8DBQE+bzMrY96i4h5M0egRAhLbAJ48tgZbgbEnsGWqhMPC/uNYCVDPqgCgyJts
CDE+JnIfxFGkmLustteqZQY=
=6O+p
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 12 Mar 2003 15:00:47 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: select ip-adress out of pipe delimited file
Message-Id: <pan.2003.03.11.17.36.50.855633@aursand.no>
On Tue, 11 Mar 2003 15:07:48 +0000, David wrote:
> $line =~ /^[^\|]*\|[^\|]*\|[^\|]*\|[^\|]*\|[^\|]*\|([^\|]+)\|/;
> my $ip = $1; # $1 is equal to the matched value in the ()
[God|whoever] forbid! :) Please use 'split()' instead, or - even better,
I think - Text::CSV if you think that you might encounter '|' as part of
the data;
my ( @fields ) = split( /\Q|\E/, $line );
my $ip_address = $fields[5];
Or - if you really want to cut down on the size of your code;
my $ip_address = ( split(/\Q|\E/, $line) )[5];
IMO, a lot easier to read/understand/write instead of a regular
expression, and I won't be surprised if it's faster too.
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Wed, 12 Mar 2003 11:41:07 -0400
From: "gary" <grobitaille@mail.com>
Subject: small parsing problem
Message-Id: <syIba.29238$cB3.140530@nnrp1.uunet.ca>
This is a multi-part message in MIME format.
------=_NextPart_000_000A_01C2E88C.45198100
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi There,
=20
If I had a line in a file that resembled this:
Firstname Lastname <firstnamelastname@someisp.com> 1234
-or-
Name <firstnamelastname@someisp.com> 1234
how can I get three fields from this line. They are:
$1 - (which is the user's name whether or not its one word or many)
$2 - (email- which is everything between the <>)
$3 - (the number at the end of the line)=20
Thanks for your help
------=_NextPart_000_000A_01C2E88C.45198100
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1141" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi There,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>If I had a line in a file that =
resembled=20
this:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Firstname Lastname <<A=20
href=3D"mailto:firstnamelastname@someisp.com">firstnamelastname@someisp.c=
om</A>>=20
1234</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>-or-</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DArial =
size=3D2></FONT></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3DArial =
size=3D2>Name <<A=20
href=3D"mailto:firstnamelastname@someisp.com">firstnamelastname@someisp.c=
om</A>>=20
1234</FONT></DIV>
<DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>how can I get three fields from this line. They are:</DIV>
<DIV>$1 - (which is the user's name whether or not its one word or=20
many)</DIV>
<DIV>$2 - (email- which is everything between the <>)</DIV>
<DIV>$3 - (the number at the end of the =
line) </DIV></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks for your help</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV></BODY></HTML>
------=_NextPart_000_000A_01C2E88C.45198100--
------------------------------
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 4699
***************************************