[31921] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3184 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 20 06:09:30 2010

Date: Wed, 20 Oct 2010 03:09:14 -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, 20 Oct 2010     Volume: 11 Number: 3184

Today's topics:
    Re: CGI, multiple page data input. <xhoster@gmail.com>
    Re: CGI, multiple page data input. <justin.1010@purestblue.com>
    Re: perl curl get data from website sln@netherlands.com
    Re: perl curl get data from website sln@netherlands.com
        PERL environment for EMACS... <daniel.eliason@excite.com>
    Re: Perl OO - combined static & instance method. <RedGrittyBrick@spamweary.invalid>
    Re: please help with creating a special iterator <xhoster@gmail.com>
    Re: reading LWP in chunks <klaus03@gmail.com>
    Re: useful modules to install <john@example.invalid>
    Re: where to install cpan modules <john@example.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 18 Oct 2010 19:33:08 -0700
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: CGI, multiple page data input.
Message-Id: <4cbe30bb$0$16894$ed362ca5@nr5-q3a.newsreader.com>

Justin C wrote:
> All of my web stuff (inhouse) until now has passed previously input data
> back to the browser in hidden form fields when more data needs to be
> collected. For example, my script that calculates shipping rates for
> customer orders collects weight, number of items, country of destination
> on the first page. When this page is submitted a new page is returned
> asking for the dimensions of each box, this second page form is
> dependent on input from the first page (each box can be different
> dimensions), but I also need some of the original page's input for my
> calculations later, so the original data is passed back in hidden form
> fields.

As long as the data is not meaningfully subject to falsification, or is 
revalidated at each stage, this is quite fine.

> I'd like to move my coding forward a little and find a better way. I'm
> guessing the cookies is the correct way to progress with this, but I
> want to be sure, or hear of other ways before I commit to a cookies
> approach for my new web-page.

It is not clear to me that the direction you indicate is a 'forward' 
direction.

Xho


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

Date: Wed, 20 Oct 2010 10:02:25 +0100
From: Justin C <justin.1010@purestblue.com>
Subject: Re: CGI, multiple page data input.
Message-Id: <1qn2p7-alf.ln1@zem.masonsmusic.co.uk>

On 2010-10-19, Xho Jingleheimerschmidt <xhoster@gmail.com> wrote:
> Justin C wrote:
>> All of my web stuff (inhouse) until now has passed previously input data
>> back to the browser in hidden form fields when more data needs to be
>> collected. For example, my script that calculates shipping rates for
>> customer orders collects weight, number of items, country of destination
>> on the first page. When this page is submitted a new page is returned
>> asking for the dimensions of each box, this second page form is
>> dependent on input from the first page (each box can be different
>> dimensions), but I also need some of the original page's input for my
>> calculations later, so the original data is passed back in hidden form
>> fields.
>
> As long as the data is not meaningfully subject to falsification, or is 
> revalidated at each stage, this is quite fine.
>
>> I'd like to move my coding forward a little and find a better way. I'm
>> guessing the cookies is the correct way to progress with this, but I
>> want to be sure, or hear of other ways before I commit to a cookies
>> approach for my new web-page.
>
> It is not clear to me that the direction you indicate is a 'forward' 
> direction.

Xho, the problem is that in some of my programs there are many fields to
the forms (invoice lines, often they number in the hundreds), and to
add:
	print hidden(-name=>'some-name', -value=>$cgi->param('some-name')); 
a few hundred times is extremely ugly. There has to be a better way. But
as Jurgen mentioned, it's not a perl problem, though it can be solved
with perl.

I've looked at CGI::Session, and decided to re-invent the wheel. The
program is for internal use only and there is nothing to be gained by
users messing around with it, so I'm creating a sort of session ID that
I will pass in a hidden field, and using Storable to store/retrieve the
entire hash submitted by the browser. CGI::Session seemed overkill.

For a session ID I'm using:
	my $sid = md5_hex (int(rand(99999999)));

and also using that as a file-name to store the data between http
submissions.

