Re: one more nice2haveit
> I've go tired of typing :"), but if I had current index-iterator ( say under > $i just as example) at hand the way I have $_ i can just type : > > print "$_ : $b[$i]\n" for @a; > OR > print "$a[$i] : $b[$i]\n" for @a; > For a general solution to this see Buddha Buck's RFC on iterators: http://dev.perl.org/rfc/207.html -- Jeremy Howard [EMAIL PROTECTED]
RE: one more nice2haveit
How about print "$a[$_]:$b[$_] for 0..$#a; or in the p6 case... print "@a[$_]:@b[$_]" for 0..$#a; Ilya -Original Message- From: raptor To: [EMAIL PROTECTED] Sent: 07/18/2001 12:14 PM Subject: one more nice2haveit hi, As I was programming i got again to one thing i alwas needed to have... especialy when write something fast or debug some result... words comes about for/foreach and accessing the current-index of the array I'm working with i.e. say I have two arrays @a and @b and want to print them (also say they are connected in some way so I want to see them both). In case of one array I write : print "$_\n" for @a; fast, simple, goodbut in my case I have to write something like this : for ($i = 0; $i < scalar @a; $i++) { print "$a[$i] : $b[$i]\n" }; I've go tired of typing :"), but if I had current index-iterator ( say under $i just as example) at hand the way I have $_ i can just type : print "$_ : $b[$i]\n" for @a; OR print "$a[$i] : $b[$i]\n" for @a; isn't that cute :") ... the same count for list in $i I just get current position in the list. (we can also use "pos" in some way!!!) print "$_ : $a[$i] : $b[$i]\n" for (qw(val1 val2 val3)); I need it very often.:") don't bother if the lenght of both arrays are different when u use it, u know what u are doing... = iVAN [EMAIL PROTECTED] =
Re: aliasing - was:[nice2haveit]
> > So, in this case, a "with" synonym for "for" would work. > > > Particularly if '$_' was implied... So with Perl 6's '.' replacing '->', > and 'with' aliasing 'for': > >with ( $XL.{Application}.{ActiveSheet} ) { > .cells(1,1) = "Title"; > .language() = "English"; >} This is my idea for it; .zebra could always be the 'default variables' attribute 'zebra'. The With could also make the [variable, alias, whatever] default, but not replace the $_: $_ = "monkey "; $foo = "coward"; with ($foo){ print; print "$_"; } would output "monkey coward". If this was universal and heirachial, then $foo.bar.quux = "chainsaw"; with ($foo){ with (.bar){ print .quux; } } Be cool if this could be overloaded (correct word?) to work for functions, too. with (print()){ "foo"; "monkey"; } I see a problem with "." being the old way of sticking strings together though. (All opinions expressed in this post are probably wrong. Trying to figure how to post this thing, the newsgroup bit didn't work.)
Re: aliasing - was:[nice2haveit]
> > So, in this case, a "with" synonym for "for" would work. > > > Particularly if '$_' was implied... So with Perl 6's '.' replacing '->', > and 'with' aliasing 'for': > >with ( $XL.{Application}.{ActiveSheet} ) { > .cells(1,1) = "Title"; > .language() = "English"; >} This is my idea for it; .zebra could always be the 'default variables' attribute 'zebra'. The With could also make the [variable, alias, whatever] default, but not replace the $_: $_ = "monkey "; $foo = "coward"; with ($foo){ print; print "$_"; } would output "monkey coward". If this was univeral and heirachial, then $foo.bar.quux = "chainsaw"; with ($foo){ with (.bar){ print .quux; } } I see a problem with "." being the old way of sticking strings together though. (All opinions expressed in this post are probably wrong.)
Re: saving attachments of mail in MIME format
Thanks, I tried using MIME-Tools-5.4.11.tar.gz I'm facing an interesting problem. I'm using the following code to dump the mail. Now I'm receiving a file "encrypted.txt" in mail as attachment. The code works fine & it dumps the contents & the attachment also. I have set my .procmailrc as :0 c |perl DumpMail.pl >DumpMail.txt :0 |perl Customizer.pl Now in Customizer.pl I want to use the attachment "encrypted.txt" , but it tells me that file does not exist which is actually seen on doing ls. Kindly guide me to rectify this problem. Thanks & Regards, Priyanka CODE of DumpMail.pl starts here - #!/usr/bin/perl 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... 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"; # Dump it out: dump_entity($entity); } exit(&main ? 0 : -1); #-- 1; CODE ends here - - Original Message - From: David L. Nicol <[EMAIL PROTECTED]> To: Priyanka porwal <[EMAIL PROTECTED]> Sent: Tuesday, July 17, 2001 2:08 AM Subject: Re: saving attachments of mail in MIME format > Priyanka porwal wrote: > > > > Hi, > > I'm facing a problem in receiving mails. I'm sending mail in MIME format with attachments. Now I want to receive this mail on server side & save the attachment separately with different names. > > > > Kindly help. > > > > Regards, > > Priya > > > search for "munpack" > > > -- >David Nicol 816.235.1187 > Irish Government Warning: SMOKERS DIE YOUNGER
one more nice2haveit
hi, As I was programming i got again to one thing i alwas needed to have... especialy when write something fast or debug some result... words comes about for/foreach and accessing the current-index of the array I'm working with i.e. say I have two arrays @a and @b and want to print them (also say they are connected in some way so I want to see them both). In case of one array I write : print "$_\n" for @a; fast, simple, goodbut in my case I have to write something like this : for ($i = 0; $i < scalar @a; $i++) { print "$a[$i] : $b[$i]\n" }; I've go tired of typing :"), but if I had current index-iterator ( say under $i just as example) at hand the way I have $_ i can just type : print "$_ : $b[$i]\n" for @a; OR print "$a[$i] : $b[$i]\n" for @a; isn't that cute :") ... the same count for list in $i I just get current position in the list. (we can also use "pos" in some way!!!) print "$_ : $a[$i] : $b[$i]\n" for (qw(val1 val2 val3)); I need it very often.:") don't bother if the lenght of both arrays are different when u use it, u know what u are doing... = iVAN [EMAIL PROTECTED] =
Re: aliasing - was:[nice2haveit]
>> Does such a thing exist already? > >A WTDI exists already: > >for ( $XL->{Application}->{ActiveSheet} ) { > $_->cells(1,1) = "Title"; > $_->language() = "English"; >} > >(presuming lvalue-methods, of course...) So, in this case, a "with" synonym for "for" would work. ]- OR with alias for; with ( $XL->{Application}->{ActiveSheet} ) { $_->cells(1,1) = "Title"; $_->language() = "English"; } :") = iVAN [EMAIL PROTECTED] =
Re: aliasing - was:[nice2haveit]
Bart Lateur wrote: > On Wed, 18 Jul 2001 09:00:25 -0400, John Porter wrote: > >for ( $XL->{Application}->{ActiveSheet} ) { > > $_->cells(1,1) = "Title"; > > $_->language() = "English"; > >} > > > >(presuming lvalue-methods, of course...) > > So, in this case, a "with" synonym for "for" would work. > Particularly if '$_' was implied... So with Perl 6's '.' replacing '->', and 'with' aliasing 'for': with ( $XL.{Application}.{ActiveSheet} ) { .cells(1,1) = "Title"; .language() = "English"; } Heh. That is nice and compact... although it's getting hard to tell it apart from VB ;-) -- Jeremy Howard [EMAIL PROTECTED]
Re: aliasing - was:[nice2haveit]
On Wed, 18 Jul 2001 09:00:25 -0400, John Porter wrote: >> Does such a thing exist already? > >A WTDI exists already: > >for ( $XL->{Application}->{ActiveSheet} ) { > $_->cells(1,1) = "Title"; > $_->language() = "English"; >} > >(presuming lvalue-methods, of course...) So, in this case, a "with" synonym for "for" would work. But this only works for scalars. You can't have a %foo alias to %Some::Other::hash this way, or a @bar alias to @Some::Other::array. -- Bart.
Re: aliasing - was:[nice2haveit]
Jeremy Howard wrote: > with $XL->{Application}->{ActiveSheet} { > ->cells(1,1) = "Title" > ->language() = "English" > } > > Does such a thing exist already? A WTDI exists already: for ( $XL->{Application}->{ActiveSheet} ) { $_->cells(1,1) = "Title"; $_->language() = "English"; } (presuming lvalue-methods, of course...) -- John Porter