[19004] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1199 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 26 18:06:41 2001

Date: Tue, 26 Jun 2001 15:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <993593112-v10-i1199@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 26 Jun 2001     Volume: 10 Number: 1199

Today's topics:
    Re: Browser interface to Perl program? <newspost@coppit.org>
    Re: Browser interface to Perl program? <newspost@coppit.org>
    Re: Browser interface to Perl program? <boa@aaanet.ru>
    Re: Browser interface to Perl program? <mjcarman@home.com>
    Re: Error handling question <mjcarman@home.com>
        FTP Catch-22 <ktappe@assocgraphics.com>
    Re: FTP Catch-22 <gerard@NOSPAMlanois.com>
        HELP! Parsing an Specific Attachement using MIME-tools- (Anthony)
        How to determine stack depth? (Sweth Chandramouli)
    Re: how to sort array of similar hashes by one of the h <thoren@southern-division.com>
    Re: how to sort array of similar hashes by one of the h <joe+usenet@sunstarsys.com>
    Re: how to sort array of similar hashes by one of the h (Randal L. Schwartz)
    Re: how to sort array of similar hashes by one of the h (Randal L. Schwartz)
    Re: how to sort array of similar hashes by one of the h <joe+usenet@sunstarsys.com>
    Re: how to sort array of similar hashes by one of the h <ren@tivoli.com>
    Re: how to sort array of similar hashes by one of the h <thoren@southern-division.com>
    Re: how to sort array of similar hashes by one of the h (Randal L. Schwartz)
        Interacting with prompts with perl (Drew Myers)
        Mail::Mailer problem - to: field twice, subject: field  <perler@yahoo.com>
        Newbie format question (Chip)
        NT Cookie problem, PLEASE HELP, this could be one for t (CPERL520335)
    Re: passing variables the 'right' way (Mark Jason Dominus)
    Re: passing variables the 'right' way <mjcarman@home.com>
    Re: Perl to Convert Code <ren@tivoli.com>
    Re: Problem with Archive::Tar <jcook@strobedata.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 26 Jun 2001 15:36:25 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Browser interface to Perl program?
Message-Id: <Pine.SUN.4.33.0106261530310.6718-100000@mamba.cs.Virginia.EDU>

On Tue, 26 Jun 2001, Michael Carman wrote:

> David Coppit wrote:
>
> > I'd like add a cross-platform GUI interface to my Perl program.
> > Perl/Tk is... well... ugly.
>
> Perhaps, but it's probably the most portable of the GUI toolkits.

Yep. Aside from wanting some widgets that weren't yet implemented, I
found it fairly easy to use.

> > AFAICT, there's no way to get Perl/Tk to use platform-specific
> > widgets.
>
> Of course there is, but it may require a lot of OS checks and liberal
> use of eval{}. IMHO, you would be better off to give up the idea of
> using platform-specific widgets. That shouldn't be a big deal, because
> most Tk widgets work across platforms, and if you want your GUI to be
> cross-platform shouldn't it look and act the same way everywhere?

Well, I want the code to be cross-platform, and the interface to be
platform-specific. Users definitely are put off by an interface that
doesn't look and behave like what they are used to. I realize that not
all platforms have all native widgets, but surely there is some
natural subset that could be used? (Fonts, dialog tabs, buttons, etc.)

> The biggest problem I've had is trying to deal with different versions
> of Tk on the different machines. I was trying to reconcile Tk 400.x and
> Tk 800.x, though. It shouldn't be too terrible if all your installs are
> at least using the same major version.

I'm not too worried about that because I bundle everything together
using perl2exe.

> > So... I'd like to use an HTML interface.
>
> This is fine for querying databases, but severely limiting for general
> programming. What does your application do?

Basically it's a series of dialogs in a "wizard" like structure. This
could be implemented with a CGI back-end. Because I don't want to be
responsible for the user's data, I'd rather things be done on the
user's side.

David



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

Date: Tue, 26 Jun 2001 15:39:23 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Browser interface to Perl program?
Message-Id: <Pine.SUN.4.33.0106261537240.6718-100000@mamba.cs.Virginia.EDU>

