[24918] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7168 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 22 18:06:49 2004

Date: Wed, 22 Sep 2004 15:05:18 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 22 Sep 2004     Volume: 10 Number: 7168

Today's topics:
    Re: $\ on Win2k and WinXP <postmaster@castleamber.com>
    Re: $\ on Win2k and WinXP (Jim Keenan)
        comp.lang.perl no longer on groups.google.com <nobull@mail.com>
    Re: comp.lang.perl no longer on groups.google.com <uri@stemsystems.com>
    Re: comp.lang.perl no longer on groups.google.com <noreply@gunnar.cc>
    Re: comp.lang.perl no longer on groups.google.com <uri@stemsystems.com>
    Re: FuzzySearch library updated to version 2.3 <troc@pobox.com>
    Re: How is this Perl Script encrypted? i6033162556-signup1@yahoo.com.cn
    Re: How is this Perl Script encrypted? <nobull@mail.com>
    Re: How is this Perl Script encrypted? <1usa@llenroc.ude.invalid>
    Re: How is this Perl Script encrypted? <jerf@jerf.org>
        Modulus Operator (%) <mikeflan@earthlink.net>
    Re: Modulus Operator (%) <1usa@llenroc.ude.invalid>
    Re: Modulus Operator (%) <mritty@gmail.com>
    Re: Modulus Operator (%) <mikeflan@earthlink.net>
    Re: Modulus Operator (%) <nobull@mail.com>
        Mystery message: Undefined subroutine &OS2::Bootdrive (Seymour J.)
    Re: Mystery message: Undefined subroutine &OS2::Bootdri <dmcbride@naboo.to.org.no.spam.for.me>
    Re: new commands written in perl <abigail@abigail.nl>
    Re: new commands written in perl <abigail@abigail.nl>
        order a semicolon-separated data file by a value of a c <stfhostf@kartos.de>
    Re: order a semicolon-separated data file by a value of <nobull@mail.com>
    Re: order a semicolon-separated data file by a value of <stfhostf@kartos.de>
    Re: Perl script to clean up file -- Dont know if it can (Larry Felton Johnson)
    Re: Perl script to clean up file -- Dont know if it can (Larry Felton Johnson)
    Re: Printing an array of hash refs <shawn.corey@sympatico.ca>
    Re: Printing an array of hash refs <mritty@gmail.com>
    Re: Printing an array of hash refs <someone@example.com>
        Regexp-matching character n times in the line. (Rodrigo A B Freire)
    Re: Regexp-matching character n times in the line. <mritty@gmail.com>
    Re: Regexp-matching character n times in the line. <nobull@mail.com>
    Re: what module could easiely load all files to a @arra <1usa@llenroc.ude.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 22 Sep 2004 18:14:14 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: $\ on Win2k and WinXP
Message-Id: <Xns956C86A7D8EEBcastleamber@130.133.1.4>

jonas.berling@knowit.se (Jonas) wrote in news:95db9f5c.0409220516.66ca6cc7
@posting.google.com:

> I've got a fairly straightforward Perl script that does a RegEx match
> over whole files, i.e. it matches things even if they are on separate
> rows. I do this by undefining $\ and it works great on Win2k using
> ActivePerl 5.8.4.810. But using the same script and the same version
> of ActivePerl on a WinXp Professional machine does not work though,
> unless I specify a -0777 command line parameter to the Perl
> interpreter. Does anybody know of this problem and if so, is there a
> solution?

Haven't seen it here IIRC (WinXP, Spanish version). I use File::Slurp most 
of the time anyway. 

-- 
John                               MexIT: http://johnbokma.com/mexit/
                           personal page:       http://johnbokma.com/
        Experienced programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html


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

Date: 22 Sep 2004 14:32:21 -0700
From: jkeen_via_google@yahoo.com (Jim Keenan)
Subject: Re: $\ on Win2k and WinXP
Message-Id: <196cb7af.0409221332.3901d779@posting.google.com>

jonas.berling@knowit.se (Jonas) wrote in message news:<95db9f5c.0409220516.66ca6cc7@posting.google.com>...
> I've got a fairly straightforward Perl script that does a RegEx match
> over whole files, i.e. it matches things even if they are on separate
> rows. I do this by undefining $\ and it works great on Win2k using
> ActivePerl 5.8.4.810. But using the same script and the same version
> of ActivePerl on a WinXp Professional machine does not work though,
> unless I specify a -0777 command line parameter to the Perl
> interpreter. Does anybody know of this problem and if so, is there a
> solution?
> 
Could you post a *short* version of a file which works on Win2K but
not on WinXP without the parameter cited?

Also, can you specify what you mean by "does not work"?  Does the
pattern patch simply fail?  Or is it something more serious, such as a
warning or error?

Thanks.

Jim Keenan


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

Date: Wed, 22 Sep 2004 20:25:27 +0100
From: Brian McCauley <nobull@mail.com>
Subject: comp.lang.perl no longer on groups.google.com
Message-Id: <cisjja$h4r$1@slavica.ukpost.com>

