Results 1 to 4 of 4

Thread: [perl] pulling variables

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517

    [perl] pulling variables

    Perl questions:


    In my code I have the variable $custidno
    now i take a file into a string, and I print it onto
    the page, in this file there is the take $custidno.

    the problem is, that it actually shows up in that form on the paper (the variable is not inserted if you read it from the file. )

    How would I read it in such a way that it gets the proper value.

    (not PHP: PERL)
    PHP Code:
     sub get_page {
        
    open TL"templates/cargo.htm"
          
    or die "Template not found! ($!)";

        while (<
    TL>) {
            
    $html .= "$_";
        }


  2. #2
    Addicted Member
    Join Date
    Sep 2002
    Location
    Durham, NC, US
    Posts
    218
    It is easier to understand your question if you attempt proper grammar. Either use English, or use another language, but don't use both.

    I'm guessing:
    Code:
    sub get_page { 
        open TL, "templates/cargo.htm" or die "Template not found! ($!)"; 
    
        while (<TL>) { 
            $html .= s/(\$\w+)/$1/eeg; 
        } 
    }
    You may only need one e, I'm not sure. Test it and see. This will replace any text in $_ that looks like a scalar variable ($custidno, $foo, etc).
    Travis, Kung Foo Journeyman

    Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
    Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    OSS: Mozilla, MySQL (Manual)

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    thanks alot for the code.. ill see if it works

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    it didnt work. replaced the whole page oddly enough.

Posting Permissions

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



Click Here to Expand Forum to Full Width