Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Help Reversing Data

Expand Messages
  • Carlo Antonio Tan
    John A double quoted string translates variables (e.g., $header) and escape sequences (e.g., n) while single quoted strings do not. i.e., $header = My
    Message 1 of 2 , Sep 4, 2000
    • 0 Attachment
      John

      A double quoted string translates variables (e.g.,
      $header) and escape sequences (e.g., \n) while single
      quoted strings do not. i.e.,

      $header = '"My Header"';
      print "$header\n"; # outputs "My Header"<newline>
      print '$header\n'; # outputs $header\n

      btw, these should also work:

      print $header . "\n";
      print $header, "\n";

      --- joach@... wrote:
      >
      > Carlo this does work ..... I just ran it and it's
      > fine. Maybe a bad
      > cut and paste the first time...
      >
      > Now I understand the /n that's a new line
      > ........ but why the "
      > " about the Header.....???
      > Could you post us a small note as to how this
      > works....and it works very
      > fine indeed.
      >
      > Thanks again.....gives me another small utility that
      > is useful
      >
      > John
      >
      > #!/usr/bin/perl -w
      > use strict;
      >
      > my $infile = shift;
      > my $outfile = shift;
      > my $header='"My Header"';
      > print "Reversing date sequence\n";
      >
      > open (IN,$infile) || die "Could not open $infile
      > $!";
      > open (OUT, ">$outfile")|| die "can't open $outfile:
      > $!";
      > my @data = (<IN>);
      >
      >
      > push @data,"$header\n";
      >
      > @data = reverse @data;
      >
      > print OUT @data;
      > close IN;
      > close OUT;
      >
      >
      > Carlo Antonio Tan wrote:
      >
      > > try replacing the line:
      > >
      > > push @data,$header;
      > >
      > > with:
      > >
      > > push @data,"$header\n";
      > >
      > > hth,
      > > Carlo


      __________________________________________________
      Do You Yahoo!?
      Yahoo! Mail - Free email you can access from anywhere!
      http://mail.yahoo.com/
    Your message has been successfully submitted and would be delivered to recipients shortly.