groups.google.com has finally dropped comp.lang.perl.  I'd tried to 
persuade them to keep it but to include a prominant warning.  I failed.

Well, I guess this means those people who post to the defunct groups 
will now have to wallow in their own ignorance.



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

Date: Wed, 22 Sep 2004 19:40:29 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: comp.lang.perl no longer on groups.google.com
Message-Id: <x7llf2ks9f.fsf@mail.sysarch.com>

>>>>> "BM" == Brian McCauley <nobull@mail.com> writes:

  BM> groups.google.com has finally dropped comp.lang.perl.  I'd tried
  BM> to persuade them to keep it but to include a prominant warning.  I
  BM> failed.

hopefully they still archive and keep searchable the old stuff when it
was a live group.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Wed, 22 Sep 2004 22:00:12 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: comp.lang.perl no longer on groups.google.com
Message-Id: <2re3s4F193u1fU1@uni-berlin.de>

Uri Guttman wrote:
>>>>>>"BM" == Brian McCauley <nobull@mail.com> writes:
> 
>   BM> groups.google.com has finally dropped comp.lang.perl.  I'd tried
>   BM> to persuade them to keep it but to include a prominant warning.  I
>   BM> failed.
> 
> hopefully they still archive and keep searchable the old stuff when it
> was a live group.

