[25263] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7508 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Dec 11 14:05:43 2004

Date: Sat, 11 Dec 2004 11:05: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           Sat, 11 Dec 2004     Volume: 10 Number: 7508

Today's topics:
    Re: FAQ 4.36: How can I expand variables in text string <nobull@mail.com>
    Re: FAQ 4.36: How can I expand variables in text string <nobull@mail.com>
    Re: FAQ 4.36: How can I expand variables in text string <nobull@mail.com>
    Re: FAQ 4.36: How can I expand variables in text string <nobull@mail.com>
    Re: FAQ 4.36: How can I expand variables in text string <nobull@mail.com>
    Re: forwarding cgi->param() (David Efflandt)
    Re: grammar function [OT - English Grammar] <matthew.garrish@sympatico.ca>
        how access to hash which contains hash and sclar var? <xthua111@zju.edu.cn>
    Re: how access to hash which contains hash and sclar va <noreply@gunnar.cc>
        How can I strip keywords out of a search string <bill@hotmail.com>
    Re: How can I strip keywords out of a search string <spamtrap@dot-app.org>
    Re: How can I strip keywords out of a search string <bik.mido@tiscalinet.it>
    Re: How can I strip keywords out of a search string <pobugfix@peterlink.ru>
    Re: Loop Logic Question <ccarpenter@erols.com>
    Re: Open All files one by one <bik.mido@tiscalinet.it>
    Re: Open All files one by one <bik.mido@tiscalinet.it>
    Re: Open All files one by one <bik.mido@tiscalinet.it>
    Re: Open All files one by one <bik.mido@tiscalinet.it>
    Re: Open All files one by one <bustanut2020@yahoo.com>
    Re: Passing hashes to a function <spamtrap@dot-app.org>
    Re: perl port to my m68k calculator bulk88@hotmail.com
    Re: Reg Hash of Hash <nobull@mail.com>
    Re: Regaular Expression <jurgenex@hotmail.com>
    Re: Regaular Expression <shawn.corey@sympatico.ca>
    Re: Regaular Expression <jurgenex@hotmail.com>
    Re: Regaular Expression <gene_leung@kader.com.hk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 11 Dec 2004 11:49:54 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: FAQ 4.36: How can I expand variables in text strings?
Message-Id: <cpemjm$gav$1@sun3.bham.ac.uk>



PerlFAQ Server wrote:

> 4.36: How can I expand variables in text strings?

>         $text =~ s/(\$\w+)/$1/eeg;
>         die if $@;                  # needed /ee, not /e

This is broken.  /g makes s/// into a looping construct.  You should 
check the value of $@ inside the loop if at all.

This should be corrected to either ignore the possibility of error or 
check it properly.  i.e.

          $text =~ s/(\$\w+)/$1/eeg; # ignore errors

 ...OR...

          $text =~ s/(\$\w+)/my $s=eval $1; die if $@; $s/eg;



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

Date: Sat, 11 Dec 2004 11:54:13 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: FAQ 4.36: How can I expand variables in text strings?
Message-Id: <cpemrp$gb0$1@sun3.bham.ac.uk>

PerlFAQ Server wrote:

> 4.36: How can I expand variables in text strings?

>     See also ``How do I expand function calls in a string?'' in this section
>     of the FAQ.

Despite a superfical similariy in wording these questions are not 
related.  One refers to interpolation in Perl source the other to 
processing data.  Unless one is using eval() the two are totally dissimilar.

This "see also" would be relevant (to illustrate the dangers of using 
eval()) if the FAQ gave the simple/obvious/honest answer "How can I 
expand variables in text strings?" but it doesn't so there's no point.



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

Date: Sat, 11 Dec 2004 12:01:15 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: FAQ 4.36: How can I expand variables in text strings?
Message-Id: <cpen91$gjp$1@sun3.bham.ac.uk>



PerlFAQ Server wrote:

> 
> 4.36: How can I expand variables in text strings?
> 
>     Let's assume that you have a string like:
> 
>         $text = 'this has a $foo in it and a $bar';

This is question is clearly asking for a simple templating system.  The 
answer given in the FAQ shows how to roll ones own simple templating 
system.

