[23033] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5253 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 21 21:05:58 2003

Date: Mon, 21 Jul 2003 18:05:08 -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           Mon, 21 Jul 2003     Volume: 10 Number: 5253

Today's topics:
    Re: Any advice on how to fix this? <krahnj@acm.org>
    Re: Anyone using Perl to develop and deploy MS Windows  <krahnj@acm.org>
        Effective Group ID not changing <abaugher@esc.pike.il.us>
        Get file extention from path <his_ron@yahoo.com>
    Re: Get file extention from path <usenet@expires082003.tinita.de>
    Re: Get file extention from path <his_ron@yahoo.com>
    Re: Get file extention from path <asu1@c-o-r-n-e-l-l.edu>
    Re: IP Conversion..Sending to Subroutine.. <joecool118@nospam.hotmail.com>
    Re: JOIN problem ? (2nd attempt to post) (stu7)
    Re: localize values of an object's hash key <REMOVEsdnCAPS@comcast.net>
    Re: New to cig question <emschwar@pobox.com>
    Re: New to cig question <his_ron@yahoo.com>
    Re: Newbie  - skipping lines of a file. <REMOVEsdnCAPS@comcast.net>
    Re: One Off Script <pinyaj@rpi.edu>
    Re: One Off Script (Tad McClellan)
        recompile Perl, with new function names ? (stu7)
    Re: retrieve wishlist from Amazon <bwalton@rochester.rr.com>
    Re: See y'all in Paris?  YAPC::Europe::2003 <abigail@abigail.nl>
    Re: See y'all in Paris?  YAPC::Europe::2003 <REMOVEsdnCAPS@comcast.net>
        Using 'my' within nested loops <spamblock@junkmail.com>
    Re: Using 'my' within nested loops <bwalton@rochester.rr.com>
    Re: Using 'my' within nested loops <REMOVEsdnCAPS@comcast.net>
    Re: Variable reference <pinyaj@rpi.edu>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 21 Jul 2003 23:08:43 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Any advice on how to fix this?
Message-Id: <3F1C72BB.55CFBE35@acm.org>

Bruce Bowler wrote:
> 
> I'll start by saying I'm NOT a perl programmer and I'm not sure this is
> the right group, but I'm sure you'll tell me where to go if it's not :-)
> 
> I have a perl script that I didn't write that works with perl 5.005_03
> (solaris 2.7).  It doesn't even compile with 5.8.0 (Redhat 8.0).

Did you try contacting the author Chris Cornuelle <bob@math.umn.edu>?


> The error message from the compiler is
> 
> Can't modify reference constructor in list assignment at ./f77toM.pl line 465, near ");"
> Execution of ./f77toM.pl aborted due to compilation errors.

That warning must have been added to version 5.8 as it doesn't produce a
warning in version 5.6.


> The code in question is
> 
>   for ( $ifmt=0;$ifmt<=$#fmt_array;$ifmt++ ) {
> 
>     ($space_str,$nchars,$imat,\@fmt_matlab,\@fmt_matvar) =

Should be written as:

      ( $space_str, $nchars,$imat ) =

Or probably:

      ( $space_str, $nchars,$imat, $fmt_matlab_ref, $fmt_matvar_ref ) =


>
parse_write_fmt($space_str,$nchars,$ifmt,$imat,\@fmt_array,\@fmt_matlab,\@fmt_matvar,\@fmtstr,\@var_type);
> 
>     }  # end for on ifmt
> 
> where line 465 is the "parse_write_fmt" line.
> 
> The entire script is almost 3K lines long so I wont post it, but if you
> want to examine the whole thing, it can be found at
> ftp://ftp.math.umn.edu/pub/MCIM/f77toM.pl.gz

If you and the original author don't mind a little constructive
criticism.  :-)

    49  # Typical usage stuff here.
    50  if ( 0 > $#ARGV ) {  # Should be one arg, at least.
    51    usage();
    52    }  # endif 

The usual perl idiom is:

