[23370] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5589 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 29 21:15:56 2003

Date: Mon, 29 Sep 2003 18:15:16 -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, 29 Sep 2003     Volume: 10 Number: 5589

Today's topics:
    Re: How exactly do I build %INC keys? <tcurrey@no.no.i.said.no>
    Re: How exactly do I build %INC keys? <scriptyrich@yahoo.co.uk>
    Re: LWP::Simple get() refined problem <kuujinbo@hotmail.com>
    Re: Max Memory in Perl and How to reuse gabage? <jurgenex@hotmail.com>
    Re: New FAQ: How do I compute the difference of two arr (Anno Siegel)
    Re: New FAQ: How do I compute the difference of two arr <usenet@dwall.fastmail.fm>
    Re: Perl command to copy one file into another file? <WA5JUL@hotmail.com>
    Re: Perl command to copy one file into another file? <kuujinbo@hotmail.com>
    Re: Perl command to copy one file into another file? <michael.p.broida@boeing_oops.com>
        Perl command to copy one file into another <WA5JUL@hotmail.com>
    Re: Perl command to copy one file into another (David Efflandt)
    Re: Perl command to copy one file into another <michael.p.broida@boeing_oops.com>
    Re: Perl command to copy one file into another <abigail@abigail.nl>
    Re: Perl Help - Windows Perl script accessing a Unix pe <jgibson@mail.arc.nasa.gov>
    Re: Perl Help - Windows Perl script accessing a Unix pe <bart.lateur@pandora.be>
    Re: perl makefile.pl --help <king21122@yahoo.com>
    Re: perl makefile.pl --help (Jay Tilton)
    Re: perl makefile.pl --help (Malcolm Dew-Jones)
        read meta data from image <_nospam_stigerikson@yahoo.se>
    Re: read meta data from image <noreply@gunnar.cc>
    Re: refer to object in another package <coo_t2-NO-LIKE-SPAM@yahoo.com>
    Re: refer to object in another package (Jay Tilton)
    Re: refer to object in another package <coo_t2-NO-LIKE-SPAM@yahoo.com>
    Re: reg exp help (laura fairhead)
    Re: reg exp help (Tad McClellan)
    Re: strip newlines in TD cell ? (Tad McClellan)
    Re: Unique identifiers in Sendmail::Milter 0.18 (Malcolm Dew-Jones)
        What is standard? <noreply@gunnar.cc>
    Re: What is standard? <grazz@pobox.com>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 29 Sep 2003 11:12:38 -0700
From: "Trent Curry" <tcurrey@no.no.i.said.no>
Subject: Re: How exactly do I build %INC keys?
Message-Id: <bl9sn9$s9b$1@news.astound.net>

Tad McClellan wrote:
> Rich <scriptyrich@yahoo.co.uk> wrote:
>
>> I know Win32 perl allows '/' as well as '\' directory separators,
>
>
> It is not "Win32 perl" that allows / as the directory separator,
> it is the Windows OS itself that allows that.
>
> Only the command interpreter requires the use of backslash
> (because forward slash is already used for something else, switches).

A "switch" is nothing more then a comand line parameter.
   test.exe /1 /2 /3
works as does
   test.exe \1 \2 \3
and
   test.exe 1 2 3

-- 
Trent Curry

perl -e
'($s=qq/e29716770256864702379602c6275605/)=~s!([0-9a-f]{2})!pack("h2",$1)!eg
;print(reverse("$s")."\n");'




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

Date: Mon, 29 Sep 2003 20:57:59 +0100
From: Rich <scriptyrich@yahoo.co.uk>
Subject: Re: How exactly do I build %INC keys?
Message-Id: <bla2l1$jek$1@newsg1.svr.pol.co.uk>

Rafael Garcia-Suarez wrote:

> Rich wrote:
>>As the point of my initial post wasn't terribly clear, here's a beter
>>version:
>>
>>If I want to check that Data::Dumper (for example) has been used, will:
>>
>>  $INC{"Data/Dumper.pm"}
>>
>>Work on all platforms, not just on the platforms I've tested on (Linux and
>>Win32)?
> 
> This is not a 100% reliable way to check whether a module has been
> loaded, because if you do
>     require "../lib/Data/Dumper.pm";
> you'll end up with $INC{"../lib/Data/Dumper.pm"} set.
> (in fact perl bypasses @INC searching when the require'd filename
> is absolute or begins with ./ or ../).
> 
> Moreover an @INC hook may fiddle with %INC entries as it wants.
> 
> But, to answer your original question : yes, file names in %INC are
> normalized to use forward slashes.

Yay - that's all I needed to know! I didn't feel the docs were 100% clear
that forward slashes are always used - could be me not RTFM properly
though.

> Usually you don't have to worry about this, what's your actual problem ?

The main thing is I need to know where one of my modules is physically
located. As it's an internal module in a larger framework, I can guarantee
that it will be use'd rather than require'd in the way you describe above,
so $INC{"My/Module.pm"} should reliably give me the full filename of
My::Module.

Thanks for your help
-- 
Rich
scriptyrich@yahoo.co.uk


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

Date: Tue, 30 Sep 2003 08:15:10 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: LWP::Simple get() refined problem
Message-Id: <blaeh8$par$1@pin3.tky.plala.or.jp>