The trouble is that simple hand-rolled templating systems often evolve 
into complex ones.  It is often said that writting ones own templating 
system is a rite of passage for Perl programmers - perhaps that why the 
FAQ deliberately witholds the simple and valuable advice: "take a look 
at templating systems on CPAN".



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

Date: Sat, 11 Dec 2004 12:25:14 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: FAQ 4.36: How can I expand variables in text strings?
Message-Id: <cpeolv$ha0$1@sun3.bham.ac.uk>



PerlFAQ Server wrote:
> 
> 4.36: How can I expand variables in text strings?
> 
>     Let's assume that you have a string like:
> 
>         $text = 'this has a $foo in it and a $bar';
> 
>     If those were both global variables, then this would suffice:
> 
>         $text =~ s/\$(\w+)/${$1}/g;  # no /e needed

There is a much simpler and more powefull solution using eval().

There are, of course, dangers in using the eval() solution resulting 
from its unbounded power.

There are much greater dangers in trying to withold the knowledge from 
the masses because you consider it dangerous and the masses too stupid 
to be truseted with it.

When people realise for themselves they can simply use eval():

     1. They'll not do it right (use qq() rather than here-doc).
     2. They'll not be warned of the dangers of eval().
     3. They'll come to distrust and even resent the FAQ.

   # Only do this if $text is known to come from a source that would
   # be trusted to write/execute their own scripts.

   chop ( $text = eval "<<__END__\n$text\n__END__" );
   die if $@;



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

Date: Sat, 11 Dec 2004 18:45:32 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: FAQ 4.36: How can I expand variables in text strings?
Message-Id: <cpfev0$rjl$1@sun3.bham.ac.uk>



brian d foy wrote:

> In article <cpemjm$gav$1@sun3.bham.ac.uk>, Brian McCauley
> <nobull@mail.com> wrote:
> 
> 
>>PerlFAQ Server wrote:
>>
>>
>>>4.36: How can I expand variables in text strings?
>>
>>>        $text =~ s/(\$\w+)/$1/eeg;
>>>        die if $@;                  # needed /ee, not /e
>>
>>This is broken.  /g makes s/// into a looping construct.  You should 
>>check the value of $@ inside the loop if at all.
  >
> can you give an example of how this breaks?

use strict;
use warnings;

my $bar = 777;
my $text='$foo $bar';
$text =~ s/(\$\w+)/$1/eeg;
die if $@;

The error 'Global symbol "$foo" requires explicit package name' gets 
ignored.

And before you say "well that doesn't matter" I said "inside the loop if 
at all".  It quite possbily makes more sense simply not to check $@ at 
all.  It doesn't make sense to worry about errors in the last 
substitution but not the previous ones.



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

Date: Sat, 11 Dec 2004 18:59:32 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: forwarding cgi->param()
Message-Id: <slrncrmgsk.rlb.efflandt@typhoon.xnet.com>

On 10 Dec 2004 19:15:16 -0800, krakle@visto.com <krakle@visto.com> wrote:
> 
> David Efflandt wrote:
>> On Fri, 10 Dec 2004 21:27:14 +0000, Colombo <colo@megapolis.pl>
> wrote:
>> > hi,
>> > how to forward parameters from $cgi->param() to another page when I
> 
>> > don't know how many parameters are there and how they are called?
>>
>> Not clear if you are generating another form and want to pass
> variables
>> through it, or attempting to redirect them to some other handler.
> But to
>> pass submitted variables through another form as hidden variables,
>> somewhere within the CGI generated form do something like:
>>
>> foreach ($cgi->param) { print $cgi->hidden($_), "\n"; }
> Their is VARS..
> 
> my $FORM = $cgi->Vars;

Perhaps you mean:  my %FORM = $cgi->VARS;

> now $FORM{'name'}

But how would that help at all if he does not know which 'name's were 
passed from previous form?


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

Date: Sat, 11 Dec 2004 13:23:11 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: grammar function [OT - English Grammar]
Message-Id: <hWGud.85266$l%5.2329704@news20.bellglobal.com>


