[27939] in Perl-Users-Digest
Perl-Users Digest, Issue: 9303 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 15 21:05:58 2006
Date: Thu, 15 Jun 2006 18:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 15 Jun 2006 Volume: 10 Number: 9303
Today's topics:
=?gb2312?B?sNm2yL66vNvKx8rVutrQxMeutcSjocbz0rWyu9Kqyc+1 <njhotel@gmail.com>
Re: automate command line script using perl <shahrahulb@gmail.com>
Re: automate command line script using perl <tadmc@augustmail.com>
Re: automate command line script using perl <hoosier45678@hotmail.com>
Re: automate command line script using perl <tintin@invalid.invalid>
Re: Binding array to pattern <tadmc@augustmail.com>
Re: can I trust on key %hash natural order? <jl_post@hotmail.com>
Re: Can you clear a form in a perl script <tadmc@augustmail.com>
Re: Can you clear a form in a perl script <no@email.com>
Can't locate Text/CSV.pm in @INC (@INC contains: /usr/l dacoman@gmail.com
Re: Can't locate Text/CSV.pm in @INC (@INC contains: /u xhoster@gmail.com
Re: Can't locate Text/CSV.pm in @INC (@INC contains: /u <john@castleamber.com>
File operations module <hobosalesman@gmail.com>
Re: File operations module <jurgenex@hotmail.com>
How to print to URL via IPP? <some@body.com>
Re: How to print to URL via IPP? <sherm@Sherm-Pendleys-Computer.local>
Perl Web Developer Wanted! <hrit24@gmail.com>
Re: question installing DBD::mysql <"v.niekerk at hccnet.nl">
Re: reference to object method <christoph.lamprecht.no.spam@web.de>
Re: reference to object method <uri@stemsystems.com>
Re: reference to object method <christoph.lamprecht.no.spam@web.de>
Re: reference to object method <christoph.lamprecht.no.spam@web.de>
Re: Testing a new password <jgibson@mail.arc.nasa.gov>
Re: Testing a new password <someone@example.com>
Re: The Nature of the "Unix Philosophy" (long) <ed@noreply.com>
Re: What am I missing in perlre <tadmc@augustmail.com>
Re: Why doesn't chdir (@args) work? <rvtol+news@isolution.nl>
Re: Why doesn't chdir (@args) work? <penryu@saiyix.ath.cx>
Re: Why doesn't chdir (@args) work? <rvtol+news@isolution.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Jun 2006 12:46:53 -0700
From: "=?gb2312?B?vfC41Q==?=" <njhotel@gmail.com>
Subject: =?gb2312?B?sNm2yL66vNvKx8rVutrQxMeutcSjocbz0rWyu9Kqyc+1saOh?=
Message-Id: <1150400813.471855.108660@i40g2000cwc.googlegroups.com>
ILDZtsi+urzbysfK1bra0MTHrrXEo6HG89K1srvSqsnPtbGjoQoKMjAwNsTqo7XUwqOyo7PI1c7S
tcTN+NW+uvPMqM2zvMa3w87KtM7K/c6qo7e0zqO7sNm2yM2zvMbOqqO0o7a0zqOsz+Cy7qOzo7m0
zqOsteO798rH0qq9u8eutcSjrNXio7OjubTOx661xM7Svbu1xLK7w/eyu7DXo64KCjIwMDbE6qO1
1MKjsqO0yNXO0rXEzfjVvrrzzKjNs7zGt8POyrTOyv3OqqOxo7G0zqO7sNm2yM2zvMbOqqO0o7e0
zqOsz+Cy7qOzo7a0zqOsteO798rH0qq9u8eutcSjrNXio7OjtrTOx661xM7Svbu1xLK7w/eyu7DX
LgoKtNO0y7K71Nm6zbDZtsjN5sHLo66w2bbIysfK1bra0MTHrqOhCgrS1MnPsrvKx7r6y7WjutPQ
zbzGrMr9vt3Oqtako6x3d3cubW9maWxlLmNvbQrPwtTYtdjWt6O6ztLN+NW+yv2+3czhyKHC66O6
MTcyMTcxNDM3NjcxMjgyOCAgo6yw2bbIuvPMqM2zvMbK/b7dzbzGrMzhyKHC66O6ODY2ODY1NjYw
OTIxMjExMQoK09DQy8iktcTF89PRv8nS1L+00rvPwqOsv7TO0srHsrvKx7r6y7WjoQo=
------------------------------
Date: 15 Jun 2006 11:47:52 -0700
From: "perlperl" <shahrahulb@gmail.com>
Subject: Re: automate command line script using perl
Message-Id: <1150397272.357398.98030@c74g2000cwc.googlegroups.com>
Example)
how can i automate this script using perl
#!/usr/bin/csh
echo "Would you like o continue [y/n]?"
set test = $<
if ($test == "y") then
echo "How many time do you want to run the script: ?"
set times = $<
echo "You enters $times "
else
echo "Exit"
endif
------------------------------
Date: Thu, 15 Jun 2006 14:03:25 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: automate command line script using perl
Message-Id: <slrne93bnt.44i.tadmc@magna.augustmail.com>
perlperl <shahrahulb@gmail.com> wrote:
> Do you mein "use Expect" of Perl?
Does who mean what?
Please quote some context in your followups like everybody else does.
There is not "Expect of Perl", but there is an "Expect module" for Perl:
http://search.cpan.org/~rgiersig/Expect-1.17/
See also:
perldoc -q module
What modules and extensions are available for Perl? What is CPAN?
What does CPAN/src/... mean?
How do I find which modules are installed on my system?
How do I create a module?
How do I install a module from CPAN?
How do I keep my own module/library directory?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 15 Jun 2006 15:30:43 -0500
From: James <hoosier45678@hotmail.com>
Subject: Re: automate command line script using perl
Message-Id: <pan.2006.06.15.20.30.38.352376@hotmail.com>
On Thu, 15 Jun 2006 10:32:11 -0700, perlperl wrote:
> i have a bash script,
> when i run this script, its a interactive script and ask users couple of
> questions and move forward and completes the script.
>
> is there a way i can automate that using perl, if i know the sequence of
> questions and the answer i need to provide.
Yes, but two other techniques to solve your problem suggest themselves:
1. grep getline script.csh
Delete those lines and just set the answers manually.
2. run autoexpect (which comes with expect)
it generates a script that you can run to your heart's content. It will
generate an expect script with a bunch of lines like:
expect "blah blah blah\nthis: "
send -- "that\r"
just open it up and delete the coincidences and incidentals that would
trip detection up (like dates, or your command prompt), and chmod +x
------------------------------
Date: Fri, 16 Jun 2006 08:31:18 +1200
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: automate command line script using perl
Message-Id: <4491b622$0$3622$88260bb3@free.teranews.com>
"perlperl" <shahrahulb@gmail.com> wrote in message
news:1150392730.951527.165660@u72g2000cwu.googlegroups.com...
> i have a bash script,
> when i run this script, its a interactive script and ask users couple
> of questions and move forward and completes the script.
>
> is there a way i can automate that using perl, if i know the sequence
> of questions and the answer i need to provide.
If you have simple questions that are predictable, you can simple pipe or
redirect the answers, eg:
echo "yes\nno" | /path/to/script
or create a file with the responses, eg:
$ cat responses
yes
no
$ /path/to/script <responses
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: Thu, 15 Jun 2006 12:57:47 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Binding array to pattern
Message-Id: <slrne937sq.3uc.tadmc@magna.augustmail.com>
Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid> wrote:
> In <x7veraf2kp.fsf@mail.sysarch.com>, on 06/09/2006
> at 05:20 PM, Uri Guttman <uri@stemsystems.com> said:
>>the massive redundant use of $host_info{$host}{Email} in there?
>>factor that out into a scalar before the loop.
>> push @Contacts, @{$emails};
>> push @abuseContacts, @{$emails};
>
> No; that would change the logic. What would be needed is:
>
> push @abuseContacts, @{$emails};
> my $scalarContacts = "@{$emails}"
> if (/abuse/ or $scalarContacts =~ /abuse/);
You flipped the lines from what you posted before, which was:
push @Contacts, @{$host_info{$host}{Email}{$_}};
my $scalarContacts="@{$host_info{$host}{Email}{$_}}";
push @abuseContacts, @{$host_info{$host}{Email}{$_}}
if (/abuse/ or $scalarContacts =~ /abuse/);
Applying both Uri's and my suggestions to that code yields:
push @Contacts, @{$emails};
push @abuseContacts, @{$emails}
if grep /abuse/, $_, @{$emails};
Or, taking advantage of the special case of the reference
being a simple standalone scalar allowing you to leave out
some curlies:
push @Contacts, @$emails;
push @abuseContacts, @$emails
if grep /abuse/, $_, @$emails;
>>and why do you push the same stuff into 2 different arrays?
>
> I don't; the 2nd push is conditional.
Not in the code you posted this time.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 15 Jun 2006 15:19:41 -0700
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: can I trust on key %hash natural order?
Message-Id: <1150409981.888285.320160@u72g2000cwu.googlegroups.com>
Ciao, filippo!
filippo scrisse:
>
> I load my hash with my order, am I sure that the order is preserved on
> command 'foreach (key %myHash)?
No. Hashes are not guaranteed to return the keys in the order they
were made. The keys() function returns the keys in the order most
convenient to the hash, which is almost never the same as the order
most convenient to you.
If you want to get the keys in the order they were inserted, run
this command at your DOS/Unix prompt:
perldoc -q "keep my hash sorted"
It'll tell you to look at the Tie::IxHash module, which is a special
module that allows you to create hashes that remember what order their
keys were added in -- and so will return the keys in that order when
you call the keys() function.
Buona fortuna, filippo.
-- Jean-Luc
------------------------------
Date: Thu, 15 Jun 2006 13:00:36 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Can you clear a form in a perl script
Message-Id: <slrne93824.3uc.tadmc@magna.augustmail.com>
terry@av1611.org <terry@av1611.org> wrote:
> please email me at twatkins@charter.net with any suggestions.
It sure has been a long time since I've seen this most heinous
form of netiquette breach.
Off to perpetual invisibility for you...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 15 Jun 2006 20:46:23 +0100
From: Brian Wakem <no@email.com>
Subject: Re: Can you clear a form in a perl script
Message-Id: <4fdrofF1hmpupU1@individual.net>
terry@av1611.org wrote:
> I need a simple way to clear a form after the form is processed in a
> perl script.
>
> It's a "tell a friend" type cgi script. I'm getting users using the
> "back button" and resubmitting the form and spaming me.
>
> I've got many pages using this script and I don't want to use a
> javascript (which would require changing all the pages).
>
> please email me at twatkins@charter.net with any suggestions.
Try something like:
use CGI;
my $query = new CGI;
print $query->header( -type => 'text/html', -expires => '-1d',
'Cache-Control' => 'max-age=0, no-store' );
--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
------------------------------
Date: 15 Jun 2006 12:16:23 -0700
From: dacoman@gmail.com
Subject: Can't locate Text/CSV.pm in @INC (@INC contains: /usr/lib/perl5/5.8.8
Message-Id: <1150398983.709155.308830@r2g2000cwb.googlegroups.com>
Hello,
I have recently upgraded the server to Suse 10.1. Now I have a problem
wiht and old cgi script that does not compile anymore.
The error when I run the script with perl -w is:
> # perl -cw reg.cgi
Can't locate Text/CSV.pm in @INC (@INC contains:
/usr/lib/perl5/5.8.8/i586-linux-thread-multi /usr/lib/perl5/5.8.8
/usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl .) at
reg.cgi line 13.
BEGIN failed--compilation aborted at reg.cgi line 13.
The line that is causing the problem is:
Use Text::CSV;
Here is piece of code:
use strict;
use warnings;
use CGI qw(:standard);
use Text::CSV;
##################################################
# create a new CGI object and CSV object
my $query = new CGI;
my $csv = Text::CSV->new();
The perl version is perl5.8.8 and I did install the package
perl-Text-CSV_XS that came with the Suse 10.1 distro.
What am I missing here? I would realy appreciate your help.
Thank you,
--D
------------------------------
Date: 15 Jun 2006 19:31:09 GMT
From: xhoster@gmail.com
Subject: Re: Can't locate Text/CSV.pm in @INC (@INC contains: /usr/lib/perl5/5.8.8
Message-Id: <20060615153132.547$XG@newsreader.com>
dacoman@gmail.com wrote:
...
>
> The line that is causing the problem is:
>
> use Text::CSV;
...
>
> The perl version is perl5.8.8 and I did install the package
> perl-Text-CSV_XS that came with the Suse 10.1 distro.
>
> What am I missing here?
What you are missing is that Text::CSV is not the same thing as
Text::CSV_XS
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 15 Jun 2006 19:39:56 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Can't locate Text/CSV.pm in @INC (@INC contains: /usr/lib/perl5/5.8.8
Message-Id: <Xns97E3952FE3B9Ccastleamber@130.133.1.4>
dacoman@gmail.com wrote:
> Use Text::CSV;
^ no it isn't ;-)
:
:
> The perl version is perl5.8.8 and I did install the package
> perl-Text-CSV_XS that came with the Suse 10.1 distro.
What does:
perl -MText::CVS -e1
on the command line give?
--
John Bokma Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/
------------------------------
Date: 15 Jun 2006 17:24:55 -0700
From: "Hobo Salesman" <hobosalesman@gmail.com>
Subject: File operations module
Message-Id: <1150417495.371368.166600@g10g2000cwb.googlegroups.com>
Does anyone know offhand of a module that can make file operations a
little easier? For instance, create a file and any directories needed
in it's path if they don't exist?
------------------------------
Date: Fri, 16 Jun 2006 00:35:38 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: File operations module
Message-Id: <u1nkg.26804$X02.15865@trnddc02>
Hobo Salesman wrote:
> Does anyone know offhand of a module that can make file operations a
> little easier?
Many. Just search for File on CPAN
> For instance, create a file and any directories needed
> in it's path if they don't exist?
File::Path
jue
------------------------------
Date: Thu, 15 Jun 2006 20:16:50 -0400
From: somebody <some@body.com>
Subject: How to print to URL via IPP?
Message-Id: <dOOdneyD7oHvZQzZnZ2dnUVZ_rOdnZ2d@giganews.com>
I just installed Net::IPP, and was disappointed to
find that it does not support printing to a url,
such as http://myhost:631/printers/LaserJet.
Is there a module which will support printing
to a remote printer via a URL?
-Thanks
------------------------------
Date: Thu, 15 Jun 2006 20:22:01 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: How to print to URL via IPP?
Message-Id: <m2bqsuueza.fsf@Sherm-Pendleys-Computer.local>
somebody <some@body.com> writes:
> I just installed Net::IPP, and was disappointed to
> find that it does not support printing to a url,
> such as http://myhost:631/printers/LaserJet.
> Is there a module which will support printing
> to a remote printer via a URL?
Does your printer support CUPS? If so, you might try Net::CUPS.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 15 Jun 2006 13:00:12 -0700
From: "hrit24@gmail.com" <hrit24@gmail.com>
Subject: Perl Web Developer Wanted!
Message-Id: <1150401612.868554.160440@g10g2000cwb.googlegroups.com>
Are you looking to join a dynamic, innovative Interactive Marketing &
Technology Company?
Advertising.com is the most innovative company in online advertising,
with pioneering technologies and strategies that have made us one of
most successful dots in the dot.com world. We conduct strategic
marketing campaigns that guarantee results for our clients. And for
employees, we offer a one-of-a-kind place to begin or advance your
career. We're the best in our business because we attract the best
people. So we hope you'll take a minute to see what the dot is all
about.
The Web Applications Developer will be involved in developing and
maintaining on-line dynamic content and web based applications for the
organization and its clients.
Essential Duties and Responsibilities:
=B7 Full life cycle development of web pages and web applications for
the company and external clients.
=B7 Provide technical support for internal and external clients.
=B7 Provide support and operations of production systems in a 24x7
environment.
=B7 Perform other job-related activities and duties as requested.
Required Skills:
=B7 Thorough knowledge of web page production and design.
=B7 Thorough knowledge of the software development life cycle with
emphasis on implementing production level systems in a rapid
development environment.
=B7 Proficient use in HTML, JavaScript, Style Sheets (CSS), frames and
design implementation.
=B7 Working knowledge of PERL, PHP and Unix/Apache website management.
=B7 Working knowledge of Java, JSP and Tomcat website management.
=B7 Prior knowledge and use of database technologies: SQL, Oracle,
MySQL, PERL DBI.
=B7 Ability to maintain own workflow and work under minimal
supervision.
=B7 Must possess strong customer service skills, excellent
communication skills (both written and verbal), and exchange
information with others clearly and concisely; ability to present ideas
and facts.
=B7 Ability to respond to frequent pressure to meet deadlines when work
speed and sustained accuracy are paramount.
=B7 Ability to work harmoniously and effectively as part of a work
team.
Experience Required:
=B7 3-5 years experience.
=B7 Bachelor's degree.
Here's what you'll get:
=B7 Entrepreneurial environment.
=B7 Competitive compensation program and Comprehensive benefits.
=B7 Approachable leadership.
=B7 A corporate culture where fun is a priority.
=B7 Opportunities to further develop your skills and refine your
talent.
=B7 Work life / personal life balance.
Don't miss out on this great opportunity-Take Charge of Your Career and
Apply Now!
Located on Tide Point's beautiful promenade in Baltimore's Inner
Harbor, Advertising.com is an energetic, fun, progressive place to
work. If you are interested in this exciting opportunity, please
reference the job title included in this posting in your cover letter
and submit your resume to
http://www2.openhire.com/epostings/jobs/submit.cfm?fuseaction=3Ddspjob&jobi=
d=3D108007&company_id=3D15671&version=3D1&jobboardid=3D24.
To review our professional credentials in more detail and find out more
about our fun, creative, collaborative environment, please view our
website; www.advertising.com
EEO/AA
------------------------------
Date: Thu, 15 Jun 2006 20:22:51 +0200
From: Huub <"v.niekerk at hccnet.nl">
Subject: Re: question installing DBD::mysql
Message-Id: <4491a57b$0$7804$e4fe514c@dreader14.news.xs4all.nl>
>
> You forgot the "run the other steps manually" part. The "look" command
> doesn't run "perl Makefile.PL; make; make test; make install" for you,
> which is more or less the point of it. It's there so that you can pass
> extra parameters to those commands when you need to, while still taking
> advantage of the CPAN module's ability to identify the latest version,
> check it against the installed version, choose a mirror site, etc.
>
> sherm--
>
Found that out just after my last-but-one post. Mysql connection is
running fine now and trying to get the rest of my code running.
Thanks for helping out.
Huub
------------------------------
Date: Fri, 16 Jun 2006 00:04:53 +0200
From: Ch Lamprecht <christoph.lamprecht.no.spam@web.de>
Subject: Re: reference to object method
Message-Id: <e6sli2$di6$1@online.de>
Uri Guttman wrote:
>>>>>>"x" == xhoster <xhoster@gmail.com> writes:
>
>
> x> Uri Guttman <uri@stemsystems.com> wrote:
> >> much better to use UNIVERSAL::can:
> >> my $meth = $obj->can( 'method_name' ) ;
> >>
> >> $meth->( $arg ) ;
>
> x> Doesn't that call the method as a regular subroutine, with $arg where $self
> x> should be?
>
> x> Wouldn't that need to be: ?
> x> $obj->$meth($arg);
>
> my bad. brain wasn't fully engaged. and i have used can like that a few
> times so i should know how to call the method! your code is correct
> there.
It will still call the method as a regular subroutine...
So maybe it should be better written as
$meth->( $obj,$arg );
Christoph
--
perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"
------------------------------
Date: Thu, 15 Jun 2006 18:53:59 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: reference to object method
Message-Id: <x7zmgevxmg.fsf@mail.sysarch.com>
>>>>> "CL" == Ch Lamprecht <christoph.lamprecht.no.spam@web.de> writes:
CL> Uri Guttman wrote:
>>>>>>> "x" == xhoster <xhoster@gmail.com> writes:
x> Uri Guttman <uri@stemsystems.com> wrote:
>> >> much better to use UNIVERSAL::can:
>> >> my $meth = $obj->can( 'method_name' ) ;
>> >> >> $meth->( $arg ) ;
x> Doesn't that call the method as a regular subroutine, with $arg
>> where $self
x> should be?
x> Wouldn't that need to be: ?
x> $obj->$meth($arg);
>> my bad. brain wasn't fully engaged. and i have used can like that a
>> few
>> times so i should know how to call the method! your code is correct
>> there.
CL> It will still call the method as a regular subroutine...
CL> So maybe it should be better written as
CL> $meth->( $obj,$arg );
no, xhoster's fix of my bug is correct. your way skips inheritance.
$obj->$meth($arg);
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Fri, 16 Jun 2006 01:24:09 +0200
From: Ch Lamprecht <christoph.lamprecht.no.spam@web.de>
Subject: Re: reference to object method
Message-Id: <e6sq6m$nkl$1@online.de>
Uri Guttman wrote:
>>>>>>"CL" == Ch Lamprecht <christoph.lamprecht.no.spam@web.de> writes:
>
>
> CL> Uri Guttman wrote:
> >>>>>>> "x" == xhoster <xhoster@gmail.com> writes:
> x> Uri Guttman <uri@stemsystems.com> wrote:
>
> >> >> much better to use UNIVERSAL::can:
>
> >> >> my $meth = $obj->can( 'method_name' ) ;
> >> >> >> $meth->( $arg ) ;
> x> Doesn't that call the method as a regular subroutine, with $arg
> >> where $self
> x> should be?
> x> Wouldn't that need to be: ?
> x> $obj->$meth($arg);
> >> my bad. brain wasn't fully engaged. and i have used can like that a
> >> few
> >> times so i should know how to call the method! your code is correct
> >> there.
>
> CL> It will still call the method as a regular subroutine...
> CL> So maybe it should be better written as
>
> CL> $meth->( $obj,$arg );
>
> no, xhoster's fix of my bug is correct. your way skips inheritance.
>
> $obj->$meth($arg);
>
> uri
>
so does his:
#!/usr/bin/perl
use strict;
use warnings;
package Object;
sub new {
my $self = {};
bless $self;
}
sub method{
my $self = shift;
print "Object::method invoked on $self with args @_\n";
}
package DerivedObject;
our @ISA = qw/Object/;
sub new {
my $self = {};
bless $self;
}
sub method{
my $self = shift;
print "ObjectDerived::method invoked on $self with args @_\n";
}
package main;
my $object = Object->new;
my $object_derived = DerivedObject->new;
my $method_ref = $object->can("method");
my @args = qw/foo bar/;
for ($object, $object_derived, 'nothing'){
$method_ref->($_,@args);
$_->$method_ref(@args);
$_->method(@args);
print "\n";
}
Christoph
--
perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"
------------------------------
Date: Fri, 16 Jun 2006 01:38:50 +0200
From: Ch Lamprecht <christoph.lamprecht.no.spam@web.de>
Subject: Re: reference to object method
Message-Id: <e6sr28$nkl$2@online.de>
Ch Lamprecht wrote:
> Uri Guttman wrote:
>
>>>>>>> "CL" == Ch Lamprecht <christoph.lamprecht.no.spam@web.de> writes:
>>
>>
>>
>> CL> Uri Guttman wrote:
>> >>>>>>> "x" == xhoster <xhoster@gmail.com> writes:
>> x> Uri Guttman <uri@stemsystems.com> wrote:
>>
>> >> >> much better to use UNIVERSAL::can:
>>
>> >> >> my $meth = $obj->can( 'method_name' ) ;
>> >> >> >> $meth->( $arg ) ;
>> x> Doesn't that call the method as a regular subroutine, with $arg
>> >> where $self
>> x> should be?
>> x> Wouldn't that need to be: ?
>> x> $obj->$meth($arg);
>> >> my bad. brain wasn't fully engaged. and i have used can like that a
>> >> few
>> >> times so i should know how to call the method! your code is correct
>> >> there.
>>
>> CL> It will still call the method as a regular subroutine...
>> CL> So maybe it should be better written as
>>
>> CL> $meth->( $obj,$arg );
>>
>> no, xhoster's fix of my bug is correct. your way skips inheritance.
>>
>> $obj->$meth($arg);
>>
>> uri
>>
> so does his:
Added the case you might be thinking of: ...??
#!/usr/bin/perl
use strict;
use warnings;
package Object;
sub new {
my $self = {};
bless $self;
}
sub method{
my $self = shift;
print "Object::method invoked on $self with args @_\n";
}
package DerivedObject;
our @ISA = qw/Object/;
sub new {
my $self = {};
bless $self;
}
sub method{
my $self = shift;
print "ObjectDerived::method invoked on $self with args @_\n";
}
package main;
my $object = Object->new;
my $object_derived = DerivedObject->new;
my $method_ref = $object->can('method');
my $method_name = 'method';
my @args = qw/foo bar/;
for ($object, $object_derived, 'nothing'){
$method_ref->($_,@args);
$_->$method_ref(@args); # function call
$_->$method_name(@args); # method call
$_->method(@args);
print "\n";
}
Christoph
--
perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"
------------------------------
Date: Thu, 15 Jun 2006 13:00:10 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Testing a new password
Message-Id: <150620061300106598%jgibson@mail.arc.nasa.gov>
In article <slrne935pv.i06.glennj@smeagol.ncf.ca>, Glenn Jackman
<glennj@ncf.ca> wrote:
> At 2006-06-15 12:40PM, Mark Drummond <mark@gangwarily.ca> wrote:
> > > Try:
> > > next unless $pass =~ /[[:lower]]/;
> > > or
> > > next if $pass !~ /[[:lower]]/;
> >
> > Sorry about that. I don't know if this is correct or not but my test
> > lines were actually:
> >
> > next if $pass =~ /[[:^lower:]]/;
>
> Which would reject the password if it contained a single non-lower case
> character. You probably had the same for [:^upper:] and [:^digit:]
>
> You might also test to accept passwords instead of rejecting them:
> while (1) {
> $pass = random_password();
> last if $pass =~ /[[:lower:]] and
> $pass =~ /[[:upper:]] and
> $pass =~ /[[:digit:]] ;
> }
For a slightly better approach, I would start the password with a
lowercase letter, an uppercase letter, and a digit, add as many
characters as need to meet the length requirement, and then do a random
shuffle of the characters. No testing required!
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Thu, 15 Jun 2006 23:23:06 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Testing a new password
Message-Id: <uZlkg.45309$A8.37783@clgrps12>
Mark Drummond wrote:
> I have a chunk of code that generates a random password form a specified
> set of characters. Once the password is generated I want to test it for
> certain characteristics and if it does not meet those characteristics
> then I want to toss it and start again. What I am working with looks
> something like (not necessarily correct code below!):
>
> sub newpass {
> my $pass
> my $badpass = 1;
> my $rand;
> my $passlen = $_[0];
> $passlen = 8 if !$passlen;
> my @chars = qw/ a b c ...
> A B C ...
> 0 1 2 ... /;
>
> while ($badpass == 1) {
> $pass = "";
> for (my $i=0; $i < $passlen; $i++) {
> $rand = int(rand $#chars+1);
> $pass .= $chars[$rand];
> }
> #
> # INSERT PASSWORD TESTS HERE
> #
> $badpass = 0;
> }
>
> return $pass
> }
>
> I wanted to do something like the following for my tests:
>
> # test for at least one lowercase char
> next if $pass =~ /[[:lower:]]/;
> # test for at least one uppercase char
> next if $pass =~ /[[:upper:]]/;
> # test for at least one digit
> next if $pass =~ /[[:digit:]]/;
>
> But my program just spins in an infinite loop. So clearly I have no idea
> what I am doing!!
>
> Any tips?!
$ perl -le'
sub newpass {
my $passlen = $_[ 0 ] || 8;
my @chars = ( q[a] .. q[z], q[A] .. q[Z], 0 .. 9 );
my $pass;
$pass = join q[], map $chars[ rand @chars ], 1 .. $passlen
until $pass =~ y/a-z// && $pass =~ y/A-Z// && $pass =~ y/0-9//;
$pass;
}
print newpass 10 for 1 .. 10;
'
SXH35wmcgG
besJUyjs4S
DLEiG9VrFI
teWFIT0U7U
ec3wODsDgk
K9JfO7swpB
5ptyCLRPAU
48w5T9qo7z
pC2aBddYSh
2tCYrE65Y6
John
--
use Perl;
program
fulfillment
------------------------------
Date: Thu, 15 Jun 2006 20:42:00 GMT
From: ed <ed@noreply.com>
Subject: Re: The Nature of the "Unix Philosophy" (long)
Message-Id: <20060615214243.7ed6c31b@localhost.localdomain>
On Wed, 14 Jun 2006 13:40:58 +0000 (UTC)
roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote:
> In article <128ut3uqitovuff@corp.supernews.com>,
> SM Ryan <wyrmwif@tango-sierra-oscar-foxtrot-tango.fake.org> wrote:
>
> ># Commercial software tends towards one huge tool that can be used
> >to
>
> >Except for Linux and BSD, Unix is commercial software.
>
> Linux is not UNIX. BSD isn't either.
>
> UNIX is a trademark of The Open Group (www.opengroup.org); see
> www.unix.org for OpenGroup's unix section.
Anyway SUS/POSIX is a better guide to the OS rather.
> No Linux or BSD systems have passed the UNIX certification programs.
Why would they want to? The BSD kernel is closer to what UNIX was than
it has become in the past decade. The Linux kernel has never tried to
be either.
--
Regards, Ed :: http://www.gnunix.net
just another c++ person
braaaaaaains....
------------------------------
Date: Thu, 15 Jun 2006 13:08:45 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: What am I missing in perlre
Message-Id: <slrne938hd.3uc.tadmc@magna.augustmail.com>
janfure@gmail.com <janfure@gmail.com> wrote:
> #!/usr/local/bin/perl -w
use warnings; # the modern way, much better than -w
> if ($_ =~ m/\D/x){
> This script does not do what I expected, the presence of the space in
> the string seems to cause a match with /\D/x,
Yes, because space _is_ a non-digit character.
> despite the 'x' modifier,
> which causes the regex engine to ignore MOST whitespace,
*in the pattern*. (not in the string that the pattern is to match against)
spaces are ignored in the _pattern_
m/ \D /x
is equivalent to writing the pattern the way you originally did.
The m//x modifier does not change the meaning of any of
the regex backslash escape shortcuts.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 15 Jun 2006 15:51:40 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Why doesn't chdir (@args) work?
Message-Id: <e6rvn0.1es.1@news.isolution.nl>
Tad McClellan schreef:
> If it wanted a list, it would have been
>
> chdir LIST
>
> (which doesn't make much sense of course, you can't have
> multiple working directories.
> )
Heheh, on winDOwS it can make sense, because you have a "working
directory" per disk letter.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Thu, 15 Jun 2006 22:19:56 GMT
From: Tim Hammerquist <penryu@saiyix.ath.cx>
Subject: Re: Why doesn't chdir (@args) work?
Message-Id: <slrne93n8c.2f2m.penryu@ruri.saiyix>
Dr.Ruud <rvtol+news@isolution.nl> wrote:
> Tad McClellan schreef:
>
>> If it wanted a list, it would have been
>>
>> chdir LIST
>>
>> (which doesn't make much sense of course, you can't have
>> multiple working directories.
>> )
>
> Heheh, on winDOwS it can make sense, because you have a "working
> directory" per disk letter.
It doesn't really work in practice.
C:\>copy con file.txt
This is C:
^Z
1 file(s) copied.
C:\>d:
D:\>copy con file.txt
This is D:
^Z
1 file(s) copied.
D:\>type file.txt
This is D:
D:\>perl -MCwd -e "print getcwd()"
D:/
D:\>
Cheers,
Tim Hammerquist
------------------------------
Date: Fri, 16 Jun 2006 00:46:00 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Why doesn't chdir (@args) work?
Message-Id: <e6sv0i.1fg.1@news.isolution.nl>
Dr.Ruud schreef:
> Tad McClellan:
>> If it wanted a list, it would have been
>>
>> chdir LIST
>>
>> (which doesn't make much sense of course, you can't have
>> multiple working directories.
>> )
>
> Heheh, on winDOwS it can make sense, because you have a "working
> directory" per disk letter.
See also perldoc Cwd, about get*d*cwd().
<q>
The getdcwd() function is also provided on Win32 to get the current
working directory on the specified drive, since Windows maintains a
separate current working directory for each drive. If no drive is
specified then the current drive is assumed.
</q>
And getdcwd() doesn't want nor returns a list either.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 9303
***************************************