473,583 Members | 2,875 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

open(data,' variable problem

I am trying to open a text file in the same directory as the script is
located to retrieve stored info. The text file is simply named:
216.1.1.2
This code will NOT work:

$ip = '216.1.1.2';
open (data, $ip);
@mailtext=<data >;
close data;
print @mailtext;
however if I replace $ip as below, It DOES work. Any ideas?

open (data, '216.1.1.2');
@mailtext=<data >;
close data;
print @mailtext;
Jul 19 '05 #1
3 1615
MM
NoViagraHere wrote:
I am trying to open a text file in the same directory as the script is
located to retrieve stored info. The text file is simply named:
216.1.1.2
This code will NOT work:

$ip = '216.1.1.2';
open (data, $ip);
@mailtext=<data >;
close data;
print @mailtext;
however if I replace $ip as below, It DOES work. Any ideas?

open (data, '216.1.1.2');
@mailtext=<data >;
close data;
print @mailtext;


It works both ways on a Linux system using perl 5.8.1.

MM

Jul 19 '05 #2

"MM" <mm*********@co mcast.net> wrote in message
news:65MAb.3278 87$9E1.1609413@ attbi_s52...
NoViagraHere wrote:
I am trying to open a text file in the same directory as the script is
located to retrieve stored info. The text file is simply named:
216.1.1.2
This code will NOT work:

$ip = '216.1.1.2';
open (data, $ip);
@mailtext=<data >;
close data;
print @mailtext;
however if I replace $ip as below, It DOES work. Any ideas?

open (data, '216.1.1.2');
@mailtext=<data >;
close data;
print @mailtext;


I'd say try making it look like "open (data, '$ip');" or "open (data,
"$ip");" I doubt it'll work, but it's worth a shot
Jul 19 '05 #3
In article <3f************ ***********@new scene.com>, NoViagraHere
<No**********@f lyingballs.com> wrote:
I am trying to open a text file in the same directory as the script is
located to retrieve stored info. The text file is simply named:
216.1.1.2
This code will NOT work:

$ip = '216.1.1.2';
open (data, $ip);
@mailtext=<data >;
close data;
print @mailtext;
however if I replace $ip as below, It DOES work. Any ideas?

open (data, '216.1.1.2');
@mailtext=<data >;
close data;
print @mailtext;


You don't say why it is not working. You should be checking if the open
succeeded:

open( data, $ip ) or die("Can't open $ip: $!");

FYI: this newsgroup is defunct. Use comp.lang.perl. misc in the future
for better response.
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1308
by: MostlyH2O | last post by:
Hi Folks, I've been cobbling together a rather complex web utility, and was wondering if there is a way to monitor the number of data connections and open recordsets currently being used by the server. I am using IIS5. I'm essentially looking for a tool that would help identify sloppy code by showing a list of currently open data...
0
1410
by: melledge | last post by:
XTECH 2005 Program Available - Web Technologies, Browsers, Open Data, and XML Headline Event XTECH 2005 http://www.xtech.org takes place 24-27 May at the RAI Centre, Amsterdam, The Netherlands. The full program can be found at: http://www.xtech-conference.org/2005/schedule.asp This year's event brings to the forefront Web Technologies, Open...
0
1185
by: melledge | last post by:
Worldwide Debate on Open Data Highlighted at XTech 2005 Presentation Topics Include Web Services, RSS, FOAF, OAI, Open Access, and More;Special Focus on OpenOffice.org's Influence on Standards and New Technologies Alexandria, Va. - April 20, 2005 - The opportunities and challenges of "open data" on the Web will be the focus of a new...
5
1950
by: Richard Trahan | last post by:
I have an inscrutable problem with window.open. Consider the following code: var graphwin = window.open("","graphWin","height=400,width=400,resizable=yes"); It works perfectly in one place in my program. The window opens, I write stuff to it, close the document, and it sits there like it's supposed to. I put the identical line in a...
23
6395
by: Markus | last post by:
Hi, i have this problem: Sometimes, i can't reproduce, if i click on an small image on the website, the popup _AND_ an other Tab in firefox open. Here are the linkcode: <div align="center">
1
1239
by: Melissa | last post by:
I have inherited an intranet ASP.NET (C#) page running on Windows 2000. The page populates a label control with some javascript to open a pop-up to a document (xls, doc, pdf, etc.). This is what is output onto the page: <span id="javascriptLabel"> <script language="javascript"> <!--
3
4517
by: blackpuppy | last post by:
I am just beginner on PHP. I am reading "Spring Into PHP 5" but cannot make the ftp examples work. I am running PHP scripts on a Fedora Core 5 (VMWare virtual machine) on top of a Windows XP Professional. The PHP version is 5.1.4. The PHP script is shown below. #! /usr/bin/php <?php $ftp_server = "myftpserver";
2
1998
by: defabiisk | last post by:
Hello, I'm trying to open some data I've collected in my Perl DBI script - in excel. I'm using Javascript function to try and open the data in execl - without trying to do a SaveAs first. So I have data all formatted in a Variable and I want this to open in excel - once I get the data to open i n excel - its then the use can review the data...
1
4112
by: Laszlo Nagy | last post by:
Hi All, I'm using a simple program that uploads a file on a remote ftp server. This is an example (not the whole program): def store(self,hostname,username,password,destdir,srcpath): self.ftp = ftplib.FTP(hostname) self.ftp.login(username,password) self.ftp.set_pasv(False)
0
7896
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8329
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8197
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6583
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5704
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3821
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3847
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1436
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1160
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.