On 26 Jun 2001, Anno Siegel wrote:

> David Coppit wrote:
>
> > If not, has anyone written a simple embedded web server with a CGI
> > interface?
>
> I fail to see the point.  While I'm not an expert in either, I have
> the distinct impression that whatever you can implement in HTML you
> can implement in Tk.  Both are platform-independent, so neither will
> give you platform-specific widgets.  What do you hope to gain from
> HTML?

A familiar interface. For some, the browser interface is more familiar
than their native OS interface. :)

David



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

Date: Tue, 26 Jun 2001 23:52:12 +0400
From: "Oleg Bakiev" <boa@aaanet.ru>
Subject: Re: Browser interface to Perl program?
Message-Id: <9hap61$61h$1@pa.aaanet.ru>


"David Coppit" <newspost@coppit.org>
news:Pine.SUN.4.33.0106261530310.6718-100000@mamba.cs.Virginia.EDU...
>
> Basically it's a series of dialogs in a "wizard" like structure. This
> could be implemented with a CGI back-end. Because I don't want to be
> responsible for the user's data, I'd rather things be done on the
> user's side.
>
You could look at the Nusphere (www.nusphere.com) mysql installer. It's
written on perl, it has html-interface and it uses a tiny program instead of
web server



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

Date: Tue, 26 Jun 2001 15:39:12 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Browser interface to Perl program?
Message-Id: <3B38F2F0.EF1DD7FD@home.com>

David Coppit wrote:
> 
> I want the code to be cross-platform, and the interface to be
> platform-specific. Users definitely are put off by an interface
> that doesn't look and behave like what they are used to.

True, in which case you may have to establish some priorities. Which is
more important to you -- having a single piece of code to maintain
(platform-independance) or having a comfortable, "native" feel for your
users?

The first reduces maintenance effort on your part, and makes using your
program consistent if (the same) people are likely to run it on multiple
platforms. The latter is better if not-so-savvy end users will only run
it on their own familiar systems.

> I realize that not all platforms have all native widgets, but
> surely there is some natural subset that could be used? (Fonts,
> dialog tabs, buttons, etc.)

Fonts is one of things that gave me some trouble, because the naming
scheme is completely different between X (*nix) and Win*. I worked
around this by using variables for all my font types within my code, and
reading the actual names in from a configuration file. There's probably
a better way...

Most widgets should be portable: buttons, radio buttons, checkboxes,
list and drop boxes, menus, text areas... What things did you want to
use that you couldn't on all platforms?
 
> Basically it's a series of dialogs in a "wizard" like structure.

Ah, data collection. CGI would probably be okay then. I was worried that
you might be trying to write an event-based application GUI with CGI. 

-mjc


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

Date: Tue, 26 Jun 2001 12:53:03 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Error handling question
Message-Id: <3B38CBFF.956EA82E@home.com>

rdlittle wrote:
> 
> Hello,
> 
> What is the best way to intercept error messages or exception
> messages from a perl script?

Replace the handler for warn() and/or die() with your own.

$SIG{__DIE__} = sub {
    print "I'm a goner!\n";
    exit;
}

See the perlvar manpage for more info.

-mjc


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

Date: 26 Jun 2001 18:48:28 GMT
From: Kurt Tappe <ktappe@assocgraphics.com>
Subject: FTP Catch-22
Message-Id: <9halds$uon$0@216.155.1.6>

I need Net::FTP from CPAN for a project I'm working on.  But during
installation, I get to the "make test" step and get the error:

   Can't locate Net/FTP.pm in @INC

If I'm reading this right, Net/FTP.pm is required before I can install
Net/FTP.pm???