"This group is no longer archived" indicates something else. :(

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


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

Date: Wed, 22 Sep 2004 20:31:07 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: comp.lang.perl no longer on groups.google.com
Message-Id: <x77jqmkpx2.fsf@mail.sysarch.com>

>>>>> "GH" == Gunnar Hjalmarsson <noreply@gunnar.cc> writes:

  GH> Uri Guttman wrote:
  >>>>>>> "BM" == Brian McCauley <nobull@mail.com> writes:
  BM> groups.google.com has finally dropped comp.lang.perl.  I'd
  >> tried
  BM> to persuade them to keep it but to include a prominant warning.  I
  BM> failed.
  >> hopefully they still archive and keep searchable the old stuff when
  >> it
  >> was a live group.

  GH> "This group is no longer archived" indicates something else. :(

that could mean no longer 'actively' archived. i see no reason why they
won't keep the old posts as it was the only valid perl group in those
days. i don't think they would delete the group from the archive but
more likely just stop adding any new posts in the group to the archive.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Wed, 22 Sep 2004 20:15:07 GMT
From: Rocco Caputo <troc@pobox.com>
Subject: Re: FuzzySearch library updated to version 2.3
Message-Id: <slrncl3nbe.hdf.troc@eyrie.homenet>

On 22 Sep 2004 00:25:11 -0700, SoftComplete Development wrote:
> FuzzySearch library is  an approximate string matching concerns to
> find patterns in texts in presence of "mismatches" or "errors".
[...]
> FuzzySearch library available for Delphi, VC, VB/VBA, and also can
> be used in any language as COM-object.

See also String::Approx and perldoc perlre for Perl solutions that
aren't dependent on the presence of Windows.

-- 
Rocco Caputo - http://poe.perl.org/


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

Date: 22 Sep 2004 12:19:11 -0700
From: i6033162556-signup1@yahoo.com.cn
Subject: Re: How is this Perl Script encrypted?
Message-Id: <23d1674e.0409221119.166cb8de@posting.google.com>

> 
> > I got the file, but still can not find how they use a key to verfy the
> > lisence of the script. Also, once I made some change to the file then
> > change it back, it does not work. It has some self destruction feature
> > that once the script is changed, it is not working.
> 
> You might want to look at the key_isValid and key_isValid_simple 
> subroutines.
> 
> Your time working on this is wasted.
I think I am not wasting time, as this code is 100% protected.
Unbreakable.
If you don't think so, make a change to the unpacked file and run it.
It gaves errors once the file is changed.
I looked at both key_isValid and key_isValid_simple. However, I did
not see any unicode or special charactors to prevent the file from
resave. How does he do that in the file? My theory is that there is a
character like "Copyright C" and text editors can not save it, so once
somebody trys to change the file and re save it. The whole script will
not work.


sub key_isValid
{
local($p, $i, $k) = @_;
$k = &key_format($k);
return (0, 0) if ($i eq "" || $k eq "");
return (1, 0) if ($k eq &key_make($p, $i));
local($t) = &clock_sub("%y%m%d", $^T);
local($d) = substr($k, 20, 4) . substr($k, 25, 2);
local($v) = $k eq &key_make_dated($p, $i, $d);
local($s) = sprintf("%s/%s/%s", substr($d, 0, 2), substr($d, 2, 2),
substr($d, 4, 2));
return ($v && $d > $t, $v ? $s : 0);
}
sub key_make
{
local($p, $i) = @_;
return &key_format(sprintf("%08x%08x", &crc32_calc($p . $i),
&crc32_calc($i x 3)));
}
sub key_make_dated
{
local($p, $i, $d) = @_;
return &key_format(sprintf("%08x%08x", &crc32_calc($p . $i . $d),
&crc32_calc(($i x 3) . $d)) . $d);
}
sub key_isValid_simple
{
local($p, $i, $k) = @_;
return &key_format($k) eq &key_format(sprintf("%08x",
&crc32_calc("$p:$i")));
}
sub key_format
{
local($s) = @_;
$s =~ s/o/0/ig;
$s =~ s/i/1/ig;
$s =~ s/s/5/ig;
$s =~ s/[^0-9a-f]//ig;
$s =~ s/(....)/$1\-/ig;
$s =~ s/\-$//;
return uc $s;
}


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

Date: Wed, 22 Sep 2004 22:07:34 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: How is this Perl Script encrypted?
Message-Id: <cispim$hl8$1@slavica.ukpost.com>



i6033162556-signup1@yahoo.com.cn wrote:
>>>I got the file, but still can not find how they use a key to verfy the
>>>lisence of the script. Also, once I made some change to the file then
>>>change it back, it does not work. It has some self destruction feature
>>>that once the script is changed, it is not working.
>>
>>You might want to look at the key_isValid and key_isValid_simple 
>>subroutines.
>>
>>Your time working on this is wasted.
> 
> I think I am not wasting time,

In that case, I've got this design for a perpetual motion machine. All I 
need is a bit of capital to develop it.  Are you interested in investing?

> If you don't think so, make a change to the unpacked file and run it.
> It gaves errors once the file is changed.

Unless, of course, you remove the check.

> I looked at both key_isValid and key_isValid_simple. However, I did
> not see any unicode or special charactors to prevent the file from
> resave. How does he do that in the file? My theory is that there is a
> character like "Copyright C" and text editors can not save it, so once
> somebody trys to change the file and re save it.

Errr.. so get a better editor.

> The whole script will not work.

But the script, less the protection mechanism, will.



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

Date: 22 Sep 2004 21:14:54 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: How is this Perl Script encrypted?
Message-Id: <Xns956CAF761B39Aasu1cornelledu@132.236.56.8>

i6033162556-signup1@yahoo.com.cn wrote in
news:23d1674e.0409221119.166cb8de@posting.google.com: 

[ Don't snip attributions ]

"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in
news:Xns956C5659DF5DBasu1cornelledu@132.236.56.8: 

>> Your time working on this is wasted.

> I think I am not wasting time, as this code is 100% protected.
> Unbreakable.

That is more a statement about your abilities than the strength of the 
protection scheme.

> If you don't think so, make a change to the unpacked file and run it.
> It gaves errors once the file is changed.

Does it still give errors if you replace the two subs with:

sub key_isValid { return 1; }

sub key_isValid_simple { return 1; }

Or if you remove the calls to those subs?

> How does he do that in the file? My theory is 

You don't need a theory. The code is there for you read.

> that there is a character like "Copyright C" and text editors 
> can not save it, so once somebody trys to change the file and 
> re save it. The whole script will not work.

Sigh.

-- 
A. Sinan Unur
1usa@llenroc.ude.invalid 
(remove '.invalid' and reverse each component for email address)



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

Date: Wed, 22 Sep 2004 21:51:52 GMT
From: Jeremy Bowers <jerf@jerf.org>
Subject: Re: How is this Perl Script encrypted?
Message-Id: <pan.2004.09.23.22.15.35.212539@jerf.org>

On Wed, 22 Sep 2004 12:19:11 -0700, i6033162556-signup1 wrote:
> I think I am not wasting time, as this code is 100% protected.
> Unbreakable.

Only for you, apparently. You need to consider whether you are protecting
your code from yourself, or the vastly more skilled people all around you.
If the former is your goal, say so clearly and I'm sure some people will
help you shoot yourself in the foot out of some perverse pleasure. If the
latter is your goal, the advice has already been given; what you want is
not possible, not in Perl, not in any language.

At any rate, even if it were possible, you'd need to be more skilled than
the hackers, and you show no particular evidence of being anywhere near
that skilled. Rather you look like you just started perl, and maybe
programming in general, a matter of months ago. Frankly, given your
attitude and skills demonstrated in this thread, I think you first need to
worry about producing code worth protecting at all. Don't put the cart
before the horse.



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

Date: Wed, 22 Sep 2004 18:56:13 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Modulus Operator (%)
Message-Id: <4151CB14.7F04762C@earthlink.net>


Got an easy one here:

use strict;
use warnings;

my $num1 = 10.564;
my $num2 = 4;
my $num3 = $num1 % $num2;

print "\n$num1 - $num2 - $num3\n\n";


When I run that I get
10.564 - 4 - 2

I expected
10.564 - 4 - 2.564


The documentation says:
Binary ``%'' computes the modulus of two numbers. Given integer operands
$a
and $b: If $b is positive, then $a % $b is $a minus the largest multiple
of
$b that is not greater than $a.

snip

Note than when use integer is in scope, ``%'' gives you
direct access to the modulus operator as implemented by your C compiler.
This
operator is not as well defined for negative operands, but it will
execute faster.


What am I not seeing in all this?


Mike Flannigan




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

Date: 22 Sep 2004 19:04:05 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Modulus Operator (%)
Message-Id: <Xns956C9948C8B09asu1cornelledu@132.236.56.8>

Mike Flannigan <mikeflan@earthlink.net> wrote in 
news:4151CB14.7F04762C@earthlink.net:

> 
> Got an easy one here:
> 
> use strict;
> use warnings;
> 
> my $num1 = 10.564;
> my $num2 = 4;
> my $num3 = $num1 % $num2;
> 
> print "\n$num1 - $num2 - $num3\n\n";
> 
> 
> When I run that I get
> 10.564 - 4 - 2
> 
> I expected
> 10.564 - 4 - 2.564
> 
> 
> The documentation says:
> Binary ``%'' computes the modulus of two numbers. Given integer 
> operands $a and $b: 

 ...

> What am I not seeing in all this?

"Integer operands".

Sinan.
-- 
A. Sinan Unur
1usa@llenroc.ude.invalid 
(remove '.invalid' and reverse each component for email address)



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

Date: Wed, 22 Sep 2004 19:04:32 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Modulus Operator (%)
Message-Id: <41k4d.7643$uz1.5581@trndny03>

"Mike Flannigan" <mikeflan@earthlink.net> wrote in message
news:4151CB14.7F04762C@earthlink.net...
> use strict;
> use warnings;
>
> my $num1 = 10.564;
> my $num2 = 4;
> my $num3 = $num1 % $num2;
>
> print "\n$num1 - $num2 - $num3\n\n";
> When I run that I get
> 10.564 - 4 - 2
>
> I expected
> 10.564 - 4 - 2.564
>
> The documentation says:
> Binary ``%'' computes the modulus of two numbers. Given integer
operands
> $a and $b: If $b is positive, then $a % $b is $a minus the largest
multiple
> of $b that is not greater than $a.
>
>
> What am I not seeing in all this?

The part that said "given integer operands".  That means that the
operands to % are converted to integers, regardless of what they
actually are.  This is a lesser example of Perl's well known type
conversions (ex, converting the string "5\n" to the number 5 when used
in an addition operation).  The arguments are converted from whatever
they are (strings, decimals, etc) to integers, and the results of those
conversions are used in the operation.

Paul Lalli




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

Date: Wed, 22 Sep 2004 19:10:00 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Modulus Operator (%)
Message-Id: <4151CE52.73BDD9C3@earthlink.net>


Paul Lalli wrote:

> The part that said "given integer operands".  That means that the
> operands to % are converted to integers, regardless of what they
> actually are.  This is a lesser example of Perl's well known type
> conversions (ex, converting the string "5\n" to the number 5 when used
> in an addition operation).  The arguments are converted from whatever
> they are (strings, decimals, etc) to integers, and the results of those
> conversions are used in the operation.
>
> Paul Lalli

Ah yes - I thought I'd be hitting myself in the head.
Thanks alot guys.


Mike




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

Date: Wed, 22 Sep 2004 20:14:42 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Modulus Operator (%)
Message-Id: <cisiv4$h3d$1@slavica.ukpost.com>



Mike Flannigan wrote:

> my $num1 = 10.564;
> my $num2 = 4;
> my $num3 = $num1 % $num2;
> 
> print "\n$num1 - $num2 - $num3\n\n";
> 
> 
> When I run that I get
> 10.564 - 4 - 2
> 
> I expected
> 10.564 - 4 - 2.564
> 
> 
> The documentation says:
> Binary ``%'' computes the modulus of two numbers. Given integer operands
> $a and $b:

> What am I not seeing in all this?

The implication that "given integer operands" really means "given 
operands that will be converted to integers".



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

Date: Wed, 22 Sep 2004 16:12:08 -0300
From: "Shmuel (Seymour J.) Metz" <spamtrap@library.lspace.org.invalid>
Subject: Mystery message: Undefined subroutine &OS2::Bootdrive
Message-Id: <4151dc98$12$fuzhry+tra$mr2ice@news.patriot.net>

I've been modifying a Perl Program to support OS/2, and I've run into
a bizare anomaly with the ternary operator. I was getting an error
message on the statement

   my $etc   = $ENV{ETC} or ($^O eq 'os2') ? OS2::Bootdrive() :
'/etc';

So I decided to try testing it a bit at a time. Each of the following
produces the expected output:

 print '$ENV{ETC}=',$ENV{ETC},"\n";
 print "OS=$^O\n";
 print '$^O eq os2=',($^O eq 'os2'),"\n";
 print 'BootDrive=',OS2::BootDrive(),"\n";
 print "($^O eq 'os2') ? OS2::Bootdrive() : '/etc'=";
 print  $^O eq 'os2' ? 'true' : 'false',"\n";

 [H:\]bwwhois 200.204.145.122
 $ENV{ETC}=G:\MPTN\ETC
 OS=os2
 $^O eq os2=1
 BootDrive=g
 (os2 eq 'os2') ? OS2::Bootdrive() : '/etc'=true

However, 

 print  $^O eq 'os2' ? OS2::Bootdrive() : '/etc',"\n";

gives me

 Undefined subroutine &OS2::Bootdrive called at H:\UTILITY/BWwhois.cmd
line 61.

Note that the spelling is identical to the one that worked, so I
assume that the problem has something to do with the context of a
ternary operator. Any assistance will be appreciated.

The relevant code in context is:

 require 5.006_00;   # must use a modern perl
 use strict;
 use IO::File;
 use IO::Socket;
 use Getopt::Long;
 use Fcntl ':flock';

 my $VERSION = "3.4";

 # Changes in support of OS/2
 print '$ENV{ETC}=',$ENV{ETC},"\n";
 print "OS=$^O\n";
 print '$^O eq os2=',($^O eq 'os2'),"\n";
 print 'BootDrive=',OS2::BootDrive(),"\n";
 print "($^O eq 'os2') ? OS2::Bootdrive() : '/etc'=";
 print  $^O eq 'os2' ? 'true' : 'false',"\n";
 print  $^O eq 'os2' ? OS2::Bootdrive() : '/etc',"\n";
 exit;
 my $etc   = $ENV{ETC};
 #my $etc   = $ENV{ETC} or ($^O eq 'os2') ? OS2::Bootdrive() : '/etc';
 my $whois = File::Spec->catdir($etc,'whois');
 # print '$etc=',$etc,"\n";
 # print '$whois=',$whois,"\n";


-- 
Shmuel (Seymour J.) Metz, SysProg and JOAT  <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action.  I reserve the
right to publicly post or ridicule any abusive E-mail.  Reply to
domain Patriot dot net user shmuel+news to contact me.  Do not
reply to spamtrap@library.lspace.org



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

Date: Wed, 22 Sep 2004 21:37:57 GMT
From: Darin McBride <dmcbride@naboo.to.org.no.spam.for.me>
Subject: Re: Mystery message: Undefined subroutine &OS2::Bootdrive
Message-Id: <Vgm4d.75406$%S.49494@pd7tw2no>

Shmuel (Seymour J.) Metz wrote:

> I've been modifying a Perl Program to support OS/2, and I've run into
> a bizare anomaly with the ternary operator. I was getting an error
> message on the statement
> 
>    my $etc   = $ENV{ETC} or ($^O eq 'os2') ? OS2::Bootdrive() :
> '/etc';
> 
> So I decided to try testing it a bit at a time. Each of the following
> produces the expected output:
> 
>  print '$ENV{ETC}=',$ENV{ETC},"\n";
>  print "OS=$^O\n";
>  print '$^O eq os2=',($^O eq 'os2'),"\n";
>  print 'BootDrive=',OS2::BootDrive(),"\n";
>  print "($^O eq 'os2') ? OS2::Bootdrive() : '/etc'=";
>  print  $^O eq 'os2' ? 'true' : 'false',"\n";
> 
>  [H:\]bwwhois 200.204.145.122
>  $ENV{ETC}=G:\MPTN\ETC
>  OS=os2
>  $^O eq os2=1
>  BootDrive=g
>  (os2 eq 'os2') ? OS2::Bootdrive() : '/etc'=true
> 
> However,
> 
>  print  $^O eq 'os2' ? OS2::Bootdrive() : '/etc',"\n";
> 
> gives me
> 
>  Undefined subroutine &OS2::Bootdrive called at H:\UTILITY/BWwhois.cmd
> line 61.
> 
> Note that the spelling is identical to the one that worked, so I
> assume that the problem has something to do with the context of a
> ternary operator. Any assistance will be appreciated.

I would actually assume it's the comma ... try putting some extra
parens in there to keep your meaning clear:

  print ($^O eq 'os2' ? OS2::Bootdrive() : '/etc'),"\n";

> The relevant code in context is:
> 
>  require 5.006_00;   # must use a modern perl
>  use strict;
>  use IO::File;
>  use IO::Socket;
>  use Getopt::Long;
>  use Fcntl ':flock';
> 
>  my $VERSION = "3.4";
> 
>  # Changes in support of OS/2
>  print '$ENV{ETC}=',$ENV{ETC},"\n";
>  print "OS=$^O\n";
>  print '$^O eq os2=',($^O eq 'os2'),"\n";
>  print 'BootDrive=',OS2::BootDrive(),"\n";
>  print "($^O eq 'os2') ? OS2::Bootdrive() : '/etc'=";
>  print  $^O eq 'os2' ? 'true' : 'false',"\n";
>  print  $^O eq 'os2' ? OS2::Bootdrive() : '/etc',"\n";
>  exit;
>  my $etc   = $ENV{ETC};
>  #my $etc   = $ENV{ETC} or ($^O eq 'os2') ? OS2::Bootdrive() : '/etc';
>  my $whois = File::Spec->catdir($etc,'whois');
>  # print '$etc=',$etc,"\n";
>  # print '$whois=',$whois,"\n";
> 
> 


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

Date: 22 Sep 2004 21:01:54 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: new commands written in perl
Message-Id: <slrncl3q22.ka0.abigail@alexandra.abigail.nl>

Gregory Toomey (nospam@bigpond.com) wrote on MMMMXL September MCMXCIII in
<URL:news:2rd6jhF18jmuvU1@uni-berlin.de>:
;;  Abigail wrote:
;;  
;; > Of course, the shell has much
;; > cooler strings than Perl has.
;; > 
;; > Abigail
;;  
;;  Why do you say that. I don't know where I'd be without
;;  " ...@{[subcall()]} ..."  (or japhs for that matter).

In the shell, I write that as:

    "...`prog`..." 

or

    "...$(prog)..."



Abigail
-- 
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;        
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";


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

Date: 22 Sep 2004 21:04:24 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: new commands written in perl
Message-Id: <slrncl3q6o.ka0.abigail@alexandra.abigail.nl>

Eric Schwartz (emschwar@pobox.com) wrote on MMMMXL September MCMXCIII in
<URL:news:etosm9ab5yd.fsf@wilson.emschwar>:
__  Abigail <abigail@abigail.nl> writes:
__ > No, no, no. As a general principle, use single quotes if your string
__ > contains (or may contain in the future) quotes, or a dollar or @ sign
__ > you don't want to interpolate. Otherwise, use double quotes.
__  
__  As I said, opinions differ, and I don't particularly care either way--
__  If I worked where the local style was different, I would adjust easily.
__  
__ > You'll notice that means you will have to change quotes far less often
__ > than if your default is single quotes.
__  
__  It all depends on what you're saying.  My style says, "I'm calling
__  your attention to when I want to interpolate something," yours calls
__  attention to when you DON'T want to interpolate.  That's fine, too.

No. Not at all. My style doesn't "call attention". It minimizes work.
I use quotes for what they are, quotes. It doesn't have a meta meaning.
They are there for the parser and nothing else.



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'


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

Date: Wed, 22 Sep 2004 21:06:59 GMT
From: Stefan H. <stfhostf@kartos.de>
Subject: order a semicolon-separated data file by a value of a column
Message-Id: <omp3l0d83du14d7kcace011ngrupkrfm3g@4ax.com>

Hi,

I have a text data file with some thousands of rows like those:


foo;bar;33ec32.34c;0_164425;12.2;old;;99;dg; ;#asa;
table;mouse;3c32.34c;0_164425;12.2;corner;;99;ddaw2; ;/#;
see;lock;33ec3erwc;5_1121;12.2;bold;;99;ddaw2; ;//;
 ...

the records are semicolon separated and each field can contain letters,
digits, dots, #, / and so on. All records have the same number of
fields.

I need to order the data file by the value of the fifth column (a real
number). How can I do? Sorry but I'm a very beginner in perl :-(

Thanks
Stefan


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

Date: Wed, 22 Sep 2004 22:11:52 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: order a semicolon-separated data file by a value of a column
Message-Id: <cispqo$hmp$1@slavica.ukpost.com>



Stefan H. wrote:

> I have a text data file with some thousands of rows like those:
> 
> 
> foo;bar;33ec32.34c;0_164425;12.2;old;;99;dg; ;#asa;
> table;mouse;3c32.34c;0_164425;12.2;corner;;99;ddaw2; ;/#;
> see;lock;33ec3erwc;5_1121;12.2;bold;;99;ddaw2; ;//;
> ...
> 
> the records are semicolon separated and each field can contain letters,
> digits, dots, #, / and so on. All records have the same number of
> fields.
> 
> I need to order the data file by the value of the fifth column (a real
> number). How can I do?

What have you tried so far?

Has it invoved...

perldoc -q sort
perldoc -f sort



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

Date: Wed, 22 Sep 2004 21:47:37 GMT
From: Stefan H. <stfhostf@kartos.de>
Subject: Re: order a semicolon-separated data file by a value of a column
Message-Id: <6ks3l0larol8qc86d52b18euu079krgapg@4ax.com>

On Wed, 22 Sep 2004 22:11:52 +0100, Brian McCauley <nobull@mail.com>
wrote:

>What have you tried so far?
>
>Has it invoved...


yes, you're right

I tried this:
(for simplicity I removed declarations etc)




open(DATAFILE, "data.csv");

while (<DATAFILE>) {
push @not_ordered_list, $_;
}

sub by_value {
# this function is used by sort
local @a, @b;

# put each line into a list
@a = split /;/, $a;
@b = split /;/, $b;

#then compare the values
$a = $a[5];
$b = $b[5];

$a <=> $b;
}

open (DATA_OUT, ">ordered_data.csv");

my @ordered_list = sort by_value @not_ordered_list;

seek (DATAFILE, 0,0);
 while (<DATAFILE>) {
   $,=";";   
   @data_record = split /;/, $_;

print DATA_OUT @data_record;
 }

close (DATAFILE);
close (DATA_OUT);


the output file is not ordered.

Sorry for the bad code!

Thanks


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

Date: 22 Sep 2004 11:31:38 -0700
From: larryj@gsu.edu (Larry Felton Johnson)
Subject: Re: Perl script to clean up file -- Dont know if it can be done
Message-Id: <4ae7bf57.0409221031.5463bd7d@posting.google.com>

thundergnat <thundergnat@hotmail.com> wrote in message news:<415191b4$0$2661$61fed72c@news.rcn.com>...
> LHradowy wrote:
> > I thought I would throw this out there, I think it can not be done, but I am
> > not a guru.
> > 
> > This is the problem I get a file that I must pull the pertanent data out. I
> > has a header and footer, as well as page breaks, this is all in ASCII
> > format. I need to pull out just the columns.
> > I do this all manually (delete the header and footer, and well as all the
> > page breaks) there are also at times a 0 at the beginning of a record that I
> > do not want there as well.
> > 
> > This is what the file looks like...
> 
> Assuming the datas format ALWAYS looks like that:
> 
> pass the data file as a parameter.
> 
> while(<>){
>      if (/CUSTOMER HAS|TELN NOT BILL/){
>          $_ =~ s/^0?\s+(\d+)\D+(.{10})\W+(.+?)/$1,$2,$3/;
>          print;
>      }
> }


thundergnat's correct, and in fact if a file has enough consistency to
describe in plain English, you can almost always find a set of regexes
to include, rearrange and exclude the things you'd like.  Assuming
that you are working in two passes on this data (the one described in
your previous post to deal with the individual data line and this more
verbose file) you could probably substitute the line from the regex I
posted to the other thread for the one above and do the entire
transformation in one pass.  I'll cut and paste and run it later, but
the if statement above might even be unneccessary, since the
substitution probably only matches the relevant lines.

Larry


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

Date: 22 Sep 2004 12:07:02 -0700
From: larryj@gsu.edu (Larry Felton Johnson)
Subject: Re: Perl script to clean up file -- Dont know if it can be done
Message-Id: <4ae7bf57.0409221107.631e23e7@posting.google.com>

"LHradowy" <laura.hradowy@NOSPAM.mts.caaaaa> wrote in message news:<WWe4d.2141$IO.13667@news1.mts.net>...
> I thought I would throw this out there, I think it can not be done, but I am
> not a guru.
> 
> This is the problem I get a file that I must pull the pertanent data out. I
> has a header and footer, as well as page breaks, this is all in ASCII
> format. I need to pull out just the columns.
> I do this all manually (delete the header and footer, and well as all the
> page breaks) there are also at times a 0 at the beginning of a record that I
> do not want there as well.
> 
> This is what the file looks like...
> 

The following code did it in one pass (stripping the file of the extraneous
stuff and doing the transformation).  Since I only have access to what you've
presented, I don't consider my run a real test.  But you get the general
picture.  If you are only interested in certain lines you can just focus
your match on the characteristics of those lines and try to do any transformations 
at the same time.

Here's the code snippett (I named the file I copied your code into file2

#!/usr/bin/perl -w

use strict;

my $infile = 'file2';
my $outfile = 'outfile';

open INFILE, "$infile" or die "Can't open $infile: $!\n";
open OUTFILE, ">$outfile" or die "Can't open $outfile: $!\n";


while (<INFILE>) {
  if (s/^0?\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(.*)/$1,$2  $3  $4  $5,$6/) {
      print OUTFILE "$_";
  }
}


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

Date: Wed, 22 Sep 2004 14:08:13 -0400
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: Printing an array of hash refs
Message-Id: <Fbj4d.17679$pA.1240792@news20.bellglobal.com>

Paul Lalli wrote:
> "Tony N." <tnitzke@simpson.com> wrote in message
> news:638483db.0409220735.49486c78@posting.google.com...
> 
>>I'm using the following code to print an array of hash refs.  It seems
>>to me there should be a more concise way to do this.  I don't like the
>>trailing \t or the extra line of code to get the \n.  Any pointers
>>would be appreciated.
>>for my $row (@rows) {
>>  print "$row->{$_}\t" for sort keys %{$row};
>>  print "\n";
>>}
> 
> 
> for my $row (@rows){
>     print (join ("\t", sort keys %$row), "\n");
> }
> 
> Paul Lalli
> 
> 
Isn't it?

   print join( "\t", map { $row->{$_} } sort keys %$row ), "\n";

	--- Shawn



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

Date: Wed, 22 Sep 2004 18:28:07 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Printing an array of hash refs
Message-Id: <Xuj4d.3400$Ec4.1940@trndny04>

"Shawn Corey" <shawn.corey@sympatico.ca> wrote in message
news:Fbj4d.17679$pA.1240792@news20.bellglobal.com...
> Paul Lalli wrote:
> > "Tony N." <tnitzke@simpson.com> wrote in message
> > news:638483db.0409220735.49486c78@posting.google.com...
> >
> >>for my $row (@rows) {
> >>  print "$row->{$_}\t" for sort keys %{$row};
> >>  print "\n";
> >>}
> >
> > for my $row (@rows){
> >     print (join ("\t", sort keys %$row), "\n");
> > }
>
> Isn't it?
>
>    print join( "\t", map { $row->{$_} } sort keys %$row ), "\n";

Ah, quite correct.  I neglected to realize the OP wanted the hash values
rather than the hash keys.  Thanks for the correction.

Paul Lalli




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

Date: Wed, 22 Sep 2004 21:24:27 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Printing an array of hash refs
Message-Id: <f4m4d.75234$KU5.22026@edtnps89>

Tony N. wrote:
> I'm using the following code to print an array of hash refs.  It seems
> to me there should be a more concise way to do this.  I don't like the
> trailing \t or the extra line of code to get the \n.  Any pointers
> would be appreciated.
> 
> print "$_\t" for sort keys %{$rows[0]};
> print "\n";
> 
> for my $row (@rows) {
> 	print "$row->{$_}\t" for sort keys %{$row};
> 	print "\n";
> 
> }

print map { my $row = $_; join( "\t", map $row->{$_}, sort keys %$row ) . "\n" 
} @rows;


John
-- 
use Perl;
program
fulfillment


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

Date: 22 Sep 2004 11:49:14 -0700
From: nntpstuffs@brasilia.br (Rodrigo A B Freire)
Subject: Regexp-matching character n times in the line.
Message-Id: <74f425c.0409221049.46918809@posting.google.com>

Regexp gurus,

I'm trying to build a regular expression that matches a exact count of
a character.

I explain.

Analyzing my mail log, I noticed that *every* traffic with sender
addresses containing four underscores are spam. Examples:

as_2asf_345__e@foo.bar
a_b_fefa_or_@foo.bar
__fooad3__@foo.bar

The regexp should match every email address containing 4 underscores.

Any idea?

Thank you,

Rod.


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

Date: Wed, 22 Sep 2004 19:00:55 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Regexp-matching character n times in the line.
Message-Id: <HZj4d.2202$Pz3.902@trndny01>

"Rodrigo A B Freire" <nntpstuffs@brasilia.br> wrote in message
news:74f425c.0409221049.46918809@posting.google.com...
> Regexp gurus,
>
> I'm trying to build a regular expression that matches a exact count of
> a character.
>
> I explain.
>
> Analyzing my mail log, I noticed that *every* traffic with sender
> addresses containing four underscores are spam. Examples:
>
> as_2asf_345__e@foo.bar
> a_b_fefa_or_@foo.bar
> __fooad3__@foo.bar
>
> The regexp should match every email address containing 4 underscores.
>
> Any idea?

perldoc -q count
             There are a number of ways, with varying efficiency.
             If you want a count of a certain single character
             (X) within a string, you can use the "tr///"
             function like so:

                 $string = "ThisXlineXhasXsomeXx'sXinXit";
                 $count = ($string =~ tr/X//);
                 print "There are $count X characters in the string";

Paul Lalli




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

Date: Wed, 22 Sep 2004 20:10:49 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Regexp-matching character n times in the line.
Message-Id: <cisinv$h34$1@slavica.ukpost.com>



Rodrigo A B Freire wrote:

> I'm trying to build a regular expression that matches a exact count of
> a character.
> 
> I explain.
> 
> Analyzing my mail log, I noticed that *every* traffic with sender
> addresses containing four underscores are spam. Examples:
> 
> as_2asf_345__e@foo.bar
> a_b_fefa_or_@foo.bar
> __fooad3__@foo.bar
> 
> The regexp should match every email address containing 4 underscores.

/^([^_]*_){4}[^_]*$/




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

Date: 22 Sep 2004 18:15:36 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: what module could easiely load all files to a @array from a specified folder(and subfolders)?
Message-Id: <Xns956C910FFF633asu1cornelledu@132.236.56.8>

Alont <end@dream.life> wrote in news:4151a17b.15044562@130.133.1.4:

> just tell me the name of module,

Don't order people around.

> my english too poor to can't understand all module help files, forgive
> me....

Oh, you put your entire question in the subject line. Don't do that. 
(This has nothing to do with your language abilities, it is just common 
sense).

Your question was:

> what module could easiely load all files to a @array 
> from a specified folder(and subfolders)?

Well, there is actually a nontrivial choice between using a hash versus 
an array to store the list of files, so think about that. It depends on 
what you want to do with those files ones you have the names.

Take a look at File::Find or File::Finder.

-- 
A. Sinan Unur
1usa@llenroc.ude.invalid 
(remove '.invalid' and reverse each component for email address)



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

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


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