"? the Platypus {aka David Formosa}" <dformosa@zeta.org.au> wrote in message 
news:m3y8g5flkj.fsf@dformosa.zeta.org.au...
> "Paul Lalli" <mritty@gmail.com> writes:
>
>> "Ken Sington" <ken_sington@nospam_abcdefg.com> wrote in message
>> news:HJmdnb8C-OEc-CvcRVn-pw@speakeasy.net...
>> >
>> > chair remains chair if there are one or zero.
>>
>> You have "zero chair"?  "zero desk"?  That doesn't especially sound like
>> correct (American) English to me.
>
> I have three chairs.
> I have two chairs.
> I have I chair;
> I have no chairs;
>
>>  Singular is used for one item.
>> Plural is used for not-one items.
>
> Looks like it.
>

Looks are always deceiving:

You have no senses at all
You have no sense at all

Matt 




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

Date: Sat, 11 Dec 2004 23:09:41 +0800
From: kenneth <xthua111@zju.edu.cn>
Subject: how access to hash which contains hash and sclar var?
Message-Id: <cpf2mu$24d8$1@mail.cn99.com>

hi
i'd like to access to hash which contains hash and sclar var,and failed.
access to hash of hash is ok, i find that in <<Programming Perl>>.
use the code below:
for my $family ( keys %test ) {
	print "$family: \n";
	for my $role ( keys %{ $test{$family} } ) {
		print "$role=$test{$family}{$role} ";
	}
	print "\n";

}
but now i construct a structure use below codes:
	my %test=(
		number => "20",
	);

	$test{"homepage"}{"index.html"}=21;
	$test{"homepage"}{"index.php"}=2;
and the above code failed to access to the element of the structure with
error of "Can't use string ("20") as a HASH ref while "strict refs" in 
use at hash_of_hash.pl line 26.
shell returned 255"
any advises? thank you!


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

Date: Sat, 11 Dec 2004 16:30:27 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: how access to hash which contains hash and sclar var?
Message-Id: <320i67F3gfav9U1@individual.net>

kenneth wrote:
> i'd like to access to hash which contains hash and sclar var,and failed.
> access to hash of hash is ok, i find that in <<Programming Perl>>.
> use the code below:
> for my $family ( keys %test ) {
>     print "$family: \n";
>     for my $role ( keys %{ $test{$family} } ) {
>         print "$role=$test{$family}{$role} ";
>     }
>     print "\n";
> 
> }
> but now i construct a structure use below codes:
>     my %test=(
>         number => "20",
>     );
> 
>     $test{"homepage"}{"index.html"}=21;
>     $test{"homepage"}{"index.php"}=2;
> and the above code failed to access to the element of the structure with
> error of "Can't use string ("20") as a HASH ref ...

You need to check whether respective key is a reference. Something like:

     for my $key ( keys %test ) {
         print "$key: \n";
         if ( ref $test{$key} ) {
             for ( keys %{ $test{$key} } ) {
                 print "$_=$test{$key}{$_} ";
             }
         } else {
             print $test{$key};
         }
         print "\n";
     }

You may also want to use this convenient method to print a complex data 
structure:

     use Data::Dumper;
     print Dumper \%test;

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Sat, 11 Dec 2004 07:15:07 -0500
From: "blnukem" <bill@hotmail.com>
Subject: How can I strip keywords out of a search string
Message-Id: <FyBud.2302$mP1.2136@fe10.lga>

How can I strip keywords "machinery liquidator" out of a search string I 
cant seem to loose the "web/" in my query results

my $String = 
'http://msxml.excite.com/info.xcite/search/web/machinery%2Bliquidator';

#my($Domain,$Query) = $ String =~m((http://.+?)/.*?(web/)([^&]*));
#my($Domain,$Query) = $ String =~m((http://.+?)/.*(web/)([^&]*));
#my($Domain,$Query) = $ String =~m((http://.+?)/.*[web/]([^&]*));