Thanks to all for the suggestions, they've got me to a solution to the
problem that is rather simple. I guess that I will have to learn about
real sessions should I ever make something like this available to the
world.

   Justin.

-- 
Justin C, by the sea.


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

Date: Tue, 19 Oct 2010 20:10:42 -0700
From: sln@netherlands.com
Subject: Re: perl curl get data from website
Message-Id: <67nsb6dt32l4hef5u2mv4khabscnl6d5st@4ax.com>

On Tue, 19 Oct 2010 07:17:14 -0700 (PDT), SVCitian <emailsrvr-groups@yahoo.com> wrote:

>On Oct 19, 2:26 am, s...@netherlands.com wrote:
>> On Mon, 18 Oct 2010 05:58:42 -0700 (PDT),SVCitian<emailsrvr-gro...@yahoo.com> wrote:
>> >On Oct 17, 10:21 pm, Tad McClellan <ta...@seesig.invalid> wrote:
>> >>SVCitian<emailsrvr-gro...@yahoo.com> wrote:
>> >> > I even tried to user "tamper data" firefox add to get behind the
>> >> > scenes of GET, POST, etc... but I can't proceed any further than the
>> >> > URLs given above.
>
>I have no clue of how to make heads or tails of the result.
>
>If you could post the result in a more helpful format.. I would
>appreciate it.
>
>Thanks.

This may be better, my first afternoon with LWP.

-sln

----------------------
use strict;
use warnings;

use HTML::TableExtract;
use HTTP::Cookies;
use HTTP::Request::Common qw(POST GET);
use LWP::UserAgent;

my $show_content = 0;
my ($content1, $content2);

# Create cookies
 my $jar = HTTP::Cookies->new();

# Create user agent
 my $ua = LWP::UserAgent->new();
 $ua->timeout( 10 );
 $ua->cookie_jar( $jar );
 $ua->agent("Microsoft Internet Explorer/6.0");


# Create a first request: "get track table"
# ---------

 my $request = HTTP::Request->new('GET' => 
  join '', qw{
http://www.bangkokflightservices.com/TrackTrace/showc_track.php?m_prefix=176&m_s
n=75064953&h_prefix=HWB&h_sn=&ecy=e076438db64c6190f7b9689a379b7f7093368f1652d14d
b65fee1ab916713f3f5f4030f53369cb1f669614312c4748899c272f4d976a2b299274a21ad80fc0
72b1bab2ab1c181d08c670188722e51ec162f9ae337e3f2f132c88d249133815558d241ce8a4e9b3
fa75c144268b9e901037c2c7257142ee42ff9b2bf2767f57ed62b94fd938ea4dd2b28c53fea6af74
be&ch=%A0%A0%A0%A0 } );

# Pass request to agent

 my $res = $ua->request( $request );
 if ( $res->is_success ) {
      print "\nContent-1 .. OK\n\n";
      if ($show_content) {
          print $res->content, "\n\n";
      }
      $content1 = $res->content;
 }
 else {
      print "Request-1 Failed\n";
      print $res->status_line, "\n\n";
      die;
 }

 print '='x20, "\n\n";


# Create asecond request: "get search table"
# ---------

 $request = HTTP::Request->new('GET' => 
  join '', qw{
http://www.bangkokflightservices.com/TrackTrace/search_awb.php?m_prefix=176&m_s
n=75064953&h_prefix=HWB&h_sn=&ch= } );

# Pass the request to agent

 $res = $ua->request( $request );
 if ( $res->is_success ) {
      print "Content-2 .. OK\n\n";
      if ($show_content) {
          print $res->content, "\n\n";
      }
      $content2 = $res->content;
 }
 else {
      print "Request-2 Failed\n";
      print $res->status_line, "\n\n";
      die;
 }

print '='x20, "\n\n";
print "Done!\n\n\n";
print "Content 1 tables:\n", '-'x20, "\n\n";
print_tables( $content1 );
print "\nContent 2 tables:\n", '-'x20, "\n\n";
print_tables( $content2 );

exit;

