[29794] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1037 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 15 18:09:39 2007

Date: Thu, 15 Nov 2007 15:09:06 -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           Thu, 15 Nov 2007     Volume: 11 Number: 1037

Today's topics:
    Re: Connector Macro Help joey_costanza@msn.com
    Re: Connector Macro Help <SubstituteMyFirstNameHere@pherber.com>
        Datastructure <bio@perls.pam>
    Re: Datastructure <peter@makholm.net>
    Re: Datastructure <krahnj@telus.net>
    Re: Datastructure <bio@perls.pam>
    Re: error in tkGlue.c when building Tk <ben@morrow.me.uk>
        Extract Email Address <no@spam.tonsjunkmail.com>
    Re: OS X, installing modules from CPAN <brian.d.foy@gmail.com>
    Re: Rename files using directory names <jimsgibson@gmail.com>
    Re: Rename files using directory names <ldolan@thinkinghatbigpond.net.au>
    Re: Rename files using directory names <ldolan@thinkinghatbigpond.net.au>
    Re: Repeating element string parsing and iteration <throwaway43054@gmail.com>
        Syntax for a slice of a hashref <usenet@davidfilmer.com>
    Re: Syntax for a slice of a hashref <glex_no-spam@qwest-spam-no.invalid>
    Re: Two Perl programming questions <jimsgibson@gmail.com>
    Re: Two Perl programming questions <TimKnoll@gmail.com>
    Re: Two Perl programming questions <bik.mido@tiscalinet.it>
    Re: Two Perl programming questions <glex_no-spam@qwest-spam-no.invalid>
        YAML and Bless to dump subset of object fails for me <nospam_tigre@yahoo.es>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 15 Nov 2007 12:49:17 -0800 (PST)
From: joey_costanza@msn.com
Subject: Re: Connector Macro Help
Message-Id: <e38851a9-cc25-434c-979e-ec84e2f0253f@s19g2000prg.googlegroups.com>

