[19916] in Perl-Users-Digest
Perl-Users Digest, Issue: 2111 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 11 18:10:53 2001
Date: Sun, 11 Nov 2001 15:10:18 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1005520217-v10-i2111@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 11 Nov 2001 Volume: 10 Number: 2111
Today's topics:
Re: module to help change login shell (no..chsh is not <none@nothere.please.net>
Re: module to help change login shell (no..chsh is not <none@nothere.please.net>
Re: module to help change login shell (no..chsh is not <stuart@otenet.gr>
Re: Perl/DBI update q <mikecook@cigarpool.com>
Re: please help me turn a string into a hash <uri@stemsystems.com>
Re: please help me turn a string into a hash <Laocoon@eudoramail.com>
Re: please help me turn a string into a hash <uri@stemsystems.com>
Re: please help me turn a string into a hash <Laocoon@eudoramail.com>
Re: please help me turn a string into a hash <uri@stemsystems.com>
Re: please help me turn a string into a hash <Laocoon@eudoramail.com>
Re: Random element from array? <bart.lateur@skynet.be>
Re: Random element from array? (Wiliam Stephens)
Re: Random element from array? <Tassilo.Parseval@post.rwth-aachen.de>
Regex question sprenger@network.rahul.net
Re: Regex question <mbudash@sonic.net>
Re: Regex question <s_grazzini@hotmail.com>
Re: Regex question (Damian James)
Re: Regex question <Tassilo.Parseval@post.rwth-aachen.de>
Re: Regex question (Garry Williams)
Re: Regex question <s_grazzini@hotmail.com>
Same global variables for many scripts <markus.cl@gmx.de>
Re: Same global variables for many scripts <tsee@gmx.net>
self-printing perl program (Charles Blair)
Re: self-printing perl program <uri@stemsystems.com>
Re: self-printing perl program <markus.cl@gmx.de>
Re: self-printing perl program <uri@stemsystems.com>
Server crashes cause of swap space... Pls Help! <admin@eurokeen.com>
SOAP::Lite - print SOM object as string? (rlyacht)
Strings concatenation how? <juergen@gmx.de>
Re: Strings concatenation how? <uri@stemsystems.com>
Re: Strings concatenation how? <alex@peculiar.co.uk>
Re: Strings concatenation how? (Garry Williams)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 11 Nov 2001 20:45:17 GMT
From: jeff <none@nothere.please.net>
Subject: Re: module to help change login shell (no..chsh is not available on solaris...)
Message-Id: <ojotut08hh4rm9cqo8304ud56a3d7aubfc@4ax.com>
On the glorious day of 10 Nov 2001 17:19:37 -0600, logan@cs.utexas.edu
(Logan Shaw) felt the need to utter
>In article <kdarutggbmbko8btss4ajugeqbh25jotij@4ax.com>, jeff <hk63a> wrote:
>>Solaris does not have chsh functionality any longer (bastards..)
>>so, i am trying to write a setuid (*GASP*) script to enable users to
>>change their passwords and gecos info without bothering me anymore!!
> :
> :
>>I'd rather not rewrite the whole /etc/passwd file each time manually
>>using "open" and such..thats just waiting to crash the system.
>
>So call /usr/bin/passwd and have it make the changes to /etc/passwd.
>
Ive been trying to do this, granted Im only a novice perl programmer,
so Im sure im missing something important...notably, I seem to
remember somethng about perl not just letting perl script be setuid,
in that it will still not just let anyone do anything.
I just would always get "Permission denied" even when I called
"/usr/bin/passwd -e <username>" with a suid script...did it with c,
but..that was last night when i got fed up with perl :-(
>Actually, it seems like you should be able to get sudo to do this for
>you, but from looking at the sudoers manual page, I can't find a way to
>tell it to allow a user to run "passwd" only with their own login name
>as an argument. OTOH, the version of sudo I'm looking at isn't the
>latest, so maybe there is a way. And even if there isn't, it's a minor
>modification to make, and it would solve the problem for you.
>
we have sudo, but we are a school, and there are ~200 new, different
students every semester in 10 groups or so. Guess i could just add the
groups to sudo to the sudoers. But, yes..then they would be able to do
it to anybodies login....hmmm
>You might also try posting to comp.unix.solaris and asking there.
>
thanks. I did that a while ago..and, well..didnt get much. I'll try
again. Thanks!
> - Logan
jeff
------------------------------
Date: Sun, 11 Nov 2001 20:52:54 GMT
From: jeff <none@nothere.please.net>
Subject: Re: module to help change login shell (no..chsh is not available on solaris...)
Message-Id: <jsotutgnbjed8oqsuavkguh6fack9paqsh@4ax.com>
On the glorious day of Sun, 11 Nov 2001 01:07:17 GMT,
tadmc@augustmail.com (Tad McClellan) felt the need to utter
>jeff <none@nothere.please.net> wrote:
>
>>X-No-Archive: yes
>
>
>What is the point of using that when you use a fake address
>and only first name anyway
well, my first name and fake email would have statistics listed
according to that, unless I changed the name and email every time I
posted.
>
>Nobody is going to know who you are, so why not let the
>thread have a "head"?
maybe, one time I'll slip and someone will know, then they will be
able to search for this fake email and track down all the messages
over the years (or 2 week period before I change the fake email
again..)
or, maybe i just forgot to uncheck X-No-Archive under default
properties..?? (more likely) im trying to get used to agent, coming
from netscape.
Just because Im paranoid doesnt mean they arent out to get me
------------------------------
Date: Sun, 11 Nov 2001 23:13:19 +0200
From: "Stuart Gall" <stuart@otenet.gr>
Subject: Re: module to help change login shell (no..chsh is not available on solaris...)
Message-Id: <9smppg$t7s$1@usenet.otenet.gr>
"jeff" <none@nothere.please.net> wrote in message
news:ojotut08hh4rm9cqo8304ud56a3d7aubfc@4ax.com...
> On the glorious day of 10 Nov 2001 17:19:37 -0600, logan@cs.utexas.edu
> (Logan Shaw) felt the need to utter
>
> >In article <kdarutggbmbko8btss4ajugeqbh25jotij@4ax.com>, jeff <hk63a>
wrote:
> >>Solaris does not have chsh functionality any longer (bastards..)
> >>so, i am trying to write a setuid (*GASP*) script to enable users to
> >>change their passwords and gecos info without bothering me anymore!!
> > :
> > :
> >>I'd rather not rewrite the whole /etc/passwd file each time manually
> >>using "open" and such..thats just waiting to crash the system.
> >
> >So call /usr/bin/passwd and have it make the changes to /etc/passwd.
> >
>
> Ive been trying to do this, granted Im only a novice perl programmer,
> so Im sure im missing something important...notably, I seem to
> remember somethng about perl not just letting perl script be setuid,
Dont see why perl would care or even know. Most kernels wont let you setuid
on any script by default.
> in that it will still not just let anyone do anything.
> I just would always get "Permission denied" even when I called
> "/usr/bin/passwd -e <username>" with a suid script...did it with c,
> but..that was last night when i got fed up with perl :-(
You do not need to be setuid to call passwd. Just call it from the sctipt.
You are not trying to do this from a cgi are you ?
--
Stuart Gall
------------------------------------------------
This message is not provable.
------------------------------
Date: Sun, 11 Nov 2001 12:16:36 -0700
From: "Michael Cook" <mikecook@cigarpool.com>
Subject: Re: Perl/DBI update q
Message-Id: <b9AH7.48$wB3.216312@news.uswest.net>
"Steven Edwards" <sconfusion1@home.com> wrote in message
news:3bee952c.22765762@news...
> On Sat, 10 Nov 2001 13:04:44 -0700, "Michael Cook"
> <mikecook@cigarpool.com> wrote:
>
> >Hi folks!
> > I am writing a site which has an admin page where data can be added,
> >removed & updated in a database via DBI. I have the add & remove working
now
> >(many thanks to you fine folks!!!) and on the update section, I can
update a
> >row if only 1 field is specified; if more than 1 is specified the entire
> >update fails. I have checked Programming the Perl DBI, the man pages, the
> >perldoc pages & I am baffled. I am guessing is it a problem with quoting
or
> >SQL statement formation. Below is the code & the SQL generated by it.
> > Many many thanks in advance!!!
> > Michael
> >
> >== CigarPool ==
> >http://www.cigarpool.com
>
> I don't think you can use sprintf to format an sql statement like
> that. The proper SQL should be:
>
> SET BRAND = 'ee', MODEL = 'ee' WHERE PRODUCTNUMBER = 'e1007'
>
> Try this; a workaround using sprintf:
>
> $set = '';
> while (@fields) {
> $set .= sprintf "%s = '%s'", pop(@fields), pop(@values);
> }
> $STATEMENT = "UPDATE $db SET $set WHERE PRODUCTNUMBER =
> '$modproductnumber'";
>
> That should get you a proper SQL statement. :-)
>
> -Steven
You are da man!!! You guys rock. I am using a slighlty modified version to
pretty up my SQL (for possible future modification) & to handle the ", " in
the SQL statement. Here it is:
while (@fields)
{
$set .= sprintf ", %s = '%s'", pop(@fields), pop(@values);
$set=~s/^, //;
}
$STATEMENT = "
UPDATE $db
SET $set
WHERE PRODUCTNUMBER = '$modproductnumber'
";
Thanks a million!!!
Michael
--
== CigarPool ==
http://www.cigarpool.com
------------------------------
Date: Sun, 11 Nov 2001 17:36:28 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: please help me turn a string into a hash
Message-Id: <x7adxtmcnk.fsf@home.sysarch.com>
>>>>> "L" == Laocoon <Laocoon@eudoramail.com> writes:
L> *snip*
>> $departmentinfo = "A,Accounting;IS,Info
>> Systems;MGT,Management;PSP,Pepsi;Coke,Coca Cola;RA,;Win,Windows;SPN,";
>>
>> I got this...I want to put this into a hash using the first value as a
>> key, and the 2nd as the data..example
>>
>> %hash1 = key value
>> A Accounting
>> IS Info Systems
>> etc
L> *snip*
L> example :
L> while ($departmentinfo =~ /(\w+),(\w*)/g) {
L> $hash{$1} = "$2"
L> }
try that on his example data, coca cola.
assuming his text is properly delimited/separated by ; and the key
values always have no , then you can do it with a regex. if embedded ;
or , occur, you need to parse it probably with a CSV module.
note that his example text has a dangling 'SPN,' at the end.
so given my simple assumptions you can do it with a m//g:
%hash = $departmentinfo =~ /([^,]+),([^;]);/g ;
that assumes clean key/values and ; after each comma separated pair.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 11 Nov 2001 19:30:08 +0100
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: please help me turn a string into a hash
Message-Id: <Xns9156C6699D09CLaocooneudoramailcom@62.153.159.134>
Uri Guttman <uri@stemsystems.com> wrote in
news:x7adxtmcnk.fsf@home.sysarch.com:
>>>>>> "L" == Laocoon <Laocoon@eudoramail.com> writes:
>
> L> *snip*
> >> $departmentinfo = "A,Accounting;IS,Info
> >> Systems;MGT,Management;PSP,Pepsi;Coke,Coca
> >> Cola;RA,;Win,Windows;SPN,";
> >>
> >> I got this...I want to put this into a hash using the first value
> >> as a key, and the 2nd as the data..example
> >>
> >> %hash1 = key value
> >> A Accounting
> >> IS Info Systems etc
> L> *snip*
>
> L> example :
>
> L> while ($departmentinfo =~ /(\w+),(\w*)/g) {
> L> $hash{$1} = "$2"
> L> }
>
>
> try that on his example data, coca cola.
> assuming his text is properly delimited/separated by ; and the key
> values always have no , then you can do it with a regex. if embedded ;
> or , occur, you need to parse it probably with a CSV module.
>
> note that his example text has a dangling 'SPN,' at the end.
Sorry must have missed those while testing
> so given my simple assumptions you can do it with a m//g:
>
> %hash = $departmentinfo =~ /([^,]+),([^;]);/g ;
You forgot a * there.. and add a ; in ur first char class..
%hash = $departmentinfo =~ /([^;,]*),([^;,]*)/g;
this will also catch SPN,
> that assumes clean key/values and ; after each comma separated pair.
>
> uri
Lao
------------------------------
Date: Sun, 11 Nov 2001 18:44:39 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: please help me turn a string into a hash
Message-Id: <x77ksxm9hx.fsf@home.sysarch.com>
>>>>> "L" == Laocoon <Laocoon@eudoramail.com> writes:
>> so given my simple assumptions you can do it with a m//g:
>>
>> %hash = $departmentinfo =~ /([^,]+),([^;]);/g ;
L> You forgot a * there.. and add a ; in ur first char class..
i didn't forget ; in the first class. i assumed a , separates the
key/value pair. i did forget a + after the second class.
L> %hash = $departmentinfo =~ /([^;,]*),([^;,]*)/g;
* is not best here - assuming a decent spec and data + is faster. but the
OP didn't spec it well nor did he provide clean example data so arguing
about the best way to do this is useless.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 11 Nov 2001 20:17:06 +0100
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: please help me turn a string into a hash
Message-Id: <Xns9156CE605635FLaocooneudoramailcom@62.153.159.134>
Uri Guttman <uri@stemsystems.com> wrote in
news:x77ksxm9hx.fsf@home.sysarch.com:
>>>>>> "L" == Laocoon <Laocoon@eudoramail.com> writes:
>
> >> so given my simple assumptions you can do it with a m//g:
> >>
> >> %hash = $departmentinfo =~ /([^,]+),([^;]);/g ;
>
> L> You forgot a * there.. and add a ; in ur first char class..
>
> i didn't forget ; in the first class. i assumed a , separates the
> key/value pair. i did forget a + after the second class.
I didn't say you forgot that i said you should add that
> L> %hash = $departmentinfo =~ /([^;,]*),([^;,]*)/g;
>
> * is not best here - assuming a decent spec and data + is faster. but the
> OP didn't spec it well nor did he provide clean example data so arguing
> about the best way to do this is useless.
Um..no.. you might use + for the first one.. but not for the second. It
won't catch the empty fields otherwise.
> uri
Lao
------------------------------
Date: Sun, 11 Nov 2001 22:10:58 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: please help me turn a string into a hash
Message-Id: <x7wv0xkldm.fsf@home.sysarch.com>
>>>>> "L" == Laocoon <Laocoon@eudoramail.com> writes:
>> * is not best here - assuming a decent spec and data + is faster. but the
>> OP didn't spec it well nor did he provide clean example data so arguing
>> about the best way to do this is useless.
L> Um..no.. you might use + for the first one.. but not for the second. It
L> won't catch the empty fields otherwise.
but my point was that empty fields would be bad data or a bad spec. as
we don't know we can't say which is better. i said, that + is better
assuming the fields must have text and be properly paired.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 11 Nov 2001 23:20:30 +0100
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: please help me turn a string into a hash
Message-Id: <Xns9156ED78C7A13Laocooneudoramailcom@62.153.159.134>
Uri Guttman <uri@stemsystems.com> wrote in
news:x7wv0xkldm.fsf@home.sysarch.com:
>>>>>> "L" == Laocoon <Laocoon@eudoramail.com> writes:
>
> >> * is not best here - assuming a decent spec and data + is faster.
> >> but the OP didn't spec it well nor did he provide clean example
> >> data so arguing about the best way to do this is useless.
>
> L> Um..no.. you might use + for the first one.. but not for the
> second. It L> won't catch the empty fields otherwise.
>
> but my point was that empty fields would be bad data or a bad spec. as
> we don't know we can't say which is better. i said, that + is better
> assuming the fields must have text and be properly paired.
We do know actually..The OP stated in his post that those fields are
intended to be blank :
"Include at least two codes that do not currently have a value "
Those values are prolly to be filled in later.
> uri
Lao
------------------------------
Date: Sun, 11 Nov 2001 15:38:00 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Random element from array?
Message-Id: <bk6tut84l5fkjfp3d0guuhairgv3dru6k0@4ax.com>
Wiliam Stephens wrote:
>I've got an array containing 5 elements. I want to be able to pick one
>of these elements at random.
>
>Has anyone got a snippet of code that will pick an element from an
>array at random?
Dead easy.
@array = qw(one two three four five);
for my $i (1 .. 10) {
# here's the snippet you asked for:
$_ = $array[int rand @array];
print "$i: $_\n";
}
The "int" isn't absolutely necessary, it works without it, too.
--
Bart.
------------------------------
Date: 11 Nov 2001 09:06:02 -0800
From: wil@fbagroup.co.uk (Wiliam Stephens)
Subject: Re: Random element from array?
Message-Id: <39e3e00a.0111110906.eab09eb@posting.google.com>
Thank you for the replies. Exactly what I needed.
> print $a[int rand @a];
Did int() go out in Perl 4? Am I right in assuming that int() is no
longer needed in Perl 5? I can just go ahead and write:
print $a[rand @a];
Thanks!
Wil Stephens
------------------------------
Date: Sun, 11 Nov 2001 18:14:02 +0100
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Random element from array?
Message-Id: <9smbkq$6dq$04$1@news.t-online.com>
On 11 Nov 2001 09:06:02 -0800, Wiliam Stephens wrote:
> Did int() go out in Perl 4? Am I right in assuming that int() is no
> longer needed in Perl 5? I can just go ahead and write:
>
> print $a[rand @a];
As for the deprecation of int: No, this still exists and should be used
where necessary.
In this special case however it is not needed since Perl will
automatically use the integer portion of the number returned by rand in
an array subscription.
Tassilo
--
Tomorrow's computers some time next month.
-- DEC
------------------------------
Date: 11 Nov 2001 20:16:23 GMT
From: sprenger@network.rahul.net
Subject: Regex question
Message-Id: <9smman$bop$1@samba.rahul.net>
I need a regex that will print all lines in the "To:" part of an
email heading except those lines that contain a particular user. The
line is to be omitted even if there are other names on the line.
For example to exclude "joeuser" lines it would work something like
this:
while (<>) {
if (/^To: _not joeuser_/) {
print "$_";
}
}
Program output:
To: hello@world.com #prints
To: big@little.com, joeuser@sample.com #does not print
To: sanjose@california.com #prints
To: joeuser@large.com # does not print
Have tried variations of /foo(?!joeuser)/ but cant get it to work.
Any ideas on this problem will be greatly appreciated.
--
Bob Sprenger
------------------------------
Date: Sun, 11 Nov 2001 20:48:39 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Regex question
Message-Id: <mbudash-282F9F.12483911112001@news.sonic.net>
In article <9smman$bop$1@samba.rahul.net>, sprenger@network.rahul.net
wrote:
> I need a regex that will print all lines in the "To:" part of an
> email heading except those lines that contain a particular user. The
> line is to be omitted even if there are other names on the line.
>
> For example to exclude "joeuser" lines it would work something like
> this:
>
> while (<>) {
> if (/^To: _not joeuser_/) {
> print "$_";
> }
> }
>
> Program output:
>
> To: hello@world.com #prints
> To: big@little.com, joeuser@sample.com #does not print
> To: sanjose@california.com #prints
> To: joeuser@large.com # does not print
>
> Have tried variations of /foo(?!joeuser)/ but cant get it to work.
>
> Any ideas on this problem will be greatly appreciated.
er:
while (<>) {
print unless /^To:.+joeuser\@/;
}
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Sun, 11 Nov 2001 20:54:31 GMT
From: "Steve Grazzini" <s_grazzini@hotmail.com>
Subject: Re: Regex question
Message-Id: <bABH7.98779$n5.12166837@typhoon.nyc.rr.com>
<sprenger@network.rahul.net> wrote in message
news:9smman$bop$1@samba.rahul.net...
>
> I need a regex that will print all lines in the "To:" part of an
> email heading except those lines that contain a particular user. The
> line is to be omitted even if there are other names on the line.
>
> For example to exclude "joeuser" lines it would work something like
> this:
>
> while (<>) {
> if (/^To: _not joeuser_/) {
> print "$_";
> }
> }
[..]
Does this do what you want?
while (<>) {
break if /^$/;
print if /^To:/ && !/joeuser/;
}
-Steve
------------------------------
Date: 11 Nov 2001 21:12:43 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Regex question
Message-Id: <slrn9utq68.9hk.damian@puma.qimr.edu.au>
On 11 Nov 2001 20:16:23 GMT, sprenger@network.rahul.net said:
>
>I need a regex that will print all lines in the "To:" part of an
>email heading except those lines that contain a particular user. The
>line is to be omitted even if there are other names on the line.
>...
>[sample data]
>To: hello@world.com #prints
>To: big@little.com, joeuser@sample.com #does not print
>To: sanjose@california.com #prints
>To: joeuser@large.com # does not print
>
>Have tried variations of /foo(?!joeuser)/ but cant get it to work.
>
>Any ideas on this problem will be greatly appreciated.
Since you have data you want remove, a substitution should
be a bit simpler. For the data you have given:
/^To:/ && ( s[joeuser\S+,?\s*][]g, print ) while <>;
HTH,
Cheers,
Damian
--
@:=grep!(m!$/|#!..$|),split//,<DATA>;@;=0..$#:;while($:=@;){$;=rand
$:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,,
$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker,### http://home.pacific.net.au/~djames.hub
------------------------------
Date: Sun, 11 Nov 2001 22:15:29 +0100
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Regex question
Message-Id: <9smpph$ufe$04$1@news.t-online.com>
On Sun, 11 Nov 2001 20:54:31 GMT, Steve Grazzini wrote:
> Does this do what you want?
>
> while (<>) {
> break if /^$/;
Hmmh....
ethan@ethan:~$ perldoc -f break
No documentation for perl function `break' found
Perhaps you mean last? Or next?
[...]
> -Steve
Tassilo
--
A political man can have as his aim the realization of freedom,
but he has no means to realize it other than through violence.
-- Jean Paul Sartre
------------------------------
Date: Sun, 11 Nov 2001 21:57:54 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Regex question
Message-Id: <slrn9utt34.2dq.garry@zfw.zvolve.net>
On Sun, 11 Nov 2001 20:54:31 GMT, Steve Grazzini <s_grazzini@hotmail.com> wrote:
> <sprenger@network.rahul.net> wrote in message
> news:9smman$bop$1@samba.rahul.net...
>>
>> I need a regex that will print all lines in the "To:" part of an
>> email heading except those lines that contain a particular user. The
>> line is to be omitted even if there are other names on the line.
[ snip ]
> Does this do what you want?
>
> while (<>) {
> break if /^$/;
> print if /^To:/ && !/joeuser/;
> }
Even if your intent is clear, that will not run cleanly when warnings
are enabled. Plus, the second statement in the loop makes the
_intent_ of the first unnecessary.
--
Garry Williams
------------------------------
Date: Sun, 11 Nov 2001 22:06:44 GMT
From: "Steve Grazzini" <s_grazzini@hotmail.com>
Subject: Re: Regex question
Message-Id: <UDCH7.98787$n5.12186216@typhoon.nyc.rr.com>
"Garry Williams" <garry@ifr.zvolve.net> wrote in message
news:slrn9utt34.2dq.garry@zfw.zvolve.net...
[..]
>
> Even if your intent is clear, that will not run cleanly when warnings
> are enabled. Plus, the second statement in the loop makes the
> _intent_ of the first unnecessary.
>
> --
> Garry Williams
Oops! Guess that was the 'Inline::Java' bit. :)
And I was imagining 'read the whole mail; just parse the header'
-Steve
------------------------------
Date: Sun, 11 Nov 2001 20:29:58 +0100
From: "Markus Dehmann" <markus.cl@gmx.de>
Subject: Same global variables for many scripts
Message-Id: <9smjli$143oj6$1@ID-101658.news.dfncis.de>
I have some scripts that need all the same variable values. I don't want to
write the same variables into each script but store them separately.
My solution was to have a module with class variables:
package MyVars;
$test = "test";
1;
Then, each script accesses this variable by
print $MyVars::test;
The solution works but is it okay? Or is there a better solution? Do I have
to use Exporter? Or is Exporter slower? There are some variables that are
only needed in a few scripts, other variables are needed in each script.
------------------------------
Date: Sun, 11 Nov 2001 20:47:44 +0100
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Same global variables for many scripts
Message-Id: <9smkgb$me9$00$1@news.t-online.com>
"Markus Dehmann" <markus.cl@gmx.de> schrieb im Newsbeitrag
news:9smjli$143oj6$1@ID-101658.news.dfncis.de...
| I have some scripts that need all the same variable values. I don't want
to
| write the same variables into each script but store them separately.
|
| My solution was to have a module with class variables:
| package MyVars;
use strict; # ALWAYS!
| $test = "test";
| 1;
|
|
| Then, each script accesses this variable by
| print $MyVars::test;
|
|
| The solution works but is it okay? Or is there a better solution? Do I
have
| to use Exporter? Or is Exporter slower? There are some variables that are
| only needed in a few scripts, other variables are needed in each script.
Is this just about some static data? Why not write a short module that will
read in the data from a flat file db and store it in an array or a hash
then?
If the data's not static, you could use file locking with the same
technique.
Steffen
--
$_=q;0cb212c210b0bb010c0113bb0c410c0b516c0bb3d212c2b0b0b016b6cb2b2c21010c0
b41110b3bba0e0c0d2c4b2b6bc013d2c0d0b01012b0b0;;s/\n//g;s/(\d)/$1<2?$1:'0'x
$1/ge;s/([a-f])/'1'x(ord($1)-97)/ge;print"\n";$o=$_;push@o,substr($o,$_*8,
8)for(0..24);for(@o){print"\0"x(26-$i).chr(oct('0b'.($_)))."\n";$i++}#st_m
------------------------------
Date: Sun, 11 Nov 2001 18:57:31 GMT
From: c-blair@uiuc.edu (Charles Blair)
Subject: self-printing perl program
Message-Id: <vSzH7.5053$Wa1.66988@vixen.cso.uiuc.edu>
I'm sure this must be an FAQ, but I couldn't find it in admittedly
cursory searching. What is the shortest perl program that will
print itself? I suspect something can be done with eval, but haven't
figured out what.
------------------------------
Date: Sun, 11 Nov 2001 19:03:14 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: self-printing perl program
Message-Id: <x74ro1m8my.fsf@home.sysarch.com>
>>>>> "CB" == Charles Blair <c-blair@uiuc.edu> writes:
CB> I'm sure this must be an FAQ, but I couldn't find it in
CB> admittedly cursory searching. What is the shortest perl program
CB> that will print itself? I suspect something can be done with
CB> eval, but haven't figured out what.
search the web for quine and perl. there are plenty of examples of that.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 11 Nov 2001 20:41:27 +0100
From: "Markus Dehmann" <markus.cl@gmx.de>
Subject: Re: self-printing perl program
Message-Id: <9smkb5$13ri8u$1@ID-101658.news.dfncis.de>
> What is the shortest perl program that will
> print itself? I suspect something can be done with eval, but haven't
open 0;print<0>;close 0;
This works because the script file name is stored in $0. And if you have the
name in a variable, let's say, in $var, you don't have to say open(F,
"<$var") but just: open $var;
In the same way, you can say open 0 instead of open(F, "<$0");
------------------------------
Date: Sun, 11 Nov 2001 22:12:12 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: self-printing perl program
Message-Id: <x7u1w1klbk.fsf@home.sysarch.com>
>>>>> "MD" == Markus Dehmann <markus.cl@gmx.de> writes:
>> What is the shortest perl program that will
>> print itself? I suspect something can be done with eval, but haven't
MD> open 0;print<0>;close 0;
MD> This works because the script file name is stored in $0. And if
MD> you have the name in a variable, let's say, in $var, you don't
MD> have to say open(F, "<$var") but just: open $var; In the same way,
MD> you can say open 0 instead of open(F, "<$0");
that doesn't usually qualify as a true self printing program. reading
your own source file is considered cheating.
there are many examples of this on the web. search for them.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 11 Nov 2001 17:15:29 GMT
From: "News" <admin@eurokeen.com>
Subject: Server crashes cause of swap space... Pls Help!
Message-Id: <RmyH7.3403$p31.2250846@carnaval.risq.qc.ca>
This is a multi-part message in MIME format.
------=_NextPart_000_0288_01C16AAA.57D5D2A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi !
I have a Unix server, with Free BSD, and I have many Perl Scripts that =
use to work fine on another server for years... Now my new ISP as set =
things up in such a way that my server crashes every 2 days or so... =
They say I always miss swap space and my program does not terminate =
properly.
I need someone to give a hand on looking to my Scripts to find out the =
problem, ready to pay for it...
Reach me on ICQ 509619 DAL
Thanks
------=_NextPart_000_0288_01C16AAA.57D5D2A0
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.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi !</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I have a Unix server, with Free BSD, =
and I have=20
many Perl Scripts that use to work fine on another server for years... =
Now my=20
new ISP as set things up in such a way that my server crashes every 2 =
days or=20
so... They say I always miss swap space and my program does not =
terminate=20
properly.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I need someone to give a hand on =
looking to my=20
Scripts to find out the problem, ready to pay for it...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Reach me on ICQ 509619 =
DAL</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks</FONT></DIV><FONT face=3DArial =
size=3D2>
<DIV><BR></FONT> </DIV></BODY></HTML>
------=_NextPart_000_0288_01C16AAA.57D5D2A0--
------------------------------
Date: 11 Nov 2001 07:58:09 -0800
From: robt@aya.yale.edu (rlyacht)
Subject: SOAP::Lite - print SOM object as string?
Message-Id: <7a47713f.0111110758.7fa04984@posting.google.com>
If $s is the result of a SOAP call (using SOAP::Lite), how can I
obtain a string representation of $s? I'm sure that there's some sort
of asString method somwhere so that I can just say
$xml = $s->asString();
but I can't find it. Thanks.
------------------------------
Date: Sun, 11 Nov 2001 20:12:01 +0100
From: juergen <juergen@gmx.de>
Subject: Strings concatenation how?
Message-Id: <d6jtuto99kh1vm881r7jt29r10vvsean8u@4ax.com>
I tried:
$msgt=" ";
$MSGMM="has sent a card to ";
$MSGMMM=" today ";
(or so)
then:
$msgt=$fields{sender_email}+$MSGMM+$fields{recip_email}+$MSGMMM;
the field array seems to be ok, but $msgt is a zero
Thx
juergen
------------------------------
Date: Sun, 11 Nov 2001 19:12:19 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Strings concatenation how?
Message-Id: <x71yj5m87t.fsf@home.sysarch.com>
>>>>> "j" == juergen <juergen@gmx.de> writes:
j> I tried:
j> $msgt=" ";
j> $MSGMM="has sent a card to ";
j> $MSGMMM=" today ";
j> $msgt=$fields{sender_email}+$MSGMM+$fields{recip_email}+$MSGMMM;
where did you get the idea that + concatenates strings?
perldoc perlop and look for the proper concatenation operator. even
better, read perldata and do that in an interpolated string.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 11 Nov 2001 19:18:48 +0000
From: Alex Warren <alex@peculiar.co.uk>
Subject: Re: Strings concatenation how?
Message-Id: <0ojtutkqf3se1u3bnunc3tv2su7co62u3d@4ax.com>
juergen wrote:
> $msgt=$fields{sender_email}+$MSGMM+$fields{recip_email}+$MSGMMM;
>
> the field array seems to be ok, but $msgt is a zero
You need to use "." not "+".
--
Alex Warren
alex@axeuk.com
Quest - make adventure games easily - http://www.axeuk.com/quest/
------------------------------
Date: Sun, 11 Nov 2001 21:49:21 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Strings concatenation how?
Message-Id: <slrn9utsj2.2dq.garry@zfw.zvolve.net>
On Sun, 11 Nov 2001 20:12:01 +0100, juergen <juergen@gmx.de> wrote:
> I tried:
>
> $msgt=" ";
>
> $MSGMM="has sent a card to ";
> $MSGMMM=" today ";
>
> (or so)
>
> then:
>
> $msgt=$fields{sender_email}+$MSGMM+$fields{recip_email}+$MSGMMM;
>
> the field array seems to be ok, but $msgt is a zero
Others have pointed you to the correct operator.
Enable warnings and perl will help, too.
--
Garry Williams
------------------------------
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 2111
***************************************