## Table extract Util from wsp
##
sub print_tables {
    my ($table, $row, $cell);
    my $tc = 0;
    my $table_extractor = HTML::TableExtract->new();
    $table_extractor->parse($_[0]);
    foreach $table ($table_extractor->table_states) {
	print "TABLE $tc:\n"; $tc++;
        my $rc = 0;
        foreach $row ($table->rows) {
	    print "ROW $rc:\n"; $rc++;
            foreach $cell ( @$row ) {
                $cell = '' unless defined $cell;
                $cell =~ s/\n/ /g;
		$cell =~ s/[ \t]+/ /g;
		$cell =~ s/^[ \t]//;
		$cell =~ s/[ \t]$//;
		$cell =~ s/ *<\/td *//g;
                print "$cell|";
            }
            print "\n";
        }
    }
}
__END__


Content-1 .. OK

====================

Content-2 .. OK

====================

Done!


Content 1 tables:
--------------------

TABLE 0:
ROW 0:
|á||
TABLE 1:
ROW 0:
á|||
ROW 1:
á||á|
ROW 2:
á|||
TABLE 2:
ROW 0:
|
ROW 1:
|
TABLE 3:
ROW 0:
á|
ROW 1:
|
TABLE 4:
ROW 0:
|
ROW 1:
|
TABLE 5:
ROW 0:
|

Content 2 tables:
--------------------

TABLE 0:
ROW 0:
á||||
ROW 1:
 á|Enter Master Air Waybill (MAWB)|
ROW 2:
 Optional (For Import MAWB Only)|
ROW 3:
á||||
ROW 4:
||* Master Air Waybill number example 123 - 12345678||
TABLE 1:
ROW 0:
|||||||||||
ROW 1:
Item|AWB No|Flight No|Flight Date|Origin|Dest|ULD No|Status|Pieces|Weight|Time|
ROW 2:
1|176-75064953|EK 419|Oct 15 2010|BKK|DXB|Flight Changeá|Export Transshipment|3|
743.00|Oct 14 2010 5:37PM|
ROW 3:
2|176-75064953|EK 419|Oct 15 2010|BKK|DXB|á|Accepted|3|743.00|Oct 14 2010 5:37PM
|
ROW 4:
3|176-75064953|EK 373|Oct 15 2010|BKK|DXB|Flight Changeá|Export Transshipment|3|
743.00|Oct 14 2010 6:12PM|
ROW 5:
4|176-75064953|EK 373|Oct 15 2010|BKK|DXB|SHCá|Export Transshipment|3|743.00|Oct
 14 2010 6:12PM|
ROW 6:
5|176-75064953|EK 373|Oct 14 2010|BKK|DXB|Flight Changeá|Export Transshipment|3|
743.00|Oct 14 2010 6:42PM|
ROW 7:
6|176-75064953|EK 373|Oct 14 2010|BKK|DXB|PMC31131EKá|Manifested|3|743.00|Oct 14
 2010 6:57PM|
ROW 8:
7|176-75064953|EK 373|Oct 14 2010|BKK|DXB|á|Departed|3|743.00|Oct 14 2010 9:54PM
|



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

Date: Tue, 19 Oct 2010 20:47:50 -0700
From: sln@netherlands.com
Subject: Re: perl curl get data from website
Message-Id: <5dpsb6p2odi296ci2p66lgsmme8os3rm2b@4ax.com>

On Tue, 19 Oct 2010 20:10:42 -0700, sln@netherlands.com wrote:

>On Tue, 19 Oct 2010 07:17:14 -0700 (PDT), SVCitian <emailsrvr-groups@yahoo.com> wrote:
>
>>On Oct 19, 2:26 am, s...@netherlands.com wrote:
>>> On Mon, 18 Oct 2010 05:58:42 -0700 (PDT),SVCitian<emailsrvr-gro...@yahoo.com> wrote:
>>> >On Oct 17, 10:21 pm, Tad McClellan <ta...@seesig.invalid> wrote:
>>> >>SVCitian<emailsrvr-gro...@yahoo.com> wrote:
>>> >> > I even tried to user "tamper data" firefox add to get behind the
>>> >> > scenes of GET, POST, etc... but I can't proceed any further than the
>>> >> > URLs given above.
>>
>>I have no clue of how to make heads or tails of the result.
>>
>>If you could post the result in a more helpful format.. I would
>>appreciate it.
>>
>>Thanks.
>
>This may be better, my first afternoon with LWP.
>
>-sln
>
>----------------------
>use strict;
>use warnings;
>
>use HTML::TableExtract;
>use HTTP::Cookies;
>use HTTP::Request::Common qw(POST GET);
>use LWP::UserAgent;
>
>my $show_content = 0;
>my ($content1, $content2);
>

[snip code]

># Create asecond request: "get search table"
># ---------
>
> $request = HTTP::Request->new('GET' => 
>  join '', qw{
>http://www.bangkokflightservices.com/TrackTrace/search_awb.php?m_prefix=176&m_s
>n=75064953&h_prefix=HWB&h_sn=&ch= } );
>

## Or, to create a variable AWB lookup
#  my $WBNprefix = '176';
#  my $WBN       = '75064953';
#   $request = HTTP::Request->new('GET' => 
#  "http://www.bangkokflightservices.com/TrackTrace/search_awb.php?m_prefix=" .
#   $WBNprefix. "&m_sn=" . $WBN . "&h_prefix=HWB&h_sn=&ch= ");

-sln


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

Date: Tue, 19 Oct 2010 13:36:22 -0700 (PDT)
From: fortunatus <daniel.eliason@excite.com>
Subject: PERL environment for EMACS...
Message-Id: <a14e9ed3-2ab4-49b9-81fa-9d720a276c13@x42g2000yqx.googlegroups.com>

Does everyone use PDE?

I'm using it now (first day) and I like it so far.  But anyone have
any other suggestions?

Thanks from a PERL newbie!!


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

Date: Wed, 20 Oct 2010 10:42:26 +0100
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: Perl OO - combined static & instance method.
Message-Id: <4cbeb984$0$2526$da0feed9@news.zen.co.uk>

On 19/10/2010 18:01, Uri Guttman wrote:
>>>>>> "R" == RedGrittyBrick<RedGrittyBrick@spamweary.invalid>  writes:
>
>    R>  An instance method in traditional Perl OO might be like this.
>    R>    Package Foo;
>    R>    ...
>    R>    sub bar {
>    R>      my $self = shift;
>    R>      my ($x, $y, $z) = @_;
>    R>      ...
>    R>    }
>
>    R>  I'd like to be able to invoke this either as a (static) class method
>    R>    $result = Foo::bar(1,2,3);
>
> that is not a method at all. that is a plain sub call. the only way to
> tell if it isn't a method is to check the first arg and see if it is a
> blessed object of that class.
>
>    R>  or as an instance method
>    R>    my $foo = Foo->new(Foo::INVERTED);
>
> that is a class method call
>
>    R>    $result = $foo->bar(1,2,3);
>
> that is an instance or object method call. those you can differentiate
> by looking at the first arg. but it is a BAD idea for one method to
> support both styles. there are idioms for allowing the new() (or other)
> methods work both ways but it is better to have different methods for
> each api style
>
>    R>  What is the usual idiom for checking for the presence of the class ref?.
>
> there is no standard way to tell a method call from a plain sub call as
> you never want to use the same sub both ways. if you could call a method
> without its object, what is the point of making it a method to begin
> with?
>

Thanks for clearing up my misunderstanding.

The background is that I have a handful of programs, the earlier ones 
have some subroutines in common so these were moved into a common 
procedural module. A set of programs written later use an OO version of 
the module. I wanted to merge the OO and procedural modules whilst 
delaying the refactoring of the earlier programs.

-- 
RGB


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

Date: Mon, 18 Oct 2010 20:17:01 -0700
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: please help with creating a special iterator
Message-Id: <4cbe30bc$0$16894$ed362ca5@nr5-q3a.newsreader.com>

