[32442] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3709 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 8 16:09:19 2012

Date: Fri, 8 Jun 2012 13:09: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           Fri, 8 Jun 2012     Volume: 11 Number: 3709

Today's topics:
        calling graph for a Perl module jaialai.technology@gmail.com
    Re: Can I avoid 'Possible attempt to put comments in qw <nospam-abuse@ilyaz.org>
    Re: How can I type in input to a perl pgm that is eithe <dave@invalid.invalid>
        How can I type in input to a perl pgm that is either in <kquirici@yahoo.com>
    Re: How can I type in input to a perl pgm that is eithe <hSoPrAsMt@raSdPnAeMrs.de>
        Perl Developer <tekskills.aqil@gmail.com>
    Re: Problem with syntax getting array elements <rweikusat@mssgmbh.com>
        using Archive::Zip::MemberRead fails to find "opened" m <davidmichaelkarr@gmail.com>
    Re: using Archive::Zip::MemberRead fails to find "opene <bjoern@hoehrmann.de>
    Re: using Archive::Zip::MemberRead fails to find "opene <ben@morrow.me.uk>
    Re: using Archive::Zip::MemberRead fails to find "opene <davidmichaelkarr@gmail.com>
    Re: using Archive::Zip::MemberRead fails to find "opene <ben@morrow.me.uk>
    Re: using Archive::Zip::MemberRead fails to find "opene <rweikusat@mssgmbh.com>
    Re: using Archive::Zip::MemberRead fails to find "opene <ben@morrow.me.uk>
    Re: using Archive::Zip::MemberRead fails to find "opene <davidmichaelkarr@gmail.com>
    Re: using Archive::Zip::MemberRead fails to find "opene <ben@morrow.me.uk>
    Re: using Archive::Zip::MemberRead fails to find "opene <davidmichaelkarr@gmail.com>
    Re: using Archive::Zip::MemberRead fails to find "opene <jimsgibson@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 08 Jun 2012 14:54:24 -0400
From: jaialai.technology@gmail.com
Subject: calling graph for a Perl module
Message-Id: <2e5f2$4fd24a66$813f0835$24234@news.eurofeeds.com>

I am looking to present some code to a group of people and someone in
the group suggested that I show them a "calling graph" of the code.
This code is just a single module consisting of one .pm file.
Now, I figured I could just sketch out something in Visio
quickly enough. However, a Google search reveals some tools for automating
this sort of thing and creating the graph for me automatically.
The problem is that none of these seem to be able to restrict the
calling graph to just the functions within the namespace of the module.
All the functions located in the modules use()d by this one are included
and it the resulting graphic is just a giant mess.
Specifically I am thinking of the calling graph generated by NYTProf
or by Autodia. So, back to hand creating something in Visio...unless
someone here has a suggestion? Does anyone have a favorite way of
generating a calling graph or UML-ish diagram of a perl module
that restricts itself to just the function defined within that module?
Perhaps that is already possible with a tool that I tried but I somehow
missed how to do it?
Any advice?


------------------------------

Date: Thu, 7 Jun 2012 19:10:17 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Can I avoid 'Possible attempt to put comments in qw() list '?
Message-Id: <jqquap$n21$1@dont-email.me>

16-04-2012, Rainer Weikusat <rweikusat@mssgmbh.com> ÐÉÛÅÔ:
> Uri Guttman <uri@stemsystems.com> writes:
>> where did you get the idea you needed to escape # in qw? inside qw (and
>> usually in other q* things) the only thing that needs escaping is the
>> closing delimiter.
>
> This is not quite true: If 'the delimiters'(s) are 'some kind of
> [pairing] brackets' (at least (), {} and []), 'the closing delimiter'
> only needs to be escaped if it appears at the same nesting level as
> the opening delimiter, eg
>
> [rw@sapphire]~ $perl -e '$a = qw[[[]]\]]; print $a, "\n";'
> [[]]]