Hon Guin Lee - Web Producer - SMI Marketing wrote:
> Dominik Seelow wrote:
> 
>>Hon Guin Lee - Web Producer - SMI Marketing wrote:
>>
>>
>>>Hi all,
>>>
>>>The LWP::get() function manages to retrieve some of the localised web document content from local web servers displayed on my web browser using Mozilla 1.1, for URL's without the www.
>>>However for URLs that begin with www, the get() functon just returns an undef (shown in subroutine get_url) hence the web browser unables to display the web content.
>>>
>>>To narrow the problem further, I used some of the other functions such as getstore(url,file) and mirror(url,file) where I replace url with shift, and a filename specified, but the LWP::Debug just throws up: -

[snip]

>>>--------------------------------------------------------------------------
>>
>>Do you use a proxy to display web content from outside when using your
>>browser?
>>
>>perldoc LWP says:
>>ENVIRONMENT
>>    The following environment variables are used by LWP:
>><snip>
>>    http_proxy
>>    ftp_proxy
>>    xxx_proxy
>>    no_proxy
>>        These environment variables can be set to enable communication
>>        through a proxy server. See the description of the "env_proxy"
>>        method in LWP::UserAgent.
>>
>>It /might/ help to specify a proxy server.
>>
>>Good luck,
>>Dominik
> 
> 
> I have used a proxy server, usin the LWP::UserAgent module, from the new script as shown below: - 
> 
> ------------------------------------------------------------------------
> 
> #!/usr/local/perl5.6/bin/perl -wT
> 
> use LWP::UserAgent;
> use LWP::Debug '+';
> use CGI ':standard';
> use strict;
> 
> print "Content-type: text/html\n\n";
> 
> my $content;
> my $ua = new LWP::UserAgent;
> my $old_handle;
> my $url = param('url');
> my $lang = param('lang');
> 
> $|++;                            #sets $| for STDOUT
> $old_handle = select( STDERR );   #change to STDERR
> $|++;                            #sets $| for STDERR
> select( $old_handle );           #change back to STDOUT
> 
> $ua->proxy(['http','https','ftp'], 'file:///usr/dist/share/proxy_config/uk.pac');  # set proxy

I think that you need to pass a URL to proxy(), not a filename - the 
examples in the docs use URLs. In fact, if you print out the server 
response message with the status_line() method you get (at least I did 
when trying to use a filename):

	400 You can not proxy through the filesystem


> $ua->env_proxy();        # load proxy info from environment variables

I'm not sure this will work for you, as this is a CGI script and the 
method is loading the *_proxy environment variables from the user the 
*web server* is running under. It might be better to load your settings 
with proxy() and leave this out.

> 
> $ua->agent("Mozilla/1.1");  
> 
> my $req = new HTTP::Request GET => $url;
> my $res = $ua->request($req);
>  
> if ($res->is_success) 
> {
>   $content= $res->content;
> } 
> 
> else 
> {
>   die "Could not get content";
> }
> 
> ----------------------------------------------------------------------
> 
> The following error messages were shown: - 
> 
> LWP::UserAgent::proxy: ARRAY(0x2d5e60) file:///usr/dist/share/proxy_config/uk.pac LWP::UserAgent::proxy: http file:///usr/dist/share/proxy_config/uk.pac
> LWP::UserAgent::proxy: https file:///usr/dist/share/proxy_config/uk.pac LWP::UserAgent::proxy: ftp file:///usr/dist/share/proxy_config/uk.pac LWP::UserAgent::request: ()
> LWP::UserAgent::request: Simple response: Bad Request Could not get content at /export/home/sdltool/www/cgi-bin/automation1-2.cgi line 40. 
> 
> ----------------------------------------------------------------------

You should also probably call the no_proxy() method somewhere to disable 
proxying for requests to your internal network.

HTH - keith



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

Date: Mon, 29 Sep 2003 21:15:53 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Max Memory in Perl and How to reuse gabage?
Message-Id: <di1eb.26688$FH3.5360@nwrddc02.gnilink.net>

Chris Richmond - MD6-FDC ~ wrote:
> In article <uFBdb.23175$ZR1.14953@nwrddc01.gnilink.net>,
>  "Jürgen Exner" <jurgenex@hotmail.com> writes:
>> The maximum size of a Perl array is limited by the available amount
>> of virtual memory and maximum index size. Depending on your OS, 32
>> versus 64 bit, and your version of Perl that should be somewhere in
>> the GB or TB range.
>
> I will contend that this isn't necessarily true.  At least on
> Solaris, we had to make a special effort to enable more than a
> 1GB process size.  The same application on AIX keeled over when
> that limit was hit.  Same thing on linux when I tried.
>
>> Only limited by your virtual memory and the 32 resp. 64 bit index
>> boundary.
>
> Are you positive?  We were using perl5.00404 at the time.
> What actual perl process sizes have you dealt with?

You are right, there is of course the additional limit as imposed by the OS.
And of course the admin can even set that limit pretty low for some users if
he wishes so.

jue




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

Date: 29 Sep 2003 18:23:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: New FAQ: How do I compute the difference of two arrays?
Message-Id: <bl9tbu$j0a$1@mamenchi.zrz.TU-Berlin.DE>

David K. Wall <usenet@dwall.fastmail.fm> wrote in comp.lang.perl.misc:
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:

[union, intersection of arrays]