Mathematisch wrote:
> Hi,
> 
> The problem: I would like to create an iterator to iterate through a
> csv file with the following structure:
> 
> 
> field_1,field_2,...field_14
> field_1,field_2,...field_14
> (...)
> 
> Note that this is a csv file with 14 fields and it is already sorted
> by field_1 and then by field_2. There are usually only 5-10 lines
> having the same field_1 and field_2 value.

What is usually the case is of precious little value.  If the unusual 
case causes ICBMs to be erroneously launched, where is the comfort in 
the fact that this is unusual?  What is the *maximum plausible* number 
of lines with the same field_1 and field_2?

> There could be up to hundreds of millions of lines in the file. The
> desired iterator should work like this: At each "next_entry" call, the
> iterator should return a reference to an array of the lines having the
> identical field_1 and field_2 values.
> 
> Because of my lack of understanding the iterator concept, I could not
> come up with a solution yet. The file is too big to use the field_1
> and field_2 as a hash key to achieve the same goal of grouping the
> entries.

package whatever;
sub new {
   shift; # not meant for subclassing
   open my $fh, (shift) or die $!;
   my $x=<$fh>; chomp $x;
   return bless [$fh,$x];
};

sub next_entry {
   my $this=shift;
   my $fh=$this->[0];
   return unless defined $this->[1];
   my @return=$this->[1];
   my @line=split /,/, $this->[1];
   while(1) {
     $this->[1]=<$fh>;
     return [@return] unless defined $this->[1];
     chomp $this->[1];
     my @line2=split /,/, $this->[1];
     return [@return] unless $line2[0]eq$line[0] and $line2[1]eq$line[1];
     push @return, $this->[1];
   };
};



> 
> Thank you very much for any help on this. I hope I can learn from the
> eventual proposed solutions.
> 
> Kind regards.
> F.
> 
> 
> 



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

Date: Tue, 19 Oct 2010 12:47:48 -0700 (PDT)
From: Klaus <klaus03@gmail.com>
Subject: Re: reading LWP in chunks
Message-Id: <123a7e18-879f-491c-baf7-9e66fddab018@j25g2000yqa.googlegroups.com>

On 19 oct, 19:29, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth Klaus <klau...@gmail.com>:
> > My problem is that I can't figure out for my life how to write a
> > closure :content_cb => sub {...} that, after reading one chunk, allows
> > me to jump completely out of all nested LWP subroutines, and then,
> > later, if and when I want to read another chunk, I need to jump back
> > exactly to that point into the closure where I left off.
> > [...]
> > I think what I need is called "continuations", and I need it in Perl
> > 5.12.
>
> Oh! Sorry, I hadn't thought that far.
>
> The obvious answer is 'use Coro', or rather Coro::LWP, but I'm not sure
> how far I trust it. The fact it requires a rather invasive set of hacks
> to get LWP to work right is... worrying.
>
> The other obvious answer is 'use Net::HTTP::NB'. This will obviously
> only support HTTP, and will require you to do all the redirect-following
> logic and so on yourself, but gives you a basic non-blocking HTTP
> client.

Thanks, Net::HTTP::NB is exactly what I was looking for all along.

 ...and no need for me to write LWP::Chunk :-)

--
Klaus


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

Date: Tue, 19 Oct 2010 20:57:26 -0600
From: John Smith <john@example.invalid>
Subject: Re: useful modules to install
Message-Id: <gOOdnWv5tukLxyPRnZ2dnUVZ5judnZ2d@giganews.com>

[mis-post]
[intended ng was c.lp.misc]
[x-posted]


John Smith wrote:

> [OP is posting as John Smith]
> [OP posts as Uno on his other ubuntu identity, which could happen]
> 
> I'm shaking the bugs out of a recent cpan install, and I can't really 
> re-visit what I've done already.  These are the modules I installed the 
> old-fashioned way, and I think almost all of them were necessary to get 
> cpan rolling:
> 
> $ pwd
> /home/ron/perl
> $ ls
> Digest-MD5-2.51            local-lib-1.006007.tar.gz
> Digest-MD5-2.51.tar.gz     Parse-RecDescent-1.965001
> Inline-0.46                Parse-RecDescent-1.965001.tar.gz
> Inline-0.46.tar.gz         text1
> Inline-Python-0.37         Wiki-Gateway-0.001991.tar.gz
> Inline-Python-0.37.tar.gz  YAML-0.72
> local-lib-1.006007         YAML-0.72.tar.gz
> $
> 
> Then, you throw in some of the modules that cpan interactive suggested 
> and a couple to test capabilities:
> 
> $ pwd
> /home/ron/.cpan/build
> $ ls
> ExtUtils-CBuilder-0.2703-bIw2ps        Module-Build-0.3607-3OtTSN.yml
> ExtUtils-CBuilder-0.2703-bIw2ps.yml    Test-Harness-3.22-Cd0hSu
> ExtUtils-ParseXS-2.2206-WNAX3h         Test-Harness-3.22-Cd0hSu.yml
> ExtUtils-ParseXS-2.2206-WNAX3h.yml     Test-Pod-1.44-196VsY
> Inline-Python-0.37-dlPnsX              Test-Pod-1.44-196VsY.yml
> Inline-Python-0.37-EB3Kq4              text1
> Inline-Python-0.37-OXNJnE              Wiki-Gateway-0.001991-MOAYwl
> Math-Polynomial-Solve-2.54-4hiBRx      Wiki-Gateway-0.001991-rBHT9I
> Math-Polynomial-Solve-2.54-4hiBRx.yml  Wiki-Gateway-0.001991-xt9oW2
> Module-Build-0.3607-3OtTSN             Wiki-Gateway-0.001991-xt9oW2.yml
> $
> 
> I'll be only too happy to delete these files, once I'm certain that I've 
> got a working cpan install.
> 
> So, I'm fishing for what others think are useful modules, so as to a) 
> test cpan capability, b) increase perl capability, c) have joy in seeing 
> software work automatically, the most precious event that follows from 
> the Virtue of Laziness.
> 
> A respondent's first thought might be, "well, what do you want to do 
> with perl," and the answer to that might begin with building a 
> bare-bones browser.  I'd like to be able to go to my own youtube account 
> and grab a file.
> 
> I like to goof around with video.  I have a webcam now, having joined 
> the 21st century.
> 
> I'm also in the market for useful scripts.  I'll go after almost any 
> suggestion.
> 
> Thanks for your comment, and cheers,


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

Date: Tue, 19 Oct 2010 21:35:02 -0600
From: John Smith <john@example.invalid>
Subject: Re: where to install cpan modules
Message-Id: <EpadnRFERJT7_iPRnZ2dnUVZ5sKdnZ2d@giganews.com>

Tad McClellan wrote:
> Uno <merrilljensen@q.com> wrote:
>                    ^^^^^
>                    ^^^^^
> 
> If you are not a Qwest customer, then you should not use
> the domain name that belongs to them.
> 
> You should fix this account's posting address as you did
> the (poorly chosen) "John Smith" account.
> 
> 

No, that's really me, and I'm a reluctant qwest customer.  I'm hugely 
frustrated with sounding like two people.  I think the underlying 
syndrome is that I don't know how to share data among unix users.
>> [x-posted to c.u.p.]
> 
>> Newsgroups: comp.lang.perl.misc
> 
> 
> Your article was NOT crossposted. 
> 
> It was perhaps multiposted, I cannot tell because I cannot see articles
> in c.u.p.
> 
> Multiposting is very bad manners. 
> 
> If you must crosspost, you should learn how to do it properly.
> 
> If it had been crossposted, then the header would have been something like:
> 
>     Newsgroups: comp.lang.perl.misc, comp.unix.programmer
> 
> 

Yesterday, I hit my head so hard on the garage door I'm remodeling that 
I can't touch my hair without wincing in pain.  I haven't been able to 
see straight since.  I meet a lot of people who tell me how nice it must 
be to be 6'7".  They don't know this pain.

