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

Re: [PBML] Re: A Perl Question (Was: Not a perl question)

Expand Messages
  • Sreeram B S
    Thanks Damien.. Really it was an excellent solution. By using echo before and echo after and by removal of the -i option... I could make out that the way I
    Message 1 of 7 , Nov 6, 2003
    • 0 Attachment
      Thanks Damien..
      Really it was an excellent solution. By using 'echo before and echo after' and by removal of the -i option... I could make out that the way I was invoking the command itself was wrong. Now I have corrected it and it is working fine.

      Thanks for your timely support.

      Regards,
      Sreeram


      Damien Carbery <daymobrew@...> wrote:
      --- In perl-beginner@yahoogroups.com, Sreeram B S <sreeramabsc@y...>
      wrote:
      > Hi friends,
      > The script is not giving any errors or warnings. It is executing
      silently. But the relevant changes that had to be done in the file are
      not done!!!
      > What may be the reason for this?
      > I have also put on, the warning flag ie. #!/usr/bin/perl -w
      >
      > Need your help.
      >
      > Thanks,
      > Sreeram
      >
      >
      > Damien Carbery <daymobrew@y...> wrote:
      > --- In perl-beginner@yahoogroups.com, Sreeram B S <sreeramabsc@y...>
      > wrote:
      > > Hi,
      > > The command:
      > > perl -pi -e 's/fmt1/fmt2/g' file1
      > > will change all occurences of fmt1 with fmt2 and we get the
      > results in file1 only.
      > > But I am not able to use this command from a script..like this:
      > >
      > > system("perl -pi -e 's/fmt1/fmt2/g' file1");
      > > or `perl -pi -e 's/fmt1/fmt2/g' file1 `
      > >
      > > Why is this happening..?
      > > Please tell the modifications to the command(if any) to use it
      > in the script.
      > >
      > > Thanks in advance.
      > >
      > > From,
      > > Sreeram
      > >
      > > snip old stuff
      >
      > I was had no problems using
      > $ perl -pi -e 's/fmt1/fmt2/g' file1 # At command line
      > or
      > system( "perl -pi -e 's/fmt1/fmt2/g' file1" );
      >
      > Are you getting any warnings?
      > Are warnings on? Does your #! line have '-w' at the end.
      >

      Change the system() line to :
      system( "echo Before;perl -pi -e 's/fmt1/fmt2/g' file1;echo After" );

      This will display "Before" and "After" in your console window to
      confirm the command was run. Even when running correctly it runs
      silently so there is no harm in generating some visual feedback.

      Even better, remove the -i switch (change '-pi' to '-p') so the
      modified lines are sent to STDOUT. You should see the modified lines.



      Yahoo! Groups SponsorADVERTISEMENT

      Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html

      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


      ---------------------------------
      Do you Yahoo!?
      Protect your identity with Yahoo! Mail AddressGuard

      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.