unless ( @ARGV ) {
    usage();
    }

    58  for ( $ifl=0;$ifl<=$#ARGV;$ifl++ ) {  # Loop over arg list
files.
    59  
    60    $fname = $ARGV[ $ifl ];

The usual perl idiom is:

for my $fname ( @ARGV ) {

    71  #   Copy Fortran file to backup, open file with original name
for input.
    72      $file_bkp = "";$file_bkp .= $fname."\.bkp";

my $file_bkp = "$fname.bkp";

    73      system("cp -f $fname $file_bkp");

Using system with a string will run the process via the shell which
means that if there are any shell meta-characters in $fname or $file_bkp
it may not work as expected.  You should also verify that system()
executed the command correctly.

    89  #   Read file in, scanning for labels, managing continuations,
etc.
    90  #   This is an initial parsing.
    91      open( F77FL, "<$file_bkp" );

You should _ALWAYS_ verify that the file opened correctly.

    93      $lineno = 0;
    94      foreach ( <F77FL> ) {

Using foreach on a filehandle will slurp the entire file into a list in
memory.  You should use a while loop instead and if you use a while loop
the current line number will be in the $. variable so $lineno is not
needed.

   246  #   Now that we have the text, let's parse.
   247      open( MFL, ">$m_file" );

You should _ALWAYS_ verify that the file opened correctly.

   436    $fmt_edited =~ s/N([^\,|^\)])/N\,$1/g;
   437    $fmt_edited =~ s/N([^\,|^\)])/N\,$1/g;

The regular expression reads 'N' followed by a character that is not ','
or '|' or '^' or ')'.

   438    $fmt_edited =~ s/([^\,|^\(])N/$1\,N/g;
   439    $fmt_edited =~ s/([^\,|^\(])N/$1\,N/g;

The regular expression reads a character that is not ',' or '|' or '^'
or '('.followed by a 'N'.
If you really want to match '|' or '^' then it is fine but it looks like
you really want:

    $fmt_edited =~ s/N([^,\)])/N,$1/g;
    $fmt_edited =~ s/N([^,\)])/N,$1/g;
    $fmt_edited =~ s/([^,\(])N/$1,N/g;
    $fmt_edited =~ s/([^,\(])N/$1,N/g;

A lot of the character classes in the code use '|' erroneously.

There are probably some more corrections that could be made but that is
all I can handle for now.  :-)  Oh, by the way, you should have strict
enabled and declare all your variables with my().

HTH

John
-- 
use Perl;
program
fulfillment


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

Date: Mon, 21 Jul 2003 23:18:19 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Anyone using Perl to develop and deploy MS Windows apps?
Message-Id: <3F1C74FB.D30E32C2@acm.org>

Stefan Fischerländer wrote:
> 
> I'm looking for some experiences or even some guidance ...
> 
> There are some freeware tools I provide on my homepage, which are
> written in Visual Basic. For a couple of reasons I want to get rid of
> VB and want to switch to another language.
> 
> Because I'm rather experienced with Perl, this would be an obvious
> choice. But there is one problem: the deployment of my Perl apps. My
> users are no tech gurus, just average computer users. This means the
> programs have to be deployed as self-installing single .exe files. (To
> tell them to install ActiveState Perl for Windows distribution is no
> option!)

If you already know BASIC then you may want to have a look at
PowerBASIC.
http://www.powerbasic.com/


John
-- 
use Perl;
program
fulfillment


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

Date: Mon, 21 Jul 2003 19:53:14 -0500
From: Aaron Baugher <abaugher@esc.pike.il.us>
Subject: Effective Group ID not changing
Message-Id: <86wueb1ix1.fsf@cail.baugher.pike.il.us>

I have a program that runs as root and accepts logins and commands
through a network socket.  On each login, it changes the effective uid
and gid to that of the user, like so:

  my( $uid, $gid ) = (getpwnam($user))[2,3];
  $> = $uid;
  $) = $gid;
 
In most cases, $gid will be 1001, and $uid will be > 1000.  This
worked fine on FreeBSD, and files created after this point would be
created with the uid/gid ownership assigned here.  I recently tried
running this program on RedHat (perl 5.6.1), and the gid doesn't
change, although the uid does.  If I print $), it still contains a
list of root's groups, and files created get root's group ownership.

Is there something I should be doing differently to get this to work?
My program has to be able to reset these values repeatedly; that's why
I don't set $( (Real gid).  I figured I wouldn't be able to set it
back after that.


Thanks,
-- 
Aaron
abaugher@esc.pike.il.us



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

Date: Mon, 21 Jul 2003 22:38:51 GMT
From: "Ron" <his_ron@yahoo.com>
Subject: Get file extention from path
Message-Id: <%XZSa.93619$hV.6702783@twister.austin.rr.com>

I need to get the file extension from a path(file location+file
name+extension)