> > ...a variation on the theme:
> > 
> >     my %tally;
> >     $tally{$_} += 1 for @array_a; # or |=
> >     $tally{$_} += 2 for @array_b;
> >     # use more powers of two for more arrays
> >     my @union = keys %tally;
> >     my @intersection = grep $tally{$_} == 3, @union;
> 
> This assumes there are no duplicated values in either array, right?

Yes, if you use +=, as in the code above.  Not if you use |= instead,
as indicated in a comment.  I must have been thinking of sets, not lists.

> >     my $a_not_b = grep $tally{$_} == 1, @union;
> 
> I think you mean @a_not_b.

More sloppiness.

Thanks.  The code should definitely use "$tally{$_} |= ...".

Anno




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

Date: Mon, 29 Sep 2003 21:10:04 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: New FAQ: How do I compute the difference of two arrays?
Message-Id: <Xns9405AEA407A44dkwwashere@216.168.3.30>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:

> David K. Wall <usenet@dwall.fastmail.fm> wrote in
> comp.lang.perl.misc: 
>> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> 
> [union, intersection of arrays]
> 
>> > ...a variation on the theme:
>> > 
>> >     my %tally;
>> >     $tally{$_} += 1 for @array_a; # or |=
>> >     $tally{$_} += 2 for @array_b;
>> >     # use more powers of two for more arrays
>> >     my @union = keys %tally;
>> >     my @intersection = grep $tally{$_} == 3, @union;
>> 
>> This assumes there are no duplicated values in either array,
>> right? 
> 
> Yes, if you use +=, as in the code above.  Not if you use |=
> instead, as indicated in a comment.  I must have been thinking of
> sets, not lists. 

Aha.  I didn't notice the comment.  It makes sense now.  

As an exercise for myself I found a number of subsets of three sets 
this way.  Although I didn't do any benchmarking I'm pretty sure this 
is faster than the string method, but I must say I can think more 
quickly and easily about regular expressions than I can about bit 
sequences. :-)  A trade-off as usual, I guess.

-- 
David Wall


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

Date: Mon, 29 Sep 2003 22:15:47 GMT
From: "Bill" <WA5JUL@hotmail.com>
Subject: Re: Perl command to copy one file into another file?
Message-Id: <na2eb.46116$ah.5468@twister.austin.rr.com>

 while ( <INPUT1> ) {
#    print "Reading $ARGV[0]\n";
 print OUTPUT $_;
}

The copy statment, copy("file1","file2") or die "Copy failed: $!"; is
supposed to replace the above while statement.

I get this error with the copy statment ...
C:\PERL1\OUTPUT7>bbbb5.pl output5.txt output6.txt output7.txt
Undefined subroutine &main::copy called at C:\PERL1\OUTPUT7\bbbb5.pl line
24.

This is the script code ...

open (INPUT1, "$ARGV[0]") or die "Cannot open $ARGV[0]";
open (OUTPUT, "> $ARGV[2]");

#print "First  input  file is: $ARGV[0]\n";
#print "Second input  file is: $ARGV[1]\n";
#print "The    output file is: $ARGV[2]\n\n";

# This half of the code dumps everything in 'file1' to the output 'file3'
#    while ( <INPUT1> ) {
#    print "Reading $ARGV[0]\n";
#    print OUTPUT $_;
#    }

File :: COPY;
copy("$ARGV[0]","$ARGV[2]") or die "Copy failed: $!";

# This half of the code compares 'file2' to 'file1' and writes out
# any line that doesn't match to the output 'file3'

open (INPUT1, "$ARGV[1]") or die "Cannot open $ARGV[1]";

while ( <INPUT1> ) {
  $match = 0;

  $a = $_;
  open (INPUT2, "$ARGV[0]") or die "Cannot open $ARGV[0]";
  while ( <INPUT2> ) {
    $b = $_;
    if ($a eq $b) {
      $match = 1;
      last;
    }
  }

  if ($match == 0) {
    print OUTPUT $a;
  }
}

"ko" <kuujinbo@hotmail.com> wrote in message
news:bl37di$j2a$1@pin3.tky.plala.or.jp...
> Bill wrote:
> > Is there a single Perl command to copy file 1 into file 2 with out going
> > through the where-with-all of a while loop? Thanks, Bill
> >
> > Perl command to copy one file into another file?
> >
> >
>
> The File::Copy module.
>
> use File::Copy;
> copy("file1","file2") or die "Copy failed: $!";
>
> 'perldoc File::Copy' gives you all the details
>
> HTH - keith
>




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

Date: Tue, 30 Sep 2003 08:42:03 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: Perl command to copy one file into another file?
Message-Id: <blag3m$qmr$1@pin3.tky.plala.or.jp>

Bill wrote:

>  while ( <INPUT1> ) {
> #    print "Reading $ARGV[0]\n";
>  print OUTPUT $_;
> }
> 
> The copy statment, copy("file1","file2") or die "Copy failed: $!"; is
> supposed to replace the above while statement.
> 
> I get this error with the copy statment ...
> C:\PERL1\OUTPUT7>bbbb5.pl output5.txt output6.txt output7.txt
> Undefined subroutine &main::copy called at C:\PERL1\OUTPUT7\bbbb5.pl line
> 24.
> 
> This is the script code ...
> 
> open (INPUT1, "$ARGV[0]") or die "Cannot open $ARGV[0]";
> open (OUTPUT, "> $ARGV[2]");
> 
> #print "First  input  file is: $ARGV[0]\n";
> #print "Second input  file is: $ARGV[1]\n";
> #print "The    output file is: $ARGV[2]\n\n";
> 
> # This half of the code dumps everything in 'file1' to the output 'file3'
> #    while ( <INPUT1> ) {
> #    print "Reading $ARGV[0]\n";
> #    print OUTPUT $_;
> #    }
> 
> File :: COPY;