> The ConnectShapes method will return an object, the shape object of
> your new connector. This will be your $connector.
> (I haven't tried or checked this.)
>
> >Anyway...my main goal is to change the color of the connector. Is
> >there anyway to do this by way of the method I am using. I think I
> >need to set the connector it created equal to a variable somehow, that
> >way I can use the $connector->cells("LineColor")->{Formula} = color.
>
> use an RGB(r,g,b) string for your colour.
>
> --
> Regards, Paul Herber, Sandrila Ltd.
> Electronics for Visio        http://www.electronics.sandrila.co.uk/- Hide quoted text -

Thanks for the quick reply Paul, but according to the VB help (and
many trials and failures on my part) the ConnectShapes method doesn't
return anything. Do you know of another way I could make a variable
equal to the connector that is created?
Thanks,
Joe


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

Date: Thu, 15 Nov 2007 23:03:27 +0000
From: Paul Herber <SubstituteMyFirstNameHere@pherber.com>
Subject: Re: Connector Macro Help
Message-Id: <rpjpj3d76c6kstsmugd79qt1vugvocqkmm@news.gradwell.net>

On Thu, 15 Nov 2007 12:49:17 -0800 (PST), joey_costanza@msn.com wrote:

>> The ConnectShapes method will return an object, the shape object of
>> your new connector. This will be your $connector.
>> (I haven't tried or checked this.)
>>
>> >Anyway...my main goal is to change the color of the connector. Is
>> >there anyway to do this by way of the method I am using. I think I
>> >need to set the connector it created equal to a variable somehow, that
>> >way I can use the $connector->cells("LineColor")->{Formula} = color.
>>
>> use an RGB(r,g,b) string for your colour.


>Thanks for the quick reply Paul, but according to the VB help (and
>many trials and failures on my part) the ConnectShapes method doesn't
>return anything. Do you know of another way I could make a variable
>equal to the connector that is created?

Well, you might be better off using the Drop method with a suitable
connector master. The Visio SDK has examples of this. The Drop method
certainly returns a shape object.



-- 
Regards, Paul Herber, Sandrila Ltd.
DFD for Visio               http://www.gane-sarson.sandrila.co.uk/


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

Date: Thu, 15 Nov 2007 20:19:33 +0100
From: Bioperler <bio@perls.pam>
Subject: Datastructure
Message-Id: <473c9bc6$0$13107$9b4e6d93@newsspool2.arcor-online.net>

HI!

Actually I'm about to code a tool, that's able to track users of a
website (using cookies). However, I've got a problem with the sorting of
the data. I need a data structure like this:

%hash(array(array)) "hash of an array of an array"

So for testing purposes I generated a small dataset, which looks like this:


%HoAoA = (
    hash1    => [
    					( [ "first", "second" ],
    					  [ "third" , "fourth" ],
    					  [ "fifth" , "sixth" ]
    					)
    				 ],
    hash2   => [
    					( [ "9th", "10th" ],
    					  [ "11th" , "12th" ]
    					)
    				 ]
    				
);

So while it was no problem to acces all data fields using nested loops,
I was not able to append data to these arrays listed above. Array's push
doesn't seem to work for this.

Example of what I want to do:
push($HoAoA{hash1}[2], "seventh");


Any suggestions?


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

Date: Thu, 15 Nov 2007 19:26:37 +0000
From: Peter Makholm <peter@makholm.net>
Subject: Re: Datastructure
Message-Id: <87zlxfnwcy.fsf@hacking.dk>

Bioperler <bio@perls.pam> writes:

> %HoAoA = (
>     hash1    => [
>     					( [ "first", "second" ],
>     					  [ "third" , "fourth" ],
>     					  [ "fifth" , "sixth" ]
>     					)
>     				 ],

You don't need the inner ()'s

>     hash2   => [
>     					( [ "9th", "10th" ],
>     					  [ "11th" , "12th" ]
>     					)
>     				 ]
>     				
> );
>

> Example of what I want to do:
> push($HoAoA{hash1}[2], "seventh");

The first argument to push should be an actual array and not just an
reference. So you have to dereference it:

  push @{ $HoAoA{hash1}[2] }, "seventh";

//Makholm


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

Date: Thu, 15 Nov 2007 19:28:47 GMT
From: "John W. Krahn" <krahnj@telus.net>
Subject: Re: Datastructure
Message-Id: <473C9DCC.A66732F7@telus.net>

Bioperler wrote:
> 
> Actually I'm about to code a tool, that's able to track users of a
> website (using cookies). However, I've got a problem with the sorting of
> the data. I need a data structure like this:
> 
> %hash(array(array)) "hash of an array of an array"
> 
> So for testing purposes I generated a small dataset, which looks like this:
> 
> %HoAoA = (
>     hash1    => [
>                                         ( [ "first", "second" ],
>                                           [ "third" , "fourth" ],
>                                           [ "fifth" , "sixth" ]
>                                         )
>                                  ],
>     hash2   => [
>                                         ( [ "9th", "10th" ],
>                                           [ "11th" , "12th" ]
>                                         )
>                                  ]
> 
> );
> 
> So while it was no problem to acces all data fields using nested loops,
> I was not able to append data to these arrays listed above. Array's push
> doesn't seem to work for this.
> 
> Example of what I want to do:
> push($HoAoA{hash1}[2], "seventh");
> 
> Any suggestions?

You have to dereference the array (push only modifies arrays):

push @{ $HoAoA{ hash1 }[ 2 ] }, 'seventh';



John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 15 Nov 2007 20:39:51 +0100
From: Bioperler <bio@perls.pam>
Subject: Re: Datastructure
Message-Id: <473ca084$0$16655$9b4e6d93@newsspool3.arcor-online.net>

Peter Makholm wrote:
> Bioperler <bio@perls.pam> writes:
> 
>> %HoAoA = (
>>     hash1    => [
>>     					( [ "first", "second" ],
>>     					  [ "third" , "fourth" ],
>>     					  [ "fifth" , "sixth" ]
>>     					)
>>     				 ],
> 
> You don't need the inner ()'s
Yes, you're right. But actually the structure is a bit more complex - I
just shorted it a little bit to ease it.

> 
>>     hash2   => [
>>     					( [ "9th", "10th" ],
>>     					  [ "11th" , "12th" ]
>>     					)
>>     				 ]
>>     				
>> );
>>
> 
>> Example of what I want to do:
>> push($HoAoA{hash1}[2], "seventh");
> 
> The first argument to push should be an actual array and not just an
> reference. So you have to dereference it:
> 
>   push @{ $HoAoA{hash1}[2] }, "seventh";
Thanks! This works. Seems as I have to read a little bit about that :-)


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

Date: Thu, 15 Nov 2007 20:13:04 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: error in tkGlue.c when building Tk
Message-Id: <grlu05-e42.ln1@osiris.mauzo.dyndns.org>

[quoting re-arranged somewhat for clarity]

Quoth mariakvelasco@gmail.com:
> On Nov 15, 7:26 am, mariakvela...@gmail.com wrote:
> > On Nov 13, 3:52 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> > > Quoth mariakvela...@gmail.com:
> >
> > > > We are trying to install Tk-804.027_501 on Solaris 10 using Perl
> > > > version 5.8.4. We were able to create the makefile through the command
> > > > perl Makefile.PL; however, when running make, we are getting errors
> > > > regarding the file tkGlue.c
> >
> > > > tkGlue.c: In function `do_comp':
> > > > tkGlue.c:5250: warning: passing arg 1 of `Perl_pregcomp' from
> > > > incompatible pointer type
> > > > tkGlue.c:5250: warning: passing arg 2 of `Perl_pregcomp' makes pointer
> > > > from integer without a cast
> > > > tkGlue.c:5250: too few arguments to function `Perl_pregcomp'
> >
> > > This is typically the result of an ithreads/no-ithreads mismatch. Do you
> > > have some other version of perl whose headers are being picked up by
> > > accident? Is your perl built for threads (or rather, for multiplicity;
> > > check with perl -V:useithreads -V:usemultiplicity).
>
> 1.) After typing the command perl -V:useithreads -V:usemultiplicity
> 
> root % perl -V:useithreads -V:usemultiplicity
> useithreads='undef';
> usemultiplicity='undef';
> 
> Does this mean the perl was built for neither threads or multiplicity?