This code get's me to the file name + extension.

My beginner question is.  How do I get just the extension?

 my $filename1 = $FILE1;
      $filename1 =~ s/^.*(\\|\/)//;
             $filename1 =~ s/ +/\_/g;

Thanks,
Ron




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

Date: 21 Jul 2003 22:47:40 GMT
From: Tina Mueller <usenet@expires082003.tinita.de>
Subject: Re: Get file extention from path
Message-Id: <bfhqic$etufn$3@ID-24002.news.uni-berlin.de>

Ron wrote:
> I need to get the file extension from a path(file location+file
> name+extension)

perldoc File::Basename
(function fileparse())

hth, tina
-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
- my mail address expires end of august 2003 -


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

Date: Mon, 21 Jul 2003 23:26:08 GMT
From: "Ron" <his_ron@yahoo.com>
Subject: Re: Get file extention from path
Message-Id: <kE_Sa.93625$hV.6718211@twister.austin.rr.com>

Thanks Tina although I am not sure who to put that into code I tried

my $ext1 = $FILE1(function fileparse());

How do I use it?

Thanks,
Ron

"Tina Mueller" <usenet@expires082003.tinita.de> wrote in message
news:bfhqic$etufn$3@ID-24002.news.uni-berlin.de...
> Ron wrote:
> > I need to get the file extension from a path(file location+file
> > name+extension)
>
> perldoc File::Basename
> (function fileparse())
>
> hth, tina
> --
> http://www.tinita.de/     \  enter__| |__the___ _ _ ___
> http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
> http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
> - my mail address expires end of august 2003 -




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

Date: 22 Jul 2003 00:28:50 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Get file extention from path
Message-Id: <Xns93BFD05838C85asu1cornelledu@132.236.56.8>

"Ron" <his_ron@yahoo.com> wrote in news:kE_Sa.93625$hV.6718211
@twister.austin.rr.com:

> "Tina Mueller" <usenet@expires082003.tinita.de> wrote in message
> news:bfhqic$etufn$3@ID-24002.news.uni-berlin.de...
>> Ron wrote:
>> > I need to get the file extension from a path(file location+file
>> > name+extension)
>>
>> perldoc File::Basename
>> (function fileparse())
>>
>> hth, tina
> Thanks Tina although I am not sure who to put that into code I tried
> 
> my $ext1 = $FILE1(function fileparse());
> 
> How do I use it?

First, do not top-post.

Second, do read the posting guidelines for this group. They are posted here 
regularly, and available at:

http://mail.augustmail.com/~tadmc/clpmisc.shtml

Third, RTFM!

http://www.perldoc.com/perl5.6/lib/File/Basename.html

Sinan.

-- 
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov


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

Date: Mon, 21 Jul 2003 23:35:33 GMT
From: "Joe" <joecool118@nospam.hotmail.com>
Subject: Re: IP Conversion..Sending to Subroutine..
Message-Id: <9N_Sa.706883$mA4.99808@news.easynews.com>


"David Efflandt" <efflandt@xnet.com> wrote in message
news:slrnbhlejf.t85.efflandt@typhoon.xnet.com...
> On Sun, 20 Jul 2003 09:45:24 GMT, Joe <joecool118@nospam.hotmail.com>
wrote:
> >> On Sat, 19 Jul 2003, Joe Henderson wrote:
> >>
> >> >Or does ne1 have a better way...
> >>
> >> I don't really know what you're doing, or why you're doing it.
> >
> >
> > Normally this is a whole array of sorting ip's in a file..
> > .While reading a file of ip's i want to sort then by lowest
> > to highest then print.. However.. when i do not split them
> > the values are not correctly push to the sub's.. So.. I tried
> > to use "big::int" but that did not work.. Any Ideas?
>
> This is an example of a script that can sort a file list of full or
> partial IPs, or insert (optional) single IP from the commandline into the
> sorted list.

Yes.. Correct

