On 8/4/05, Brian Volk <[EMAIL PROTECTED]> wrote:
> 
> 
[snip]
> Thank you for the reply but I don't think I understand..  The .txt files
> that I am loading into @ARGV are the files that I want to open and
> substitute the URL for a local path.... I thought that I had to include the
> foreach $text_file so I could match the basename of the .txt file and .pdf
> file and then include the "$basename.pdf" in the $link...  I'm pretty sure I
> am matching the file up correctly but the .txt file are being erased instead
> of sub'ing the url w/ the local path...   I think I'm confused... :~)
> 

$ARGV, not $_, is the value of the current open file when using <>. In
scalar context <> returns individual lines. It also concatentates
@ARGV, treating the listed files as essentially one file (at least
most of the time; it possible to find out what file you're in; read
perlop). In list context, it returns a list of lines from the
concatentated @ARGV. So, let's say I have three files in @ARGV, a.a,
b.b, and c.c, each ten lines long.

while (<>) {
    #cycles through 30 times, not stopping between files
}

@lines = <>;
   #returns a single list of all the lines in the files
   # with $lines[0] being the first line of a.a
   # and $lines[29] being the last line of c.c

What you probably want here is:

foreach my $text_file (@ARGV) {

  # ...and then the rest of your code looks like it should work.

In you current code, the block executes once for each line of each
file, and the variable $text_file = 'a line from whichever file you
happen to be in at the moment'. Since 'a line from whichever file you
happen to be in at the moment'.pdf almost certainly doesn't exist,
nothing happens. But you've set $^|, so when <> opens each file it is
renamed $ARGV.bak and an empty file $ARGV is created.

Key point: <> != @ARGV (!= $ARGV)

HTH

-- jay
--------------------------------------------------
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.dpguru.com  http://www.engatiki.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to