Now I've f'ed it up in reverse.  Sometimes, I can't win.
> That cannot really be done without knowing the environment that
> the particular Perl program was run in, and the command line
> that was used to invoke it, and the source itself.
> 
> If all of those are known, then the module is looked for in each
> of the directories in @INC in order, as Ben pointed out, and the
> first one that is found is the one that is used (relevant).
> 
> The @INC shown above is only the *default* contents of @INC.
> 
>     
>     "the environment that the particular Perl program was run in"
>     export PERL5LIB=/tmp
>     perl -le'print for @INC'
> 
>     "the command line that was used to invoke it"
>     perl -I/tmp -le'print for @INC'
> 
>     "the source itself"
>     perl -le'use lib "/tmp"; print for @INC'
> 
> 

I'm not sure what you mean by this:

$ perl l5.pl
 ...we will have peace, when you and all your works have
perished--and the works of your dark master to whom you
would deliver us. You are a liar, Saruman, and a corrupter
of men's hearts.  --Theoden in /usr/src/perl/taint.c

                 ...we will have peace, when you and all your works have
                 perished--and the works of your dark master to whom you
                 would deliver us. You are a liar, Saruman, and a corrupter
                 of men's hearts.
--Theoden in /usr/src/perl/taint.
Here's a line
	and here's another.
usr/local/
usr/local/doc
usr
$ cat l5.pl
#!/usr/bin/perl
use strict;
use warnings;

         (my $quote = <<'FINIS') =~ s/^\s+//gm;
                 ...we will have peace, when you and all your works have
                 perished--and the works of your dark master to whom you
                 would deliver us. You are a liar, Saruman, and a corrupter
                 of men's hearts.  --Theoden in /usr/src/perl/taint.c
FINIS
print $quote;

         ($quote = <<'FINISH') =~ s/\s+--/\n--/;

                 ...we will have peace, when you and all your works have
                 perished--and the works of your dark master to whom you
                 would deliver us. You are a liar, Saruman, and a corrupter
                 of men's hearts.  --Theoden in /usr/src/perl/taint.
FINISH
print $quote;

         sub fix {
             local $_ = shift;
             my ($white, $leader);  # common whitespace and common 
leading string
             if (/^\s*(?:([^\w\s]+)(\s*).*\n)(?:\s*\g1\g2?.*\n)+$/) {
                 ($white, $leader) = ($2, quotemeta($1));
             } else {
                 ($white, $leader) = (/^(\s*)/, '');
             }
             s/^\s*?$leader(?:$white)?//gm;
             return $_;
         }

print fix(<<THAT);
   Here's a line
		and here's another.
THAT
print fix(<<THIS);
usr/local/
usr/local/doc
usr
THIS
# perl l5.pl
$ echo     "the environment that the particular Perl program was run in"
the environment that the particular Perl program was run in
$     export PERL5LIB=/tmp
$     perl -le'print for @INC'
/tmp
/etc/perl
/usr/local/lib/perl/5.10.0
/usr/local/share/perl/5.10.0
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.10
/usr/share/perl/5.10
/usr/local/lib/site_perl
 .
$ echo     "the command line that was used to invoke it"
the command line that was used to invoke it
$     perl -I/tmp -le'print for @INC'
/tmp
/tmp
/etc/perl
/usr/local/lib/perl/5.10.0
/usr/local/share/perl/5.10.0
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.10
/usr/share/perl/5.10
/usr/local/lib/site_perl
 .
$ echo    "the source itself"
the source itself
$     perl -le'use lib "/tmp"; print for @INC'
/tmp
/etc/perl
/usr/local/lib/perl/5.10.0
/usr/local/share/perl/5.10.0
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.10
/usr/share/perl/5.10
/usr/local/lib/site_perl
 .
$

The first one looks "right."  I don't see your intention with the last two.

Cheers,
-- 
Humpdy Dumpdy


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

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:

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

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

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


------------------------------
End of Perl-Users Digest V11 Issue 3184
***************************************


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