>
> Simply sorting a unique list of packed IPs and then unpacking them did
> not work for partial IPs because either 192.168. or 192.168.0. became
> 192.168.0.0 which would not work for intended purpose.  So I put the IPs
> into a hash with a packed value, and sort on the value string (cmp).  Not
> sure if this is optimized, but it works.
>
> The partial IPs (ending with dot) are for class A, B, or C subnets (dot is
> appended if needed).  I did not get into more specific subnet masking yet
> (more complicated).  This demo does not check if IPs are valid and would
> need added code for multi-user access of same IP list (flock, etc.).
>
> #!/usr/bin/perl -w
> # banip 5/30/2003 by David Efflandt efflandt@xnet.com
> # Inserts (optional) single full or partial IP from commandline
> # into file list.  List is sorted and duplicates removed.
> #
> # set $file to point to your IP list file
> my $file = "$ENV{HOME}/banlist.txt";
> my $newip = shift or 0;
> $newip =~ s/^[^\d\.]+$// if $newip;
This is a new one..
> my ($iplist,%hash);
> if ($_ = $newip) {
>     $newip .= '.' unless (/\.$/ || /\d+\.\d+\.\d+\.\d+/);
>     $hash{$newip} = pack('C4',split(/\./,$newip));
need to read up on this "pack();"
>     print "using: $file\n";
> } else {
>     warn "usage: $0 ip_addr\n$file is just being sorted\n";
> }
> if (open (IN,"$file")) {
>     while (<IN>) {
>         chomp;
>         $_ .= '.' unless (/\.$/ || /\d+\.\d+\.\d+\.\d+/);
>         $hash{$_} = pack('C4',split(/\./,$_));
>     }
>     close IN;
> } elsif (!$newip) {
>     die "nothing to do!\n";
> } else {
>     die "can't read $file: $!\n";
> }
> @iplist = sort { $hash{$a} cmp $hash{$b} } keys %hash;
> open (OUT,"> $file") || die "Can't write $file: $!";
> foreach (@iplist) {
>     print OUT "$_\n";
hmm.. wonder what happen to the 2nd-4th octet.. doesn't this just print the
1st?
> }
> close OUT;
>
> --
> David Efflandt - All spam ignored  http://www.de-srv.com/
> http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
> http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/

Hey.. Good stuff tho..thanks for a different look..

Joe




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

Date: 21 Jul 2003 16:52:43 -0700
From: stuseven@hotmail.com (stu7)
Subject: Re: JOIN problem ? (2nd attempt to post)
Message-Id: <d7dd90b0.0307211552.50dee804@posting.google.com>

*** ...sets out a bowl of sugar water, to attract more
*** style-spammers


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

Date: Mon, 21 Jul 2003 20:00:07 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: localize values of an object's hash key
Message-Id: <Xns93BFD5A26E577sdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"Joly, Patrick: IAC" <Joly.Patrick@ic.gc.ca> wrote in
news:3E3612E8D41DD3118DCC0600000000000AEA96CB@pubgate-01.ic.gc.ca: 

> I need to localise (dynamically scope) the value of a hash key in an
> object but I am facing a hurdle.  I have been stuck on this problem
> for 5 days so any help would be greatly appreciated.
>
> 2) any other ideas?
> 
> 
> Thanks, I am really desperate.  Everything was going great so far,
> until I got stumped by this.

I'm not sure this is a *great* solution, but I've used this technique in
the past: 

Have your tempvar() method return an object in a different class. 
Foo::TempValue or something.  This object will have a reference to the
object (of type Stata::Data) that created it, so that it can communicate
with it.  When the object goes out of scope, its DESTROY method invokes
a method on the "parent" (or "factory") object to tell it that its value
is no longer to be used. 

The user of this object can access its value in one of several ways. 
You could make them call a method: 

    $foo = $data_obj->tempvar;
    print "I'm using ", $foo->value, "!!!";

Or you the child object could override stringification, so that

    print "I'm using $foo!!!"
would work, but
    print "I'm using ", $foo, "!!!";
would not.

Or you could return the child object as a tied scalar, so that the
calling user never need know it's an object. 

- - -- 
Eric
$_ =  reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPxyMkGPeouIeTNHoEQJOMQCeLplZNFBe04RARq85HuvD/UzezqEAn0D8
rbDjMLiUFjQN5HONw3JQzUeh
=EBBA
-----END PGP SIGNATURE-----


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

Date: Mon, 21 Jul 2003 22:16:44 GMT
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: New to cig question
Message-Id: <etowueb4jfp.fsf@wormtongue.emschwar>

Because it's hard to understand.

Why don't people like top-posting?

"Ron" <his_ron@yahoo.com> writes:
> I have printed out both
> my $size_file = (-s $FILE1)/1024;
> is value is 43

If so, then the statment

if($size_file > 0) {
  #do something
}