When you 'use' a module case matters, and you forgot 'use'. It should be:

	use File::Copy;

That's the reason for the 'undefined subroutine...' error message.

> copy("$ARGV[0]","$ARGV[2]") or die "Copy failed: $!";
> 
> # This half of the code compares 'file2' to 'file1' and writes out
> # any line that doesn't match to the output 'file3'
> 
> open (INPUT1, "$ARGV[1]") or die "Cannot open $ARGV[1]";
> 
> while ( <INPUT1> ) {
>   $match = 0;
> 
>   $a = $_;
>   open (INPUT2, "$ARGV[0]") or die "Cannot open $ARGV[0]";
>   while ( <INPUT2> ) {
>     $b = $_;
>     if ($a eq $b) {
>       $match = 1;
>       last;
>     }
>   }
> 
>   if ($match == 0) {
>     print OUTPUT $a;
>   }
> }
> 
> "ko" <kuujinbo@hotmail.com> wrote in message
> news:bl37di$j2a$1@pin3.tky.plala.or.jp...
> 
>>Bill wrote:
>>
>>>Is there a single Perl command to copy file 1 into file 2 with out going
>>>through the where-with-all of a while loop? Thanks, Bill
>>>
>>>Perl command to copy one file into another file?
>>>
>>>
>>
>>The File::Copy module.
>>
>>use File::Copy;
>>copy("file1","file2") or die "Copy failed: $!";
>>
>>'perldoc File::Copy' gives you all the details
>>
>>HTH - keith
>>

Maybe I misunderstood what you want to do. In your original post you 
stated that you want to copy a file without using a while loop. Above, 
however. the contents of the files are being compared. If you want to 
compare contents you do need a while loop.

File::Copy does a straight copy, nothing else:

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

use File::Copy;
die "Usage: SCRIPTNAME file1 file2\n" unless @ARGV == 2;
copy($ARGV[0], $ARGV[1]) or die "Copy failed: $!";

You should also add a check to see that the new file doesn't already 
exist (it will clobber an existing file), and pass the files with 
absolute paths.

HTH - keith



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

Date: Mon, 29 Sep 2003 23:57:07 GMT
From: "Michael P. Broida" <michael.p.broida@boeing_oops.com>
Subject: Re: Perl command to copy one file into another file?
Message-Id: <3F78C6D3.76178772@boeing_oops.com>