How does one get around this Catch-22?  I've tried using MCPAN, but it
requires "ncftpget" which, at $499 a license
(http://www.ncftp.com/libncftp/), isn't an option.

-Kurt

-- 
Kurt Tappe
Manager, Information Technology
Associates Graphic Services
Wilmington, DE


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

Date: 26 Jun 2001 12:32:45 -0700
From: Gerard Lanois <gerard@NOSPAMlanois.com>
Subject: Re: FTP Catch-22
Message-Id: <u8zifvxya.fsf@NOSPAMlanois.com>

Kurt Tappe <ktappe@assocgraphics.com> writes:

> I need Net::FTP from CPAN for a project I'm working on.  But during
> installation, I get to the "make test" step and get the error:
> 
>    Can't locate Net/FTP.pm in @INC
> 
> If I'm reading this right, Net/FTP.pm is required before I can install
> Net/FTP.pm???
> 
> How does one get around this Catch-22?  I've tried using MCPAN, but it
> requires "ncftpget" which, at $499 a license
> (http://www.ncftp.com/libncftp/), isn't an option.

You could download it with a web browser using http protocol instead:

    http://www.cpan.org/authors/id/GBARR/libnet-1.0703.tar.gz

-Gerard
http://www.lanois.com/perl/


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

Date: 26 Jun 2001 13:08:18 -0700
From: adsouza@globix.net (Anthony)
Subject: HELP! Parsing an Specific Attachement using MIME-tools-5.410 in Perl
Message-Id: <2ba4a7b9.0106261208.1532489c@posting.google.com>

Hello,

I am trying to have a perl script parse out a winmail.dat attachement
out of an email message using MIME::Parser.  However, upon trying
this, as the modules example, it is returning the pointer to the hash:
     MIME::Entity=HASH(0x41df38)

Now the string it has to match "winmail.dat" will be in a parts
attachement.  When the module splits the entity via parts:
     my @parts = $entity->parts;
i did not realize that this is a hash.  So i proceded to print out the
values of the hash:
     
     KEY *ME_Bodyhandle* -> VALUE *MIME::Body::File=HASH(0x421abc)*
     KEY *ME_Parts* -> VALUE *ARRAY(0x41de84)*
     KEY *mail_inet_head* -> VALUE *MIME::Head=HASH(0x41df44)*

And I was doing pattern matching on the value.  Yet it is another
pointer.

So, what I wish to do, is if there is a winmail.dat file, to ONLY
delete that attachment, if other attachements, leave them in the
parts.

Can this be done?  Any help would be greatly appreciated.  I have been
testing with the mimedump that comes with the perl module and have
hacked it to peices, yet can not seem to get what I need!  Please
Help!

Thanks a lot!!!
Anthony D.
System Architecture
Globix Corporation
adsouza@globix.net

---------------------------------------------------------------------------
My script looks something like this:
#!/usr/local/bin/perl -w

use MIME::Parser;
#------------------------------
# dump_entity ENTITY, NAME
# Recursive routine for dumping an entity.
sub dump_entity {
    my ($entity, $name) = @_;
    defined($name) or $name = "'anonymous'";
    my $IO;

    # Output the head:
    print "\n", '=' x 60, "\n";
    print "Message $name: ";
    print "\n", '=' x 60, "\n\n";
    print $entity->head->original_text;
    print "\n";

    # Output the body:
    my @parts = $entity->parts;
    if (@parts) {                     # multipart...
	my $i;
	foreach $i (0 .. $#parts) {       # dump each part...
	    print "\t\t\t\t\t>>$i<<\n";
	    foreach my $key (keys %{$parts[$i]})
	    {
			print "KEY *$key* VALUE *".%{$parts[$i]}->{$key}."*\n";
			if ($key eq "ME_Parts")
			{
				print "Found ME_Parts\n";
				my $temp = %{$parts[$i]}->{$key};
				foreach my $key1 (@$temp)
				{
					print "ARRAY VALUE *$key1*\n";
				}
			}
	    }
	    
	    #print "if (". %{$parts[$i]}->{""} ." !~ /letter2landlord.txt/i)
{\n";
	    if ($parts[$i] !~ /letter2landlord.txt/i) {
		    print "IN!!!!\n\n";
		    print "++$parts[$i]++\n";
	   	 dump_entity($parts[$i], ("$name, part ".(1+$i)));
	    }
	}
    }
    else {                            # single part...	

	# Get MIME type, and display accordingly...
	my ($type, $subtype) = split('/', $entity->head->mime_type);
	my $body = $entity->bodyhandle;
	if ($type =~ /^(text|message)$/) {     # text: display it...
	    if ($IO = $body->open("r")) {
		print $_ while (defined($_ = $IO->getline));
		$IO->close;
	    }
	    else {       # d'oh!
		print "$0: couldn't find/open '$name': $!";
	    }
	}
	else {                                 # binary: just summarize it...
	    my $path = $body->path;
	    my $size = ($path ? (-s $path) : '???');
	    print ">>> This is a non-text message, $size bytes long.\n";
	    print ">>> It is stored in ", ($path ? "'$path'" :
'core'),".\n\n";
	}
    }
    1;
}

#------------------------------
# main
sub main {
    print STDERR "(reading from stdin)\n" if (-t STDIN);

    # Create a new MIME parser:
    my $parser = new MIME::Parser;
    
    # Create and set the output directory:
    (-d "mimedump-tmp") or mkdir "mimedump-tmp",0755 or die "mkdir:
$!";
    (-w "mimedump-tmp") or die "can't write to directory";
    $parser->output_dir("mimedump-tmp");
    
    # Read the MIME message:
    $entity = $parser->read(\*STDIN) or die "couldn't parse MIME
stream";

	print ">>>>$entity\n\n\n";
    # Dump it out:
    dump_entity($entity);
}
exit(&main ? 0 : -1);

#------------------------------
1;
---------------------------------------------------------------------------


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

Date: Tue, 26 Jun 2001 21:38:53 GMT
From: sweth+perl@gwu.edu (Sweth Chandramouli)
Subject: How to determine stack depth?
Message-Id: <Nh7_6.17393$Ga.2427112@news1.rdc1.md.home.com>

	Is there an easy way to determine how deep in the
stack a particular call is?  The only way I can see to do it is to
keep calling caller with increasing arguments until it fails to
return true, which doesn't seem very efficient.

	-- Sweth.

-- 
Sweth Chandramouli ; <sweth+perl@gwu.edu>


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

Date: 26 Jun 2001 20:08:27 +0200
From: Thoren Johne <thoren@southern-division.com>
Subject: Re: how to sort array of similar hashes by one of the hash keys?
Message-Id: <m3lmmft8pw.fsf@thoren.southern-division.com>

merlyn@stonehenge.com (Randal L. Schwartz) writes:
>     @game = map {
>       my ($name, $score, $date) = split /,/;
>       +{ name => $name, score => $score, date => $date };
        ^*
>     } @scores;

what's that (*) '+' sign for?
 
-- 
# Thoren Johne - 8#X - thoren@southern-division.com
# Southern Division Classic Bikes - www.southern-division.com
no warnings;our($Just,$another,$Perl,$Hacker)=3...7,print((map{"$$_[0] "}
sort{$$a[1]<=>$$b[1]}map{[$_,eval"\$::$_"]}grep/^[JaPH][^t]/,%::),' 8#X')


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

Date: 26 Jun 2001 14:19:17 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: how to sort array of similar hashes by one of the hash keys?
Message-Id: <m3y9qfqf2y.fsf@mumonkan.sunstarsys.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:

> According to Randal L. Schwartz <merlyn@stonehenge.com>:
>  
> [...]
> 
> > More perversely perlish:
> > 
> >     @game = map +{
> >       (qw/name score date/, split /,/)[0,3,1,4,2,5]
> >     }, @scores;
> > 
> > Do Not Try This At Home. :)
> 
> Ah... retro-hashification of the unwieldy.  I knew there had to
> be something like that.

It's easy to codify:

  sub faro_shuffle {
        die "Oops! odd number of elements: " . @_ if @_ % 2;
        my $midpoint = @_/2;
        @_[ map { $_ => $midpoint + $_ }  0 .. $midpoint - 1 ];
  }

  BEGIN { *weave = *faro_shuffle }

  @game = map +{ weave qw/name score date/ => split /,/ }, @scores;


It's also not surprising that a "magician" would be so familiar with
it. :-)

-- 
Joe Schaefer             "Life is just one damn thing after another."
                                               --Mark Twain



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

Date: 26 Jun 2001 12:14:15 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: how to sort array of similar hashes by one of the hash keys?
Message-Id: <m1zoavuk8o.fsf@halfdome.holdit.com>

>>>>> "Anno" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

Anno> ...and it generalizes:

Anno>     my @keys = qw/name score date comment/;
Anno>     my @hashificator = map( ( $_, $_ + @keys), 0 .. @keys - 1);
Anno>     @game = map +{
Anno>         (@keys, split /,/)[ @hashificator]
Anno>     }, @scores;

"mommy, make him stop.  make the bad man stop!"

Auggggh!

I *like* this.  Can we name it the "anno device" or something?  You
need something named after you.

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 26 Jun 2001 12:15:20 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: how to sort array of similar hashes by one of the hash keys?
Message-Id: <m1sngnuk6v.fsf@halfdome.holdit.com>

>>>>> "Thoren" == Thoren Johne <thoren@southern-division.com> writes:

Thoren> merlyn@stonehenge.com (Randal L. Schwartz) writes:
>> @game = map {
>> my ($name, $score, $date) = split /,/;
>> +{ name => $name, score => $score, date => $date };
Thoren>         ^*
>> } @scores;

Thoren> what's that (*) '+' sign for?

Might not be necessary, but it ensures that {} is treated as a
anonhash constructor, and not a block start.  I didn't have time to
try the actual code, so I threw in the hint.

print "Just another Perl hacker,";

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 26 Jun 2001 15:52:48 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: how to sort array of similar hashes by one of the hash keys?
Message-Id: <m3sngnqar3.fsf@mumonkan.sunstarsys.com>

merlyn@stonehenge.com (Randal L. Schwartz) writes:

> >>>>> "Anno" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
> 
> Anno> ...and it generalizes:
> 
> Anno>     my @keys = qw/name score date comment/;
> Anno>     my @hashificator = map( ( $_, $_ + @keys), 0 .. @keys - 1);
> Anno>     @game = map +{
> Anno>         (@keys, split /,/)[ @hashificator]
> Anno>     }, @scores;
> 
> "mommy, make him stop.  make the bad man stop!"
> 
> Auggggh!
> 
> I *like* this.  Can we name it the "anno device" or something?  You
> need something named after you.

How bowt s/hashificator/annomaly/ ? Sounds cool, and I hope no 
negative connotation is derived from it :-)