Yup. Looking further at tkGlue.c suggests that this is not a
multiplicity problem, but the same as the problem below: Tk's configure
process thinks, for some reason, that you are running some version of
perl 5.9. As with the regex flags, the prototype of Perl_pregcomp has
changed in bleadperl: it now only takes two arguments, as opposed to the
three it took in 5.8.x.

> > > > tkGlue.c: In function `Tcl_GetRegExpFromObj':
> > > > tkGlue.c:5319: `RXf_UTF8' undeclared (first use in this function)
> > > > tkGlue.c:5319: (Each undeclared identifier is reported only once
> > > > tkGlue.c:5319: for each function it appears in.)
> > > > tkGlue.c:5319: `RXf_PMf_FOLD' undeclared (first use in this function)
> >
> > > RXf_* are new in bleadperl, they aren't present in any version of 5.8.
> > > Do you have 5.9.* or perl-current installed anywhere? Does your
> > > pTk/tkConfig.h contain the line
> >
> > >     #define HAS_PMOP_EXTRA_FLAGS 1
> >
> > > ? What happens if you run
> >
> > >     perl -I. -MConfig -MTk::MMtry -e'
> > >         $Tk::MMtry::VERBOSE = 1;
> > >         try_compile("config/pmop.c", ["-I$Config{archlibexp}/CORE"])
> > >             or die "try_compile failed: $?";'
> >
> > > (all on one line, of course)? What does perl -V:archlibexp print? Is
> > > that correct (it should be the path to your arch-specific perl core lib
> > > directory, something like /usr/lib/perl5/5.8.4/sun4-solaris)?
> 
> 2.) It looks as if we have the following versions of Perl installed:
> 5.6.1, 5.8.3, 5.8.4, but not 5.9.*
> 
> 3.) The file pTk/tkConfig.h does not contain the line  #define
> HAS_PMOP_EXTRA_FLAGS 1

Ok... that's weird. tkGlue.c doesn't attempt to use RXf_* unless
HAS_PMOP_EXTRA_FLAGS is defined. Are you able to find out where tkGlue.c
is including pTk/tkConfig.h from? With some compilers if you run the
file through the preprocessor (with all the correct arguments, of
course) it includes #line markers with the full path of the include
file. Maybe there's another copy somewhere it's finding by mistake...
I'm somewhat grasping at straws here.

> 4.) After running the following
> 
> usir-solaris:root % perl -I. -MConfig -MTk::MMtry -e'
> $Tk::MMtry::VERBOSE = 1; try_compile("config/pmop.c", ["-I
> $Config{archlibexp}/CORE"]) or die "try_compile failed: $?";'
> 
> This is the result we get:
> 
> Can't locate Tk/MMtry.pm in @INC (@INC contains: . /usr/perl5/5.8.4/

Sorry, I was unclear: I meant you to run that from in the Tk build
directory. Tk::MMtry is included in the Tk distribution. Since
tkConfig.h *didn't* define HAS_PMOP_EXTRA_FLAGS I'd expect it to fail.

> lib/sun4-solaris-64int /usr/perl5/5.8.4/lib /usr/perl5/site_perl/5.8.4/
> sun4-solaris-64int /usr/perl5/site_perl/5.8.4 /usr/perl5/site_perl/
> 5.8.4/sun4-solaris-64int /usr/perl5/5.8.4/lib/sun4-solaris-64int /usr/
> perl5/5.8.4/lib /usr/perl5/site_perl/5.8.4/sun4-solaris-64int /usr/
> perl5/site_perl/5.8.4 /usr/perl5/site_perl /usr/perl5/vendor_perl/
> 5.8.4/sun4-solaris-64int /usr/perl5/vendor_perl/5.8.4 /usr/perl5/
> vendor_perl .).

Again, rather grasping at things here, but there isn't anything weird in
/usr/perl5/{site,vendor}_perl is there? Like a previous installation of
Tk? :)

> BEGIN failed--compilation aborted.
> 
> 5.) After running the command perl -V:archlibexp we get the following:
> 
> root % perl -V:archlibexp
> archlibexp='/usr/perl5/5.8.4/lib/sun4-solaris-64int';

That looks correct.

> Can anyone see the cause of our problem from the information
> provided?  Thanks so much for the help.

No, sorry, I can't see any good reason why this is going wrong. At this
point I would recommend starting again with a fresh copy of the Tk
distribution, having made *really* sure you haven't got anything odd set
in your environment (PERL5LIB, PERL_MM_OPT, anything that might affect
where your preprocessor searches for include files), and if that fails
report a bug at rt.cpan.org.

Ben



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

Date: Thu, 15 Nov 2007 16:56:43 -0600
From: "M" <no@spam.tonsjunkmail.com>
Subject: Extract Email Address
Message-Id: <13jpjl83ad229c4@corp.supernews.com>

I am writing some house keeping scripts for my email server.  I wrote the 
following to extract email address from string.

my $imap_pos = rindex($mailfile, "imap");
my $maildir_pos = rindex($mailfile, "Maildir");
my $user_string = substr($mailfile, $imap_pos+5, $maildir_pos-$imap_pos-6);
my $slash_pos = rindex($user_string, "/");
my $domain = substr($user_string, 0, $slash_pos);
my $user_name = substr($user_string, $slash_pos+1, 40);
my $email_account = "$user_name"."\@"."$domain\n";

$Mailfile basically looks like this.

 /home/accountname/imap/some_domain_name_.net/username/Maildir/new/

Can someone point me in a neater way to do this?  This works fine though.

M




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

Date: Thu, 15 Nov 2007 15:19:51 -0600
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: OS X, installing modules from CPAN
Message-Id: <151120071519515438%brian.d.foy@gmail.com>


> Excellent, thank you. I tried 'man cpan' but that's only for
> command-line stuff, and doesn't cover the cpan shell. Well, now I know,
> and for anyone who's interested: /var/root/.cpan 

If you try

   perldoc CPAN.pm

you should get the CPAN.pm docs instead of the cpan(1) docs. :)


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

Date: Thu, 15 Nov 2007 11:43:05 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Rename files using directory names
Message-Id: <151120071143050921%jimsgibson@gmail.com>

In article <NUX_i.13265$CN4.10200@news-server.bigpond.net.au>, Peter
Jamieson <ldolan@thinkinghatbigpond.net.au> wrote:

> I have inherited many .rtf files contained in a directory structure like:
> patient_data/patient1/2007_07_11/test1.rtf
> where there are many patient directories such as patient1, patient2 etc
> and many date directories such as 2007_07_11, 2007_07_09 etc
> and there may be many .rtf files per patient and date combination.
> 
> What I would like to do is create new unique names for each .rtf file
> based on the directory names: eg patient1_2007_07_11.test1.rtf
> and put them into a new directory named patient_files.
> 
> I have checked out File::Find and tested the following script.
> It lists all the files OK as expected like test1.rtf, test2.rtf etc
> It merely replaces "_" with " " just as a test script.
> 
> However I cannot figure out how to do a rename for what
> I would like the new file names to be namely in the
> form of: patient1_2007_07_11.test1.rtf
> 
> Any help appreciated!, Cheers Peter
> 
> #!/usr/bin/perl
>  use warnings;
>  use strict;
>  use File::Find;
> 
>  my $dir = '/patient_data/patient';
> 
>  find(\&underscores, $dir);
> 
>  sub underscores {
>     next if -d $_;
>     next if /^\./;
>     next unless /_/;

Those should be 'return' statements, as you are not in an explicit loop.

>     my $new_name = $_;
>     $new_name    =~ s/_/ /g;  # just for testing!
>     chdir($File::Find::dir);

There is no need to chdir here, as find will do it for you as long as
you have not set the nochdir option.

>     rename($_, $new_name) or die $!;
>  print "$new_name \n";
>  }

You need to 1) get the full path name, 2) strip off the leading
directory, 3) change all of the path separators to underscores, 4) add
the new directory name at the front. Something like:

#!/usr/local/bin/perl
use warnings;
use strict;
use File::Find;

my $dir = '/patient_data';
my $newdir = '/patient_files';

find(\&moveit, $dir);

sub moveit {
  return if -d $_;
  return if /^\./;
  my $new_name = $File::Find::name;
  $new_name =~ s{^$dir/}{};
  $new_name =~ s{/}{_}g;
  $new_name = "$newdir/$new_name";
  rename($File::Find::name,$new_name);
}

You might want to check if $new_name already exists.

-- 
Jim Gibson

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Thu, 15 Nov 2007 21:22:46 GMT
From: "Peter Jamieson" <ldolan@thinkinghatbigpond.net.au>
Subject: Re: Rename files using directory names
Message-Id: <GM2%i.13334$CN4.253@news-server.bigpond.net.au>


"John W. Krahn" <krahnj@telus.net> wrote in message 
news:473C959D.2992BC4C@telus.net...
> Peter Jamieson wrote:
>>
>> I have inherited many .rtf files contained in a directory structure like:
>> patient_data/patient1/2007_07_11/test1.rtf
>> where there are many patient directories such as patient1, patient2 etc
>> and many date directories such as 2007_07_11, 2007_07_09 etc
>> and there may be many .rtf files per patient and date combination.
>>
>> What I would like to do is create new unique names for each .rtf file
>> based on the directory names: eg patient1_2007_07_11.test1.rtf
>> and put them into a new directory named patient_files.
>>
>> I have checked out File::Find and tested the following script.
>> It lists all the files OK as expected like test1.rtf, test2.rtf etc
>> It merely replaces "_" with " " just as a test script.
>>
>> However I cannot figure out how to do a rename for what
>> I would like the new file names to be namely in the
>> form of: patient1_2007_07_11.test1.rtf
>>
>> Any help appreciated!, Cheers Peter
>>
>> #!/usr/bin/perl
>>  use warnings;
>>  use strict;
>>  use File::Find;
>>
>>  my $dir = '/patient_data/patient';
>>
>>  find(\&underscores, $dir);
>>
>>  sub underscores {
>>     next if -d $_;
>>     next if /^\./;
>>     next unless /_/;
>
> You shouldn't use next from within a subroutine you should use return
> instead.  According to your example above your file names do not contain
> a '_' character?
>
>
>>     my $new_name = $_;
>>     $new_name    =~ s/_/ /g;  # just for testing!
>>     chdir($File::Find::dir);
>
> By default File::Find::find() already has you in the $File::Find::dir
> directory so this is superfluous.  You should always verify that system
> functions like chdir() have worked, but it doesn't matter if it failed
> as you are already in the $File::Find::dir directory!
>
>
>>     rename($_, $new_name) or die $!;
>
> You are trying to move the current file to the same directory.  You
> probably want to include the new path name in the target:
> "patient_files/$new_name" but you probably want to use an absolute path
> instead of a relative path.
>
>
>>  print "$new_name \n";
>>  }
>
>
> John
> -- 
> use Perl;
> program
> fulfillment

Thanks John!....your comments have been most useful.
I will need to look at the use of "next" and "return" in
more detail....cheers, Peter 




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

Date: Thu, 15 Nov 2007 21:22:46 GMT
From: "Peter Jamieson" <ldolan@thinkinghatbigpond.net.au>
Subject: Re: Rename files using directory names
Message-Id: <GM2%i.13335$CN4.5771@news-server.bigpond.net.au>


"Jim Gibson" <jimsgibson@gmail.com> wrote in message 
news:151120071143050921%jimsgibson@gmail.com...
> In article <NUX_i.13265$CN4.10200@news-server.bigpond.net.au>, Peter
> Jamieson <ldolan@thinkinghatbigpond.net.au> wrote:
>
>> I have inherited many .rtf files contained in a directory structure like:
>> patient_data/patient1/2007_07_11/test1.rtf
>> where there are many patient directories such as patient1, patient2 etc
>> and many date directories such as 2007_07_11, 2007_07_09 etc
>> and there may be many .rtf files per patient and date combination.
>>
>> What I would like to do is create new unique names for each .rtf file
>> based on the directory names: eg patient1_2007_07_11.test1.rtf
>> and put them into a new directory named patient_files.
>>
>> I have checked out File::Find and tested the following script.
>> It lists all the files OK as expected like test1.rtf, test2.rtf etc
>> It merely replaces "_" with " " just as a test script.
>>
>> However I cannot figure out how to do a rename for what
>> I would like the new file names to be namely in the
>> form of: patient1_2007_07_11.test1.rtf
>>
>> Any help appreciated!, Cheers Peter
>>
>> #!/usr/bin/perl
>>  use warnings;
>>  use strict;
>>  use File::Find;
>>
>>  my $dir = '/patient_data/patient';
>>
>>  find(\&underscores, $dir);
>>
>>  sub underscores {
>>     next if -d $_;
>>     next if /^\./;
>>     next unless /_/;
>
> Those should be 'return' statements, as you are not in an explicit loop.
>
>>     my $new_name = $_;
>>     $new_name    =~ s/_/ /g;  # just for testing!
>>     chdir($File::Find::dir);
>
> There is no need to chdir here, as find will do it for you as long as
> you have not set the nochdir option.
>
>>     rename($_, $new_name) or die $!;
>>  print "$new_name \n";
>>  }
>
> You need to 1) get the full path name, 2) strip off the leading
> directory, 3) change all of the path separators to underscores, 4) add
> the new directory name at the front. Something like:
>
> #!/usr/local/bin/perl
> use warnings;
> use strict;
> use File::Find;
>
> my $dir = '/patient_data';
> my $newdir = '/patient_files';
>
> find(\&moveit, $dir);
>
> sub moveit {
>  return if -d $_;
>  return if /^\./;
>  my $new_name = $File::Find::name;
>  $new_name =~ s{^$dir/}{};
>  $new_name =~ s{/}{_}g;
>  $new_name = "$newdir/$new_name";
>  rename($File::Find::name,$new_name);
> }
>
> You might want to check if $new_name already exists.
>
> -- 
> Jim Gibson
>

Hi Jim,
Thank you for your comments and suggestions!
I will rewrite some code based on the example you gave.
Your comment to check if a file name may already exist
is apt as by manual inspection I have noticed many
apparently duplicate files.
John Krahn has also mentioned my faulty use of "next" and "return"
so I need to correct my understanding of the difference.
Your help is greatly appreciated!...cheers, Peter. 




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

Date: Thu, 15 Nov 2007 14:57:14 -0800 (PST)
From: "throwaway43054@gmail.com" <throwaway43054@gmail.com>
Subject: Re: Repeating element string parsing and iteration
Message-Id: <c206cacf-be8c-4e01-a9e0-0b3e8452df24@d50g2000hsf.googlegroups.com>

Thank you both!


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

Date: Thu, 15 Nov 2007 13:58:33 -0800 (PST)
From: David Filmer <usenet@davidfilmer.com>
Subject: Syntax for a slice of a hashref
Message-Id: <819f771a-f60c-4fc9-8449-b1f98bba5cd2@i29g2000prf.googlegroups.com>

I want to do something like this:

   $hash_ref->{'key1', 'key2'} = @two_things;

but I wind up with:

   $hash_ref{'key1key2'} == 2

A couple of other guesses were also unsuccessful.

What is the proper syntax for this?

Thanks!

--
David Filmer (http://DavidFilmer.com)


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

Date: Thu, 15 Nov 2007 16:08:25 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Syntax for a slice of a hashref
Message-Id: <473cc359$0$10297$815e3792@news.qwest.net>

David Filmer wrote:
> I want to do something like this:
> 
>    $hash_ref->{'key1', 'key2'} = @two_things;
> 
> but I wind up with:
> 
>    $hash_ref{'key1key2'} == 2
> 
> A couple of other guesses were also unsuccessful.
> 
> What is the proper syntax for this?

my $hash_ref;
@$hash_ref{ 'a', 'b' } = ( 1, 2 );
use Data::Dumper;
print Dumper $hash_ref;


$VAR1 = {
           'a' => 1,
           'b' => 2
         };


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

Date: Thu, 15 Nov 2007 12:06:42 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Two Perl programming questions
Message-Id: <151120071206420463%jimsgibson@gmail.com>

In article
<4aacfcff-09c4-4d12-b874-9692762bef2c@p69g2000hsa.googlegroups.com>,
Tim <TimKnoll@gmail.com> wrote:

> Its a standard CGI application.  One HTML document, one perl script.
> The perl script is called from a post in the HTML document:
> 
> <form name="Someform" action="SomeScript.pl" method="POST">
> 
> The HTML document has two dropdowns, both of which are populated from
> within the HTML like this:
> 
> <option name="Color" value="Blue">Blue</option>
> 
> I want to externalize the dropdown lists to 1) a flat file, and 2)
> directory paths on the server.  I wanted to see if I could create this
> dynamic HTML with Perl.  You mention that doing this through print
> statements isn't recommended.  What would be the best way to do this
> using HTML and Perl?  Thanks.

If you want to make the HTML document have dynamic content, based on a
file on the server, you can use another CGI program to generate the
HTML page. You can do this with print statements, or you can use some
HTML-generating module. The easiest one to use is the CGI module. See
'perldoc CGI'. You can freely mix printing your own content with that
generated by the CGI module. HERE documents are useful for long
sections of HTML content.

For more complicated applications, you should consider using a
templating system to separate the program logic and the HTML content.
There are many (I have not used any). Go to <http://search.cpan.org>
and search for 'template'.

-- 
Jim Gibson

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Thu, 15 Nov 2007 12:08:02 -0800 (PST)
From: Tim <TimKnoll@gmail.com>
Subject: Re: Two Perl programming questions
Message-Id: <1472732d-662e-4706-8d25-e1e8d8cb4844@w34g2000hsg.googlegroups.com>

I've found a great set of articles here:
http://www.wdvl.com/Authoring/Languages/Perl/PerlfortheWeb/conclusion4.html.
Its describes how you can write a Perl script which reads in the HTML
template file, generates the live content, and uses regular expression
substitutions to generate a "new" page.

I've tried a very small test and it appears to work great.  Thanks for
everyones useful posts.

Tim.


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

Date: Thu, 15 Nov 2007 21:09:31 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Two Perl programming questions
Message-Id: <jc9pj3t6ivedtm2rqa3poi99upvnpjjff8@4ax.com>

On Thu, 15 Nov 2007 08:00:39 -0800 (PST), Tim <TimKnoll@gmail.com>
wrote:

>File::Find works great to the get the values I need and I know how to
>read the values from a flat file.  Would my Perl just create the HTML
>as output?  I have two dropdowns.  I wanted to make the second ones

No, you have to build the html code yourself. Fortunately, you can
have Perl (possibly through some module) help you to do so.

>contents dynamic based off what they select for the first.  I wanted

Nothing to do with Perl, but you may want to concoct up some
JavaScript code to do so.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 15 Nov 2007 14:22:51 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Two Perl programming questions
Message-Id: <473caa9c$0$504$815e3792@news.qwest.net>

Tim wrote:
> Its a standard CGI application.  One HTML document, one perl script.
> The perl script is called from a post in the HTML document:
> 
> <form name="Someform" action="SomeScript.pl" method="POST">
> 
> The HTML document has two dropdowns, both of which are populated from
> within the HTML like this:
> 
> <option name="Color" value="Blue">Blue</option>
> 
> I want to externalize the dropdown lists to 1) a flat file, and 2)
> directory paths on the server.  I wanted to see if I could create this
> dynamic HTML with Perl.  You mention that doing this through print
> statements isn't recommended.  What would be the best way to do this
> using HTML and Perl?  Thanks.

You have a static file of HTML and you want to make
the contents more dynamic?  As others have suggested,
use one of the many template modules: Template Toolkit,
HTML::Template, Template::Simple, etc.

http://search.cpan.org/search?query=template&mode=all

Read through the documentation for a few, and
pick one you like and install it.

They're each different, but once you install one, your HTML
will have some special 'tags', for the parts you
want to populate dynamically.  You set the value(s) and
use the methods to dynamically populate those tags.



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

Date: Thu, 15 Nov 2007 23:02:44 +0100
From: Rud1ger Sch1erz <nospam_tigre@yahoo.es>
Subject: YAML and Bless to dump subset of object fails for me
Message-Id: <ud4ub6ubf.fsf@1a-software.de>

Hi there,

I'm fiddling around with YAML and try to write out a subset of a data
object.

The example of the YAML documentation works fine for me:

use YAML qw(Dump Bless);

use strict;

my $hash = {apple => 'good', banana => 'bad', cauliflower => 'ugly'};
print Dump $hash;
Bless($hash)->keys(['banana', 'apple']);
print Dump $hash;

gives me:
---
apple: good
banana: bad
cauliflower: ugly
---
banana: bad
apple: good

But when I try to use Blessing of keys to filter and sort the output
of an object reference, YAML seems to ignore my key subset.

<code example>
#!/usr/bin/perl -w
#

{
    package DailyBuildInfoSet;

    sub new {
	my($proto ) = @_;
	my $class = ref($proto) || $proto || DailyBuildInfoSet;
	my $self  = {};

	bless ($self, $class);

	return $self;
    }

    sub value {
	my $self = shift;
	my $k    = shift;
	if (@_) { $self->{$k} = shift }

	return $self->{$k};
    }

    1;
}

use YAML qw(Dump Bless);

use strict;

my $db = DailyBuildInfoSet->new();
$db->value( "DOB", '20071114' );
$db->value( "HMI_CL", '1113617' );
$db->value( "TC_CL", '1111316' );

print Dump $db;

Bless($db)->keys(['HMI_CL', 'TC_CL']);
print Dump $db;

</code example>

Output of this example is:

$ t3.Al
--- !!perl/hash:DailyBuildInfoSet
DOB: 20071114
HMI_CL: 1113617
TC_CL: 1111316
--- !!perl/hash:DailyBuildInfoSet
DOB: 20071114
HMI_CL: 1113617
TC_CL: 1111316

On the latter, I would expect (and like to have):

--- !!perl/hash:DailyBuildInfoSet
HMI_CL: 1113617
TC_CL: 1111316

BTW, perl -v gives me:
This is perl, v5.8.8 built for cygwin-thread-multi-64int
(with 8 registered patches, see perl -V for more detail)

Could some kind soul point me to the reason, why YAML seems to ignore
my key blessing? 

Cheers,
Rudiger

-- 
Der folgende Satz ist falsch.
Der vorherige Satz ist richtig.


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

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 1037
***************************************


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