Essentially, this means that there are 3 characters which need to be
escaped: opening, closing and backslash.

    powdermilk:~->perl -wle 'print for qw[a \\[] b]'
    a
    \[]
    b
    powdermilk:~->perl -wle 'print for qw[a \[ b]'
    a
    [
    b
    powdermilk:~->perl -wle 'print for qw[a \] b]'
    a
    ]
    b

Thanks,
Ilya

P.S.  I was completely missing that this applies to q() and qw() as well...


------------------------------

Date: Fri, 8 Jun 2012 18:15:48 +0000 (UTC)
From: "Dave Saville" <dave@invalid.invalid>
Subject: Re: How can I type in input to a perl pgm that is either invisible or masked - i.e., for a password
Message-Id: <fV45K0OBJxbE-pn2-9z34QnEb34Ym@localhost>

On Fri, 8 Jun 2012 17:11:12 UTC, kquirici <kquirici@yahoo.com> wrote:

> The subject pretty much says it all. I want to write a perl program that accepts typed-in input except that the input is invisible or masked.
> 
> Any help MUCH appreciated.
> 

Well "perl input password" in google might be a good starting point 
:-)

-- 
Regards
Dave Saville


------------------------------

Date: Fri, 8 Jun 2012 10:11:12 -0700 (PDT)
From: kquirici <kquirici@yahoo.com>
Subject: How can I type in input to a perl pgm that is either invisible or masked - i.e., for a password
Message-Id: <c25b9e02-5d07-4195-9572-cc873da1e5d6@googlegroups.com>

The subject pretty much says it all. I want to write a perl program that accepts typed-in input except that the input is invisible or masked.

Any help MUCH appreciated.

Regards,

Ken


------------------------------

Date: Fri, 08 Jun 2012 20:15:01 +0200
From: "Horst-W. Radners" <hSoPrAsMt@raSdPnAeMrs.de>
Subject: Re: How can I type in input to a perl pgm that is either invisible or   masked - i.e., for a password
Message-Id: <jqtff5$p4e$1@online.de>

kquirici schrieb am 08.06.2012 19:11:
> The subject pretty much says it all. I want to write a perl program that accepts typed-in input except that the input is invisible or masked.

perldoc -q password

==> use Term::ReadKey

HTH, Horst
-- 
<remove S P A M 2x from my email address to get the real one>


------------------------------

Date: Thu, 7 Jun 2012 11:00:36 -0700 (PDT)
From: Aqil <tekskills.aqil@gmail.com>
Subject: Perl Developer
Message-Id: <c3167a0f-0357-4a7c-999a-0276b1a2b0e3@googlegroups.com>

Hi Partner,
Hope you are doing well!
Please let me know if you have any available consultant for the below posit=
ion.

Job Title: Perl Developer
Location: Newark, CA and and/or Maiden, NC 2-3 days per week (some travel m=
ight be required between the 2)
Duration: 6 months plus=20
Required Skills:
=95	At least 6-7 years of working experience as Perl Developer
=95	Strong Experience with Systems automation and Integration of software w=
ith existing systems
=95	Good Experience in Designing, coding, and debugging applications
=95	Good experience in Software testing and quality assurance
=95	Strong Web development experience in (JavaScript, ExtJS, JSON, Web serv=
ices, Apache, Tomcat, etc)
=95	Experience with Relational DB design, development, and administration (=
MySQL, Oracle, SQLite, etc.)
=95	Experience with Unix/Linux software development and administration
Preferred Skills:
Networking and Network Management experience is preferred (with CCNA, CCNP =
and/or working Cisco experience a big plus)
Java/J2EE Experience preferred
Strong presentation skills and track record with customer/stakeholder requi=
rements analysis and systems design

With Regards
Mohammed Aqil
732-640-1209
aqil@tekskillsinc.com


------------------------------

Date: Wed, 06 Jun 2012 14:22:26 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: Problem with syntax getting array elements
Message-Id: <87aa0glgml.fsf@sapphire.mobileactivedefense.com>