Bill wrote:
> 
> Is there a single Perl command to copy file 1 into file 2 with out going
> through the where-with-all of a while loop? Thanks, Bill
> 
> Perl command to copy one file into another file?

	If you know EXACTLY what kind of system it will run on,
	(Windows, Linux, etc) you can use whatever command you
	would give to a shell or commandprompt.

	Use the ` (backtick) command in perl to run the shell
	command:

		$result = `copy a.txt b.txt`;

	$result will contain whatever output the shell returned
	(error messages, success message, whatever).  Probably
	nothing if it was successful.

	Note that that method is not necessarily "portable".

		Mike


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

Date: Mon, 29 Sep 2003 22:55:51 GMT
From: "Bill" <WA5JUL@hotmail.com>
Subject: Perl command to copy one file into another
Message-Id: <XL2eb.46709$ah.32327@twister.austin.rr.com>

while ( <INPUT1> ) {
#    print "Reading $ARGV[0]\n";
 print OUTPUT $_;
}

The copy statment, copy("file1","file2") or die "Copy failed: $!"; is
supposed to replace the above while statement.

I get this error with the copy statment ...
C:\PERL1\OUTPUT7>bbbb5.pl output5.txt output6.txt output7.txt
Undefined subroutine &main::copy called at C:\PERL1\OUTPUT7\bbbb5.pl line
24.

This is the script code ...

open (INPUT1, "$ARGV[0]") or die "Cannot open $ARGV[0]";
open (OUTPUT, "> $ARGV[2]");

#print "First  input  file is: $ARGV[0]\n";
#print "Second input  file is: $ARGV[1]\n";
#print "The    output file is: $ARGV[2]\n\n";

# This half of the code dumps everything in 'file1' to the output 'file3'
#    while ( <INPUT1> ) {
#    print "Reading $ARGV[0]\n";
#    print OUTPUT $_;
#    }

File :: COPY;
copy("$ARGV[0]","$ARGV[2]") or die "Copy failed: $!";

# This half of the code compares 'file2' to 'file1' and writes out
# any line that doesn't match to the output 'file3'

open (INPUT1, "$ARGV[1]") or die "Cannot open $ARGV[1]";

while ( <INPUT1> ) {
  $match = 0;

  $a = $_;
  open (INPUT2, "$ARGV[0]") or die "Cannot open $ARGV[0]";
  while ( <INPUT2> ) {
    $b = $_;
    if ($a eq $b) {
      $match = 1;
      last;
    }
  }

  if ($match == 0) {
    print OUTPUT $a;
  }
}

"ko" <kuujinbo@hotmail.com> wrote in message
news:bl37di$j2a$1@pin3.tky.plala.or.jp...
> Bill wrote:
> > Is there a single Perl command to copy file 1 into file 2 with out going
> > through the where-with-all of a while loop? Thanks, Bill
> >
> > Perl command to copy one file into another file?
> >
> >
>
> The File::Copy module.
>
> use File::Copy;
> copy("file1","file2") or die "Copy failed: $!";
>
> 'perldoc File::Copy' gives you all the details
>
> HTH - keith
>





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

Date: Tue, 30 Sep 2003 00:01:11 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Perl command to copy one file into another
Message-Id: <slrnbnhhu6.qbs.efflandt@typhoon.xnet.com>

On Mon, 29 Sep 2003 22:55:51 GMT, Bill <WA5JUL@hotmail.com> wrote:
> while ( <INPUT1> ) {
> #    print "Reading $ARGV[0]\n";
>  print OUTPUT $_;
> }
> 
> The copy statment, copy("file1","file2") or die "Copy failed: $!"; is
> supposed to replace the above while statement.
> 
> I get this error with the copy statment ...
> C:\PERL1\OUTPUT7>bbbb5.pl output5.txt output6.txt output7.txt
> Undefined subroutine &main::copy called at C:\PERL1\OUTPUT7\bbbb5.pl line
> 24.

Read 'perldoc File::Copy' or example at bottom more carefully.
You forgot the 'use' in 'use File::Copy;' (and also have extra spaces in 
it).  Therefore, no copy sub has been defined.

> This is the script code ...
> 
> open (INPUT1, "$ARGV[0]") or die "Cannot open $ARGV[0]";
> open (OUTPUT, "> $ARGV[2]");
> 
> #print "First  input  file is: $ARGV[0]\n";
> #print "Second input  file is: $ARGV[1]\n";
> #print "The    output file is: $ARGV[2]\n\n";
> 
> # This half of the code dumps everything in 'file1' to the output 'file3'
> #    while ( <INPUT1> ) {
> #    print "Reading $ARGV[0]\n";
> #    print OUTPUT $_;
> #    }
> 
> File :: COPY;
> copy("$ARGV[0]","$ARGV[2]") or die "Copy failed: $!";
> 
> # This half of the code compares 'file2' to 'file1' and writes out
> # any line that doesn't match to the output 'file3'
> 
> open (INPUT1, "$ARGV[1]") or die "Cannot open $ARGV[1]";
> 
> while ( <INPUT1> ) {
>   $match = 0;
> 
>   $a = $_;
>   open (INPUT2, "$ARGV[0]") or die "Cannot open $ARGV[0]";
>   while ( <INPUT2> ) {
>     $b = $_;
>     if ($a eq $b) {
>       $match = 1;
>       last;
>     }
>   }
> 
>   if ($match == 0) {
>     print OUTPUT $a;
>   }
> }
> 
> "ko" <kuujinbo@hotmail.com> wrote in message
> news:bl37di$j2a$1@pin3.tky.plala.or.jp...
>> Bill wrote:
>> > Is there a single Perl command to copy file 1 into file 2 with out going
>> > through the where-with-all of a while loop? Thanks, Bill
>> >
>> > Perl command to copy one file into another file?
>> >
>> >
>>
>> The File::Copy module.
>>
>> use File::Copy;
>> copy("file1","file2") or die "Copy failed: $!";
>>
>> 'perldoc File::Copy' gives you all the details
>>
>> HTH - keith
>>
> 
> 
> 


-- 
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/


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

Date: Tue, 30 Sep 2003 00:10:13 GMT
From: "Michael P. Broida" <michael.p.broida@boeing_oops.com>
Subject: Re: Perl command to copy one file into another
Message-Id: <3F78C9E5.500B843F@boeing_oops.com>

Bill wrote:
> 
> File :: COPY;
> copy("$ARGV[0]","$ARGV[2]") or die "Copy failed: $!";

	I don't -think- the first statement above will work.
	Try:
		use File::Copy;

	No extra spaces, no changes to uppercase, and the word
	"use" is important.  I would also suggest putting THAT
	line near the beginning of your entire script, but I'm
	not sure it matters beyond style/readability.

	If that still doesn't work...  read on.

        If you know EXACTLY what kind of system it will run on,
        (Windows, Linux, etc) you can use whatever command you
        would give to a shell or commandprompt.

        Use the ` command in perl to run the shell command:

                $result = `copy a.txt b.txt`;

	NOTE: The characters before "copy" and before the
	semi-colon are both backticks (key left of the "one"
	key on common US keyboards; lowercase tilde "~").

        $result will contain whatever output the shell returned
        (error messages, success message, whatever).  Probably
        nothing if it was successful.

        Note that that method is not necessarily "portable".

                Mike


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

Date: 30 Sep 2003 00:42:35 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Perl command to copy one file into another
Message-Id: <slrnbnhkbq.m1g.abigail@alexandra.abigail.nl>