would execute.  I promise you, Perl is not capricious-- if the
variable is > 0 at that point, then the contents of the if() statement
will execute.  It seems to me that what we're seeing, and what your
code actually looks like, is not the same thing.

I would recommend you try to distill this particular problem to a very
small program (10-15 lines should be plenty), and post that program
here, along with what it outputs for you, and what it should output.

Very often, the simple exercise of trying to reduce the trouble to its
smallest essence is all that's required to find your problem. 

And again, please don't top-post; it's rude, and difficult to read.
Intersperse your replies with the material you're replying to, as most
other posters here do.  Also, please trim the post you're quoting so
that you're only replying to the most significant bits.

http://www.html-faq.com/etiquette/?toppost

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Mon, 21 Jul 2003 22:33:58 GMT
From: "Ron" <his_ron@yahoo.com>
Subject: Re: New to cig question
Message-Id: <qTZSa.93618$hV.6701159@twister.austin.rr.com>

Thanks John that works just perfect!

Ron

"John J. Trammell" <trammell+usenet@hypersloth.invalid> wrote in message
news:slrnbhog31.pgo.trammell+usenet@hypersloth.el-swifto.com.invalid...
> On Mon, 21 Jul 2003 18:36:38 GMT, Ron <his_ron@yahoo.com> wrote:
> > my $size_file = (-s $FILE1)/1024;
> > if (($size_file > 0)) {
> > my $YourFiles1 = 'File1: ' . $filename1 . ' ' . $size_file . ' KB';
> > }
> >
> > Could anyone let me know what I am doing wrong?
> >
>
> One problem with this code is that you're scoping
> $YourFiles1 to the if-block.
>
> How about this as alternative code:
>
> my $YourFiles1 = ($size_file > 0) ?
> "File1: $filename1 $size_file KB" :
> "ack!";
>
> As it stands, I'm not sure how you would ever *tell*
> that your code had found a size > 0.
>




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

Date: Mon, 21 Jul 2003 19:19:51 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Newbie  - skipping lines of a file.
Message-Id: <Xns93BFCECE72F30sdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Brian McCauley <nobull@mail.com> wrote in
news:u9ispvyfxx.fsf@wcl-l.bham.ac.uk: 

> Quick staw-poll, does anyone, appart from the OP see that as hostile?

Nope.  And might I add that your posts, Brian, are typically among the most 
cordial and patient of all the regular posters.

- -- 
Eric
$_ =  reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPxyDHmPeouIeTNHoEQIfxgCgyknExNMUpClFggBcO8To7kbaHsAAoO9m
AhgXq0V5wE7ylQXbGwbthjAX
=HGVe
-----END PGP SIGNATURE-----


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

Date: Mon, 21 Jul 2003 19:30:50 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: JP Ogden <jp@in3corp.com>
Subject: Re: One Off Script
Message-Id: <Pine.SGI.3.96.1030721192821.50304A-100000@vcmr-64.server.rpi.edu>

[posted & mailed]

On 21 Jul 2003, JP Ogden wrote:

>123                5675.68        5/24/03      Misc        Misc2
>123A               8756.67        7/3/03       Code        Code2
>
>and
>
>0234               10456.45       6/4/02       Man         Man2
>234                456.34         10/5/02      Talk        Talk2
>
>because the records in "Field 1" are what I am calling "one-off."

Do you mean that the values in Field 1 are different in that one of them
merely has an additional character appended or prepended to it?  Or are
"abc1def" and "abc2def" also one-off?  Or are "abcdef" and "abc1def" also
one-off?

If it's only pre- and appending that matters, you can get it done rather
easily, I'd imagine.

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Mon, 21 Jul 2003 19:03:57 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: One Off Script
Message-Id: <slrnbhovrd.esp.tadmc@magna.augustmail.com>

JP Ogden <jp@in3corp.com> wrote:


> Here is a sample of my data:
> Field 1            Field 2        Field 3      Field 4     Field 5
> 123                5675.68        5/24/03      Misc        Misc2
> E4678              345.76         6/23/02      Test        Test2
> 123A               8756.67        7/3/03       Code        Code2
> 0234               10456.45       6/4/02       Man         Man2
> 234                456.34         10/5/02      Talk        Talk2
> 675-02             1045.45        3/5/03       Level       Level1
> etc...
> 
> I would like to isolate only the records where the records in "Field
> 1" are "one-off."  The results from the above sample would look like
> this:
> Field 1            Field 2        Field 3      Field 4     Field 5
> 123                5675.68        5/24/03      Misc        Misc2
> 123A               8756.67        7/3/03       Code        Code2
> 
> and
> 
> 0234               10456.45       6/4/02       Man         Man2
> 234                456.34         10/5/02      Talk        Talk2
> 
> because the records in "Field 1" are what I am calling "one-off."


