SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 1999
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello everyone
    I Have a problem with a Perl script that reads a line from a file which has variable names in it and when it prints the variable names are printed as a literal.
    i.e.:
    the line in the file:
    $var01 blah blah blah $var02 blah blah
    in the script:
    $var01 = "name1";
    $var02 = "name2";
    ...
    $line1 = <INF>;
    ...
    print "<P> $line1 </P>";
    this prints the line just as is in the file:
    <P> $var01 blah blah blah $var02 blah blah </P>
    Is there a way to make the script print the contents of the variables instead of just the variable itself?
    What I need is:
    <P> name1 blah blah blah name2 blah blah </P>
    Could anyone be so kind as to help me with this?
    Thank you in advance for your cooperation

  2. #2
    Destiny Manager Plebius's Avatar
    Join Date
    Nov 1999
    Posts
    682
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    something like this:

    $filetext =~ s/\$var01/$var01/g;

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 1999
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much LuZeR,
    I just tried it and it works great, I guess is about people like you that the Perl man pages refer as members of the Perl culture and their readiness to help.
    I'm just starting with Perl and I guess it would have taken me quite a while to get to the proficiency level to find out about the answer to that one.
    Thank you for your cooperation and be well.

  4. #4
    Destiny Manager Plebius's Avatar
    Join Date
    Nov 1999
    Posts
    682
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Glad i could help!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •