Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a variable into a URL in Perl...

Status
Not open for further replies.

jmg498

Technical User
Oct 31, 2007
26
US
It's been a while since I've programmed in Perl. I am having difficulty getting $station to go into the URL as shown below. Where am I going wrong? Thanks much!

---snippet---

print 'Enter the station ID: ';
chomp ($station = <STDIN>);

system ('wget "ftp://tgftp.nws.noaa.gov/SL.us008001/DF.of/DC.radar/DS.p19r0/SI.$station/sn.last"');
 
because you are using single-quotes, there is no interpolation.

simply concatenate...

system ('wget "ftp://tgftp.nws.noaa.gov/SL.us008001/DF.of/DC.radar/DS.p19r0/SI.'.$station.'/sn.last"');

 
On general principals I would recommend qq for strings which need interpolation:

Code:
system qq{wget "ftp://tgftp.nws.noaa.gov/SL.us008001/DF.of/DC.radar/DS.p19r0/SI.$station/sn.last"};







------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top