You mean one character shorter, by either taking the first or
the last character off?

Or should  123  and  12X3  be "one off" too?

I'll assume the former.


> The characters in "Field 1" can be anything.


I will assume "anything except whitespace" below.


> Any help would be greatly appreciated.  


--------------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;

my %seen;
while ( <DATA> ) {
      $seen{$1} = $_ if /^(\S+)/;
}

my %reported;
foreach my $f1 ( sort keys %seen ) {
   foreach my $shorter ( substr($f1, 0, -1), substr($f1, 1) ) {
      if ( $seen{$shorter} and not $reported{ "$seen{$shorter}:$f1" }) {
         $reported{ "$seen{$shorter}:$f1" } = 1;
         print $seen{$shorter}, $seen{$f1}, "\n";
      }
   }
}

__DATA__
123                5675.68        5/24/03      Misc        Misc2
E4678              345.76         6/23/02      Test        Test2
123A               8756.67        7/3/03       Code        Code2
0234               10456.45       6/4/02       Man         Man2
234                456.34         10/5/02      Talk        Talk2
675-02             1045.45        3/5/03       Level       Level1
--------------------------------------------------------




[ snip TOFU.
  Please learn the proper way of formatting followups.
]

-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 21 Jul 2003 17:18:41 -0700
From: stuseven@hotmail.com (stu7)
Subject: recompile Perl, with new function names ?
Message-Id: <d7dd90b0.0307211618.277c678e@posting.google.com>

+
   Is there a way to recomplile Perl with new names
 for functions ? (...or better, probably, including the
 regular names with the replacement names... so original
 functions are still there to make old scripts work :) 

   This might be the same question, but... if we could
 for instance, include  printme  as a substitute for  print...
 would  printme  work wherever  print  had been used_ for
 instance, to print module values ? 

   I know something like this can be done temporarilly with glob.


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

Date: Tue, 22 Jul 2003 00:33:50 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: retrieve wishlist from Amazon
Message-Id: <3F1C865E.7060103@rochester.rr.com>

Patrick Flaherty wrote:

 ... 
> However this leads to the observation (error) that author is no longer parsed
> correctly (maybe Amazon has changed how this is laid out).  Do you see author
> appearing correctly in the output?


Actually, now that I look at it, the author is not printing out OK for 
me (but neither of my two entries actually have an author -- one is a 
DVD and the other a disc-cleaning kit, both from a couple of years ago, 
the first and last time I looked at Amazon's wish list).  It looks like 
I get what is probably a key for an author entry in a database table 
instead.  It's not surprising that things like this would change from 
time to time.

> 
>   pat
> 
 ...


-- 
Bob Walton



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

Date: 22 Jul 2003 00:00:01 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: See y'all in Paris?  YAPC::Europe::2003
Message-Id: <slrnbhovk1.u5c.abigail@alexandra.abigail.nl>

Brian McCauley (nobull@mail.com) wrote on MMMDCXI September MCMXCIII in
<URL:news:u9d6g3yfih.fsf@wcl-l.bham.ac.uk>:
}}  Any of the other regulars here going to YAPC::Europe::2003 this week?

Not me. ;-(

}}  Anyone for a clpm "reunion" dinner?


Abigail
-- 
#!/opt/perl/bin/perl -w
$\ = $"; $; = $$; END {$: and print $:} $SIG {TERM} = sub {$ := $_}; kill 15 =>
fork and ($; == getppid and exit or wait) foreach qw /Just another Perl Hacker/


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

Date: Mon, 21 Jul 2003 19:40:06 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: See y'all in Paris?  YAPC::Europe::2003
Message-Id: <Xns93BFD23DAA921sdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Brian McCauley <nobull@mail.com> wrote in news:u9d6g3yfih.fsf@wcl-
l.bham.ac.uk:

> Any of the other regulars here going to YAPC::Europe::2003 this week?
> 
> Anyone for a clpm "reunion" dinner?

Ah, don't I wish!  :-/   I may never be able to afford to go to Europe.