my($Domain,$Query) = $ String =~m((http://.+?)/.*?(web/[^&]*));

print "Domain: $Domain";
print"<br>Query: $Query"; 




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

Date: Sat, 11 Dec 2004 08:00:39 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: How can I strip keywords out of a search string
Message-Id: <heidnfocyInlcifcRVn-ig@adelphia.com>

blnukem wrote:

> How can I strip keywords "machinery liquidator" out of a search string I 
> cant seem to loose the "web/" in my query results
                ^^^^^
"loose" ne "lose" (It's a pet peeve...)
> 
> my $String = 
> 'http://msxml.excite.com/info.xcite/search/web/machinery%2Bliquidator';
> 
> my($Domain,$Query) = $ String =~m((http://.+?)/.*?(web/[^&]*));
> 
> print "Domain: $Domain";
> print"<br>Query: $Query"; 

If you don't want it, don't capture it. Just move it outside of the 
second subexpression:

#!/usr/bin/perl

use warnings;
use strict;

my $String =
'http://msxml.excite.com/info.xcite/search/web/machinery%2Bliquidator';

my($Domain,$Query) = $ String =~m((http://.+?)/.*?web/([^&]*));

print "Domain: $Domain\n";
print" Query: $Query\n";

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Sat, 11 Dec 2004 14:03:25 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How can I strip keywords out of a search string
Message-Id: <0trlr0pindkfccnp52hkgup2t2cc5r1mbr@4ax.com>

On Sat, 11 Dec 2004 07:15:07 -0500, "blnukem" <bill@hotmail.com>
wrote:

>How can I strip keywords "machinery liquidator" out of a search string I 
>cant seem to loose the "web/" in my query results
>
>my $String = 
>'http://msxml.excite.com/info.xcite/search/web/machinery%2Bliquidator';
>
>#my($Domain,$Query) = $ String =~m((http://.+?)/.*?(web/)([^&]*));
>#my($Domain,$Query) = $ String =~m((http://.+?)/.*(web/)([^&]*));
>#my($Domain,$Query) = $ String =~m((http://.+?)/.*[web/]([^&]*));

You can assign to undef. You can take a slice. You can use
non-capturing parentheses. Please also note that

  $ String 

doesn't add to readability. Or is it supposed to be a JAPH?!?


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: Sat, 11 Dec 2004 21:46:45 +0000
From: Andrew Tkachenko <pobugfix@peterlink.ru>
Subject: Re: How can I strip keywords out of a search string
Message-Id: <cpfffa$g7d$1@news.rol.ru>

blnukem wrote on 11 Декабрь 2004 12:15:

> How can I strip keywords "machinery liquidator" out of a search string I 
> cant seem to loose the "web/" in my query results
> 
> my $String = 
> 'http://msxml.excite.com/info.xcite/search/web/machinery%2Bliquidator';
> 
> #my($Domain,$Query) = $ String =~m((http://.+?)/.*?(web/)([^&]*));
> #my($Domain,$Query) = $ String =~m((http://.+?)/.*(web/)([^&]*));
> #my($Domain,$Query) = $ String =~m((http://.+?)/.*[web/]([^&]*));
> 
> my($Domain,$Query) = $ String =~m((http://.+?)/.*?(web/[^&]*));
> 
> print "Domain: $Domain";
> print"<br>Query: $Query";


URI.pm will help you

-- 
Andrew


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

Date: Sat, 11 Dec 2004 08:10:42 -0500
From: "Chip" <ccarpenter@erols.com>
Subject: Re: Loop Logic Question
Message-Id: <l62dnRa-hpRpbCfcRVn-3g@adelphia.com>

Thanks John,

That is exactly what I was looking for.

I like the "no warnings 'uninitialized';"
to join the array even if it does not
have data in it.

Thanks Again
Chip

"John W. Krahn" <someone@example.com> wrote in message
news:69Aud.51640$6f6.21451@edtnps89...
>
> This appears to do what you require:
>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> my $filename = 'vertical.txt';
> open FILE, '<', $filename or die "Could not open $filename: $!";
>
> my @data;
> while ( <FILE> ) {
>      chomp;
>      if ( /^\w{17}$/ or eof FILE ) {
>          push @data, $_ if eof FILE;
>          if ( @data ) {
>              no warnings 'uninitialized';
>              print join( ',', @data[ 0 .. 12 ] ), "\n";
>              }
>          @data = $_;
>          }
>      else {
>          push @data, $_;
>          }
>      }
>
> __END__
>
>
>
> John
> -- 
> use Perl;
> program
> fulfillment




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

Date: Sat, 11 Dec 2004 13:54:23 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Open All files one by one
Message-Id: <g2rlr0p6bctoecuek2hn4tq17k5o3bgoro@4ax.com>

On 10 Dec 2004 12:42:59 -0800, "foobar" <kvrahul@gmail.com> wrote:

>#!/../..perl -w

Ouch! Quite a strange shebang line!! In particular is your perl
interpreter really called '..perl'?!? Of course this would work under
Windows, and also under *NIX (I guess), *if* the script is called with

  perl programname

>use strict;

Worth mentioning that with recent enough perls it's better to

  use warnings;  # instead of -w

>$my_txt_dir = ' / .. / .. /someplace';

Huh?!? Quite a strange path, isn't it? Also, since we're under strict,
this won't compile at all.

>my $files_ref = ReadDir ($my_txt_dir);

Do you really think it is *convenient* (i) to create a dedicated sub
to be used only *once* and that (ii) really adds only a very thin
layer around Perl's readdir(), (iii) is called very similarly to it
causing potential confusion, (iv) returns (a reference to an array
containing) a full list of entries whereas these may be examined
sequentially one at a time?

>foreach my $file (@$files_ref){

This may be to a large extent a matter of personal tastes, but what is
the point of unnecessary referencing/dereferencing? Aren't we abusing
this a little too much?!?

>if ($file =~ /\.txt/){

This may well be what you want, but it may be safer to /\.txt$/
instead.

>my $file_recs_ref = ReadFile ("$my_txt_dir/$file");
>foreach $line (@$file_recs_ref){

Ditto as above (wrt referencing/dereferencing).

Oh, and this won't compile either, at least under strict. Good reason
to at least perl -c your code.

Oh, and while I'm here: quite a weird indenting style too! Please note
that it doesn't make your code much readable...

>sub ReadFile{
>my $file = shift @_;

  shift;  # shift @_; doesn't add to clarity!

>open (FH,"$file") or die "Could not open file $file";

Better include $! in the error message. It only requires a pair more
keystrokes...

BTW: it is convenient to use lexical FHs nowadays...

>sub ReadDir{
>my $dir = shift @_;

Ditto as above!

>opendir DIR, $dir or die "could not open dir $dir";

Ditto as above!

BTW: one can use lexical dirhandles too!

All in all *if* I wanted to maintain the logic of your script (which I
do *not* really want!), then at least I'd rewrite it like


  #!/usr/bin/perl
  
  use strict;
  use warnings;
  
  sub get_dir_entries;
  sub read_file;
  
  my $txt_dir='/path/to/dir';
  
  for (get_dir_entries $txt_dir) {
      next unless /\.txt$/;
      for (read_file "$txt_dir/$_") {
  	# ...
      }
  }
  
  sub get_dir_entries {
      my $dir=shift;
      opendir my $dh, $dir or 
        die "Could not open dir `$dir': $!\n";
      readdir $dh;
  }
  
  sub read_file{
      my $file=shift;
      open my $fh, '<', $file or 
        die "Could not open file `$file': $!\n";
      <$fh>;
  }
  
  __END__


HTH,
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: Sat, 11 Dec 2004 13:54:25 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Open All files one by one
Message-Id: <abqlr0lktapfm2sp3nidceg3hu8jh9uveg@4ax.com>

On Sat, 11 Dec 2004 02:07:21 GMT, "Billy" <bustanut2020@yahoo.com>
wrote:

>All how about:
>
>#!/usr/bin/perl
>use CGI::Carp qw(fatalsToBrowser);

Oh, it was a CGI thing then... ;-)

>use strict;

While you're there do a favour to yourself and

  use warnings;  # too

>my @files = <*.txt>;

Why?!? Do you realize that you do *not* use @files at all,
subsequently?

>while (<*.txt>) {

A faq entry warns about potential issues with glob() in scalar
context. Also, since C<< while (<$fh>) >> is Perl's typical idiom for
"iterate over filehandle", this could be confusing at best. I'd do

  for (<*.txt>) {  # instead.

> open (HANDLE, $_) || die ("Can't open $_: $!");

Maybe it's just me but I'd use a lexical FH anyway:

  open my $fh, '<', $_ or die ...

>Anything wrong with this approach?

Apart the cmts above, I would say: no. Still, if the script is really
that simple I'd use @ARGV's magic as of my previous post instead:


  #!/usr/bin/perl
  
  use strict;
  use warnings;
  # use CGI::Carp qw(fatalsToBrowser);
  
  @ARGV=<*.txt>;
  while (<>) {
     print; # or something else
  }
  
  __END__


HTH,
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: Sat, 11 Dec 2004 13:54:26 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Open All files one by one
Message-Id: <psqlr0dioe0rpdktkd1vi7bt3qdhb289s3@4ax.com>

On 10 Dec 2004 18:02:13 -0800, "yapp" <kvrahul@gmail.com> wrote:

>My sincere apologies for the response. This is the first time I'm
>actually posting on a discussion group. I should have read the rules.
>I just realized all the flaws in my code and appreciate the critical
>comments.

Well, then another "rule" you should get familiar with is that you'd
better quote some relevant context...


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: Sat, 11 Dec 2004 13:54:27 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Open All files one by one
Message-Id: <nuqlr0piotmlak3snvtj9r0f2f8r2a2rt9@4ax.com>

On Sat, 11 Dec 2004 03:18:36 GMT, "Billy" <bustanut2020@yahoo.com>
wrote:

>I found a problem right off... my @files = <*.txt>; only works if I have it
>in the same file directory.

Please note that nothing prevents you to from doing

  my @files = <path/to/dir/*.txt>;


HTH,
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: Sat, 11 Dec 2004 17:14:26 GMT
From: "Billy" <bustanut2020@yahoo.com>
Subject: Re: Open All files one by one
Message-Id: <SVFud.555066$D%.116867@attbi_s51>

> Apart the cmts above, I would say: no. Still, if the script is really
> that simple I'd use @ARGV's magic as of my previous post instead:
>   #!/usr/bin/perl
>
>   use strict;
>   use warnings;
>   # use CGI::Carp qw(fatalsToBrowser);
>
>   @ARGV=<*.txt>;
>   while (<>) {
>      print; # or something else
>   }
>
>   __END__
>
> HTH,
> Michele

Thank you for all the replies... Since I don't know enough of perl yet I
don't know the construct above. Plus I don't know what this will turn into,
I prefer to keep it in a form I can learn from then refine later.

Thank you again....

Billy




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

Date: Sat, 11 Dec 2004 06:23:56 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Passing hashes to a function
Message-Id: <DvKdnVhChLJQRSfcRVn-hA@adelphia.com>

Uri Guttman wrote:

> i am only upset because you gave a job to sherm and not to me.

Someone wants to give me a job? Cool!

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 11 Dec 2004 10:47:52 -0800
From: bulk88@hotmail.com
Subject: Re: perl port to my m68k calculator
Message-Id: <1102790872.147398.124600@z14g2000cwz.googlegroups.com>


Andrew Hamm wrote:
> bulk88@hotmail.com wrote:
> > Can someone please port perl to my 12 mhz Motorola 68000 CPU (same
as
> > in apples) Texas Instruments 89 graphing calculator?
> >
> > There is a C compiler available for the calculator. I would like to
be
> > able to run perl on it because, the BASIC of the calculator is
feature
> > limited, and not good at text processing, or dealing with strings.
And
> > there are no regular expressions and all the flexibility and
glue-ness
> > of Perl. And C isnt so good at strings either, and too much risk of
> > severe crashing. I've written a couple math programs in Perl, which
> > are more text manipulation than math, and it would be wonderful if
I
> > could use them on my calculator.
>
> Holy crap. How much memory? Enough for an executable that's maybe
1.5Mb in
> size, even before you start to deal with your data?
>
> This has to be a joke, surely. If you are serious, you'd have more
luck
> maybe with FORTH, although that can be crap with strings. Perhaps
LISP -
> that's been around forever and used to fit into a tiny footprint.
Both
> these languages are brain-numbing to use, however (imho)
>
> Maybe you should go looking for public source to another Tiny BASIC
which
> supports much better string handling and upload that.
>
> I'd please like someone to Port Algol-68 to my Casio PB-100 pocket
> calculator. It's got a full keyboard and some non-ASCII symbols!
>
> Just for the sake of it, what are the other specs for this
calculator?
> Memory, disk, amount of EPROM....

It has 256KB RAM, 188KB after OS, and 2.7MB FlashROM (effectivly hard
drive). Its a 12mhz Motorola 68000 processor, faster than the Macintosh
Classic realeased in 1993 (which has 8mhz).



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

Date: Sat, 11 Dec 2004 12:09:54 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Reg Hash of Hash
Message-Id: <cpenp6$gso$1@sun3.bham.ac.uk>



Bill Smith wrote:

> "Shashank Khanvilkar" <shashank@mia.ece.uic.edu> wrote in message
> news:cpa79v$594$1@newsx.cc.uic.edu...
>>             $n2 = %{$aa{$n1}};
> 
>                $n2 = (keys %{$aa{$n1}})[0];

Or

              ($n2) = %{$aa{$n1}};

Or more likely

              my ($n2) = %{$aa{$n1}};

Remember: you should always declare all varibles as lexically scoped in 
the smallest applicable scope unless you have a positive reason to do 
otherwise.  You should aquire this habit sooner rather than later - the 
later you leave it the more painfull it will be.   Some people never 
aquire this habit - they mutate into bitter and twisted trolls.



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

Date: Sat, 11 Dec 2004 12:02:00 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Regaular Expression
Message-Id: <YkBud.3521$N%6.1554@trnddc05>

gene_leung@kader.com.hk wrote:
> What is the easy way to convert the below line using regular
> expression:
>
> 123 | 456 || abc ||| cdef |||| end ------> 123 | 456 |\N| abc |\N|\N|
> cdef |\N|\N|\N| end

s/123 | 456 || abc ||| cdef |||| end/123 | 456 |\N| abc |\N|\N|cdef 
|\N|\N|\N| end/
(in one line, of course)
This does do what you asked for but maybe meant to ask for something 
different?

> Please send me email directly!! Thanks!!

That's not how Usenet works.

jue 




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

Date: Sat, 11 Dec 2004 08:08:59 -0500
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: Regaular Expression
Message-Id: <8jCud.54621$dC3.1444621@news20.bellglobal.com>

Jürgen Exner wrote:
>>Please send me email directly!! Thanks!!
> 
> 
> That's not how Usenet works.
> 
> jue 

What he means is to Reply All, not just Reply.

    --- Shawn


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

Date: Sat, 11 Dec 2004 13:38:05 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Regaular Expression
Message-Id: <1LCud.2517$DV3.1607@trnddc06>

Shawn Corey wrote:
> Jürgen Exner wrote:
>>> Please send me email directly!! Thanks!!
>>
>> That's not how Usenet works.
>
> What he means is to Reply All, not just Reply.

???
No idea what you mean with "Reply All". How do you post a reply on Usenet 
that is not visible to all?

jue 




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

Date: 11 Dec 2004 07:24:15 -0800
From: "gene_leung@kader.com.hk" <gene_leung@kader.com.hk>
Subject: Re: Regaular Expression
Message-Id: <1102778655.695059.305140@z14g2000cwz.googlegroups.com>

Sorry for the wording 'Please send me email directly'

Actually this is what I am doing,

cat some_file  | sed 's/|||/|\\N|\\N|g' | sed 's/||/|\\N|/g'

and I do not know the occurence of ||, |||, ||||, |||||, ....
All I want to do is to convert

|| to |\N|
||| to |\N|\N|
|||| to |\N|\N|\N|
|||| to |\N|\N|\N|\N
 ....

Thanks in advance. 

B/R
Gene Leung



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

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 V10 Issue 7508
***************************************


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