-- 
Joe Schaefer    "Few things are harder to put up with than the annoyance of a
                                        good example."
                                               --Mark Twain



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

Date: 26 Jun 2001 14:02:58 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: how to sort array of similar hashes by one of the hash keys?
Message-Id: <m3lmmf5ajh.fsf@dhcp9-173.support.tivoli.com>

On 26 Jun 2001, thoren@southern-division.com wrote:

> merlyn@stonehenge.com (Randal L. Schwartz) writes:
>>     @game = map {
>>       my ($name, $score, $date) = split /,/;
>>       +{ name => $name, score => $score, date => $date };
>         ^*
>>     } @scores;
> 
> what's that (*) '+' sign for?

The "+" causes the braces to be interpreted as a hash reference rather
than as a bare block.

-- 
Ren Maddox
ren@tivoli.com


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

Date: 26 Jun 2001 23:16:14 +0200
From: Thoren Johne <thoren@southern-division.com>
Subject: Re: how to sort array of similar hashes by one of the hash keys?
Message-Id: <m3bsnbt00x.fsf@thoren.southern-division.com>

merlyn@stonehenge.com (Randal L. Schwartz) writes:

> >>>>> "Thoren" == Thoren Johne <thoren@southern-division.com> writes:
> 
> Thoren> merlyn@stonehenge.com (Randal L. Schwartz) writes:
> >> @game = map {
> >> my ($name, $score, $date) = split /,/;
> >> +{ name => $name, score => $score, date => $date };
> Thoren>         ^*
> >> } @scores;
> 
> Thoren> what's that (*) '+' sign for?
> 
> Might not be necessary, but it ensures that {} is treated as a
> anonhash constructor, and not a block start.