- -- 
Eric
$_ =  reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPxyH4GPeouIeTNHoEQLRUgCfRvdexyxpbpcDVr/Nn1DV8jMBQ/wAoIF2
2t4l1yArmXyVeG8CqJnes1s4
=RiiN
-----END PGP SIGNATURE-----


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

Date: Mon, 21 Jul 2003 17:22:08 -0700
From: "David Oswald" <spamblock@junkmail.com>
Subject: Using 'my' within nested loops
Message-Id: <vhp11c9c2fgd7b@corp.supernews.com>

I am curious about the amount of overhead created with the first example
below as compared to the second example below:


Example 1:
my $this;
my $that;
foreach $this (@somearray) {
    foreach $that (@some_other_array) {
        ........
    }
}


Example 2:
foreach my $this (@somearray) {
    foreach my $that (some_other_array) {
        .......
    }
}


It seems to me that while the second example does a better job of limiting
the scope of variables just to the block in which they're applicable, the
second example does cause the construction of a variable each time the outer
foreach iterates.

Is the overhead caused by constructing and deconstructing a variable over
and over again as it comes into and falls out of scope a degree of extra
overhead that could hamper execution speed on tight loops?  Is this even an
issue?

I apologize for using "constructing" and "deconstructing"... just a loose
use of those words.

Dave






--
DJO




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

Date: Tue, 22 Jul 2003 00:43:50 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Using 'my' within nested loops
Message-Id: <3F1C88B9.5060706@rochester.rr.com>

David Oswald wrote:

> I am curious about the amount of overhead created with the first example
> below as compared to the second example below:
> 
> 
> Example 1:
> my $this;
> my $that;
> foreach $this (@somearray) {
>     foreach $that (@some_other_array) {
>         ........
>     }
> }
> 
> 
> Example 2:
> foreach my $this (@somearray) {
>     foreach my $that (some_other_array) {
>         .......
>     }
> }
> 
> 
> It seems to me that while the second example does a better job of limiting
> the scope of variables just to the block in which they're applicable, the
> second example does cause the construction of a variable each time the outer
> foreach iterates.
> 
> Is the overhead caused by constructing and deconstructing a variable over
> and over again as it comes into and falls out of scope a degree of extra
> overhead that could hamper execution speed on tight loops?  Is this even an
> issue?


Why don't you:

    use Benchmark;

and find out?


 ...
> Dave
 ...


> --
> DJO
 ...


-- 
Bob Walton



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

Date: Mon, 21 Jul 2003 20:04:40 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Using 'my' within nested loops
Message-Id: <Xns93BFD66749383sdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"David Oswald" <spamblock@junkmail.com> wrote in
news:vhp11c9c2fgd7b@corp.supernews.com: 

> Is the overhead caused by constructing and deconstructing a variable
> over and over again as it comes into and falls out of scope a degree
> of extra overhead that could hamper execution speed on tight loops? 
> Is this even an issue?

My off-the-cuff answer: Probably not.  You might shave a millisecond or two  
off each loop iteration, but unless you're up against a wall, that probably 
won't make much difference.  If it does, perhaps Perl is not the right 
language for your application.

Disclaimer:  I haven't done any timings; this is just a gut answer from 
experience.
- -- 
Eric
$_ =  reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPxyNoWPeouIeTNHoEQLcMACg9XzrzRKzESATDIkxobfkcgZjOSsAoPJG
ezdXWoBHkusM1/npZQFSvhPR
=AB2E
-----END PGP SIGNATURE-----


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

Date: Mon, 21 Jul 2003 19:05:11 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: Variable reference
Message-Id: <Pine.SGI.3.96.1030721184641.48882A-100000@vcmr-64.server.rpi.edu>

On 21 Jul 2003, Tassilo v. Parseval wrote:

>> You should use $var{ $a, $b } = "Some text";
>> The key would be $a . $; . $b
>> $; is set to \034 but you can change it to any character you like.
>
>I think this misses the point of the OP. He was essentially just asking
>how to concatenate two strings to one hash-key. Using $hash{ LIST }
>however is a Perl4ism. In a time when references weren't yet there, Perl
>needed a way to work with multidimensional data-structures. Joining the
>elements of the list together with $; was therefore just a work-around.
>Nowadays fortunately perl knows about references and thus the
>multidimensional array emulation is no longer needed.

Although, as was stated, you could set $; to "", and thereby make it work
like the OP wanted. ;)

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


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


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