[30840] in Perl-Users-Digest
Perl-Users Digest, Issue: 2085 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 30 03:10:06 2008
Date: Tue, 30 Dec 2008 00:09:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 30 Dec 2008 Volume: 11 Number: 2085
Today's topics:
Re: data access for a hash inside a Perl object <nospam-abuse@ilyaz.org>
hash table usage questions <freesoft12@gmail.com>
Re: hash table usage questions sln@netherlands.com
Re: hash table usage questions <tim@burlyhost.com>
Re: hash table usage questions <tadmc@seesig.invalid>
Re: hash table usage questions <uri@stemsystems.com>
new CPAN modules on Tue Dec 30 2008 (Randal Schwartz)
Re: searching for franken sln@netherlands.com
Re: searching for franken <george@example.invalid>
Re: searching for franken <george@example.invalid>
system("pushd $dir") doesn't work <jrwats@gmail.com>
Re: system("pushd $dir") doesn't work <jurgenex@hotmail.com>
Re: system("pushd $dir") doesn't work <tim@burlyhost.com>
Re: Unit test that checks for "croak" <uri@stemsystems.com>
Re: Unit test that checks for "croak" <rvtol+usenet@isolution.nl>
Re: Unit test that checks for "croak" sln@netherlands.com
Re: Unit test that checks for "croak" <tim@burlyhost.com>
Re: Unit test that checks for "croak" <tadmc@seesig.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 30 Dec 2008 03:04:30 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: data access for a hash inside a Perl object
Message-Id: <gjc33u$11a4$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
freesoft12@gmail.com
<freesoft12@gmail.com>], who wrote in article <7da4bb4b-afd9-4b7c-8b6e-d628e235fa7f@y1g2000pra.googlegroups.com>:
> This is the first time I've read "perllexwarn.pod". It says that '-w'
> switch switches on the warnings in all modules. This might not be
> helpful if I am including third-party modules.
In my experience, the only situation when -w is not helpful is if both
of the following conditions hold:
a) I trust the 3rd party module writers that their code is correct;
b) I know that the code of these modules is wrong (at least warning-wise).
Given that these restriction are more or less contradictory, I do not
encounter this situation often...
I see a lot of use for `no warnings "foo"'. I see very little use for
`use warnings' (only inside modules to enable warnings "no matter what";
but this may be too offensive when user's interests taken into account...).
Hope this helps,
Ilya
------------------------------
Date: Mon, 29 Dec 2008 17:02:56 -0800 (PST)
From: "freesoft12@gmail.com" <freesoft12@gmail.com>
Subject: hash table usage questions
Message-Id: <e795e871-0427-4753-8ae7-79d92785ae15@b41g2000pra.googlegroups.com>
Hi,
I am storing a large number of file paths into a hash table's keys (to
avoid duplicate paths) with well-known extensions
like .cc, .cpp, .h,.hpp. If any of the paths is a symbolic link then
the link is stored in the value field.
My questions are:
1) Is a custom data structure better than using a hash to store the
file paths?
2) I want to remove some of the files from the hash table that don't
match a regular expression (say I am only interested in *.cc files)
a) Is there a smart way to apply this regular expression on the
hash table? My current solution iterates over each item in the hash
table and then stores the keys that don't match the regex in a
separate list. I then iterate over that list and remove each key from
the hash table.
3) Does Perl allocate new memory if I were to copy the keys (paths) in
the hash table into a list or is a reference just copied?
Regards
John
------------------------------
Date: Tue, 30 Dec 2008 01:34:43 GMT
From: sln@netherlands.com
Subject: Re: hash table usage questions
Message-Id: <q9uil4998odkl99873jsbqjbo4oqmf576e@4ax.com>
On Mon, 29 Dec 2008 17:02:56 -0800 (PST), "freesoft12@gmail.com" <freesoft12@gmail.com> wrote:
>Hi,
>
>I am storing a large number of file paths into a hash table's keys (to
>avoid duplicate paths) with well-known extensions
>like .cc, .cpp, .h,.hpp. If any of the paths is a symbolic link then
>the link is stored in the value field.
>
>My questions are:
>
>1) Is a custom data structure better than using a hash to store the
>file paths?
>
>2) I want to remove some of the files from the hash table that don't
>match a regular expression (say I am only interested in *.cc files)
> a) Is there a smart way to apply this regular expression on the
>hash table? My current solution iterates over each item in the hash
>table and then stores the keys that don't match the regex in a
>separate list. I then iterate over that list and remove each key from
>the hash table.
>
>3) Does Perl allocate new memory if I were to copy the keys (paths) in
>the hash table into a list or is a reference just copied?
^^^^^^^^^^^^^
>
>Regards
>John
Why don't you clearly state what your trying to do instead of grabbing
straws and spewing all the buzzwords in the book.
You obviously need to learn Perl from the beginner position.
You seem to wan't somebody to not only write the code for you, but
provide documentation. As it is now, you exhibit knowledge below what is
necessary to understand a solution should one be provided.
Not alot of people want to do your work and not get paid for it.
Can you do my work for me?
sln
------------------------------
Date: Mon, 29 Dec 2008 19:33:25 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: hash table usage questions
Message-Id: <aEg6l.23752$701.3874@newsfe12.iad>
freesoft12@gmail.com wrote:
> Hi,
>
> I am storing a large number of file paths into a hash table's keys (to
> avoid duplicate paths) with well-known extensions
> like .cc, .cpp, .h,.hpp. If any of the paths is a symbolic link then
> the link is stored in the value field.
>
> My questions are:
>
> 1) Is a custom data structure better than using a hash to store the
> file paths?
By the sound of it, hashes might be fine. How are you originally
gathering the data to process (to obtain the paths), and exactly how
many are there? To avoid duplicates, hashes can be great for checking
that sort of thing.
> 2) I want to remove some of the files from the hash table that don't
> match a regular expression (say I am only interested in *.cc files)
You can easily do that.
> a) Is there a smart way to apply this regular expression on the
> hash table?
You'd probably want to determine if it's something you want before
adding to the hash in the first place. How are you going about
creating/populating the hash?
> My current solution iterates over each item in the hash
> table and then stores the keys that don't match the regex in a
> separate list. I then iterate over that list and remove each key from
> the hash table.
Can you provide the relevant portions of your code? You probably don't
need to iterate over anything, especially if you have a hash value
saved or rejected based upon the logistical conditions you mentioned
with an example above.
> 3) Does Perl allocate new memory if I were to copy the keys (paths) in
> the hash table into a list or is a reference just copied?
By the sound of it, you shouldn't need to store anything you don't want
to, or copy any keys, but I may have misunderstood? If you have
duplicate keys/another hash, it will use that much more memory. Maybe
I don't understand what you're asking?
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Mon, 29 Dec 2008 22:38:45 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: hash table usage questions
Message-Id: <slrnglj9el.9qv.tadmc@tadmc30.sbcglobal.net>
freesoft12@gmail.com <freesoft12@gmail.com> wrote:
> I am storing a large number of file paths into a hash table's keys (to
> avoid duplicate paths)
> 2) I want to remove some of the files from the hash table that don't
> match a regular expression (say I am only interested in *.cc files)
> a) Is there a smart way to apply this regular expression on the
> hash table?
%h = map /\.cc$/
? ($_, $h{$_})
: (),
keys %h;
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Tue, 30 Dec 2008 01:17:16 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: hash table usage questions
Message-Id: <x7myeei3v7.fsf@stemsystems.com>
>>>>> "TJM" == Tad J McClellan <tadmc@seesig.invalid> writes:
TJM> freesoft12@gmail.com <freesoft12@gmail.com> wrote:
>> 2) I want to remove some of the files from the hash table that don't
>> match a regular expression (say I am only interested in *.cc files)
>> a) Is there a smart way to apply this regular expression on the
>> hash table?
TJM> %h = map /\.cc$/
TJM> ? ($_, $h{$_})
TJM> : (),
TJM> keys %h;
delete @h{ grep !/\.cc$/, keys %h } ;
that's a bit simpler IMO and definitely should be faster. it also uses
delete with a hash slice which is a combo that should be more well
known.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Tue, 30 Dec 2008 05:42:23 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Tue Dec 30 2008
Message-Id: <KCoD6n.nCH@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Apache2-Response-FileMerge-0.29
http://search.cpan.org/~wazzuteke/Apache2-Response-FileMerge-0.29/
Merge and include static client-side style and code
----
Apache2-WURFLFilter-1.1
http://search.cpan.org/~ifuschini/Apache2-WURFLFilter-1.1/
is a Apache Mobile Filter that manage content (text & image) to the correct mobile device
----
Audio-Ecasound-Multitrack-0.975
http://search.cpan.org/~ganglion/Audio-Ecasound-Multitrack-0.975/
Perl extensions for multitrack audio processing
----
Beanstalk-Client-1.04
http://search.cpan.org/~gbarr/Beanstalk-Client-1.04/
Client class to talk to beanstalkd server
----
Bio-Graphics-1.82
http://search.cpan.org/~lds/Bio-Graphics-1.82/
Generate GD images of Bio::Seq objects
----
CPAN-Testers-Data-Generator-0.33
http://search.cpan.org/~barbie/CPAN-Testers-Data-Generator-0.33/
Download and summarize CPAN Testers data
----
Catalyst-Plugin-HashedCookies-1.04
http://search.cpan.org/~oliver/Catalyst-Plugin-HashedCookies-1.04/
Tamper-resistant HTTP Cookies
----
Compress-LZF-3.43
http://search.cpan.org/~mlehmann/Compress-LZF-3.43/
extremely light-weight Lempel-Ziv-Free compression
----
Crypt-Skip32-0.09
http://search.cpan.org/~esh/Crypt-Skip32-0.09/
32-bit block cipher based on Skipjack
----
Crypt-Skip32-0.10
http://search.cpan.org/~esh/Crypt-Skip32-0.10/
32-bit block cipher based on Skipjack
----
Crypt-Skip32-0.11
http://search.cpan.org/~esh/Crypt-Skip32-0.11/
32-bit block cipher based on Skipjack
----
Crypt-Skip32-XS-0.03
http://search.cpan.org/~gray/Crypt-Skip32-XS-0.03/
Drop-in replacement for Crypt::Skip32
----
Data-All-0.04
http://search.cpan.org/~delano/Data-All-0.04/
Access to data in many formats source many places
----
Data-All-0.041
http://search.cpan.org/~delano/Data-All-0.041/
Access to data in many formats source many places
----
Data-All-0.042
http://search.cpan.org/~delano/Data-All-0.042/
Access to data in many formats source many places
----
DateTime-Lite-0.00001_01
http://search.cpan.org/~dmaki/DateTime-Lite-0.00001_01/
A Low Calorie DateTime
----
GBrowse-1.981
http://search.cpan.org/~lds/GBrowse-1.981/
----
GBrowse-1.982
http://search.cpan.org/~lds/GBrowse-1.982/
----
GPS-Point-0.10
http://search.cpan.org/~mrdvt/GPS-Point-0.10/
Provides an object interface for a GPS point.
----
Graph-0.90
http://search.cpan.org/~jhi/Graph-0.90/
graph data structures and algorithms
----
HtmlUnit-0.01
http://search.cpan.org/~awwaiid/HtmlUnit-0.01/
Java::Inline based wrapper of the HtmlUnit library
----
Ipernity-API-0.06
http://search.cpan.org/~wneessen/Ipernity-API-0.06/
Perl interface to the Ipernity API
----
Locale-Country-Multilingual-0.21
http://search.cpan.org/~graf/Locale-Country-Multilingual-0.21/
mapping ISO codes to localized country names
----
MooseX-Emulate-Class-Accessor-Fast-0.00700
http://search.cpan.org/~groditi/MooseX-Emulate-Class-Accessor-Fast-0.00700/
Emulate Class::Accessor::Fast behavior using Moose attributes
----
Net-Abuse-Utils-0.10
http://search.cpan.org/~mikegrb/Net-Abuse-Utils-0.10/
Routines useful for processing network abuse
----
Padre-Plugin-Perl6-0.014
http://search.cpan.org/~azawawi/Padre-Plugin-Perl6-0.014/
Padre plugin for Perl6
----
Parse-ABNF-0.03
http://search.cpan.org/~bjoern/Parse-ABNF-0.03/
Parse IETF Augmented BNF (ABNF) grammars.
----
Parse-ABNF-0.04
http://search.cpan.org/~bjoern/Parse-ABNF-0.04/
Parse IETF Augmented BNF (ABNF) grammars.
----
Pod-IkiWiki-0.0.4
http://search.cpan.org/~vmoral/Pod-IkiWiki-0.0.4/
Pod translator to IkiWiki's Markdown format
----
Pod-Manual-0.08_04
http://search.cpan.org/~yanick/Pod-Manual-0.08_04/
Aggregates several PODs into a single manual
----
Simo-0.0205
http://search.cpan.org/~kimoto/Simo-0.0205/
Very simple framework for Object Oriented Perl.
----
Storable-AMF-0.38
http://search.cpan.org/~grian/Storable-AMF-0.38/
Perl extension for serialize/deserialize AMF0/AMF3 data
----
Switch-2.14
http://search.cpan.org/~rgarcia/Switch-2.14/
A switch statement for Perl
----
Syntax-Highlight-Perl6-0.0296
http://search.cpan.org/~azawawi/Syntax-Highlight-Perl6-0.0296/
Perl 6 Syntax Highlighter
----
Syntax-Highlight-Perl6-0.02961
http://search.cpan.org/~azawawi/Syntax-Highlight-Perl6-0.02961/
Perl 6 Syntax Highlighter
----
Task-Padre-Plugins-0.08
http://search.cpan.org/~azawawi/Task-Padre-Plugins-0.08/
Get many Plugins of Padre at once
----
XML-Compile-0.99
http://search.cpan.org/~markov/XML-Compile-0.99/
Compilation based XML processing
----
XML-Compile-Cache-0.14
http://search.cpan.org/~markov/XML-Compile-Cache-0.14/
Cache compiled XML translators
----
XML-Compile-SOAP-2.00_01
http://search.cpan.org/~markov/XML-Compile-SOAP-2.00_01/
base-class for SOAP implementations
----
YAML-Logic-0.01
http://search.cpan.org/~mschilli/YAML-Logic-0.01/
Simple boolean logic in YAML
----
sapnwrfc-0.24
http://search.cpan.org/~delano/sapnwrfc-0.24/
SAP Netweaver RFC support for Perl
----
sapnwrfc-0.24
http://search.cpan.org/~piers/sapnwrfc-0.24/
SAP Netweaver RFC support for Perl
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Mon, 29 Dec 2008 23:18:23 GMT
From: sln@netherlands.com
Subject: Re: searching for franken
Message-Id: <ncmil4t5nijeu31gbticccf894jd29lfe1@4ax.com>
On Mon, 29 Dec 2008 15:37:19 -0700, George <george@example.invalid> wrote:
>On Mon, 29 Dec 2008 11:11:36 +0100, Mirco Wahab wrote:
>
>
>> There is a module called LWP::Simple
>> http://search.cpan.org/~gaas/libwww-perl-5.822/lib/LWP/Simple.pm
>>
>> which does exactly that, example:
>>
>> ...
>>
>> use LWP::Simple;
>>
>> my $url = 'www.co-array.org';
>> my $html = get 'http://' . $url;
>>
>> my $what = qr'distributed.*?memory|Numerid.*?Ried|OpenMP';
>>
>> while($html =~ /$what/mg) { # note the /m modifier
>> print '...' . substr($html, pos($html)-20, 40) . "...\n"
>> }
>>
>> ...
>>
>> If you need to pass headers and cookies to the
>> site, please study the other libwww functions
>> (http://search.cpan.org/~gaas/libwww-perl-5.822/lib/Net/HTTP.pm)
>
># shebang doesn't work on windows
>
>use strict;
>use warnings;
>
>use Net::HTTP;
>use LWP::Simple;
>
>my $url = 'www.co-array.org';
>my $html = get 'http://' . $url;
>
>my $what = qr'distributed.*?memory|Numerid.*?Ried|OpenMP';
>
>while($html =~ /$what/mg) { # note the /m modifier
> print '...' . substr($html, pos($html)-20, 40) . "...\n"
> }
>
> my $s = Net::HTTP->new(Host => "www.co-array.org") || die $@;
> $s->write_request(GET => "/", 'User-Agent' => "Mozilla/5.0");
> my($code, $mess, %h) = $s->read_response_headers;
>
> while (1) {
> my $buf;
> my $n = $s->read_entity_body($buf, 1024);
> die "read failed: $!" unless defined $n;
> last unless $n;
> print $buf;
> }
>
>
># perl wahab3.pl
>
># end script begin abridged output
>
>C:\MinGW\source>perl wahab3.pl
>...n distributed memory machines but also o...
>...ranslate into OpenMP Fortran</A>
> ...
>...ay Fortran to OpenMP Fortran translator<...
>...uivalent SPMD OpenMP Fortran 90/95 progr...
>...w.openmp.org">OpenMP Fortran</A> compile...
>...tectures
>than OpenMP Fortran, programs s...
>...anslated into OpenMP as part of the comp...
>...ntrinsics for OpenMP is bundled with the...
>...anslates into OpenMP Fortran.
> <L...
>...mp99.ps">SPMD OpenMP vs MPI for Ocean Mo...
>...y Fortran and OpenMP Fortran for SPMD Pr...
><HTML>
><HEAD>
><TITLE>Co-Array Fortran</TITLE>
><LINK REL="shortcut icon" HREF="favicon.ico" />
></HEAD>
>
><BODY BACKGROUND="" BGCOLOR="#ffff99" TEXT="#000000" LINK="#0000ff"
>VLINK="#8000
>00" ALINK="#ff0000">
>
><HR WIDTH="30%" ALIGN=CENTER>
><CENTER><B><H1>Co-Array Fortran</H1></B></CENTER>
><HR WIDTH="30%" ALIGN=CENTER>
>
> <P>
>Co-array Fortran is a small extension to
>Fortran 95.
>
># end abridged output
>
>Wow, Mirco, with a little guidance, a person can go from square one to
>cruising speed *so quickly*. I think this gives me the tools I need to
>move my token forward. Thanks so much.
>
>>
>> or copy/paste the complete http query from your browser
>> and send it via IO::Socket::INET.
>>
>> Regards
>>
>> M.
>
>Do you mean that I would use the mouse or imitate the events?
This is no more than grabbing html and searching for patterns using
regexp withing it. The result is not something neither reliable nor
formattable. You will still have to parse it before searches.
No parsing, no reliable content. Its still a mixed bag of junk.
sln
------------------------------
Date: Mon, 29 Dec 2008 22:44:51 -0700
From: George <george@example.invalid>
Subject: Re: searching for franken
Message-Id: <tbnyuvuee8vy.1ft4vrqlsqu7j$.dlg@40tude.net>
On Mon, 29 Dec 2008 23:18:23 GMT, sln@netherlands.com wrote:
> This is no more than grabbing html and searching for patterns using
> regexp withing it. The result is not something neither reliable nor
> formattable. You will still have to parse it before searches.
> No parsing, no reliable content. Its still a mixed bag of junk.
I tried to address this issue with the following:
# shebang doesn't work on windows
use strict;
use warnings;
use LWP::Simple;
use HTML::Parser;
use HTML::FormatText;
my ($html, $ascii);
$html = get("http://www.co-array.com/");
defined $html
or die "Can't fetch HTML from http://www.perl.com/";
$ascii = HTML::FormatText->new->format(parse_html($html));
print $ascii;
# perl wahab4.pl
This yields:
C:\MinGW\source>perl wahab4.pl
Can't locate HTML/FormatText.pm in @INC (@INC contains: C:/Perl/site/lib
C:/Perl
/lib .) at wahab4.pl line 7.
BEGIN failed--compilation aborted at wahab4.pl line 7.
C:\MinGW\source>
Unfortunately, I get no matches when I search for Format in the PPM for
activestate, which sounds unlikely but clearly indicates that I'm over my
head.
--
George
This way of life is worth defending.
George W. Bush
Picture of the Day http://apod.nasa.gov/apod/
------------------------------
Date: Mon, 29 Dec 2008 23:10:52 -0700
From: George <george@example.invalid>
Subject: Re: searching for franken
Message-Id: <1iez5cl1yqviw$.1o2ixf6vqsvy7.dlg@40tude.net>
On Mon, 29 Dec 2008 08:07:39 -0600, Tad J McClellan wrote:
> Mirco Wahab <wahab-mail@gmx.de> wrote:
>> George wrote:
>
>>> I would like to test whether
>>> http://www.co-array.org/
>>> contains the following words:
>>> distributed memory
>>> Numerid Ried
>>> OpenMP
>
>
>> my $what = qr'distributed.*?memory|Numerid.*?Ried|OpenMP';
>>
>> while($html =~ /$what/mg) { # note the /m modifier
>
>
> Note that the /m modifier does absolutely nothing for the pattern
> being used, and so is not needed at all.
>
> You probably meant the /s modifier instead?
I think this is a significant issue and is where I'm stumbling right now:
# shebang doesn't work on windows
use strict;
use warnings;
use Net::HTTP;
use LWP::Simple;
my $url = 'www.alfrankensense.com/al_franken_quotes.html';
my $html = get 'http://' . $url;
#my $what = qr'*?-Al*?';
my $what = qr'distributed.*?memory|Al.*?Franken|OpenMP';
while($html =~ /$what/mg) { # note the /m modifier
print '...' . substr($html, pos($html)0, 40) . "...\n"
}
# perl wahab5.pl
I've tried /m /s /mg and struck out.
This is the page that I want to work on. Ultimately, I want the quotes to
be of the form where dialog can use them as randomquotes, which is:
I believe the most solemn duty of the American president is to protect the
American people. If America shows uncertainty and weakness in this decade,
the world will drift toward tragedy. This will not happen on my watch.
George W. Bush
%
I can hear you, the rest of the world can hear you and the people who
knocked these buildings down will hear all of us soon.
George W. Bush
%
I have a different vision of leadership. A leadership is someone who brings
people together.
George W. Bush
%
I just want you to know that, when we talk about war, we're really talking
about peace.
George W. Bush
--
George
The thing that's wrong with the French is that they don't have a word for
entrepreneur.
George W. Bush
Picture of the Day http://apod.nasa.gov/apod/
------------------------------
Date: Mon, 29 Dec 2008 18:56:35 -0800 (PST)
From: jrwats <jrwats@gmail.com>
Subject: system("pushd $dir") doesn't work
Message-Id: <ff0841d2-69fe-4774-995a-253fb46e9763@o40g2000prn.googlegroups.com>
Can this not work within a perl script? I'm running the program from
a windows cmd.exe command prompt.
also tried `pushd $dir`
and system("pushd", $dir);
------------------------------
Date: Mon, 29 Dec 2008 19:23:08 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: system("pushd $dir") doesn't work
Message-Id: <tq4jl4tirt59mvf4rm5t90q6a4r89movau@4ax.com>
jrwats <jrwats@gmail.com> wrote:
>Can this not work within a perl script? I'm running the program from
>a windows cmd.exe command prompt.
>
>also tried `pushd $dir`
>and system("pushd", $dir);
Of course it works, it's just not very useful.
Your code (any of the versions) creates a new process, runs pushd in
that process, and then terminates the process, thus throwing away the
effects of pushd.
What were you actually trying to achieve with that code?
jue
------------------------------
Date: Mon, 29 Dec 2008 19:27:43 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: system("pushd $dir") doesn't work
Message-Id: <Pyg6l.23749$701.13975@newsfe12.iad>
jrwats wrote:
> Can this not work within a perl script? I'm running the program from
> a windows cmd.exe command prompt.
>
> also tried `pushd $dir`
> and system("pushd", $dir);
Can you explain how this isn't working for you? Can you show the
relevant portion of the code you're using this within and what you are
trying to accomplish? Have you considered looking at the File::pushd
module? (I think there is one, but I could be wrong? If so, disregard
that portion of my reply).
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Mon, 29 Dec 2008 19:19:32 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Unit test that checks for "croak"
Message-Id: <x7ocyujyzv.fsf@stemsystems.com>
>>>>> "fc" == freesoft12@gmail com <freesoft12@gmail.com> writes:
fc> I have a module that calls 'croak' if the input argument to my
fc> function is wrong. I want to write a unit test that tests if 'croak'
fc> is called when I give a bad input.
croak is just a wrapper around die so catch the die with a block eval.
fc> $path = '../c'; # bad input. a fail/negative test
fc> # how can write a 'ok()' or 'is()' that checks that 'croak' function
fc> is called
fc> # ok(deleteDoubleDotsInPath(\$path));
first call the code in a block eval and then check if $@ is set (which
means the code called die somewhere). <untested>
eval { deleteDoubleDotsInPath(\$path) } ;
ok( !$@, 'delete double dots' ) ;
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Tue, 30 Dec 2008 01:44:48 +0100
From: "Dr.Ruud" <rvtol+usenet@isolution.nl>
Subject: Re: Unit test that checks for "croak"
Message-Id: <49596f01$0$199$e4fe514c@news.xs4all.nl>
Uri Guttman wrote:
> first call the code in a block eval and then check if $@ is set (which
> means the code called die somewhere). <untested>
>
> eval { deleteDoubleDotsInPath(\$path) } ;
>
> ok( !$@, 'delete double dots' ) ;
I promote to test the return value of eval.
eval {
deleteDoubleDotsInPath( \$path) };
1;
}
or do {
$@ ||= "unknown error";
...
};
--
Ruud
------------------------------
Date: Tue, 30 Dec 2008 01:37:18 GMT
From: sln@netherlands.com
Subject: Re: Unit test that checks for "croak"
Message-Id: <rnuil4pv3gd3b9p7qeqibhbtmqp3fl3sk6@4ax.com>
On Tue, 30 Dec 2008 01:44:48 +0100, "Dr.Ruud" <rvtol+usenet@isolution.nl> wrote:
>Uri Guttman wrote:
>
>> first call the code in a block eval and then check if $@ is set (which
>> means the code called die somewhere). <untested>
>>
>> eval { deleteDoubleDotsInPath(\$path) } ;
>>
>> ok( !$@, 'delete double dots' ) ;
>
>I promote to test the return value of eval.
^^^^^^^
what do you mean?
>
> eval {
> deleteDoubleDotsInPath( \$path) };
> 1;
> }
> or do {
> $@ ||= "unknown error";
^^^
what does this do?
> ...
> };
sln
------------------------------
Date: Mon, 29 Dec 2008 18:01:00 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Unit test that checks for "croak"
Message-Id: <whf6l.26643$wV2.15900@newsfe07.iad>
sln@netherlands.com wrote:
> On Tue, 30 Dec 2008 01:44:48 +0100, "Dr.Ruud"
> <rvtol+usenet@isolution.nl> wrote:
>
>>Uri Guttman wrote:
>>
>>> first call the code in a block eval and then check if $@ is set
>>> (which means the code called die somewhere). <untested>
>>>
>>> eval { deleteDoubleDotsInPath(\$path) } ;
>>>
>>> ok( !$@, 'delete double dots' ) ;
>>
>>I promote to test the return value of eval.
> ^^^^^^^
> what do you mean?
Probably he promotes that method of doing it, unless it meant propose.
>>
>> eval {
>> deleteDoubleDotsInPath( \$path) };
>> 1;
>> }
>> or do {
>> $@ ||= "unknown error";
> ^^^
> what does this do?
Principal Skinner -- A conjunction meaning "in the event that" or "on
condition of".
(I know that doesn't apply. Sorry, I couldn't help it.)
The ||= is just an assignment operator (give it a (probably default)
value, if it doesn't already exist).
It will assign $@ the value 'unknown error' if it doesn't have a value
already.
(defined are to allow or ignore the zero value, otherwise use without
defined if that suits your needs)
I.e., $@ is $@ (defined) or else 'unknown error'.
I.e., $@ = $@ || 'unknown error'.
I.e., $@ = 'unknown error' if ! defined $@.
I.e., $@ = 'unknown error' unless defined $@.
I.e., if (a conjunction meaning "in the event that") $@ is undefined,
that 'unknown error' will be the assigned value.
... or, were you asking something else?
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Mon, 29 Dec 2008 22:48:45 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Unit test that checks for "croak"
Message-Id: <slrnglja1d.9qv.tadmc@tadmc30.sbcglobal.net>
sln@netherlands.com <sln@netherlands.com> wrote:
> On Tue, 30 Dec 2008 01:44:48 +0100, "Dr.Ruud" <rvtol+usenet@isolution.nl> wrote:
>> $@ ||= "unknown error";
> ^^^
> what does this do?
The same as this does:
$@ = $@ || "unknown error";
Just as
$num += 1;
does the same as this:
$num = $num + 1;
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
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 V11 Issue 2085
***************************************