"Dave Saville" <dave@invalid.invalid> writes:
> my %h;
> $h{a} = [1,2,3];
> print $h{a}[2]."\n";
> my ($a, $b) = $h{a}[1,2];

The reason why this doesn't work is because the expression inside the
subscript ([]) is evaluated in scalar context in this case,
consequently, it's a comma-operator expression whose value is 2. In
order to denote a slice, a @ is needed in here.

	$h{a}[1,2]

is 'syntactic sugar' for

	$h{a}->[1,2]

which is, in turn, syntactic sugar for

	${$h{a}}[1,2]

but since you want an array slice, it should be
(as Tim Watts already posted)

	@{$h{a}}[1,2]

{{$h{a}} being a block which returns a reference of 'a suitable type'
for this expression.

If being unsure how perl 'sees' a specific expression, the Deparse
module can sometimes be helpful. For your code above, the output (perl
-MO=Deparse) is

	my %h;
	$h{'a'} = [1, 2, 3];
	print $h{'a'}[2] . "\n";
	my($a, $b) = $h{'a'}['???', 2];
	print "$a $b\n";


------------------------------

Date: Wed, 6 Jun 2012 15:17:13 -0700 (PDT)
From: David Karr <davidmichaelkarr@gmail.com>
Subject: using Archive::Zip::MemberRead fails to find "opened" method
Message-Id: <93977ab5-acc6-4892-80e0-a35299cb87a1@googlegroups.com>

I'm working on a script that can recursively examine archive files, so I'm =
using "Archive::Zip" along with "Archive::Zip::MemberRead".  I had original=
ly written it with just "Archive::Zip", and it was working fine, but I trie=
d to extend it to recursively examine the archive by adding "MemberRead".

I'm seeing the following error now:

Can't locate object method "opened" via package "Archive::Zip::MemberRead" =
at /usr/local/share/perl/5.14.2/Archive/Zip/Archive.pm line 570.

I tried adding in my script the various "File::" imports that are in "Archi=
ve.pm", but that made no difference.


------------------------------

Date: Thu, 07 Jun 2012 01:37:00 +0200
From: Bjoern Hoehrmann <bjoern@hoehrmann.de>
Subject: Re: using Archive::Zip::MemberRead fails to find "opened" method
Message-Id: <4aqvs71lunuah1r1d5088s55o40meg1s3v@hive.bjoern.hoehrmann.de>

* David Karr wrote in comp.lang.perl.misc:
>Subject: using Archive::Zip::MemberRead fails to find "opened" method

http://search.cpan.org/dist/Archive-Zip/lib/Archive/Zip/MemberRead.pm
does not seem to have any "opened" method, so you are probably calling
the wrong method, or the right method on the wrong object (or the wrong
method on the wrong object, if you want to be pedantic).
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 


------------------------------

Date: Thu, 7 Jun 2012 09:28:16 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: using Archive::Zip::MemberRead fails to find "opened" method
Message-Id: <0a56a9-esj.ln1@anubis.morrow.me.uk>


Quoth David Karr <davidmichaelkarr@gmail.com>:
> I'm working on a script that can recursively examine archive files, so
> I'm using "Archive::Zip" along with "Archive::Zip::MemberRead".  I had
> originally written it with just "Archive::Zip", and it was working fine,
> but I tried to extend it to recursively examine the archive by adding
> "MemberRead".
> 
> I'm seeing the following error now:
> 
> Can't locate object method "opened" via package
> "Archive::Zip::MemberRead" at
> /usr/local/share/perl/5.14.2/Archive/Zip/Archive.pm line 570.

That implies you are calling ->readFromFileHandle on an Archive. You
need to be calling ->readFileHandle on a Member; but this method won't
exist unless you

    use Archive::Zip::MemberRead;

> I tried adding in my script the various "File::" imports that are in
> "Archive.pm", but that made no difference.

Why on Earth would you do that?

Ben



------------------------------

Date: Thu, 7 Jun 2012 11:28:47 -0700 (PDT)
From: David Karr <davidmichaelkarr@gmail.com>
Subject: Re: using Archive::Zip::MemberRead fails to find "opened" method
Message-Id: <005af434-ab40-4a8b-b5c1-9e3915026d7d@googlegroups.com>

On Thursday, June 7, 2012 1:28:16 AM UTC-7, Ben Morrow wrote:
> Quoth David Karr <davidmichaelkarr@gmail.com>:
> > I'm working on a script that can recursively examine archive files, so
> > I'm using "Archive::Zip" along with "Archive::Zip::MemberRead".  I had
> > originally written it with just "Archive::Zip", and it was working fine,
> > but I tried to extend it to recursively examine the archive by adding
> > "MemberRead".
> > 
> > I'm seeing the following error now:
> > 
> > Can't locate object method "opened" via package
> > "Archive::Zip::MemberRead" at
> > /usr/local/share/perl/5.14.2/Archive/Zip/Archive.pm line 570.
> 
> That implies you are calling ->readFromFileHandle on an Archive. You
> need to be calling ->readFileHandle on a Member; but this method won't
> exist unless you
> 
>     use Archive::Zip::MemberRead;

Ok, based on that input, this is what I have so far.  It's not failing, but I don't think it's working properly either.  I ran this on an archive that has an archive which has an element I'm searching for, but it didn't find it.

sub processArchive($$$) {
    my ($zip, $match, $zipName) = @_;
    my @matchingList = $zip->membersMatching($match);
    my $len = @matchingList;
    if ($len > 0) {
	print $zipName . ":\n";
	if ($opt_list == 0) {
	    for my $member (@matchingList) {
		if ($opt_cat == 0) {
		    print $member->fileName() . getDetail($member) . "\n";
		}
		else {
		    print $member->fileName() . getDetail($member) . ":\n";
		    print $member->contents();
		}
	    }
	}
    }
    my @matchingArchiveList = $zip->membersMatching("\.jar");
    my $archivesLen = @matchingArchiveList;
    #print "archivesLen[" . $archivesLen . "]\n";
    if ($archivesLen > 0) {
	print "zipfile[" . $zipName . "]\n";
	for my $archiveMember (@matchingArchiveList) {
	    print "archiveMember[" . $archiveMember->fileName() . "]\n";
	    my $zipfh  = Archive::Zip::MemberRead->new($zip, $archiveMember);
	    my $archiveZip = Archive::Zip->new();
	    my $archiveStatus = $archiveMember->readFileHandle($zipfh);
	    print "archiveStatus[" . $archiveStatus . "]\n";
#	    if ($archiveStatus == AZ_OK) {
		processArchive($archiveZip, $entry, $zipName . ":" . $archiveMember->fileName());
#	    }
	}
    }
}

> 
> > I tried adding in my script the various "File::" imports that are in
> > "Archive.pm", but that made no difference.
> 
> Why on Earth would you do that?

Have you ever done anything that you knew didn't make any sense, but you didn't know what else to try?


------------------------------

Date: Thu, 7 Jun 2012 20:01:05 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: using Archive::Zip::MemberRead fails to find "opened" method
Message-Id: <hca7a9-5v5.ln1@anubis.morrow.me.uk>


Quoth David Karr <davidmichaelkarr@gmail.com>:
> On Thursday, June 7, 2012 1:28:16 AM UTC-7, Ben Morrow wrote:
> > Quoth David Karr <davidmichaelkarr@gmail.com>:
> > > I'm working on a script that can recursively examine archive files, so
> > > I'm using "Archive::Zip" along with "Archive::Zip::MemberRead".  I had
> > > originally written it with just "Archive::Zip", and it was working fine,
> > > but I tried to extend it to recursively examine the archive by adding
> > > "MemberRead".
> > > 
> > > I'm seeing the following error now:
> > > 
> > > Can't locate object method "opened" via package
> > > "Archive::Zip::MemberRead" at
> > > /usr/local/share/perl/5.14.2/Archive/Zip/Archive.pm line 570.
> > 
> > That implies you are calling ->readFromFileHandle on an Archive. You
> > need to be calling ->readFileHandle on a Member; but this method won't
> > exist unless you
> > 
> >     use Archive::Zip::MemberRead;
<snip>
> 
> 	for my $archiveMember (@matchingArchiveList) {
> 	    print "archiveMember[" . $archiveMember->fileName() . "]\n";
> 	    my $zipfh  = Archive::Zip::MemberRead->new($zip, $archiveMember);
> 	    my $archiveZip = Archive::Zip->new();
> 	    my $archiveStatus = $archiveMember->readFileHandle($zipfh);

Oh, I see now what you are doing: you did want

    my $archiveStatus = $archiveZip->readFromFileHandle($zipfh);

after all, but unfortunately it isn't going to work. AZ::MemberRead
doesn't give you a real filehandle: the object is neither a Perl
filehandle nor inherits from IO::Handle, so AZ can't read a zipfile from
it.

If you felt like it writing a tied-handle class (or a proper subclass of
IO::Handle) which read from an AZ::Member shouldn't be too difficult.
You would need to implement seeking by calling ->rewindData and then
reading forward, since AZ needs to be able to seek; you would also need
to count bytes read so as to return the correct value from tell. A tied
handle would probably be easiest: see perltie and Tie::Handle.

> > > I tried adding in my script the various "File::" imports that are in
> > > "Archive.pm", but that made no difference.
> > 
> > Why on Earth would you do that?
> 
> Have you ever done anything that you knew didn't make any sense, but you
> didn't know what else to try?

I have, but it never helps. Without understanding the cause of the
problem you've got no way of knowing you've fixed it, which means it'll
probably come back.

Ben



------------------------------

Date: Thu, 07 Jun 2012 20:04:43 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: using Archive::Zip::MemberRead fails to find "opened" method
Message-Id: <87d35b6j04.fsf@sapphire.mobileactivedefense.com>

Ben Morrow <ben@morrow.me.uk> writes:

[...]

>> > > I tried adding in my script the various "File::" imports that are in
>> > > "Archive.pm", but that made no difference.
>> > 
>> > Why on Earth would you do that?
>> 
>> Have you ever done anything that you knew didn't make any sense, but you
>> didn't know what else to try?
>
> I have, but it never helps. Without understanding the cause of the
> problem you've got no way of knowing you've fixed it, which means it'll
> probably come back.

You seem to live in a part of the universe where 'sales rep' "computer
experts" don't exist ...


------------------------------

Date: Thu, 7 Jun 2012 21:31:10 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: using Archive::Zip::MemberRead fails to find "opened" method
Message-Id: <elf7a9-sa6.ln1@anubis.morrow.me.uk>


Quoth Rainer Weikusat <rweikusat@mssgmbh.com>:
> Ben Morrow <ben@morrow.me.uk> writes:
> > Quoth David Karr <davidmichaelkarr@gmail.com>:
> >> 
> >> Have you ever done anything that you knew didn't make any sense, but you
> >> didn't know what else to try?
> >
> > I have, but it never helps. Without understanding the cause of the
> > problem you've got no way of knowing you've fixed it, which means it'll
> > probably come back.
> 
> You seem to live in a part of the universe where 'sales rep' "computer
> experts" don't exist ...

Well, I am fortunate enough not to need to have anything to do with
them, at least...

Ben



------------------------------

Date: Thu, 7 Jun 2012 14:26:48 -0700 (PDT)
From: David Karr <davidmichaelkarr@gmail.com>
Subject: Re: using Archive::Zip::MemberRead fails to find "opened" method
Message-Id: <20173cf0-5e2b-4de6-b92b-eeed3360b088@googlegroups.com>

On Thursday, June 7, 2012 12:01:05 PM UTC-7, Ben Morrow wrote:
> Quoth David Karr <davidmichaelkarr@gmail.com>:
> > On Thursday, June 7, 2012 1:28:16 AM UTC-7, Ben Morrow wrote:
> > > Quoth David Karr <davidmichaelkarr@gmail.com>:
> > > > I'm working on a script that can recursively examine archive files,=
 so
> > > > I'm using "Archive::Zip" along with "Archive::Zip::MemberRead".  I =
had
> > > > originally written it with just "Archive::Zip", and it was working =
fine,
> > > > but I tried to extend it to recursively examine the archive by addi=
ng
> > > > "MemberRead".
> > > >=20
> > > > I'm seeing the following error now:
> > > >=20
> > > > Can't locate object method "opened" via package
> > > > "Archive::Zip::MemberRead" at
> > > > /usr/local/share/perl/5.14.2/Archive/Zip/Archive.pm line 570.
> > >=20
> > > That implies you are calling ->readFromFileHandle on an Archive. You
> > > need to be calling ->readFileHandle on a Member; but this method won'=
t
> > > exist unless you
> > >=20
> > >     use Archive::Zip::MemberRead;
> <snip>
> >=20
> > 	for my $archiveMember (@matchingArchiveList) {
> > 	    print "archiveMember[" . $archiveMember->fileName() . "]\n";
> > 	    my $zipfh  =3D Archive::Zip::MemberRead->new($zip, $archiveMember)=
;
> > 	    my $archiveZip =3D Archive::Zip->new();
> > 	    my $archiveStatus =3D $archiveMember->readFileHandle($zipfh);
>=20
> Oh, I see now what you are doing: you did want
>=20
>     my $archiveStatus =3D $archiveZip->readFromFileHandle($zipfh);
>=20
> after all, but unfortunately it isn't going to work. AZ::MemberRead
> doesn't give you a real filehandle: the object is neither a Perl
> filehandle nor inherits from IO::Handle, so AZ can't read a zipfile from
> it.
>=20
> If you felt like it writing a tied-handle class (or a proper subclass of
> IO::Handle) which read from an AZ::Member shouldn't be too difficult.
> You would need to implement seeking by calling ->rewindData and then
> reading forward, since AZ needs to be able to seek; you would also need
> to count bytes read so as to return the correct value from tell. A tied
> handle would probably be easiest: see perltie and Tie::Handle.

That sounds more complicated than my backup plan, which is just to extract =
the member to a tempfile and then reading it as an archive.  I had already =
implemented that, as a result of responses to a related question I had aske=
d.  This mostly worked, but I noticed some situations where it didn't work,=
 so I thought I would return back to the hopefully more efficient mechanism=
 I asked about in this chain.  Now that I see this is more complicated than=
 I'm comfortable, I returned to try to fix the tempfile strategy, and I got=
 that working.

This is the key part of it:

	for my $archiveMember (@matchingArchiveList) {
	    #print "archiveMember[" . $archiveMember->fileName() . "]\n";
	    my $tempArchiveName =3D prepareTempFile();
	    #print "tempArchiveName[" . $tempArchiveName . "]\n";
	    $zip->extractMemberWithoutPaths($archiveMember, $tempArchiveName);
	    my $archiveZip =3D Archive::Zip->new();
	    my $archiveStatus =3D $archiveZip->read($tempArchiveName);
	    if ($archiveStatus =3D=3D AZ_OK) {
		processArchive($archiveZip, $entry, $zipName . ":" . $archiveMember->file=
Name());
		unlink($tempArchiveName);
	    }
	}

Again, this appears to work.  I'm sure this is likely a little slower than =
the other approach, but it's not noticeable for me, so it's good enough.

Do you see any problems with this approach?


------------------------------

Date: Fri, 8 Jun 2012 00:02:20 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: using Archive::Zip::MemberRead fails to find "opened" method
Message-Id: <sgo7a9-ci8.ln1@anubis.morrow.me.uk>


Quoth David Karr <davidmichaelkarr@gmail.com>:
> 
> This is the key part of it:
> 
> 	for my $archiveMember (@matchingArchiveList) {
> 	    #print "archiveMember[" . $archiveMember->fileName() . "]\n";
> 	    my $tempArchiveName = prepareTempFile();
> 	    #print "tempArchiveName[" . $tempArchiveName . "]\n";
> 	    $zip->extractMemberWithoutPaths($archiveMember, $tempArchiveName);
> 	    my $archiveZip = Archive::Zip->new();
> 	    my $archiveStatus = $archiveZip->read($tempArchiveName);
> 	    if ($archiveStatus == AZ_OK) {
> 		processArchive($archiveZip, $entry, $zipName . ":" .
> $archiveMember->fileName());
> 		unlink($tempArchiveName);

This unlink probably wants to be outside the if. If (say) the internal
zipfile is corrupted, and can't be read, you still need to clean up the
tempfile.

> 	    }
> 	}
> 
> Again, this appears to work.  I'm sure this is likely a little slower
> than the other approach, but it's not noticeable for me, so it's good
> enough.
> 
> Do you see any problems with this approach?

No, it looks entirely sensible.

Ben



------------------------------

Date: Fri, 8 Jun 2012 08:55:03 -0700 (PDT)
From: David Karr <davidmichaelkarr@gmail.com>
Subject: Re: using Archive::Zip::MemberRead fails to find "opened" method
Message-Id: <4532efe9-268f-4b96-ae9d-aa5aa582173f@googlegroups.com>

On Thursday, June 7, 2012 4:02:20 PM UTC-7, Ben Morrow wrote:
> Quoth David Karr <davidmichaelkarr@gmail.com>:
> >=20
> > This is the key part of it:
> >=20
> > 	for my $archiveMember (@matchingArchiveList) {
> > 	    #print "archiveMember[" . $archiveMember->fileName() . "]\n";
> > 	    my $tempArchiveName =3D prepareTempFile();
> > 	    #print "tempArchiveName[" . $tempArchiveName . "]\n";
> > 	    $zip->extractMemberWithoutPaths($archiveMember, $tempArchiveName);
> > 	    my $archiveZip =3D Archive::Zip->new();
> > 	    my $archiveStatus =3D $archiveZip->read($tempArchiveName);
> > 	    if ($archiveStatus =3D=3D AZ_OK) {
> > 		processArchive($archiveZip, $entry, $zipName . ":" .
> > $archiveMember->fileName());
> > 		unlink($tempArchiveName);
>=20
> This unlink probably wants to be outside the if. If (say) the internal
> zipfile is corrupted, and can't be read, you still need to clean up the
> tempfile.

I was thinking about that, but I assume that it would fail if the file didn=
't actually get created?  I figured I would need some sort of exception han=
dling to do that cleanly (of course, if that was really important, I probab=
ly should have already been doing that).  I'm not very familiar with how Pe=
rl does exception handling.


------------------------------

Date: Fri, 08 Jun 2012 10:34:24 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: using Archive::Zip::MemberRead fails to find "opened" method
Message-Id: <080620121034245621%jimsgibson@gmail.com>

In article <4532efe9-268f-4b96-ae9d-aa5aa582173f@googlegroups.com>,
David Karr <davidmichaelkarr@gmail.com> wrote:

> On Thursday, June 7, 2012 4:02:20 PM UTC-7, Ben Morrow wrote:

> > 
> > This unlink probably wants to be outside the if. If (say) the internal
> > zipfile is corrupted, and can't be read, you still need to clean up the
> > tempfile.
> 
> I was thinking about that, but I assume that it would fail if the file didn't
> actually get created?  I figured I would need some sort of exception handling
> to do that cleanly (of course, if that was really important, I probably
> should have already been doing that).  I'm not very familiar with how Perl does exception handling.

It generally just keeps going. unlink will return false and set $! to
an error number and message. That is typical. You can ignore the error,
as you have done.

-- 
Jim Gibson


------------------------------

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 3709
***************************************


home help back first fref pref prev next nref lref last post