i think it's not necessary ;)

i've never seen an example where it is necessary to force an anonhash
that way, perhaps that why i asked.

can you fill in such an example?

-- 
# Thoren Johne - 8#X - thoren@southern-division.com
# Southern Division Classic Bikes - www.southern-division.com
*42=sub{X=>35.56.32.10=>=>=>&{sub{H=>&{sub{P=>&{sub{A=>&{sub{J=>}}}}}}}}}
;no warnings;$_=reverse(&{*42})=>JustAnotherPerlHacker=>print,2.3.5.7**42


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

Date: 26 Jun 2001 14:37:10 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: how to sort array of similar hashes by one of the hash keys?
Message-Id: <m1wv5ysz21.fsf@halfdome.holdit.com>

>>>>> "Thoren" == Thoren Johne <thoren@southern-division.com> writes:

Thoren> i think it's not necessary ;)

Thoren> i've never seen an example where it is necessary to force an anonhash
Thoren> that way, perhaps that why i asked.

Thoren> can you fill in such an example?

Have you not read perlref?

           Because curly brackets (braces) are used for several
           other things including BLOCKs, you may occasionally
           have to disambiguate braces at the beginning of a
           statement by putting a + or a return in front so that
           Perl realizes the opening brace isn't starting a
           BLOCK.  The economy and mnemonic value of using
           curlies is deemed worth this occasional extra hassle.

           For example, if you wanted a function to make a new
           hash and return a reference to it, you have these
           options:

               sub hashem {        { @_ } }   # silently wrong
               sub hashem {       +{ @_ } }   # ok
               sub hashem { return { @_ } }   # ok

           On the other hand, if you want the other meaning, you
           can do this:

               sub showem {        { @_ } }   # ambiguous (currently ok, but may change)
               sub showem {       {; @_ } }   # ok
               sub showem { { return @_ } }   # ok

           Note how the leading +{ and {; always serve to
           disambiguate the expression to mean either the HASH
           reference, or the BLOCK.


-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 26 Jun 2001 11:16:08 -0700
From: bh_ent@hotmail.com (Drew Myers)
Subject: Interacting with prompts with perl
Message-Id: <d1b6a249.0106261016.1ee1be6e@posting.google.com>

Hi.

I'm working on a perl program, that will automate ejecting tapes via the
Omniback backup utility by HP.

The Omniback program uses a CLI (well, that's what I want to use) to eject the
tapes via an interactive prompt, similar to FTP.  The shell equivalent of what I
want to do is:

/opt/omni/lbin/uma -ioctl /dev/scsi/robot -barcode <<EOF >$CAP_SILO_SCAN
stat x
stat s
exit
EOF

This is the working perl code I have so far:
#!/opt/perl5/bin/perl -w
use strict;

# Determine day of week (Monday has several tape batches, Tues-Fri have 1 batch)
my $dayofweek = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat") [(localtime)[6]];

# Get list of tapes to be ejected
open (TAPES,"/opt/omni/bin/omnirpt -report used_media  -timeframe 24 24 |") ||
die "Can't open omnireport: $!\n";
my %tapecap;
while (<TAPES>) {
if (/(R\D\d+).*:\s+(\d+)/gm) {
$tapecap{$2}=$1;
}
}
open(SILO,"/opt/omni/lbin/uma -ioctl /dev/scsi/robot -barcode |") ||
die "Can't open SILO: $!\n";
chomp(my @silo = <SILO>);
close(SILO) || die "Can't close SILO: $!\n";



The /opt/omni/lbin/uma line opens a prompt, where I can interact with the Tape
Library, but I don't know how to do that via Perl.

Any ideas?

Thanks in advance.


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

Date: Tue, 26 Jun 2001 21:06:36 +0200
From: Patrick Erler <perler@yahoo.com>
Subject: Mail::Mailer problem - to: field twice, subject: field ignored
Message-Id: <Xns90CCD6C8E5015fuyyehcesyrdx@62.153.159.134>

i have a strange problem here:

perl 5.6.0, Mail::Mailer 1.21, mandrake 8.0

these simple lines of code:

=== snip ===

#!/usr/bin/perl -w
use Mail::Mailer;

$mailer = Mail::Mailer->new('test');
$mailer->open({'From' => "foo\@bar.com",
                'To' => "bar\@foo.com",
                    'Subject' => "schnarsch",
                  });

       print $mailer "test";
       $mailer->close();

=== snip ===


give me back these output:

=== snip ===

[pat@mir /root/create_vhost <21:00:17> ]# ./test
to: bar@foo.com
Subject: schnarsch
To: bar@foo.com
From: foo@bar.com

test

=== snip ===

where the hell is the first to: field coming from? when i use 

$mailer = Mail::Mailer->new('mail');

(or 'sendmail' or whatever) later on, this results in a mail without a 
subject field and the first line of the original message has a

~s subjecttext

i don't know what's going on - maybe you know?

PAT




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

Date: Tue, 26 Jun 2001 21:05:26 GMT
From: toddalewis@aol.com (Chip)
Subject: Newbie format question
Message-Id: <3b39f620.343809001@news.supernews.com>

I found out that you can not have two format sections with the same
name.

I *thought* this code would output:
A111Bill
A222Clinton

but of course I get:
A222Bill
A222Clinton

I simple do not know the proper syntax for write, print or printf to
print to the same file but using different format sections.  PLEASE
HELP!  :)


open (FILEHANDLE, ">import.txt") or die "Can't create file";

format FILEHANDLE =
A111@<<<<<<<<<<<<
    $name
 .
$name = "Bill";
write FILEHANDLE;


format FILEHANDLE =
A222@<<<<<<<<<<<<
    $name
 .
$name = "Clinton";
write FILEHANDLE;


close (FILEHANDLE);


Thanks,
Todd



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

Date: 26 Jun 2001 20:56:31 GMT
From: cperl520335@aol.com (CPERL520335)
Subject: NT Cookie problem, PLEASE HELP, this could be one for the pro's.
Message-Id: <20010626165631.14365.00000975@ng-ck1.aol.com>

print "Set-Cookie: AFFILIATE=$userhandle; path=/; expires=$timestr\r\n\n";

This works and sets the cookie. But the problem appears to be with setting a
cookie then a location header. It all works fine in Unix but no matter what I
try the cookie just wont set with a location header.

print "Set-Cookie: AFFILIATE=$userhandle; path=/; expires=$timestr\r\n";
print "Location: $sitelocation\r\n\n";

This doesn't set the cookie, but the location header works and the browser is
redirected.

No matter what I try, it just wont set the cookie when combined with a location
header.

I also tried using CGI.pm

Again, this worked:-
  print $query->header(-cookie=>$my_cookie);

But when combined with the location header:-
  print $query->redirect(-location=>$sitelocation, -cookie=>$my_cookie);
again the location changes but the cookie is not set.


I was going to give up and use a meta refresh after setting the cookie, but
then people would have problems with using the back button.

If you have an NT server then please try for yourself. I've been delayed for
weeks because of this.

Please any advice please.


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

Date: Tue, 26 Jun 2001 18:46:54 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: passing variables the 'right' way
Message-Id: <3b38d89d.1959$324@news.op.net>

In article <20010626132751.711$ia@newsreader.com>,  <ctcgag@hotmail.com> wrote:
>mjd@plover.com (Mark Jason Dominus) wrote:
>
>> This is done automatically in Perl for scalars.  When you write
>>
>>         foo($x)
>>
>> Perl internally passes a pointer to the value of $x.
>> There is no benefit to passing foo(\$x) instead.
>
>I learn something new every day.

That is why you can do

        $x = 'Hello';
        set_argument_to_57($x);
        print $x;   #  prints 57


        sub set_argument_to_57 {
          $_[0] = 57;
        }

 
>Doesn't it actually pass a very long list of reference to scalars?  to
>be consistant with the above?

Yes, that is correct.

But what it does not do is pass a reference to the hash or the array.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Tue, 26 Jun 2001 13:20:08 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: passing variables the 'right' way
Message-Id: <3B38D258.C1AC1998@home.com>

ctcgag@hotmail.com wrote:
> 
> mjd@plover.com (Mark Jason Dominus) wrote:
> 
>> For very large arrays or hashes, there may be a speed benefit,
>> since
>>
>>         foo(@a)
>>         foo(%h)
>>
>> pass a very long list of scalars.  foo(\@a) and foo(\%h) 
>> may be faster.
> 
> Doesn't it actually pass a very long list of reference to scalars?
> to be consistant with the above?

There is no inconsistency -- Mark didn't say that foo(@a) passed @a *by
value*, just that it passed a long list of scalars. (References are
scalars.) It doesn't matter whether each element of @a holds one byte or
a 10 MB string, calling foo(@a) still passes the same information -- a
scalar reference to each element.

The advantage of foo(\@a) is, of course, that it will pass only a single
reference to the array itself, regardless of its length.

Similarly, calling foo(%h) just flattens %h into a list; the same
reasoning applies.

-mjc


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

Date: 26 Jun 2001 14:09:25 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Perl to Convert Code
Message-Id: <m3hex35a8q.fsf@dhcp9-173.support.tivoli.com>

[Jeopardectomy.  In the future, please place your comments below the
suitably trimmed comments to which you are replying.]

On 26 Jun 2001, jc_va@hotmail.com wrote:

> Philip Newton <pne-news-20010626@newton.digitalspace.net> wrote in
> message news:<dv6hjtoenrhic82binuupji9nolaho70jo@4ax.com>...
>> On 26 Jun 2001 07:26:51 -0700, jc_va@hotmail.com (Buck Turgidson)
>> wrote:
>> 
>> > I have a task in which I need to take source code, and globally
>> > change some strings.  E.g. I need to change references to
>> > EMPL_RCD# TO EMPL_RCD and BENEFITS_RCD# TO BENEFITS_RCD, and
>> > other such conversions.

[snip]

>> 
>> Something like this should do what you want:
>> 
>>     #!/usr/bin/perl -wp
>>     s/\bEMPL_RCD#/EMPL_RCD/g;
>>     s/\bBENEFITS_RCD#/BENEFITS_RCD/g;
>>     # ... add more if you want ...
>>     # pattern:
>>     # s/ original / replacement /g;
>> 
>> Then go into the directory with the input files and call the script
>> (say, 'change.plx') something like this:
>> 
>>     perl -i '/otherdir/*' change.plx *

[explanation snipped]

> That's extremely helpful.  Thanks.  One other question.  If I want
> to make it case-insensitive (some of our programmers code either
> way), can you tell me what the syntax is?

Simply include the "i" modifier on the substitute:

  s/\bEMPL_RCD#/EMPL_RCD/gi;

If you want to keep the case the same, use:

  s/\b(EMPL_RCD)#/$1/gi;

For more about s///, see perlop(1).  For more about regexes, see
perlre(1).

-- 
Ren Maddox
ren@tivoli.com


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

Date: 26 Jun 2001 20:31:17 GMT
From: Jim Cook <jcook@strobedata.com>
Subject: Re: Problem with Archive::Tar
Message-Id: <3B38F115.36B59615@strobedata.com>

> $year = localtime->year() + 1900;
> $month = localtime->mon();

Isn't it true that this will break if you're really unlucky, and the
date changes from Dec to Jan between these two calls. The same thing
applies to the day. I've been stung with things that didn't get the
whole date/time as an atom, and thought I'd mention it.

If you get the day first, then everything else, then see if the day is
the same as the original day, you've got a good set of numbers. If the
day changed, try again. Or, use the seconds if you're doing H:M:S stuff.
Always use the fastest changing field.

--
jcook@strobedata.com  Live Honourably  4/1 - 4/3 + 4/5 - 4/7 + . . .
2001 Wed: Feb/last 4/4 6/6 8/8/ 10/10 12/12 9/5 5/9 7/11 11/7 3/14
Strobe Data Inc. home page   http://www.strobedata.com
My home page    O-           http://jcook.net


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 1199
***************************************


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