Michael P. Broida (michael.p.broida@boeing_oops.com) wrote on MMMDCLXXXII
September MCMXCIII in <URL:news:3F78C9E5.500B843F@boeing_oops.com>:
()  Bill wrote:
() > 
() > File :: COPY;
() > copy("$ARGV[0]","$ARGV[2]") or die "Copy failed: $!";
()  
()  	I don't -think- the first statement above will work.
()  	Try:
()  		use File::Copy;
()  
()  	No extra spaces, no changes to uppercase, and the word
()  	"use" is important.  I would also suggest putting THAT
()  	line near the beginning of your entire script, but I'm
()  	not sure it matters beyond style/readability.
()  
()  	If that still doesn't work...  read on.
()  
()          If you know EXACTLY what kind of system it will run on,
()          (Windows, Linux, etc) you can use whatever command you
()          would give to a shell or commandprompt.
()  
()          Use the ` command in perl to run the shell command:
()  
()                  $result = `copy a.txt b.txt`;
()  
()  	NOTE: The characters before "copy" and before the
()  	semi-colon are both backticks (key left of the "one"
()  	key on common US keyboards; lowercase tilde "~").
()  
()          $result will contain whatever output the shell returned
()          (error messages, success message, whatever).  Probably
()          nothing if it was successful.

Eh, no. $result will contain whatever the command wrote to
standard *output*. Error messages typically go to standard *error*
and that's is not collected by backticks - you'd first have to
merge them into the output stream.

()          Note that that method is not necessarily "portable".

I actually prefer to shell out to copy files (but not by using backticks,
but by using system), because "cp" copies files in the way I expect, while
File::Copy doesn't. File::Copy doesn't respect execute bits on files,
"cp" does.



Abigail
-- 
A perl rose:  perl -e '@}>-`-,-`-%-'


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

Date: Mon, 29 Sep 2003 13:24:03 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Perl Help - Windows Perl script accessing a Unix perl Script
Message-Id: <290920031324034174%jgibson@mail.arc.nasa.gov>

In article <BjNdb.7424$RW4.3844@newsread4.news.pas.earthlink.net>,
dpackwood <dpackwood@earthlink.net> wrote:

> Hello,
> 
> I have two different scripts that do pretty much the same thing. The main
> perl script is on Windows. It runs and in the middle of it, it then calls
> out another perl script that then should run on a Unix box I have. Both
> scripts run ok, except for the part when Windows try's to call out the
> Unix script. I have it set up where the Unix is mapped through a drive
> letter and can drop stuff into the Unix box. It is going through another
> server to do that. So I can see the script and drop files into the Unix box
> but just can't figure out why perl will not call out the script. When I call
> out the perl script through the command line of windows I get " specified
> path not found", even though I'm in that directory.
> 
> Has any one done anything like this that would be willing to either help me
> or point me in the right direction to do research on it. Thanks
> 
> -Dale
> 
> 

What do you mean by "call out" (this is where posting code would help)?
Are you trying to get the Unix box to execute its own script? For that,
you need the equivalent of ssh or rsh or the like. If you are just
calling the second script with backticks or the system call, the perl
interpreter on the Windows machine will attempt to fork a subprocess to
execute the script on the _Windows_ system. If the first line of the
Unix script contains the path to the perl program on the Unix box and
that path is different from the path to the Windows perl executable, as
it is likely to be, you will get the message you are seeing.


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

Date: Mon, 29 Sep 2003 21:57:48 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Perl Help - Windows Perl script accessing a Unix perl Script
Message-Id: <neahnvog2gu8q8jljm5oanu06duqoenm4m@4ax.com>

dpackwood wrote:

>The main
>perl script is on Windows. It runs and in the middle of it, it then calls
>out another perl script that then should run on a Unix box I have. 

You want it to *run* on the other computer? Then try something like
Net::Telnet. Example scripts can be found with the book "Network
programming with Perl" from Lincoln Stein. The chapter on telnet, and
the source code for the whole book, can be found on its website:

	<http://modperl.com:9000/perl_networking/>

-- 
	Bart.


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

Date: Tue, 30 Sep 2003 10:09:42 +1000
From: King <king21122@yahoo.com>
Subject: Re: perl makefile.pl --help
Message-Id: <3F78C9C6.2090807@yahoo.com>

Jay Tilton wrote:
> King <king21122@yahoo.com> wrote:
> : Tony Curtis wrote:
> : >>>On Sun, 28 Sep 2003 09:09:20 +1000,
> : >>>King <king21122@yahoo.com> said:
> : > 
> : >>Can't open perl script "makefile.pl": No such file or directory
> : > 
> : > Isn't it self-explanatory?  There's no such file.
> : > 
> : I am trying to follow the instruction at 
> : http://tiny-tools.sourceforge.net/README.html#quick_install_personal to 
> : install TinyTools for emacs.
> : the instruction says at point 1.6
> : 
> :        % cd bin/
> 
> Surely that means to cd into the bin/ directory created during the
> unpacking phase.
> 
> : does that 
> : impley that I have to copy the file makefile.pl to the bin/?
> 
> No, you're just in the wrong bin.

and how an I get to the right bin. I did not know there is more then one 
bin, as it only lists one bin under my "/".

> 
> This is not really a Perl issue.  It's an issue with the application and
> its instructions; Perl is only incidentally involved.
> 




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

Date: Tue, 30 Sep 2003 00:44:35 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: perl makefile.pl --help
Message-Id: <3f78d113.598955@news.erols.com>

King <king21122@yahoo.com> wrote:

: and how an I get to the right bin.

Don't you know what directory were the files unpacked into?

Your filesystem and its directory structure are off-topic to clpm.
Now is an appropriate time to ask the author to support his creation.



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

Date: 29 Sep 2003 17:47:15 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: perl makefile.pl --help
Message-Id: <3f78d293@news.victoria.tc.ca>

King (king21122@yahoo.com) wrote:

: and how an I get to the right bin. I did not know there is more then one 
: bin, as it only lists one bin under my "/".

I'm sorry, no disrespect intended, but that question shows you need to 
learn more about unix/linux before you can do anything else.

A basic how-to book for unix would be a good investment of both time and
money.  The time spent reading the first couple of chapters will quickly
be saved by knowing these basic details.

I assume there are on-line tutorials, too.




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

Date: Mon, 29 Sep 2003 21:15:11 +0200
From: stig <_nospam_stigerikson@yahoo.se>
Subject: read meta data from image
Message-Id: <bla0fh$t6d$2@oden.abc.se>

hello
is there any perl module (CPAN) that can read meta infomration from images?

thanks
stig



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

Date: Mon, 29 Sep 2003 21:35:40 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: read meta data from image
Message-Id: <bla1hu$8t6r0$1@ID-184292.news.uni-berlin.de>

stig wrote:
> is there any perl module (CPAN) that can read meta infomration from
> images?

What did you find when you searched CPAN? I searched for 'image' and 
'meta' and found:

     Image::Info

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



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

Date: Mon, 29 Sep 2003 21:28:51 GMT
From: ed <coo_t2-NO-LIKE-SPAM@yahoo.com>
Subject: Re: refer to object in another package
Message-Id: <1l8hnvkraho0tmaks49q04h6i6f538aghg@4ax.com>

On Mon, 29 Sep 2003 09:15:13 +0200, "Michael Korte"
<michael.korte@materna.de> wrote:

><snipped>
>> I want to use an object from another package.
>> { package anotherPackage;
><Snipped>
>> # I've tried $main::obj and *main::obj
>> # but neither seem to work}
>
>try :   $newobject = Package::Classname->new();
>
>HTH
>Michael
>


Thanks for the reply.  But I would like to use an object that's
already been instantiated in another package.

For now I can do something like this:


package main;

my $obj = new className;
&AnotherPackage::sendObj($obj);


{ package AnotherPackage;
    
    my $obj;

    sub sendObj
    {   $obj = shift;
    }

}


--ed



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

Date: Mon, 29 Sep 2003 23:12:46 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: refer to object in another package
Message-Id: <3f78a718.391512565@news.erols.com>

ed <coo_t2-NO-LIKE-SPAM@yahoo.com> wrote:

: Hey all.   This is probably a simple question, but I've looked around
: the faq and other parts of the manual and haven't found an answer yet.
: 
: I want to use an object from another package.
: 
: --- START Perl CODE -----
: $obj = new Object;
: 
: # ...  DO STUFF in anotherPackage ......
: 
: { package anotherPackage;
: 	# How do I refer to $obj from here?
: 	# I've tried $main::obj and *main::obj 
: 	# but neither seem to work
: }
: --- END Perl CODE ------

$obj is just a scalar.  That it is an object has no impact on its scope
or how to access it from other packages.

Unless $obj is declared with my(), there's no problem with using it as
$main::obj .

If $obj is declared with my(), and the anotherPackage package is in the
same file, as it is in the sample code, there's no problem using it at
all--its scope extends to the end of the file.

If $obj is was declared with my(), and anotherPackage is held in an
unrelated scope, you're boned.



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

Date: Mon, 29 Sep 2003 23:47:04 GMT
From: ed <coo_t2-NO-LIKE-SPAM@yahoo.com>
Subject: Re: refer to object in another package
Message-Id: <fjghnv0fsu34db73qudj3t6cujkivf0jin@4ax.com>

On Mon, 29 Sep 2003 23:12:46 GMT, tiltonj@erols.com (Jay Tilton)
wrote:

>Unless $obj is declared with my(), there's no problem with using it as
>$main::obj .
>
>If $obj is declared with my(), and the anotherPackage package is in the
>same file, as it is in the sample code, there's no problem using it at
>all--its scope extends to the end of the file.


$obj is delcared with my() in the actual script I'm working with.  My
example doesn't refect that.  Sorry about that. 
And it is being used in the same file, so I don't guess I need to use
any qualified name to access it. 

Thanks a lot.

--ed



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

Date: Mon, 29 Sep 2003 22:37:03 GMT
From: run_signature_script_for_my_email@INVALID.com (laura fairhead)
Subject: Re: reg exp help
Message-Id: <3f78b0de.36909348@NEWS.CIS.DFN.DE>

On Mon, 29 Sep 2003 11:18:30 -0400, "David Hill" <david@wmol.com> wrote:

>Hello -
>I am trying to come up with a reg exp to fi tthe following criteria.
>
>1.) can NOT be all digits
>2.) can only contain A-Za-z0-9 _ and -
>
>/[A-Za-z0-9_\-]/  is this correct?  i dont think its satisfying the #1
>criteria.

Well it doesn't satisfy #2 either.

You could do it with one regular expression but it's more natural
to use 2 here;

unless( /^[0-9]+$/ || /[^0-9A-Za-z_]/ ){
  # do whatever
  }

Your criteria would actually allow a NUL string and so does
the expression because I just translated them


seeyafrom
l

>
>- David
>
>



-- 
echo alru_aafriehdab@ittnreen.tocm |sed 's/\(.\)\(.\)/\2\1/g'


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

Date: Mon, 29 Sep 2003 19:39:39 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: reg exp help
Message-Id: <slrnbnhk6b.m9p.tadmc@magna.augustmail.com>

laura fairhead <run_signature_script_for_my_email@INVALID.com> wrote:
> On Mon, 29 Sep 2003 11:18:30 -0400, "David Hill" <david@wmol.com> wrote:

>>/[A-Za-z0-9_\-]/  is this correct? 


> Your criteria would actually allow a NUL string


No it wouldn't.


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


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

Date: Mon, 29 Sep 2003 16:02:54 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: strip newlines in TD cell ?
Message-Id: <slrnbnh7fu.lpn.tadmc@magna.augustmail.com>

Richard A. DeVenezia <radevenz@ix.netcom.com> wrote:

> How can I strip all the newlines of stuff between <TD and </TD> ?


Use a module that can properly parse HTML.


> I read in and join some HTML
><TABLE><TR><TD>1
> 2
> 3
></TD>
><TR><TD>A
> B
> C</TD></TR></TABLE>
> 
> that I want process as 
> 
><TABLE><TR><TD>1 2 3</TD>
><TR><TD>A B C</TD></TR></TABLE>


Then why did you say you wanted to _strip_ newlines?

If you stripped newlines, you'd end up with:

   <TABLE><TR><TD>123</TD>
   <TR><TD>ABC</TD></TR></TABLE>

It appears that what you actually want is to replace newlines
with spaces...


   s#(<TD>.*?</TD>)# $a=$1; $a =~ tr/\n/ /; $a #gse;


But that does not produce output like your example either.

I'll leave it to you to make it do whatever it is that you want done...


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


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

Date: 29 Sep 2003 14:58:46 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Unique identifiers in Sendmail::Milter 0.18
Message-Id: <3f78ab16@news.victoria.tc.ca>

Mark (admin@asarian-host.net) wrote:
: I am using Sendmail::Milter 0.18, on Perl 5.8.0, and I was wondering whether
: the connection object $ctx has any properties which allow me to uniquely
: identify it. For example:

: sub connect_callback {
:     my $ctx = shift;

: It appears $ctx is hardly unique, and can therefore not be use as follows:

:     my $hostname = shift;
:     my $sockaddr_in = shift;
:     my ($port, $iaddr);
:     if (defined $sockaddr_in) {
:        ($port, $iaddr) = sockaddr_in ($sockaddr_in);
:         $connections{$ctx} = inet_ntoa ($iaddr);
:     }
:     return SMFIS_CONTINUE;
: }

: Since $ctx is not unique, the %connections hash becomes useless. So, does
: $ctx have a unique property, per connection, which allows me to distinguish
: it from others?

: Much obliged,

In C, each ctx is valid from the start of a connection through to the
close of that connection.  Between that time, all the things that use that
ctx are for events occuring on the same connection, and all the things
that occur on that connection (i.e. messages, one after another and other
smtp drivel) all use the same ctx.

After the connection is closed then I think you'll find that the ctx (i.e.
a pointer to a chunk of memory) is put back on a list, and later that same
chunk of memory is reused for another connection as required - i.e. if you
were to monitor the values of the ctx's then you would see that each one
gets reused for numerous different connections over time.

So, in C, if you wanted to save information about a connection in memory
for "later" then you would need to build your own data structure that
accesses each saved connection in some other manner.  One way would be to
keep a sequential list of previous connections, 1,2,3 etc, which makes no
reference to the original ctx variable but simply stores the various
things you want to store about each connection.

I have no idea if that helps clarify anything in perl, but I assume that 
perl is mirroring what happens in C, so it might.



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

Date: Mon, 29 Sep 2003 22:21:53 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: What is standard?
Message-Id: <bla48j$91bqa$1@ID-184292.news.uni-berlin.de>

I'm distributing a Perl CGI program, and the system requirements 
include "Perl 5.005 or later with the modules included in the Perl 
distribution installed". The idea is to include such CPAN modules that 
my program uses, but that you cannot count on are available at all web 
hosting providers, together with my program.

My problem is: Where do I find the information about which modules 
that are Perl "standard" or "core"?

An example: My program uses MIME::Base64 and MIME::QuotedPrint. Are 
they core/standard?

According to 
http://www.perldoc.com/perl5.8.0/pod/perlmodlib.html#Standard-Modules
they are not.

But is that the right place to look? When I check the Perl 
distribution file, they are included in the 'ext' directory.

Does "standard"/"core" differ from what's included in the Perl 
distribution? And, if so, is it advisable to presuppose that the 
hosting providers have installed everything in the Perl distribution 
file...?

Any comments that might help me put the pieces together would be 
appreciated.

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



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

Date: Mon, 29 Sep 2003 20:50:35 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: What is standard?
Message-Id: <vW0eb.11947$yU5.7937@nwrdny01.gnilink.net>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> My problem is: Where do I find the information about which modules 
> that are Perl "standard" or "core"?

Look at the standard distribution.

For example, to see what's bundled with 5.005_03:

  http://www.cpan.org/src/5.0/perl5.005_03.tar.gz

> An example: My program uses MIME::Base64 and MIME::QuotedPrint. Are 
> they core/standard?

They are now.  They weren't in 5.005_03 or 5.6.1.

-- 
Steve


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

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


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