[17550] in Perl-Users-Digest
Perl-Users Digest, Issue: 4970 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 27 00:05:56 2000
Date: Sun, 26 Nov 2000 21:05:13 -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: <975301512-v9-i4970@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 26 Nov 2000 Volume: 9 Number: 4970
Today's topics:
Re: [Perl] Finding a file (Andrew N. McGuire)
Re: [Perl] Finding a file <harrisr@bignet.net>
Any Method for copying files to multiple servers. <driskind@austin.rr.com>
Re: Any Method for copying files to multiple servers. <someone@somehere.moc>
Re: Can you check File Size Before Storing (BUCK NAKED1)
Check File Size (BUCK NAKED1)
Re: Command Line Perl (Tad McClellan)
Re: credit card validation script <brian+usenet@smithrenaud.com>
Date::Manip unable to determine TIMEZONE??? <clarityassoc@earthlink.net>
explicit package name error <apseyed@eos.ncsu.edu>
Re: explicit package name error (Tad McClellan)
Free Contents <newsgroups@ebagus.com>
Help Needed: SORT function <genesis@magictraders.com>
Re: Help Needed: SORT function <nospam@david-steuber.com>
Re: Help Needed: SORT function (Martien Verbruggen)
Re: how to recieve the search result from google.com? <jingzx@sinaman.com>
Re: identifying $_ as variable or constant (Martien Verbruggen)
Re: identifying $_ as variable or constant (Tad McClellan)
Re: If/else problem. <johngros@Spam.bigpond.net.au>
Re: Mime type - Binary File <finster@mailexcite.com>
Much deserved praise for George Rath from www.domainven (Al Rosetti)
Perl not executing from Cron job <paul@NOSPAM.multibase.com.au>
Re: Perl not executing from Cron job <harrisr@bignet.net>
reg expression <troyr@vicnet.net.au>
Re: reg expression <jeffp@crusoe.net>
Re: reg expression (Wyzelli)
Simple Open file fails in Active Perl 5.6.0 on Windows2 <martin.long@virgin.net>
Re: Simple Open file fails in Active Perl 5.6.0 on Wind (Wyzelli)
Re: Simple Open file fails in Active Perl 5.6.0 on Wind (Sam Holden)
Re: Simple Open file fails in Active Perl 5.6.0 on Wind <tony_curtis32@yahoo.com>
Re: splitting a string into an array and preserving the (Andrew N. McGuire)
Unwanted Characters found in Script <workmonster2@home.com>
Will most servers know/have access to DATE-CALC and DAT <clarityassoc@earthlink.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 26 Nov 2000 19:01:12 -0600
From: anmcguire@ce.mediaone.net (Andrew N. McGuire)
Subject: Re: [Perl] Finding a file
Message-Id: <87k89q8bzb.fsf@hawk.ce.mediaone.net>
>>>>> "T" == TommyAu@497179 <perl@dotexpress.com> writes:
T> Hi all,
T> i am finding a file about " the stage of learning perl" (something like
T> this)
T> Thanks!
If my suspicions are correct, and you can search google on
[ tom christiansen seven perl mastery ]
and what you are looking for will be the first link...
anm
--
perl -wMstrict -e '
$a=[[qw[J u s t]],[qw[A n o t h e r]],[qw[P e r l]],[qw[H a c k e r]]];$.++
;$@=$#$a;$$=[reverse sort map$#$_=>@$a]->[$|];for$](--$...$$){for$}($|..$@)
{$$[$]][$}]=$a->[$}][$]]}}$,=$";$\=$/;print map defined()?$_:$,,@$_ for @$;
'
------------------------------
Date: Sun, 26 Nov 2000 23:46:11 -0500
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: [Perl] Finding a file
Message-Id: <t23pngnnahgm5d@corp.supernews.com>
Tad McClellan <tadmc@metronet.com> wrote in message
news:slrn91vknn.3ce.tadmc@magna.metronet.com...
> TommyAu@497179 <perl@dotexpress.com> wrote:
>
> >i am finding a file about " the stage of learning perl" (something
like
> >this)
>
> It appears that English is not your native language, so I'm not
> at all sure what you are trying to ask (or say as there is no
> question mark anywhere).
>
> But that won't stop me from guessing :-)
>
>
> Perhaps you are looking for "Stages of a Perl Programmer":
>
> http://prometheus.frii.com/~gnat/yapc/2000-stages/
>
>
> Which incorporates Tom Christiansen's "Seven Levels of Perl Mastery":
>
> http://larc.ee.nthu.edu.tw/~cfwu/perl/japh.txt
>
>
I hereby nomimate Mr. McClellan for inclusion among the Psychic Perl
Masters of CLPM.
------------------------------
Date: Mon, 27 Nov 2000 00:14:53 GMT
From: "David Riskind" <driskind@austin.rr.com>
Subject: Any Method for copying files to multiple servers.
Message-Id: <1IhU5.24181$S55.399205@typhoon.austin.rr.com>
Challenge:
Find all occurences of Oracle sqlnet client on all NT servers in 4 different
workgroups, where account is trusted on some, and must logon to server on
most. Once found, copy sqlnet.ora and tnsnames.ora to a saved copy and
replace with fresh copies of these 2 files. Once copied, verify files are
same as source.
This is done through a list of known servers, known user accounts and
passwords.
I have done this by manually locating all the directories I need and
manually verifying correct directory by examining PATH variable.
What I would like to do is programmattically locate the directory on each
server to update the files.
Pseudo code EX:
while (list_of_servers) {
&logon or die "ErrorMsg.\n" ;
&Parse_OraPath or die "ErrorMsg\n" ;
&Save_oldcopy or warn "WarningMsg\n" ;
©_tnsnames_ora or die "ErrorMsg\n" ;
&Verify or warn warn "WarningMsg\n" ;
©_sqnet_ora or die "ErrorMsg\n" ;
&Verify of warn warn "WarningMsg\n" ;
&Logoff or warn warn "WarningMsg\n" ;
}
close (list_of_servers) ;
sub logon {
if (logon without passwd ) { trusted logon string } ### better way to do
this
else { fully qualified login string } ;
}
sub Parse_OraPath { #this is what I do not know how to do
get %PATH% variable ; ### how?
parse for first Oracle bin in Path ;
format directory variable ;
}
Other subroutines (omitted) ;
End of pseudo code example.
I am an extreme novice, and I really need help with how to manage this
process on NT platform. Are there calls in the WIN32 module to use? Do you
get values from the registry of each server?
Thanks in advance.
David Riskind
driskind freemarkets com
------------------------------
Date: Sun, 26 Nov 2000 21:19:20 -0500
From: Prasanth Mudundi <someone@somehere.moc>
Subject: Re: Any Method for copying files to multiple servers.
Message-Id: <3A21C4A8.C140DA0D@somehere.moc>
i did the same, for 74 Servers.
however i did it just using Dos batch scripts.
here is what i did,
1: map a drive to the server where application (Oracle client) is
installed.
2: do a dir /s *ora and pipe it to file.
3: use this output file and generate a distribution list
4: used "if exist" condition to backup and copy new version.
i confess... generating these scripts for 74 servers was done with perl.
it did take a couple of hours though.
David Riskind wrote:
>
> Challenge:
> Find all occurences of Oracle sqlnet client on all NT servers in 4 different
> workgroups, where account is trusted on some, and must logon to server on
> most. Once found, copy sqlnet.ora and tnsnames.ora to a saved copy and
> replace with fresh copies of these 2 files. Once copied, verify files are
> same as source.
> This is done through a list of known servers, known user accounts and
> passwords.
> I have done this by manually locating all the directories I need and
> manually verifying correct directory by examining PATH variable.
> What I would like to do is programmattically locate the directory on each
> server to update the files.
> Pseudo code EX:
> while (list_of_servers) {
> &logon or die "ErrorMsg.\n" ;
> &Parse_OraPath or die "ErrorMsg\n" ;
> &Save_oldcopy or warn "WarningMsg\n" ;
> ©_tnsnames_ora or die "ErrorMsg\n" ;
> &Verify or warn warn "WarningMsg\n" ;
> ©_sqnet_ora or die "ErrorMsg\n" ;
> &Verify of warn warn "WarningMsg\n" ;
> &Logoff or warn warn "WarningMsg\n" ;
> }
> close (list_of_servers) ;
>
> sub logon {
> if (logon without passwd ) { trusted logon string } ### better way to do
> this
> else { fully qualified login string } ;
> }
> sub Parse_OraPath { #this is what I do not know how to do
> get %PATH% variable ; ### how?
> parse for first Oracle bin in Path ;
> format directory variable ;
> }
> Other subroutines (omitted) ;
>
> End of pseudo code example.
>
> I am an extreme novice, and I really need help with how to manage this
> process on NT platform. Are there calls in the WIN32 module to use? Do you
> get values from the registry of each server?
>
> Thanks in advance.
>
> David Riskind
> driskind freemarkets com
------------------------------
Date: Sun, 26 Nov 2000 22:26:20 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Can you check File Size Before Storing
Message-Id: <29208-3A21E26C-98@storefull-243.iap.bryant.webtv.net>
OK, guys! I've changed the subject line to be more accurate. Now, can I
get an answer?
How do I check the file size of a URL that I get from param('input')
before storing it?
Many happy nites to ya!
--Dennis
------------------------------
Date: Sun, 26 Nov 2000 20:15:00 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Check File Size
Message-Id: <21806-3A21C3A4-102@storefull-247.iap.bryant.webtv.net>
I'm trying to check the size of a file from user input, before allowing
it to be stored. In this instance, if it's over 12K, I want it to print
a message that the "directory is full".
I'm using CGI qw(param). Also, I'm using LWP/Simple to grab the URL and
store it. The question is: Can I check the size of the URL that is being
grabbed BEFORE storing it? or do I have to store it first?
What am I doing wrong?
[top part of script snipped]
$URL = param('url') || null;
$file = "\.\./TEMP/temp_file";
### check filesize
while (<$URL*>) {
$filesize+=-s $_;
}
if ($filesize > 12000) {
print "directory is full\n";
} else {
getstore($URL,$file)
};
I find nothing about this problem in the FAQ except for perhaps the use
of BSD/Resource which I cannot use.
Please help. ... and thanks.
Regards,
--Dennis
------------------------------
Date: Sun, 26 Nov 2000 19:57:36 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Command Line Perl
Message-Id: <slrn923cc0.bt1.tadmc@magna.metronet.com>
Joe Smith <inwap@best.com> wrote:
>In article <slrn91ikb0.fv3.rgarciasuarez@rafael.kazibao.net>,
>Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:
>> ls|perl -lne 'print"$_\t",-M'
^
^
>Doesn't work: you forgot to chomp().
^^^^^^^^^^^^^^^
No he didn't.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 26 Nov 2000 20:10:52 -0500
From: brian d foy <brian+usenet@smithrenaud.com>
Subject: Re: credit card validation script
Message-Id: <brian+usenet-981E15.20105226112000@news.panix.com>
In article <j7fU5.3140$tR2.88044@news1.news.adelphia.net>, "hokiebear"
<ayambema@adelphia.net> wrote:
> Can anyone point me to a free source of cgi/perl script for validation
> credit card data? Thank you.
it depends on what "validating" means. if you simply want to
make sure that the number *could* be a valid credit number (before
you attempt a transaction, for instance), then Business::CreditCard
should work for you.
otherwise, you need to make an actual transaction and see what the
card processor says.
--
brian d foy
Perl Mongers <URL:http://www.perl.org>
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Mon, 27 Nov 2000 02:45:31 GMT
From: "Alan Mailer" <clarityassoc@earthlink.net>
Subject: Date::Manip unable to determine TIMEZONE???
Message-Id: <fVjU5.9140$nh5.767677@newsread1.prod.itd.earthlink.net>
I'm new to Perl... and even more new to Date::Manip. I use a Windows 98
(not networked) system to develop scripts on. My first stab at attempting
to use Date::Manip in some code yielded the following error message:
ERROR: Date::Manip unable to determine TimeZone
Now the documentation seems to indicate that Manip looks for TimeZone info
in the following places:
$ENV{TZ}
$main::TZ
unix 'date' command
/etc/TIMEZONE
... but, I'm assuming none of these places exist in my Windows development
environment; hence the error.
Is there a way of working around this? For example, is there a way to
*supply* the appropriate TimeZone indication in my code?
Thanks in advance.
------------------------------
Date: Mon, 27 Nov 2000 00:58:41 GMT
From: Patrice Seyed <apseyed@eos.ncsu.edu>
Subject: explicit package name error
Message-Id: <3A247D9D.3408A763@eos.ncsu.edu>
Global symbol "$tosplit" requires explicit package name at
_shifts_rev.pl line 378. Execution of _shifts_rev.pl aborted due to
compilation errors.
@tosplit = split(/ /,$date);
use locale;
#Line 378:
$tosplit = uc($tosplit[1]);
---------------------
got the same error for this circumstance, line 439:
#here is the subroutine call
$month = Decode_Month($tosplit[0]);
sub Decode_Month
{
#Line 439:
my $deco_month = $tosplit[0];
.
.
return deco_month;
}
use strict;
is being used at the top of all the code.
I was told I must specify that the variable is global, being that use
strict is used..
but I'm not sure how.
Any ideas? if you need more info, i can send you the code...
thanx for any advice, please respond personally as well as to newsgroup
------------------------------
Date: Sun, 26 Nov 2000 20:31:03 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: explicit package name error
Message-Id: <slrn923ean.c8v.tadmc@magna.metronet.com>
Patrice Seyed <apseyed@eos.ncsu.edu> wrote:
>Global symbol "$tosplit" requires explicit package name at
>_shifts_rev.pl line 378. Execution of _shifts_rev.pl aborted due to
>compilation errors.
>
> @tosplit = split(/ /,$date);
> use locale;
> #Line 378:
> $tosplit = uc($tosplit[1]);
^^^^^^^^
You have not declared that scalar with my(), our() or "use vars" yet.
I recommend that you don't either.
I recommend instead that you use a different variable name. Having
completely separate variables (1 a scalar, 1 an array) with the
same name is going to be confusing. I wouldn't be surprised
if _your_ confusion isn't because of the similar-looking names.
my $second_field = uc($tosplit[1]);
>---------------------
>got the same error for this circumstance, line 439:
^^^^
^^^^
Are you sure?
I do not see how that message could be generated below,
because there isn't even a "$tosplit" variable in there...
So I can't help you with the one below because it does NOT
match the error message you give above (I'll betcha it
had an "@" instead of a "$" before the variable name).
> my $deco_month = $tosplit[0];
>use strict;
>is being used at the top of all the code.
Type:
perldoc strict
then.
>I was told I must specify that the variable is global, being that use
^^^^
>strict is used..
That is one way to satisfy use strict. But you don't "must"
specify global variables.
The other alternative is the one given in the error message
itself, just use an explicit package name:
$main::tosplit[1] # scalar in an array
or
$main::tosplit # scalar variable
>but I'm not sure how.
>
>Any ideas?
If you have a problem related to "use strict", then you should
read the docs for "use strict" :-)
There are 4 ways to satisfy "strict vars". You should know
what all 4 of them are, and how they differ.
my() # perldoc -f my
our() # perldoc -f our (recent perls)
use vars # perldoc vars
explicit package name # as above
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 26 Nov 2000 12:32:35 +0800
From: "Free content" <newsgroups@ebagus.com>
Subject: Free Contents
Message-Id: <8vso0u$ej8$3@mango.singnet.com.sg>
Web developers can quickly set up their own classifieds sections using
easily configurable categories and other variables. The Plug-in ClassAds
Free Edition has less scalability and features than the full commercial
versions. and other great tools,Plug-in Chat room and The Plug-in NewsWatch
with more than 350+ categories of news from difference resources..
visit http://www.ebagus.com today!
------------------------------
Date: Sun, 26 Nov 2000 18:42:10 -0800
From: Genesis Montano <genesis@magictraders.com>
To: genesis.montano@intel.com
Subject: Help Needed: SORT function
Message-Id: <3A21CA01.7EB9AA89@intel.com>
Hi. I'm currently a new programmer and I'm trying to use the sort
function. The PERL sort function
orders a list in ASCII order, wherein a capital "A" comes first before
the small "a" and number comes
first before letters. All is based in an ASCII value. Here's an example,
29144860_W335.itf
29144860_W336.itf
29144860_W337.itf
29144861_W337.itf
4920A009_7251_1.itf
4920A009_7251_11.itf
4920A009_7251_11A.itf
4920A009_7251_1A.itf
4920A009_7251_1B.itf
4920A009_7251_2A.itf
4920A009_7251_2B.itf
4920A009_7251_3B.itf
4920A009_7251_3Y.itf
4920A009_7251_3a.itf
4920A009_7251_STD1.itf
4920A009_7251_STD2.itf
4920A009_7251_STD3.itf
I_4920A009_7251_STD3.itf
RegressionTest_Inputtest.itf
RegressionTest_Inputtest_1A.itf
_RegressionTest_Inputtest_1A.itf
degressionTest_Inputtest_1A.itf
i_4920A009_7251_1A.itf
i_4920A009_7251_1B.itf
i_4920A009_7251_2A.itf
i_4920A009_7251_2B.itf
i_4920A009_7251_3A.itf
i_4920A009_7251_3Y.itf
i_4920A009_7251_STD1.itf
i_4920A009_7251_STD2.itf
regressionTest_Inputtest_1.itf
However, my problem is I want to sort in aphabetical order. I don't know
if there is a default function for
it. I'd checked my manual and it does not give that option. I hope u can
help me on this one or direct me
where I can find the function.
4920A009_7251_1.itf
4920A009_7251_1A.itf
4920A009_7251_1B.itf
4920A009_7251_2A.itf
4920A009_7251_2B.itf
4920A009_7251_3a.itf
4920A009_7251_3B.itf
4920A009_7251_3Y.itf
4920A009_7251_11.itf
4920A009_7251_11A.itf
4920A009_7251_STD1.itf
4920A009_7251_STD2.itf
4920A009_7251_STD3.itf
Please email me back at genesis.montano@intel.com
Thank you.
Genesis
------------------------------
Date: Mon, 27 Nov 2000 04:09:28 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: Help Needed: SORT function
Message-Id: <m3u28uqcnb.fsf@solo.david-steuber.com>
perldoc -f sort
Note that you can pass a subroutine or a block to alter the order
returned from sort.
--
David Steuber | Perl apprentice. The axe did not stop the
NRA Member | mops and buckets from flooding my home.
ICQ# 91465842
*** http://www.david-steuber.com/ ***
------------------------------
Date: Mon, 27 Nov 2000 04:30:03 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Help Needed: SORT function
Message-Id: <slrn923omq.850.mgjv@verbruggen.comdyn.com.au>
On Sun, 26 Nov 2000 18:42:10 -0800,
Genesis Montano <genesis@magictraders.com> wrote:
> Hi. I'm currently a new programmer and I'm trying to use the sort
> function. The PERL sort function
It's not PERL. It's Perl, or perl. The FAQ, section 1 talks about
this, and why.
> orders a list in ASCII order, wherein a capital "A" comes first before
> the small "a" and number comes
That is the default sort that the sort() function uses, yes. But the
documentation for sort() in the perlfunc pages does explain quite
clearly how to use another one.
> first before letters. All is based in an ASCII value. Here's an example,
[snip]
> However, my problem is I want to sort in aphabetical order. I don't know
> if there is a default function for
You mean with 'alphabetical' that you want to sort case-inseinsitively,
right?
my @result = sort { lc $a cmp lc $b } @input;
> it. I'd checked my manual and it does not give that option. I hope u can
> help me on this one or direct me
> where I can find the function.
Which manual did you check?
# man perlfunc
or
# perldoc -f sort
or if you have the ActiveState version, the perlfunc.html file. The
FAQ, section 4 also talks extensively about more complex sorts.
> Please email me back at genesis.montano@intel.com
Nope. Post here, read here.
Martien
--
Martien Verbruggen |
Interactive Media Division | In the fight between you and the
Commercial Dynamics Pty. Ltd. | world, back the world - Franz Kafka
NSW, Australia |
------------------------------
Date: Sun, 26 Nov 2000 23:48:30 +0800
From: jin zengxiang <jingzx@sinaman.com>
Subject: Re: how to recieve the search result from google.com?
Message-Id: <3A2130CE.693A8CD4@sinaman.com>
Hi:
thanks .but I wonder what is returned by HTTP:Request ?
is it the html codes?I use following code segment:
.........................................
my $req = new HTTP::Request GET =>
'http://www.google.com/search?q=$keyword';
my $res = $ua->request($req);
$result=$res->content;
print $result;
open(OUTHTML,">result.html");
print OUTHTML $result;
close(OUTHTML);
..................................
by above codes ,I can print the html page ,but it seems that there is
something wrong
when I save $result to "result.html" .so inorder to parse the result ,what
should I do ?
H C wrote:
> See the response I sent to this question in comp.lang.perl.modules
>
> jin zengxiang wrote:
>
> > Hi,there:
> > I want to develop a personal search engine by perl .It should:
> > 1,send a request to the http://www.google.com
> > 2,recieve the search result in google.com so I can do something else .
> > I know perl must can do it ,but don't know how to do it ,
> > would you pls teach me how to solve this problem?
> > thanks
> >
> > Regards
> > Alan
>
> --
> Q: Why is Batman better than Bill Gates?
> A: Batman was able to beat the Penguin.
------------------------------
Date: Sun, 26 Nov 2000 23:08:57 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: identifying $_ as variable or constant
Message-Id: <slrn9235sn.850.mgjv@verbruggen.comdyn.com.au>
On Sun, 26 Nov 2000 11:38:26 -0500,
Tad McClellan <tadmc@metronet.com> wrote:
>
>>I have learnt not to ask "is this
>>possible" but rather "how" in clpm - maybe this case is an exception?
>
>
> Ahh. I think I finally see what you are asking. Let me recast
> it to something people will understand, then maybe someone
> can answer it :-)
>
>
> How can you tell if a subroutine argument is an lvalue or not?
>
>
> I dunno how you do that (apart from eval()).
>
> That's a good question.
It is a good question. I can't easily think of a solution without eval
either. Maybe something like:
#!/usr/local/bin/perl -w
use strict;
sub is_lvalue { eval {$_[0] = 1} }
sub grumble
{
print "$_ is ", is_lvalue($_) ? '' : 'not ', "an lvalue\n"
for (@_);
}
my $foo = 12;
grumble($foo, 42);
This seems to work under 5.6.0 and 5.005_03. I don't have 5.004 on
this machine, so can't test. Do note that it is important to not pass
copies of $_[$n] around.
Note also that undef is an lvalue.
> I await an enlightening followup...
I seem to vaguely recall that this came up a while ago on this group,
or maybe clp.moderated. I seem to recall there is any exposed
functionality yet, but that it can be done in XS. Maybe there's some
debugger facility that can be used, but unless speed is really
important, the above will probably do as well.
I don't have the time right now to do a full deja search, but it may
be beneficial for anyone interested to have a look around there.
Martien
--
Martien Verbruggen |
Interactive Media Division | Unix is user friendly. It's just
Commercial Dynamics Pty. Ltd. | selective about its friends.
NSW, Australia |
------------------------------
Date: Sun, 26 Nov 2000 18:53:49 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: identifying $_ as variable or constant
Message-Id: <slrn9238kd.bt1.tadmc@magna.metronet.com>
Eric Smith <eric@fruitcom.com> wrote:
>In comp.lang.perl.misc, you wrote:
^^^
Errr, which you do you mean?
Judging from the References: header, I think you mean Uri.
Please fix your attribution string.
>> 2 char indents are also
> > poor style IMO. a quick glance doesn't show me the blocking at all.
> mmm, how many do you want?
I think 4 spaces is most common, but some use 8 (like tabs) or 3 spaces.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 27 Nov 2000 00:23:06 GMT
From: "John Boy Walton" <johngros@Spam.bigpond.net.au>
Subject: Re: If/else problem.
Message-Id: <KPhU5.6071$GW5.39072@news-server.bigpond.net.au>
Thanks Joe.
It is the answer I needed.
"Joe Smith" <inwap@best.com> wrote in message
news:8vqjqe$5jd$1@nntp1.ba.best.com...
> In article <s33T5.460$GW5.3300@news-server.bigpond.net.au>,
> John Boy Walton <johngros@Spam.bigpond.net.au> wrote:
> >open BOGUS,"+>>$file" or die "Cannot open file: $!";
>
> Opens $file for appending and reading, positions to end of file.
>
> > if ($pass eq <BOGUS>){
>
> Attempt to read beyond end of file, returns undef.
>
> If you are intending to read from a file, "+>>$file" is not the way to do
it.
> -Joe
> --
> See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
------------------------------
Date: Mon, 27 Nov 2000 09:39:06 +0800
From: "h" <finster@mailexcite.com>
Subject: Re: Mime type - Binary File
Message-Id: <3a21dc46@usenet.per.paradox.net.au>
OK,
I'll try rephrasing my question in the hope that someone might read messages
beyond the last on I received.
What we are doing is using a series of perl scripts to capture user
information for an isp signup.We then need to be able to compile a binary to
send back to the user that contains configuration data to setup the browser.
This information uses a specific mime type with a particular format. We have
seen the header format for the mime type but would like to see an example
with appropriate data to illustrate the format more effectively to us.
As Perl is the common tool to do this type of work I am hoping someone here
has experience with it and might be able to offer an example on the mime
type format.
If you can help it would be appreciated.
Regards
Gavin
"h" <finster@mailexcite.com> wrote in message
news:3a1f5937$1@usenet.per.paradox.net.au...
> Hi,
>
> I am trying to do the Netscape Customisation Kit signup server. I can
> create all the file can create the accounts but am having trouble
returning
> the correct Mime file back to the user.
>
> The instruction from NEtscape are as follows...
> =======
> application/x-netscape-autoconfigure-dialer-v2
>
> When Navigator sees this MIME type, it expects data in the format
described
> below. The binary file format used by this MIME type is simple, yet
> extensible. It
> consists of consecutive name/value pairs separated by 4 bytes of size
> information:
>
> | 4 bytes | ------ x bytes ------ | 4 bytes | ------ y bytes ------ | (x)
> (name) (y) (value)
>
> The parser iterates as follows until it reaches the end of the stream:
>
> Read 4 bytes of binary data and cast to int for size of Name in bytes
> (x)
> Read (x) bytes of ASCII data for the name
> Read 4 bytes of binary data and cast to int for size of Value in
bytes
> (y)
> Read (y) bytes of ASCII data for the value
> ================
>
> Can someone possibly provide a sample of how to do this.
>
> On a related note, the netscape doucmentation says to return the encrypted
> password, but how is the password encryted?
>
> Cheers
> gavin
>
>
>
>
>
------------------------------
Date: Mon, 27 Nov 2000 03:00:29 GMT
From: al@maystreet.com (Al Rosetti)
Subject: Much deserved praise for George Rath from www.domainventures.on.ca
Message-Id: <3a21da58.4033524@news>
A few days ago I asked for some help on this board regarding two
scripts I needed for my site www.maystreet.com. One was a counter,
the other was a search tool. Thanks goes out to all that offered to
help but a very special thanks goes out to George Rath. He came
through more than I could have imagined. He was knowledgable enough
to guide me in the right direction and in the process give me more
than I had asked for... way more. I couldn't have dreamed of a
better deal. If you need help on something I highly advise you get in
touch with this guy. WOW!!!
Very sincerely,
Al Rosetti
------------------------------
Date: Mon, 27 Nov 2000 11:03:32 +1000
From: "Paul Mulloni" <paul@NOSPAM.multibase.com.au>
Subject: Perl not executing from Cron job
Message-Id: <3a21b2e1@grissom>
Hello all,
System:
Red hat 6.1
Perl 5.005_03
The perl script will execute from the command line but when the perl scripts
is run from a cron job it does not work. It looks like it wants to run the
script file using the /usr/sh shell instead of the perl shell even though
the "#!/usr/bin/perl" line is set. I have found that a SHELL environment
variable can be set within the cron job so setting it to "/usr/bin/perl"
has the perl script working to a certain extent. When this is set then the
perl script is executed as if the -c option is set so it does not actually
execute the script only compiles it!!!
Not sure why this is happening??
Paul.
------------------------------
Date: Sun, 26 Nov 2000 23:34:25 -0500
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: Perl not executing from Cron job
Message-Id: <t23p1dgt6b7k85@corp.supernews.com>
Paul Mulloni <paul@NOSPAM.multibase.com.au> wrote in message
news:3a21b2e1@grissom...
> Hello all,
> System:
> Red hat 6.1
> Perl 5.005_03
>
> The perl script will execute from the command line but when the perl
scripts
> is run from a cron job it does not work. It looks like it wants to
run the
> script file using the /usr/sh shell instead of the perl shell even
though
> the "#!/usr/bin/perl" line is set. I have found that a SHELL
environment
> variable can be set within the cron job so setting it to
"/usr/bin/perl"
> has the perl script working to a certain extent. When this is set
then the
> perl script is executed as if the -c option is set so it does not
actually
> execute the script only compiles it!!!
>
> Not sure why this is happening??
>
> Paul.
>
Perhaps an obvious question... Are you certain that the #!/usr/bin/perl
is on the very first line of your program file?
------------------------------
Date: Mon, 27 Nov 2000 10:56:00 +1100
From: "Troy Rasiah" <troyr@vicnet.net.au>
Subject: reg expression
Message-Id: <MrhU5.46119$SF5.837256@ozemail.com.au>
Hi..i was wondering if anyone could assist me in making these series of reg
expressions more compact
my ($var)=@_;
my $error=0;
#no white spaces
if (!($var =~m /\s/)) {
# At least 6 alpha numeric chars
if ($var =~m /(\w{6}?)/) {
# No non alpha numeric chars
if (!($var =~m /\W/)) {
# At least 1 digit
if ($var =~m /(\d+)/) {
}
else {
$error=1;
}
}
else {
$error=1;
}
}
else {
$error=1;
}
}
else {
$error=1;
}
return ($error);
Thanks in Advance
-------------------------
TR
------------------------------
Date: Sun, 26 Nov 2000 19:19:54 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: reg expression
Message-Id: <Pine.GSO.4.21.0011261916140.714-100000@crusoe.crusoe.net>
[posted & mailed]
On Nov 27, Troy Rasiah said:
> #no white spaces
> if (!($var =~m /\s/)) {
This could be: $var !~ /\s/ for simplicity. Anyway, your test for
non-alphanumerics would catch whitespace.
What you want is a string of 6 or more alphanumerics, with at least 1
digit, correct?
sub is_valid {
local $_ = shift;
m{
\A # beginning of string
(?= # look ahead for...
\w{6,} # 6 or more word characters
\Z # and then end of string
)
\D* # match 0 or more non-digits
\d # and then a digit
}x;
}
This method works by making sure we have the proper number of characters
first, and THEN it makes sure it can find a digit.
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
PerlMonks - An Online Perl Community http://www.perlmonks.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
------------------------------
Date: Mon, 27 Nov 2000 01:27:34 GMT
From: wyzelli@yahoo.com (Wyzelli)
Subject: Re: reg expression
Message-Id: <Xns8FF97AABDwyzelliyahoocom@203.39.3.131>
"Troy Rasiah" <troyr@vicnet.net.au> wrote in
<MrhU5.46119$SF5.837256@ozemail.com.au>:
>Hi..i was wondering if anyone could assist me in making these series of
>reg expressions more compact
>
> #no white spaces
> # At least 6 alpha numeric chars
> # No non alpha numeric chars
> # At least 1 digit
if (checkdata('asaerand8fr')){
#data is bad;
}
sub checkdata {
my $var = shift;
# return 0 if data OK, 1 if bad data
return ($var =~ /^(?=\w{6,}$).*\d/)?0:1;
}
Note the alphanumeric test excludes whitespace and non alphanumerics, but
also allows underscore. Do you want that?
Wyzelli
--
#beer v2
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";
------------------------------
Date: Mon, 27 Nov 2000 02:01:16 -0000
From: "Martin Long" <martin.long@virgin.net>
Subject: Simple Open file fails in Active Perl 5.6.0 on Windows2000 Advanced Server + IIS 5.0
Message-Id: <CbjU5.14443$ea7.297716@news2-win.server.ntlworld.com>
A very simple perl program fails on the open for input with "No such file or
directory" if I run it through the web server (i.e. as a link from a web
page) . The file to be opened does exist in the cgi-bin directory (it also
fails wherever I put the file and with whatever permissions I put on the
file). It fails using the < modifier. It also fails with the sysopen
method. If I run it standalone (i.e. from the command line) it works fine
and appropriate HTML is output.
Other perl functions are fine provided I don't try to open a file. This
smacks of permissions but so far I have no idea what is going wrong having
tried most things I can think of.
I am an experienced programmer but new to perl.
Any help would be appreciated. Failing script below.
Martin
#!d:/perl/bin/perl
print "Content-type: text/html\n\n";
print "<html><head><title>Glee form data</title></head><body>\n";
print "<center><b>Gleesons booking form data</b></center>\n";
print "<hr><p>\n";
$file="availability.txt";
open INF,"< $file" or print "Failed $!";
@x=<INF>;
@z=@x;
close(INF);
$i=0;
foreach $x (@x) {
chomp($x);
($z[$i],$z[$i+1]) = split(/,/,$x);
print "$z[$i] , $z[$i + 1]<hr><br>";
$i++;
}
print "</body></html>\n";
exit;
------------------------------
Date: Mon, 27 Nov 2000 02:03:42 GMT
From: wyzelli@yahoo.com (Wyzelli)
Subject: Re: Simple Open file fails in Active Perl 5.6.0 on Windows2000 Advanced Server + IIS 5.0
Message-Id: <Xns8FF97BC8Awyzelliyahoocom@203.39.3.131>
"Martin Long" <martin.long@virgin.net> wrote in
<CbjU5.14443$ea7.297716@news2-win.server.ntlworld.com>:
>A very simple perl program fails on the open for input with "No such
>file or directory" if I run it through the web server (i.e. as a link
>from a web page) .
<snip>
>#!d:/perl/bin/perl
no use strict, no -w
>$file="availability.txt";
Try inserting the correct full path to the file here because you are
probably not where you think you are.
$file = 'd:/inetpub/wwwroot/website/cgi-bin/availability.txt';
>open INF,"< $file" or print "Failed $!";
Wyzelli
--
#beer v2
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";
------------------------------
Date: 27 Nov 2000 02:04:49 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Simple Open file fails in Active Perl 5.6.0 on Windows2000 Advanced Server + IIS 5.0
Message-Id: <slrn923ga1.snr.sholden@pgrad.cs.usyd.edu.au>
On Mon, 27 Nov 2000 02:01:16 -0000, Martin Long <martin.long@virgin.net> wrote:
>A very simple perl program fails on the open for input with "No such file or
>directory" if I run it through the web server (i.e. as a link from a web
>page) . The file to be opened does exist in the cgi-bin directory (it also
>fails wherever I put the file and with whatever permissions I put on the
>file). It fails using the < modifier. It also fails with the sysopen
>method. If I run it standalone (i.e. from the command line) it works fine
>and appropriate HTML is output.
>
>Other perl functions are fine provided I don't try to open a file. This
>smacks of permissions but so far I have no idea what is going wrong having
>tried most things I can think of.
What makes you think that the working directory the CGI program is executed
in by the web server will be the directory the CGI program is located in?
The web server may have a different working directory than you think it does.
Use the full path to the file instead.
--
Sam Holden
------------------------------
Date: 26 Nov 2000 20:05:21 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Simple Open file fails in Active Perl 5.6.0 on Windows2000 Advanced Server + IIS 5.0
Message-Id: <874s0u41b2.fsf@limey.hpcc.uh.edu>
>> On Mon, 27 Nov 2000 02:01:16 -0000,
>> "Martin Long" <martin.long@virgin.net> said:
> A very simple perl program fails on the open for input
> with "No such file or directory" if I run it through the
> web server (i.e. as a link from a web page) . The file
> to be opened does exist in the cgi-bin directory (it
> also fails wherever I put the file and with whatever
> permissions I put on the file). It fails using the <
> modifier. It also fails with the sysopen method. If I
> run it standalone (i.e. from the command line) it works
> fine and appropriate HTML is output.
Try doing
cd /tmp
then run the program. Extrapolate from this...
You want to specify exactly where the file is, and make
sure that the user executing the perl program (possibly
"nobody") has read access to the file. See
http://www.boutell.com/openfaq/cgi/
> #!d:/perl/bin/perl print "Content-type: text/html\n\n";
> print "<html><head><title>Glee form
> data</title></head><body>\n"; print "<center><b>Gleesons
> booking form data</b></center>\n"; print "<hr><p>\n";
> $file="availability.txt"; open INF,"< $file" or print
> "Failed $!"; @x=<INF>; @z=@x; close(INF); $i=0; foreach
> $x (@x) { chomp($x); ($z[$i],$z[$i+1]) = split(/,/,$x);
> print "$z[$i] , $z[$i + 1]<hr><br>"; $i++; } print
> "</body></html>\n"; exit;
Note the CGI.pm module provides lots of nice HTML shortcut
methods which would make the HTML output more readable,
e.g.
print header,
start_html("Glee form data"),
center(...), ...
I'll leave others to comment on the code itself...
hth
t
--
Eih bennek, eih blavek.
------------------------------
Date: 26 Nov 2000 18:50:24 -0600
From: anmcguire@ce.mediaone.net (Andrew N. McGuire)
Subject: Re: splitting a string into an array and preserving the "\n"
Message-Id: <87n1em8chb.fsf@hawk.ce.mediaone.net>
>>>>> "RG" == Rafael Garcia-Suarez <rgarciasuarez@free.fr> writes:
RG> Bernie Cosell wrote in comp.lang.perl.misc:
RG> ! rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote:
RG> !
RG> ! } Eric Smith wrote in comp.lang.perl.misc:
RG> ! } > I want to split a multi-line scalar into an array. I want each element of
RG> ! } > the array to have a line terminated by a "\n".
RG> ! } > Problem is that when I split on "\n", then this newline character is lost.
RG> ! } my @array = split /(?<=\n)/, $multi_line_string;
Is the lookbehind necessary? Why not:
my @lines = split '^', $mlstring;
I am probably missing something though...
anm
--
perl -wMstrict -e '
$a=[[qw[J u s t]],[qw[A n o t h e r]],[qw[P e r l]],[qw[H a c k e r]]];$.++
;$@=$#$a;$$=[reverse sort map$#$_=>@$a]->[$|];for$](--$...$$){for$}($|..$@)
{$$[$]][$}]=$a->[$}][$]]}}$,=$";$\=$/;print map defined()?$_:$,,@$_ for @$;
'
------------------------------
Date: Mon, 27 Nov 2000 04:32:15 GMT
From: "jelly belly" <workmonster2@home.com>
Subject: Unwanted Characters found in Script
Message-Id: <jtlU5.710016$8u4.11384804@news1.rdc1.bc.home.com>
Just an oddity that perhaps a few of you have noticed before;
I just imported two scripts; one is a .cgi and the other a .pl file. Both
were cut 'n' pasted from a browser. When they didn't work properly on the
Windows server, I moved them to a Linux box. Before setting permissions,
though, I noticed that each script had a strange carriage-return character ~
an underscored capital-M at the end of each line. Once these characters
were removed from all 150 lines, the scripts worked well.
I'm sure this is not new to the folks in this newsgroup. Any comments would
be welcome.
Kev
--
www.workmonster.bc.ca
------------------------------
Date: Mon, 27 Nov 2000 02:38:53 GMT
From: "Alan Mailer" <clarityassoc@earthlink.net>
Subject: Will most servers know/have access to DATE-CALC and DATE-MANIP?
Message-Id: <1PjU5.9126$nh5.772997@newsread1.prod.itd.earthlink.net>
From what I understand I really need to have Date::Calc and Date::Manip on
my system to be able to work with Perl and Dates.
Please excuse the complete naivete of this question but: since I may be
deploying my perl scrips on a Unix based web server... am I able to assume
that most servers know how to deal with my use of the Calc and Manip
modules?
Thanks in advance.
------------------------------
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 4970
**************************************