adding chomp($src) soon after the foreach begins before the if statement
corrects the records printing.
foreach $src (@contents)
{
chomp($src);
if(<for some bla condition1)
.................

Thanks.

On 7/25/06, Nishi Bhonsle <[EMAIL PROTECTED]> wrote:

 Sadly doesnt work. I still get ouput like
 "<SH>/$src
" "%HOME%/$src
" "$src
"
 instead of
 "<SH>/$src" "%HOME%/$src" "$src"

 I tried putting the chomp($src) after the 1st foreach loop and test and
then put it after the second foreach loop and test. Neither works.


 On 7/25/06, bright true <[EMAIL PROTECTED]> wrote:
>
> remove the new line from $src , using
>
> chomp($src);
>
> after your foreach loop
>
> HTH
>
> On 7/26/06, Nishi Bhonsle <[EMAIL PROTECTED]> wrote:
> > Hi:
> > The following code ends up adding new line after each column/field in
> the
> > record $record in FILE2.
> >
> > #!/usr/bin/perl
> >
> >  use strict;
> >  use warnings;
> >  use File::Basename;
> >  use File::Find;
> >  use IO::All;
> >
> > my $path = $ARGV[0];
> > my $io = io($path);
> > my @new = $io->all_files;  #get all files under $path
> >
> > foreach $_ (@new)
> > {
> >  $src = basename($_); #get only the filenames of the above files
> >  open FILE,">>$logfile";
> >  print FILE $src;
> >  print FILE "\n";
> > }
> > close FILE;
> >
> > open FILE,"+<$logfile";
> > @contents = <FILE>;
> >
> > foreach $src (@contents)
> > {
> >
> > if(<for some bla condition1)
> >
> > {
> >  my $record = qq("<SH>/$src" "%HOME%/$src" "$src"\n);
> >  print FILE2 $record;    }
> >
> > elsif(<for some bla condition 2){ ..... }
> > }
> >
> > close FILE2;
> > close FILE;
> >
> > So, instead of printing "<SH>/$src" "%HOME%/$src" "$src" in one single
> line,
> > it prints each field of the record ie "<SH>/$src", "%HOME%/$src" and
> "$src"
> > on a separate line.
> >
> >
>


Reply via email to